使用Azure 的Openai 调用的时候需要注意的的一些地方
比如
model="gpt-4o"
api_version="2024-02-15-preview"
model
一般为你部署的名字通常是azure_endpoint
https://xxxx.openai.azure.com/
的xxx
的名字
api_version
并不是 gpt
的版本
改动后前
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint = "https://XXXX.openai.azure.com/",
api_key="XXXXX",
api_version="2024-05-13"
)
message_text = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"Was ist 4x6?"}]
completion = client.chat.completions.create(
model="GPT-4o", # model = "deployment_name"
messages = message_text,
temperature=0.7,
max_tokens=800,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None
)
print(completion.choices[0].message.content)
改动后
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint = "https://swcgpt4.openai.azure.com/",
api_key="XXXX",
api_version="2024-02-15-preview"
)
message_text = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"Was ist 4x6?"}]
completion = client.chat.completions.create(
model="SWgpt40", # model = "deployment_name"
messages = message_text,
temperature=0.7,
max_tokens=800,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None
)
print(completion.choices[0].message.content)
参考