import openai
import json
import os
# openai.api_key = get_api_key()
openai.api_key = "your key"
# q = "用python实现:提示手动输入3个不同的3位数区间,输入结束后计算这3个区间的交集,并输出结果区间"
# q = "What is th vbScript?"
# q = "翻译成日语:市场非常有潜力"
# q = "北京、上海、广州的经纬度以表的形式给我"
q = """翻译成日语:
市场非常有潜力
电影很精彩
您买牛奶都重视哪些要素?
"""
rsp = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
# model="gpt-4-0613",
messages=[
{"role": "system", "content": "一个有10年Python开发经验的资深算法工程师"},
# {"role": "system", "content": "Where is China's capital?"},
{"role": "user", "content": q}
]
)
result = rsp.choices[0].message["content"]
print(result)