Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,6 @@ if torch.cuda.is_available():
|
|
28 |
def generate(
|
29 |
message: str,
|
30 |
chat_history: list[tuple[str, str]],
|
31 |
-
system_prompt: str,
|
32 |
max_new_tokens: int = 1024,
|
33 |
temperature: float = 0.6,
|
34 |
top_p: float = 0.9,
|
@@ -36,8 +35,11 @@ def generate(
|
|
36 |
repetition_penalty: float = 1.2,
|
37 |
) -> Iterator[str]:
|
38 |
conversation = []
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
for user, assistant in chat_history:
|
42 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
43 |
conversation.append({"role": "user", "content": message})
|
@@ -111,11 +113,11 @@ chat_interface = gr.ChatInterface(
|
|
111 |
],
|
112 |
stop_btn=None,
|
113 |
examples=[
|
114 |
-
["
|
115 |
-
["
|
116 |
-
["
|
117 |
-
["
|
118 |
-
["
|
119 |
],
|
120 |
)
|
121 |
|
|
|
28 |
def generate(
|
29 |
message: str,
|
30 |
chat_history: list[tuple[str, str]],
|
|
|
31 |
max_new_tokens: int = 1024,
|
32 |
temperature: float = 0.6,
|
33 |
top_p: float = 0.9,
|
|
|
35 |
repetition_penalty: float = 1.2,
|
36 |
) -> Iterator[str]:
|
37 |
conversation = []
|
38 |
+
conversation.append({"role": "system", "content":
|
39 |
+
'''Sei un an assistente AI di nome 'AvvoChat' specializzato nel rispondere a domande riguardanti la legge Italiana.
|
40 |
+
Rispondi in lingua italiana in modo chiaro, semplice ed esaustivo alle domande che ti vengono fornite.
|
41 |
+
Le risposte devono essere sintetiche e chiare di massimo 500 token o anche più corte.
|
42 |
+
Firmati alla fine di ogni risposta '-AvvoChat'.'''})
|
43 |
for user, assistant in chat_history:
|
44 |
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
45 |
conversation.append({"role": "user", "content": message})
|
|
|
113 |
],
|
114 |
stop_btn=None,
|
115 |
examples=[
|
116 |
+
["Posso fare un barbecue sul balcone di casa?"],
|
117 |
+
["Posso essere multato se esco di casa senza documento d'identità?"],
|
118 |
+
["Una persona single può adottare un bambino?"],
|
119 |
+
["Posso usare un immagine creada con l'intelligenza artificiale?"],
|
120 |
+
["Se il mio pallone da calcio cade in un giardino di un'abitazione privata, poss scavalcare il concello per riprendermelo?"],
|
121 |
],
|
122 |
)
|
123 |
|