Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def generate(
|
|
| 48 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
| 49 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
| 50 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
| 51 |
-
gr.Warning(f"
|
| 52 |
input_ids = input_ids.to(model.device)
|
| 53 |
|
| 54 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
|
@@ -75,7 +75,7 @@ def generate(
|
|
| 75 |
chat_interface = gr.ChatInterface(
|
| 76 |
fn=generate,
|
| 77 |
additional_inputs=[
|
| 78 |
-
gr.Textbox(label="System prompt", lines=6),
|
| 79 |
gr.Slider(
|
| 80 |
label="Max new tokens",
|
| 81 |
minimum=1,
|
|
@@ -90,6 +90,10 @@ chat_interface = gr.ChatInterface(
|
|
| 90 |
step=0.1,
|
| 91 |
value=0.6,
|
| 92 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
gr.Slider(
|
| 94 |
label="Top-p (nucleus sampling)",
|
| 95 |
minimum=0.05,
|
|
@@ -114,16 +118,16 @@ chat_interface = gr.ChatInterface(
|
|
| 114 |
],
|
| 115 |
stop_btn=None,
|
| 116 |
examples=[
|
| 117 |
-
["
|
| 118 |
-
["
|
| 119 |
-
["
|
| 120 |
-
["
|
| 121 |
-
["Write a 100-word article on 'Benefits of Open-Source in AI research'"],
|
| 122 |
],
|
| 123 |
)
|
| 124 |
|
| 125 |
with gr.Blocks(css="style.css") as demo:
|
| 126 |
gr.Markdown("# AvvoChat")
|
|
|
|
| 127 |
gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
|
| 128 |
chat_interface.render()
|
| 129 |
|
|
|
|
| 48 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
| 49 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
| 50 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
| 51 |
+
gr.Warning(f"Domanda e/o conversazione troppo lungha: superati {MAX_INPUT_TOKEN_LENGTH} tokens.")
|
| 52 |
input_ids = input_ids.to(model.device)
|
| 53 |
|
| 54 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
|
|
|
| 75 |
chat_interface = gr.ChatInterface(
|
| 76 |
fn=generate,
|
| 77 |
additional_inputs=[
|
| 78 |
+
#gr.Textbox(label="System prompt", lines=6),
|
| 79 |
gr.Slider(
|
| 80 |
label="Max new tokens",
|
| 81 |
minimum=1,
|
|
|
|
| 90 |
step=0.1,
|
| 91 |
value=0.6,
|
| 92 |
),
|
| 93 |
+
gr.Checkbox(
|
| 94 |
+
label = "Do-sample(False)",
|
| 95 |
+
value = False,
|
| 96 |
+
)
|
| 97 |
gr.Slider(
|
| 98 |
label="Top-p (nucleus sampling)",
|
| 99 |
minimum=0.05,
|
|
|
|
| 118 |
],
|
| 119 |
stop_btn=None,
|
| 120 |
examples=[
|
| 121 |
+
["Posso fare una grigliata sul balcone di casa?"],
|
| 122 |
+
["Se esco di casa senza documento di identità posso essere multato?"],
|
| 123 |
+
["Le persone single possono adottare un bambino?"],
|
| 124 |
+
["Posso usare un'immagine prodotto dall'intelligenza artificiale?"],
|
|
|
|
| 125 |
],
|
| 126 |
)
|
| 127 |
|
| 128 |
with gr.Blocks(css="style.css") as demo:
|
| 129 |
gr.Markdown("# AvvoChat")
|
| 130 |
+
gr.Image("AvvoVhat.png", width = 50, height=200)
|
| 131 |
gr.Markdown("Fai una domanda riguardante la legge italiana all'AvvoChat e ricevi una spiegazione semplice al tuo dubbio.")
|
| 132 |
chat_interface.render()
|
| 133 |
|