wxywb / history_rag

825 stars 108 forks source link

想使用代理的openai,该怎么办 #22

Closed wei851246721 closed 7 months ago

wei851246721 commented 7 months ago

请问如果我i使用的API不是直接连接到openai api而是经过中转的接口,调用前需要转换,在你的程序里需要修改哪里呢?

下面是中转站给的示例: from openai import OpenAI

api_key = "xxx" api_base = "https://one.aiskt.com/v1" client = OpenAI(api_key=api_key, base_url=api_base)

completion = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ] )

print(completion.choices[0].message)

wxywb commented 7 months ago

https://github.com/wxywb/history_rag/issues/10

wei851246721 commented 7 months ago

非常感谢,现在可以了

will2023-abc commented 2 months ago

非常有用,感谢