Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,59 +10,26 @@ from transformers import pipeline
|
|
10 |
p = pipeline("automatic-speech-recognition")
|
11 |
|
12 |
|
13 |
-
os.environ["OPENAI_API_KEY"] = 'sk-
|
14 |
|
15 |
css = """
|
16 |
-
.gradio-container {
|
17 |
-
background-color: #ffffff;
|
18 |
-
}
|
19 |
-
|
20 |
#component-2 {position: absolute; bottom: 0; width: 100%;
|
21 |
}
|
22 |
-
|
23 |
-
.app.svelte-ac4rv4>.main.svelte-ac4rv4 {
|
24 |
-
display: flex;
|
25 |
-
flex-grow: 1;
|
26 |
-
flex-direction: column;
|
27 |
-
background-image: url(https://i.ibb.co/3rVCQz0/background-GPT-1.png);
|
28 |
-
}
|
29 |
-
div.svelte-awbtu4 {
|
30 |
-
display: flex;
|
31 |
-
flex-direction: inherit;
|
32 |
-
flex-wrap: wrap;
|
33 |
-
gap: var(--form-gap-width);
|
34 |
-
box-shadow: var(--block-shadow);
|
35 |
-
border: var(--block-border-width) solid #5f0000;
|
36 |
-
border-radius: var(--radius-lg);
|
37 |
-
background: #ffffff;
|
38 |
-
overflow: hidden;
|
39 |
-
position: fixed;
|
40 |
-
bottom: 0;
|
41 |
-
margin-left: -16px;
|
42 |
-
}
|
43 |
-
.bot.svelte-6roggh.svelte-6roggh,.pending.svelte-6roggh.svelte-6roggh {
|
44 |
-
border-color: var(--border-color-primary);
|
45 |
-
background: #00adef;
|
46 |
-
color: white;
|
47 |
-
font-weight: bolder;
|
48 |
-
}
|
49 |
div.float.svelte-1frtwj3 {
|
50 |
position: absolute;
|
51 |
opacity: 0;
|
52 |
top: var(--block-label-margin);
|
53 |
left: var(--block-label-margin);}
|
|
|
54 |
.wrap.svelte-6roggh.svelte-6roggh {
|
55 |
padding: var(--block-padding);
|
56 |
height: 100%;
|
57 |
max-height: 100%;
|
58 |
overflow-y: auto;
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
background: #0D1233;
|
64 |
-
color: white;
|
65 |
-
font-weight: bolder;
|
66 |
}
|
67 |
div.svelte-1frtwj3 {
|
68 |
display: inline-flex;
|
@@ -81,83 +48,30 @@ div.svelte-1frtwj3 {
|
|
81 |
width: 100%;
|
82 |
line-height: var(--line-sm);
|
83 |
}
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
div.bot.svelte-17nzccn.svelte-17nzccn {
|
92 |
-
background: #199FDA;
|
93 |
-
}
|
94 |
-
|
95 |
-
div.user.svelte-6roggh.svelte-6roggh {
|
96 |
-
background: #0D1233;
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
div.user.svelte-17nzccn.svelte-17nzccn {
|
101 |
-
background: #0D1233;
|
102 |
-
}
|
103 |
-
|
104 |
-
div.textBoxBot {
|
105 |
-
display: flex;
|
106 |
-
flex-direction: inherit;
|
107 |
-
flex-wrap: wrap;
|
108 |
-
gap: var(--form-gap-width);
|
109 |
-
box-shadow: var(--block-shadow);
|
110 |
-
border: var(--block-border-width) solid #0D1233;
|
111 |
-
border-radius: var(--radius-lg);
|
112 |
-
background: #ffffff;
|
113 |
-
overflow: hidden;
|
114 |
-
position: fixed;
|
115 |
-
bottom: 0;
|
116 |
-
margin-left: -16px;
|
117 |
-
}
|
118 |
-
|
119 |
-
.textarea.svelte-1pie7s6.svelte-1pie7s6 {
|
120 |
display: flex;
|
121 |
flex-direction: inherit;
|
122 |
flex-wrap: wrap;
|
123 |
gap: var(--form-gap-width);
|
124 |
box-shadow: var(--block-shadow);
|
125 |
-
border: var(--block-border-width) solid
|
126 |
border-radius: var(--radius-lg);
|
127 |
-
background:
|
128 |
overflow: hidden;
|
129 |
position: fixed;
|
130 |
bottom: 0;
|
131 |
margin-left: -16px;
|
132 |
}
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
flex-wrap: wrap;
|
138 |
-
gap: var(--form-gap-width);
|
139 |
-
box-shadow: var(--block-shadow);
|
140 |
-
border: 5px solid #0D1233;
|
141 |
-
border-radius: var(--radius-lg);
|
142 |
-
border-color: #0D1233;
|
143 |
-
background: #ffffff;
|
144 |
-
color: #0D1233;
|
145 |
-
font-size: 16px;
|
146 |
-
overflow: hidden;
|
147 |
-
position: fixed;
|
148 |
-
bottom: 20px; /* Ajuste a distância vertical do rodapé */
|
149 |
-
margin-left: -5px;
|
150 |
-
max-height: 80vh; /* Ajuste a altura máxima da div */
|
151 |
-
max-width: 78%; /* Ajuste a largura máxima da div */
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
-
.img.svelte-ms5bsk {
|
156 |
-
width: 100%;
|
157 |
-
height: 100%;
|
158 |
-
background-color: #ffffff;
|
159 |
-
border: 0px;
|
160 |
-
border-width: 0px;
|
161 |
}
|
162 |
.app.svelte-ac4rv4.svelte-ac4rv4 {
|
163 |
max-width: none;
|
@@ -165,19 +79,29 @@ div.textBoxBot {
|
|
165 |
}
|
166 |
.app.svelte-ac4rv4.svelte-ac4rv4{max-width:none}
|
167 |
.wrap.svelte-1o68geq.svelte-1o68geq {max-height: none}
|
168 |
-
|
169 |
.block.svelte-mppz8v {
|
170 |
position: relative;
|
171 |
margin: 0;
|
172 |
box-shadow: var(--block-shadow);
|
173 |
border-width: var(--block-border-width);
|
174 |
-
border-color: #
|
175 |
border-radius: var(--block-radius);
|
176 |
-
background: #
|
177 |
width: 100%;
|
178 |
line-height: var(--line-sm);
|
179 |
}
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
"""
|
182 |
|
183 |
md = """This is some code:
|
@@ -218,13 +142,15 @@ def chatbot(input_text):
|
|
218 |
|
219 |
with gr.Blocks(css=css, elem_classes=".app.svelte-ac4rv4.svelte-ac4rv4") as demo:
|
220 |
realPath = str(os.path.dirname(os.path.realpath(__file__)))
|
221 |
-
img1 = gr.Image("images/
|
222 |
gpt = gr.Chatbot(label="Converse com GPT Super da CD2",elem_classes=".wrap.svelte-1o68geq.svelte-1o68geq", elem_id="chatbot").style(container=True)
|
223 |
msg = gr.Textbox(elem_id="div.svelte-awbtu4",elem_classes="div.svelte-awbtu4", show_label=False,
|
224 |
placeholder="Bem vindo ao ExpoSuper, Qual sua pergunta?",
|
225 |
).style(container=True)
|
226 |
# clear = gr.Button("Limpar Conversa")
|
227 |
-
# gr.
|
|
|
|
|
228 |
def respond(message, chat_history):
|
229 |
chat_history.append((message, chatbot(message)))
|
230 |
time.sleep(1)
|
@@ -526,13 +452,11 @@ with gr.Blocks(css=css, elem_classes=".app.svelte-ac4rv4.svelte-ac4rv4") as demo
|
|
526 |
vetor = vetor + [((realPath + "\\images\\22-14.png",), "")]
|
527 |
vetor = vetor + [((realPath + "\\images\\22-15.png",), "")]
|
528 |
vetor = vetor + [((realPath + "\\images\\22-15-1.png",), "")]
|
529 |
-
elif str(message).upper() == "ME CONTE SOBRE O TECH CONECTION" or str(message).upper() == "TECH CONECTION":
|
530 |
-
vetor = vetor + [((realPath + "\\images\\luis.mp4",), "")]
|
531 |
-
|
532 |
|
533 |
return "", chat_history+vetor
|
534 |
|
535 |
-
|
|
|
536 |
msg.submit(respond, [msg, gpt], [msg,gpt])
|
537 |
|
538 |
index = construct_index("docs")
|
|
|
10 |
p = pipeline("automatic-speech-recognition")
|
11 |
|
12 |
|
13 |
+
os.environ["OPENAI_API_KEY"] = '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'
|
14 |
|
15 |
css = """
|
|
|
|
|
|
|
|
|
16 |
#component-2 {position: absolute; bottom: 0; width: 100%;
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
div.float.svelte-1frtwj3 {
|
19 |
position: absolute;
|
20 |
opacity: 0;
|
21 |
top: var(--block-label-margin);
|
22 |
left: var(--block-label-margin);}
|
23 |
+
|
24 |
.wrap.svelte-6roggh.svelte-6roggh {
|
25 |
padding: var(--block-padding);
|
26 |
height: 100%;
|
27 |
max-height: 100%;
|
28 |
overflow-y: auto;
|
29 |
+
}
|
30 |
+
.bot.svelte-6roggh.svelte-6roggh, .pending.svelte-6roggh.svelte-6roggh {
|
31 |
+
border-color: #759ce9;
|
32 |
+
background: #ffffff;
|
|
|
|
|
|
|
33 |
}
|
34 |
div.svelte-1frtwj3 {
|
35 |
display: inline-flex;
|
|
|
48 |
width: 100%;
|
49 |
line-height: var(--line-sm);
|
50 |
}
|
51 |
+
.img.svelte-ms5bsk {
|
52 |
+
width: 100%;
|
53 |
+
height: 100%;
|
54 |
+
background-color: #ffffff;
|
55 |
+
border: 0px;
|
56 |
+
border-width: 0px;}
|
57 |
+
div.svelte-awbtu4 {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
display: flex;
|
59 |
flex-direction: inherit;
|
60 |
flex-wrap: wrap;
|
61 |
gap: var(--form-gap-width);
|
62 |
box-shadow: var(--block-shadow);
|
63 |
+
border: var(--block-border-width) solid var(--border-color-primary);
|
64 |
border-radius: var(--radius-lg);
|
65 |
+
background: var(--border-color-primary);
|
66 |
overflow: hidden;
|
67 |
position: fixed;
|
68 |
bottom: 0;
|
69 |
margin-left: -16px;
|
70 |
}
|
71 |
+
img.svelte-ms5bsk {
|
72 |
+
width: var(--size-full);
|
73 |
+
height: 90px;
|
74 |
+
object-fit: contain;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
.app.svelte-ac4rv4.svelte-ac4rv4 {
|
77 |
max-width: none;
|
|
|
79 |
}
|
80 |
.app.svelte-ac4rv4.svelte-ac4rv4{max-width:none}
|
81 |
.wrap.svelte-1o68geq.svelte-1o68geq {max-height: none}
|
|
|
82 |
.block.svelte-mppz8v {
|
83 |
position: relative;
|
84 |
margin: 0;
|
85 |
box-shadow: var(--block-shadow);
|
86 |
border-width: var(--block-border-width);
|
87 |
+
border-color: #dbeafe;
|
88 |
border-radius: var(--block-radius);
|
89 |
+
background: #dbeafe;
|
90 |
width: 100%;
|
91 |
line-height: var(--line-sm);
|
92 |
}
|
93 |
+
div.bot.svelte-6roggh.svelte-6roggh {
|
94 |
+
background: #D9A13D;
|
95 |
+
}
|
96 |
+
div.bot.svelte-17nzccn.svelte-17nzccn {
|
97 |
+
background: #D9A13D;
|
98 |
+
}
|
99 |
+
div.user.svelte-6roggh.svelte-6roggh {
|
100 |
+
background: #5F0000;
|
101 |
+
}
|
102 |
+
div.user.svelte-17nzccn.svelte-17nzccn {
|
103 |
+
background: #5F0000;
|
104 |
+
}
|
105 |
"""
|
106 |
|
107 |
md = """This is some code:
|
|
|
142 |
|
143 |
with gr.Blocks(css=css, elem_classes=".app.svelte-ac4rv4.svelte-ac4rv4") as demo:
|
144 |
realPath = str(os.path.dirname(os.path.realpath(__file__)))
|
145 |
+
img1 = gr.Image("images/imagem teste.png")
|
146 |
gpt = gr.Chatbot(label="Converse com GPT Super da CD2",elem_classes=".wrap.svelte-1o68geq.svelte-1o68geq", elem_id="chatbot").style(container=True)
|
147 |
msg = gr.Textbox(elem_id="div.svelte-awbtu4",elem_classes="div.svelte-awbtu4", show_label=False,
|
148 |
placeholder="Bem vindo ao ExpoSuper, Qual sua pergunta?",
|
149 |
).style(container=True)
|
150 |
# clear = gr.Button("Limpar Conversa")
|
151 |
+
# sendAudio = gr.Button("Enviar Audio")
|
152 |
+
# sendAudio.click(gr.Audio(source="microphone", type="filepath",label="ESTÁ COM DIFICULDADES EM ESCREVER? CLIQUE E ME DIGA O QUE DESEJA"))
|
153 |
+
|
154 |
def respond(message, chat_history):
|
155 |
chat_history.append((message, chatbot(message)))
|
156 |
time.sleep(1)
|
|
|
452 |
vetor = vetor + [((realPath + "\\images\\22-14.png",), "")]
|
453 |
vetor = vetor + [((realPath + "\\images\\22-15.png",), "")]
|
454 |
vetor = vetor + [((realPath + "\\images\\22-15-1.png",), "")]
|
|
|
|
|
|
|
455 |
|
456 |
return "", chat_history+vetor
|
457 |
|
458 |
+
#clear.click(lambda:None, None, gpt, queue=False,)
|
459 |
+
|
460 |
msg.submit(respond, [msg, gpt], [msg,gpt])
|
461 |
|
462 |
index = construct_index("docs")
|