-2

所以,我试图制作一个程序,您可以在其中提出问题,它会给出答案。程序输出应该是这样的:

Question: What is a game?
Answer: A game is some form of entertainment.
Wiki: https://en.wikipedia.org/wiki/Wikipedia:Wiki_Game

但它只根据你的问题给出答案或维基(问一个词通常会返回维基,但问题会返回答案。

这是我的代码:

import openai
import os

openai.api_key = os.getenv('OPENAI_API_KEY')
while True:
  ask = input('Question: ')

response = openai.Completion.create(
  engine="text-davinci-001",
  prompt=f"Q: What is Minecraft? \nA: Minecraft is a game about placing blocks in a 
  infinite world, creating with friends and discovering new things.\nWiki: 
  https://en.wikipedia.org/wiki/Minecraft\n\n Q: {ask}\nA: \nWiki: ",
  temperature=0.8,
  max_tokens=60,
  top_p=1,
  frequency_penalty=0,
  presence_penalty=0,
  stop=["\n\n"]
)
print(response.choices[0].text)

任何帮助都会很棒

4

0 回答 0