Closed JosenJin closed 3 months ago
默认就兼容,只需要更改api base和api key即可
下面是openai的调用,貌似不可以呀,返回是none,我写的不对吗? response = openai.chat.completions.create( model=self.model_name, messages=history, temperature=temperature, tools=tools, max_tokens=max_length, )
用openai的调用方式就会返回这些
ChatCompletion(id=None, choices=None, created=None, model=None, object=None, system_fingerprint=None, usage=None, code=-2001, message='请求失败', data=None)
这代表你的refresh_token错误
Bearer eyJhbGciOiJIUzUxMiI。。。。。我用api方式可以的,就是用同样的token,难道不用加Bearer ?
是不是没有这个两个参数呀?这两个参数如何放进去?
// 是否开启联网搜索,默认false "use_search": true, // 如果使用SSE流请设置为true,默认false "stream": false
refresh token不需要加上Bearer ,那个是Authorization头才需要加的
问题是这个open ai的标准调用方式如何兼容呀?tools可以吗?麻烦给指导下? response = openai.chat.completions.create( model=self.model_name, messages=history, temperature=temperature, tools=tools, max_tokens=max_length, )
不需要如何兼容,默认就兼容,tools不用加
您能不能帮忙写一个python调用openai标准的方式?我怎么试都是报错。。。另外我想加tools就是外部api tools怎么加?跪谢!
response = openai.chat.completions.create( model=self.model_name, messages=history, temperature=temperature, tools=tools, max_tokens=max_length, )
from openai import OpenAI
os.environ["OPENAI_BASE_URL"] = "http://127.0.0.1:8000/v1"
os.environ["OPENAI_API_KEY"] = "eyJhbGciOiJIUzUxMiI..."
response = OpenAI().chat.completions.create(
model="kimi",
messages=[
{"role": "user", "content": '你是谁'},
]
)
tools不用填,逆向也不会支持自定义工具调用,默认会使用官网的联网。
如何兼容openai的调用方法? response = openai.chat.completions.create( model=self.model_name, messages=history, temperature=temperature, tools=tools, max_tokens=max_length, )