Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否可以考虑出个统一的接口 用户可以自定义传入 apikey baseurl model 等,符合openai标准格式就行,类似如下这样,因为现在很多第三方例如硅基流动,字节豆包等接入了deepseek,这个接口好像调用不了-~ #38

Open
ecooz opened this issue Feb 15, 2025 · 2 comments

Comments

@ecooz
Copy link

ecooz commented Feb 15, 2025

from openai import OpenAI # 导入OpenAI

deepseek model

client = OpenAI(api_key="sk-123456", base_url="http://localhost:11434/v1") # 实例化OpenAI对象

use deepseek model

response = client.chat.completions.create(
model="deepseek-r1:14b",
messages=[
{"role": "user", "content": "常见的十字花科植物有哪些?"}
],
stream=False
)

print(response.choices[0].message.content) # 输出文案

@LnYo-Cly
Copy link
Owner

from openai import OpenAI # 导入OpenAI

deepseek model

client = OpenAI(api_key="sk-123456", base_url="http://localhost:11434/v1") # 实例化OpenAI对象

use deepseek model

response = client.chat.completions.create( model="deepseek-r1:14b", messages=[ {"role": "user", "content": "常见的十字花科植物有哪些?"} ], stream=False )

print(response.choices[0].message.content) # 输出文案

如果与OpenAi的输入与输出的格式相同,那么Platform选择OPENAI即可。
如果你是spring boot应用,可以直接在yml配置,第三方平台对应的url, apikey
例如:

ai:
  openai:
    api-host: https://xxxxx.xxxxx.com/
    chat-completion-url: /my/v1/chat/completion
    api-key: abcdefg

非spring boot应用可以修改config:

        OpenAiConfig openAiConfig = new OpenAiConfig();
        openAiConfig.setApiHost("https://xxxxx.xxxxx.com/");
        openAiConfig.setChatCompletionUrl("/my/v1/chat/completion");
        openAiConfig.setApiKey("abcdefg");
        configuration.setOpenAiConfig(openAiConfig);

请求参数的传递以及返回对象均与OpenAi的相同。

@ecooz
Copy link
Author

ecooz commented Feb 15, 2025

好滴 谢谢大佬~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants