File size: 892 Bytes
161e673
 
d6fb159
161e673
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2950cbe
 
 
 
161e673
6ba1616
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import openai
import gradio
import os

openai.api_key = os.environ.get("open_ai_token")

text_file = open("Alfred.txt", "r")
texto = text_file.read()

messages = [{"role": "system", "content":texto}]

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

user_input = gradio.inputs.Textbox(lines=2, placeholder="Como posso te ajudar?", label="Como posso te ajudar?")
output = gradio.outputs.Textbox(label="Resposta:")

demo = gradio.Interface(fn=CustomChatGPT, inputs = user_input, outputs = output, title = "Marina - Evento Páscoa 8/Abril")

demo.launch()