diff --git a/main.py b/main.py index 4c0c135f61696bcf42c375ca5ab62aa5b105afc8..56917ddd10ee8ab92592052813bc6854703343e3 100644 --- a/main.py +++ b/main.py @@ -1 +1,18 @@ -print('欢迎来到 InsCode') \ No newline at end of file +import openai +# 输入你的 api_key +chat_gpt_key = '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' +# 将 Key 进行传入 +openai.api_key = chat_gpt_key +def completion(prompt): + response = openai.Completion.create( + # text-davinci-003 是指它的模型 + model="text-davinci-003", + prompt=prompt, + temperature=0.5, + max_tokens=1024, + n=1, + stop=None + ) + message = response.choices[0].text + return message +print(completion(input("在这里输入你想对chatgpt说的话,然后它就会给出答案:"))) \ No newline at end of file