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

请问是否目前chatgpt翻译不支持Azure OpenAI的api? #134

Open
Ami0617 opened this issue Oct 17, 2023 · 4 comments
Open

请问是否目前chatgpt翻译不支持Azure OpenAI的api? #134

Ami0617 opened this issue Oct 17, 2023 · 4 comments

Comments

@Ami0617
Copy link

Ami0617 commented Oct 17, 2023

QQ截图20231017234129
测试如图显示错误

@PantsuDango
Copy link
Owner

PantsuDango commented Oct 17, 2023 via email

@Ami0617
Copy link
Author

Ami0617 commented Oct 18, 2023

你好,感谢回复!
根据官方文档(learn.microsoft.com/en-us/azure/ai-services/openai/reference),
request的部分需要resource_name和deployment_name,api-version也需要指定
header和data的部分也与openai的文档所记载的参数有些不同
API_KEY需要在header中填写,没有Authorization的参数

data部分的话看起来也不需要指定model参数,
因为根据部署不同即YOUR_DEPLOYMENT_NAME不同模型也会不同

以下是我用于测试的curl和python的代码

curl https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/completions?api-version=2023-05-15\
-H "Content-Type: application/json"
-H "api-key: YOUR_API_KEY"
-d "{
"messages": [{"role":"system","content":"You are an AI assistant that helps people find information."}],
"max_tokens": 4000,
"temperature": 0.7,
"frequency_penalty": 0,
"presence_penalty": 0,
"top_p": 0.95,
"stop": null
}"

test.py

import os
import openai
openai.api_type = "azure"
openai.api_base = "https://YOUR_RESOURCE_NAME.openai.azure.com/"
openai.api_version = "2023-07-01-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")

openai.api_key = API_KEY

response = openai.ChatCompletion.create(
engine="YOUR_DEPLOYMENT_NAME",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."}],
temperature=0.7,
max_tokens=4000,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None)

@as3long
Copy link

as3long commented Jun 5, 2024

chatgpt-ollama
chatgpt-ollama-test
可以考虑直接用ollama 。模型用qwen:4b 如果你的显卡够好的话也可以用qwen:7b 翻译的更好。ollama直接兼容chatgpt的api,非常好使。

@PantsuDango
Copy link
Owner

chatgpt-ollama chatgpt-ollama-test 可以考虑直接用ollama 。模型用qwen:4b 如果你的显卡够好的话也可以用qwen:7b 翻译的更好。ollama直接兼容chatgpt的api,非常好使。

看到你的调用耗时才0.72s...我承认我心动了w

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

3 participants