Spaces:
Sleeping
Sleeping
Commit
·
e6f2e4b
1
Parent(s):
605c191
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,22 +11,38 @@ def get_manual_content():
|
|
| 11 |
# global manual_content
|
| 12 |
# response = requests.get(manual_url)
|
| 13 |
# if response.status_code == 200:
|
| 14 |
-
manual_content =
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
def format_prompt(message, history):
|
| 20 |
global manual_content
|
| 21 |
if manual_content is None or not history or not any(user_prompt for user_prompt, _ in history):
|
| 22 |
get_manual_content()
|
| 23 |
prompt = "<s>"
|
| 24 |
-
if manual_content:
|
| 25 |
-
prompt += f"[INST]Leggi questo MANUALE dopo ti farò delle domande: [/INST] {manual_content}"
|
| 26 |
for user_prompt, bot_response in history:
|
| 27 |
prompt += f"[INST] {user_prompt} [/INST]"
|
| 28 |
-
prompt += f" {bot_response}
|
| 29 |
-
prompt +=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
return prompt
|
| 31 |
|
| 32 |
def generate(
|
|
|
|
| 11 |
# global manual_content
|
| 12 |
# response = requests.get(manual_url)
|
| 13 |
# if response.status_code == 200:
|
| 14 |
+
manual_content = input: '''
|
| 15 |
+
{
|
| 16 |
+
role: "system",
|
| 17 |
+
content: "Tu sei BonsiAI l'assistente virtuale per studenti direttamente incaricato dal Sig.Bonsignori. Rispondi alle domande degli studenti in modo pertinente mantenendoti coerente alle INSTRUCTION ricevute. Sii cordiale, gentile e simpatico, utilizzando gerghi giovanili tipici della Generazione Z",
|
| 18 |
+
},
|
| 19 |
+
messages: [
|
| 20 |
+
{
|
| 21 |
+
role: "instructions",
|
| 22 |
+
content: [
|
| 23 |
+
"Per le info sui compiti di tecnologia alimentare, rivolgersi alla Professoressa Lampugnani.",
|
| 24 |
+
"Per le questioni amministrative, rivolgersi a Rossano della segreteria.",
|
| 25 |
+
"Per il compito di matematica devi seguire il PDF su Classroom",
|
| 26 |
+
"Se vuoi lamentarti per i compiti non farlo dal preside ma chiedi un appuntamento al tuo tutor",
|
| 27 |
+
"Per il colloquio con i genitori manda una mail a colloqui@bonsignori.it"
|
| 28 |
+
],
|
| 29 |
+
},
|
| 30 |
+
''';
|
| 31 |
|
| 32 |
def format_prompt(message, history):
|
| 33 |
global manual_content
|
| 34 |
if manual_content is None or not history or not any(user_prompt for user_prompt, _ in history):
|
| 35 |
get_manual_content()
|
| 36 |
prompt = "<s>"
|
|
|
|
|
|
|
| 37 |
for user_prompt, bot_response in history:
|
| 38 |
prompt += f"[INST] {user_prompt} [/INST]"
|
| 39 |
+
prompt += f" {bot_response}"
|
| 40 |
+
prompt += '</s>'
|
| 41 |
+
prompt += manual_content + f'''{{
|
| 42 |
+
"role": "user",
|
| 43 |
+
"content": "{message}",
|
| 44 |
+
}},
|
| 45 |
+
]'''
|
| 46 |
return prompt
|
| 47 |
|
| 48 |
def generate(
|