当前位置:   article > 正文

GPT-3 API接口调用_gpt api接口

gpt api接口
  1. import os
  2. import openai
  3. #
  4. # openai.api_key = "sk-t你自己的API key"
  5. # response = openai.Completion.create(
  6. # model="text-davinci-003",
  7. # #prompt="Translate this into 1. French, 2. Spanish and 3. Japanese:\n\nWhat rooms do you have available?\n\n1.",
  8. # prompt="Translate this into English:\n\n操你妈呀!\n\n1.",
  9. # temperature=0.3,
  10. # max_tokens=100,
  11. # top_p=1.0,
  12. # frequency_penalty=0.0,
  13. # presence_penalty=0.0
  14. # )
  15. # print(response)
  16. # # openai.api_key = os.getenv("sk-t你自己的API key"") # 这个会报错
  17. # openai.api_key = "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" # 这个不报错
  18. # response = openai.Completion.create(
  19. # model="text-davinci-003",
  20. # prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",
  21. # temperature=0,
  22. # max_tokens=100,
  23. # top_p=1,
  24. # frequency_penalty=0.0,
  25. # presence_penalty=0.0,
  26. # stop=["\n"]
  27. # )
  28. # print(response)
  29. openai.api_key = "sk-t你自己的API key"" # 这个不报错
  30. response = openai.Completion.create(
  31. model="text-davinci-003",
  32. prompt="The following is a list of companies and the categories they fall into:\n\nApple, Facebook, Fedex\n\nApple\nCategory:",
  33. temperature=0,
  34. max_tokens=64,
  35. top_p=1.0,
  36. frequency_penalty=0.0,
  37. presence_penalty=0.0
  38. )
  39. print(response)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/356892
推荐阅读
相关标签
  

闽ICP备14008679号