tian-minghui / openai-style-api

支持将openai、claude、azure openai, gemini,kimi, 智谱AI,通义千问,讯飞星火API等模型服务方的调用转为openai方式调用。屏蔽不同大模型API的差异,统一用openai api标准格式使用大模型(Shield the differences between different large model APIs and use large models in a unified openai API standard format)
MIT License
328 stars 55 forks source link

新版本openai库无法请求 #15

Closed HuaShanWoZuiShuai closed 4 months ago

HuaShanWoZuiShuai commented 5 months ago

使用openai==0.28可以正常使用,curl也能通,但是换用新版openai配置后,无法接收请求

tian-minghui commented 5 months ago

使用openai==0.28可以正常使用,curl也能通,但是换用新版openai配置后,无法接收请求

可以贴一下报错信息么

tian-minghui commented 4 months ago

openai>=1.0.0使用以下方式调用

import os
from openai import OpenAI

client = OpenAI(
    # This is the default and can be omitted
    api_key='kimi-GxqT3BlbkFJj',
    base_url = 'http://localhost:8090/v1'
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-3.5-turbo",
)

print(chat_completion.choices[0].message.content)