openai_api.py 485 B

123456789101112
  1. import openai
  2. openai.api_key = "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" # 需要填写
  3. def get_reply(message):
  4. response = openai.ChatCompletion.create(model="gpt-3.5-turbo",
  5. messages=[{
  6. "role": "user",
  7. "content": message
  8. }])
  9. return response["choices"][0]["message"]["content"]