Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -87,9 +87,10 @@ def generate(
|
|
87 |
#prompt_finale = prompt_template(materiali, message)
|
88 |
conversation = []
|
89 |
conversation.append({"role": "system", "content":
|
90 |
-
'''Sei un an assistente AI di nome 'AvvoChat' specializzato nel rispondere
|
|
|
91 |
Rispondi in lingua italiana in modo chiaro, semplice ed esaustivo alle domande che ti vengono fornite.
|
92 |
-
Le risposte devono essere
|
93 |
Firmati alla fine di ogni risposta '-AvvoChat'.'''})
|
94 |
for user, assistant in chat_history:
|
95 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
@@ -98,7 +99,7 @@ def generate(
|
|
98 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
99 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
100 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
101 |
-
gr.Warning(f"
|
102 |
input_ids = input_ids.to(model.device)
|
103 |
|
104 |
streamer = TextIteratorStreamer(tokenizer, timeout=30.0, skip_prompt=True, skip_special_tokens=True)
|
|
|
87 |
#prompt_finale = prompt_template(materiali, message)
|
88 |
conversation = []
|
89 |
conversation.append({"role": "system", "content":
|
90 |
+
'''Sei un an assistente AI di nome 'AvvoChat' specializzato nel rispondere la legge Italiana.
|
91 |
+
Se le domande non riguardano questioni legali astieniti dal rispondere e scrivi "Sono specializzato in domande di tipo legale: non sono accurato su questo tipo di domande".
|
92 |
Rispondi in lingua italiana in modo chiaro, semplice ed esaustivo alle domande che ti vengono fornite.
|
93 |
+
Le risposte devono essere chiare e semplici con argomentazioni valide e puntuali.
|
94 |
Firmati alla fine di ogni risposta '-AvvoChat'.'''})
|
95 |
for user, assistant in chat_history:
|
96 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
|
|
99 |
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt")
|
100 |
if input_ids.shape[1] > MAX_INPUT_TOKEN_LENGTH:
|
101 |
input_ids = input_ids[:, -MAX_INPUT_TOKEN_LENGTH:]
|
102 |
+
gr.Warning(f"Conversazione troppo lunga: sforati i {MAX_INPUT_TOKEN_LENGTH} tokens.")
|
103 |
input_ids = input_ids.to(model.device)
|
104 |
|
105 |
streamer = TextIteratorStreamer(tokenizer, timeout=30.0, skip_prompt=True, skip_special_tokens=True)
|