- from openai.lib.azure import AzureOpenAI
-
- client = AzureOpenAI(
- azure_endpoint="https://xxxxxx.openai.azure.com/",
- api_key="xxxxxxxxxx",
- api_version="2024-05-01-preview"
- )
-
- start_phrase = "翻译当前语言为英文,只进行文本翻译,只输出翻译结果,禁止其他任何回答。"
- text1 = "我是谁"
-
- response = client.completions.create(
- model="xxxxx",
- prompt=start_phrase+text1,
- max_tokens=100
- )
-
- text = response.choices[0].text.replace('\n','').replace(' .','.').strip()
- print(text)
其中,openai ==1.23.3
key和endpoint:
model:
如有配置方面不懂的可以联系我,低价解答~