Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,15 @@ import os
|
|
7 |
|
8 |
os.environ["OPENAI_API_KEY"] = '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'
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def construct_index(directory_path):
|
11 |
max_input_size = 4096
|
12 |
num_outputs = 1
|
@@ -26,22 +35,39 @@ def construct_index(directory_path):
|
|
26 |
|
27 |
|
28 |
def chatbot(input_text):
|
|
|
29 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
30 |
response = index.query(input_text)
|
31 |
-
return response.response
|
32 |
|
33 |
description = """
|
34 |
|
35 |
-
<center
|
36 |
-
<
|
37 |
"""
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
index = construct_index("docs")
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
os.environ["OPENAI_API_KEY"] = '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'
|
9 |
|
10 |
+
md = """This is some code:
|
11 |
+
|
12 |
+
hello
|
13 |
+
|
14 |
+
```py
|
15 |
+
def fn(x, y, z):
|
16 |
+
print(x, y, z)
|
17 |
+
"""
|
18 |
+
|
19 |
def construct_index(directory_path):
|
20 |
max_input_size = 4096
|
21 |
num_outputs = 1
|
|
|
35 |
|
36 |
|
37 |
def chatbot(input_text):
|
38 |
+
|
39 |
index = GPTSimpleVectorIndex.load_from_disk('index.json')
|
40 |
response = index.query(input_text)
|
41 |
+
return str(response.response)
|
42 |
|
43 |
description = """
|
44 |
|
45 |
+
<center>Olá sou o Fly, fui treinado para responder perguntas baseadas na CD2 Retail Tech. Pergunte qualquer coisa. Caso eu não saiba, estarei aprendendo.
|
46 |
+
<img src="https://cdn.discordapp.com/attachments/1047272134931644526/1100145287529496687/GPTSUPER_AVATAR.png" width=200px></center>
|
47 |
"""
|
48 |
|
49 |
+
with gr.Blocks() as demo:
|
50 |
+
gpt = gr.Chatbot(label="Olá, eu sou o GPT Super da CD2. Não sabe qual trilha participar? Me diga qual suas área de atuação que eu posso ajudar na sua escolha",color_map=['.gradio-container-3-23-0' ,'background-color: #e6e6e6'])
|
51 |
+
msg = gr.Textbox(label="Insira aqui a sua pergunta :)")
|
52 |
+
clear = gr.Button("Limpar Conversa")
|
53 |
+
|
54 |
+
def respond(message, chat_history):
|
55 |
+
print(msg)
|
56 |
+
chat_history.append((message, chatbot(message)))
|
57 |
+
time.sleep(1)
|
58 |
+
return "", chat_history
|
59 |
+
|
60 |
+
msg.submit(respond, [msg, gpt], [msg, gpt])
|
61 |
+
clear.click(lambda: None, None, gpt, queue=False)
|
62 |
|
63 |
index = construct_index("docs")
|
64 |
+
demo.launch()
|
65 |
+
|
66 |
+
#iface = gr.Interface(fn=chatbot,
|
67 |
+
# inputs=gr.inputs.Textbox(lines=3, label='O quê gostaria de saber?'),
|
68 |
+
# outputs=gr.inputs.Textbox(lines=5, label="Veja o que encontrei"),
|
69 |
+
# description=description.upper(),
|
70 |
+
# css=".gradio-container-3-23-0 {background-color: #e6e6e6} .gradio-container-3-23-0 .prose * {color: #55c1e5}",
|
71 |
+
# title="Converse com Fly")
|
72 |
+
|
73 |
+
#iface.launch()
|