python openai function calling
AI 回答
由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 导入OpenAI库
import openai
2. 设置API密钥
openai.api_key = 'your-api-key'
3. 调用函数
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Translate the following English text to Chinese: 'Hello, how are you?'",
max_tokens=60
)
4. 获取结果
print(response.choices[0].text.strip())
import openai
2. 设置API密钥
openai.api_key = 'your-api-key'
3. 调用函数
response = openai.Completion.create(
engine="text-davinci-002",
prompt="Translate the following English text to Chinese: 'Hello, how are you?'",
max_tokens=60
)
4. 获取结果
print(response.choices[0].text.strip())
没有找到「python openai function calling」相关的内容
建议:检查关键词是否有错别字,或换一个更常见的说法。