Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -72,20 +72,9 @@ def generate(
|
|
72 |
|
73 |
image_path = "AvvoVhat.png"
|
74 |
|
75 |
-
with gr.Blocks() as demo:
|
76 |
-
gr.Markdown("# AvvoChat")
|
77 |
-
gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
|
78 |
-
|
79 |
-
with gr.Row():
|
80 |
-
msg = gr.Textbox(show_label=False, placeholder="Inserisci il tuo messaggio...")
|
81 |
-
btn = gr.Button("Invia")
|
82 |
-
|
83 |
-
with gr.Row():
|
84 |
-
with gr.Column(scale=0.5, min_width=100):
|
85 |
-
gr.Image(image_path, width=50, height=200)
|
86 |
-
with gr.Column(scale=6):
|
87 |
-
chatbox = gr.Chatbot(label="AvvoChat")
|
88 |
|
|
|
|
|
89 |
additional_inputs = [
|
90 |
gr.Slider(
|
91 |
label="Max new tokens",
|
@@ -134,48 +123,33 @@ with gr.Blocks() as demo:
|
|
134 |
["Una persona single può adottare un bambino?"],
|
135 |
["Posso usare un immagine creada con l'intelligenza artificiale?"],
|
136 |
["Se il mio pallone da calcio cade in un giardino di un'abitazione privata, poss scavalcare il concello per riprendermelo?"],
|
137 |
-
]
|
|
|
138 |
|
139 |
-
def on_send_message(message, chat_history, max_new_tokens, temperature, top_p, top_k, do_sample, repetition_penalty):
|
140 |
-
response_stream = generate(
|
141 |
-
message=message,
|
142 |
-
chat_history=chat_history,
|
143 |
-
max_new_tokens=max_new_tokens,
|
144 |
-
temperature=temperature,
|
145 |
-
top_p=top_p,
|
146 |
-
top_k=top_k,
|
147 |
-
do_sample=do_sample,
|
148 |
-
repetition_penalty=repetition_penalty,
|
149 |
-
)
|
150 |
-
#full_response = response_stream[-1]
|
151 |
-
full_response = ""
|
152 |
-
for response in response_stream:
|
153 |
-
full_response += response
|
154 |
-
chat_history.append((message, full_response))
|
155 |
-
return chat_history, ""
|
156 |
-
|
157 |
-
# Collegare il pulsante e la textbox alla funzione on_send_message
|
158 |
-
btn.click(
|
159 |
-
on_send_message,
|
160 |
-
inputs=[
|
161 |
-
msg,
|
162 |
-
chatbox,
|
163 |
-
*additional_inputs
|
164 |
-
],
|
165 |
-
outputs=[chatbox, msg],
|
166 |
-
)
|
167 |
-
msg.submit(
|
168 |
-
on_send_message,
|
169 |
-
inputs=[
|
170 |
-
msg,
|
171 |
-
chatbox,
|
172 |
-
*additional_inputs
|
173 |
-
],
|
174 |
-
outputs=[chatbox, msg],
|
175 |
-
)
|
176 |
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
if __name__ == "__main__":
|
181 |
demo.queue(max_size=20).launch(share=True)
|
|
|
72 |
|
73 |
image_path = "AvvoVhat.png"
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
chat_interface = gr.ChatInterface(
|
77 |
+
fn = generate
|
78 |
additional_inputs = [
|
79 |
gr.Slider(
|
80 |
label="Max new tokens",
|
|
|
123 |
["Una persona single può adottare un bambino?"],
|
124 |
["Posso usare un immagine creada con l'intelligenza artificiale?"],
|
125 |
["Se il mio pallone da calcio cade in un giardino di un'abitazione privata, poss scavalcare il concello per riprendermelo?"],
|
126 |
+
]
|
127 |
+
)
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
|
135 |
+
with gr.Blocks() as demo:
|
136 |
+
gr.Markdown("# AvvoChat")
|
137 |
+
gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
|
138 |
+
|
139 |
+
with gr.Row():
|
140 |
+
msg = gr.Textbox(show_label=False, placeholder="Inserisci il tuo messaggio...")
|
141 |
+
btn = gr.Button("Invia")
|
142 |
+
|
143 |
+
with gr.Row():
|
144 |
+
with gr.Column(scale=0.5, min_width=100):
|
145 |
+
gr.Image(image_path, width=50, height=200)
|
146 |
+
with gr.Column(scale=6):
|
147 |
+
chatbox = gr.Chatbot(label="AvvoChat")
|
148 |
+
chat_interface.render()
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
|
154 |
if __name__ == "__main__":
|
155 |
demo.queue(max_size=20).launch(share=True)
|