File size: 681 Bytes
8fbbd67
 
917bc27
e12cc58
 
917bc27
6e1e549
8fbbd67
 
 
 
 
 
 
9227e65
8fbbd67
 
 
9227e65
8fbbd67
2def70c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import openai
import gradio


openai.api_key = "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"

messages = [{"role": "system", "content": "You are chatgpt-3.5,you can solve any question"}]

def CustomChatGPT(user_input):
    messages.append({"role": "user", "content": user_input})
    response = openai.ChatCompletion.create(
        model = "gpt-3.5-turbo",
        messages = messages
    )
    ChatGPT_reply = response["choices"][0]["message"]["content"]
    messages.append({"role": "assistant", "content": ChatGPT_reply})
    return ChatGPT_reply

demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "chagpt测试网站")

demo.launch()