TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
8.81k stars 693 forks source link

How to support other interfaces like chatgpt #584

Closed vimyang closed 6 days ago

vimyang commented 6 days ago

In addition to using the official default chatgpt api, we also have some other chatgpt-like interfaces that we can refer to

from openai import OpenAI
client = OpenAI(api_key=API_KEY, base_url="https://api.siliconflow.cn/v1")
response = client.chat.completions.create(
    model='Qwen/Qwen2-7B-Instruct',
    messages=[
        {'role': 'user', 'content': "hi"}
    ]
)
print(response)

Against these interfaces, the call provides the following

Is there a generic way to solve this problem? Of course I may replace the above url in the near future.

Thank you for your reply

vimyang commented 6 days ago

Turns out that the current configuration solves my problem, fantastic.

I tried modifying the following configuration and it solved the problem

DEFAULT_MODEL=Qwen/Qwen2-7B-Instruct
OPENAI_USE_FUNCTIONS=true
API_BASE_URL=https://api.siliconflow.cn/v1
USE_LITELLM=false
OPENAI_API_KEY=sk-xxxx

Note: API_BASE_URL needs to remove the /chat/completions at the end or it will give a NotFoundError: 404 page not found error. It works fine for me though via python or shell.

Thanks to the author for such a great helper software.