Scrapegraph-ai icon indicating copy to clipboard operation
Scrapegraph-ai copied to clipboard

Whether it can support llm models compatible with the open AI api protocol?

Open goasleep opened this issue 6 months ago • 0 comments

Is your feature request related to a problem? Please describe. I've encountered an issue where I wish to utilize language models from providers other than the mainstream ones like OpenAI, Anthropic, Google, etc., such as Moonlight and Tongyi Qianwen (not the Ollama local qwen model). I've found that these models are not supported because they are considered providers that are not officially recognized.

In reality, these language models are compatible with the OpenAI protocol, meaning they can be utilized with the OpenAI SDK. For instance, Moonlight uses the OpenAI SDK as demonstrated below:

from openai import OpenAI
 
client = OpenAI(
    api_key="MOONSHOT_API_KEY", 
    base_url="https://api.moonshot.cn/v1",
)

I would like ScrapeGraph-AI to support Moonshot's language model in a similar fashion, but upon reviewing the source code, I couldn't find any hooks or parameters to facilitate this. Consequently, I made a commit to add support for Moonlight (https://github.com/ScrapeGraphAI/Scrapegraph-ai/commit/3275001c9a258a0458ba0cf1db59719bb7949411), and I'm uncertain if there might be other issues arising from this change.

Describe the solution you'd like I propose adding a parameter to override_provider to allow for the custom definition of the provider, enabling other language models to work with ScrapeGraph-AI. The configuration would look something like this:

graph_config = {
    "llm": {
        "model":"moonshot-v1-8k",
        "base_url": "https://api.moonshot.cn/v1", 
        "api_key": api_key
        "override_provider": "openai",
    },
}

Describe alternatives you've considered I am open to the possibility of other solutions, but I am not entirely certain if all options have been explored.

Other I am unsure of the impact of the aforementioned change and whether there are other aspects of the system that this change might affect. However, I have tested the example provided in the commit, and no issues were encountered.

I kindly request a review of this demo. If there are no problems, I am interested in taking on this task and would appreciate the opportunity to contribute by submitting a PR when appropriate.

goasleep avatar Aug 19 '24 01:08 goasleep