Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
from __future__ import annotations
|
| 2 |
from abc import ABC, abstractmethod
|
|
|
|
| 3 |
from openai_utils import chat_completion_request
|
| 4 |
import gradio as gr
|
| 5 |
|
|
@@ -300,17 +301,9 @@ class erroregptdomandaaperta(NodePrintText):
|
|
| 300 |
super().__init__(text, nextNode)
|
| 301 |
|
| 302 |
class stamparispostaaperta(NodePrintText):
|
| 303 |
-
def __init__(self, text="Hai fatto una domanda di {}. Risposta: {}. Desideri fare un'altra domanda aperta
|
| 304 |
super().__init__(text, nextNode, get_variable_list)
|
| 305 |
|
| 306 |
-
class altradomandaapertaripeti(NodePrintText):
|
| 307 |
-
def __init__(self, text="Scusa non ho capito, puoi ripetere? Rispondi con 'si' o 'no'.", nextNode='altradomandaapertaclassifica'):
|
| 308 |
-
super().__init__(text, nextNode)
|
| 309 |
-
|
| 310 |
-
class altradomandaapertaclassifica(NodeSingleChoiceNextNode):
|
| 311 |
-
def __init__(self, choice_list=['si', 'no'], repeatNode='altradomandaapertaripeti', node_list=['domandaaperta', 'NodeTerminate']):
|
| 312 |
-
super().__init__(choice_list, repeatNode, node_list)
|
| 313 |
-
|
| 314 |
|
| 315 |
# lato operazione matematica
|
| 316 |
class operazionemate(NodePrintText):
|
|
@@ -340,21 +333,27 @@ class erroregptmate(NodePrintText):
|
|
| 340 |
super().__init__(text, nextNode)
|
| 341 |
|
| 342 |
class stamparispostamate(NodePrintText):
|
| 343 |
-
def __init__(self, text="Soluzione: {}. Desideri fare un'altra domanda di matematica
|
| 344 |
get_variable_list=['risposta']):
|
| 345 |
super().__init__(text, nextNode, get_variable_list)
|
| 346 |
|
| 347 |
-
|
| 348 |
-
|
|
|
|
|
|
|
| 349 |
super().__init__(text, nextNode)
|
| 350 |
|
| 351 |
-
class
|
| 352 |
-
def __init__(self,
|
| 353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
-
######################################################################################
|
| 358 |
chatbot = Chat(introduzione())
|
| 359 |
|
| 360 |
def generate_message(message, history):
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
from abc import ABC, abstractmethod
|
| 3 |
+
from typing import List
|
| 4 |
from openai_utils import chat_completion_request
|
| 5 |
import gradio as gr
|
| 6 |
|
|
|
|
| 301 |
super().__init__(text, nextNode)
|
| 302 |
|
| 303 |
class stamparispostaaperta(NodePrintText):
|
| 304 |
+
def __init__(self, text="Hai fatto una domanda di {}. Risposta: {}. Desideri fare un'altra domanda aperta, una domanda di matematica oppure terminare la conversazione?", nextNode='altradomandaclassifica', get_variable_list=['tema', 'risposta']):
|
| 305 |
super().__init__(text, nextNode, get_variable_list)
|
| 306 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
# lato operazione matematica
|
| 309 |
class operazionemate(NodePrintText):
|
|
|
|
| 333 |
super().__init__(text, nextNode)
|
| 334 |
|
| 335 |
class stamparispostamate(NodePrintText):
|
| 336 |
+
def __init__(self, text="Soluzione: {}. Desideri fare un'altra domanda di matematica, una domanda aperta oppure terminare la conversazione?", nextNode='altradomandaclassifica',
|
| 337 |
get_variable_list=['risposta']):
|
| 338 |
super().__init__(text, nextNode, get_variable_list)
|
| 339 |
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
class altradomandaripeti(NodePrintText):
|
| 343 |
+
def __init__(self, text="Non ho capito, puoi ripetere?", nextNode='altradomandaclassifica'):
|
| 344 |
super().__init__(text, nextNode)
|
| 345 |
|
| 346 |
+
class altradomandaclassifica(NodeEntityExtractionNextNode):
|
| 347 |
+
def __init__(self, prompt="Leggi l'input utente e scrivi una delle seguenti opzioni, in base a cosa sta chiedendo l'utente: 'terminare conversazione', 'fare domanda aperta', 'fare operazione matematica'. Input utente: {}",
|
| 348 |
+
entity_list=['terminare conversazione', 'domanda aperta', 'operazione matematica'],
|
| 349 |
+
entity_parsing_list=['terminare', 'domanda', 'mate'], repeatNode='altradomandaripeti',
|
| 350 |
+
node_list=['NodeTerminate', 'domandaaperta', 'operazionemate']):
|
| 351 |
+
super().__init__(prompt, entity_list, entity_parsing_list, repeatNode, node_list)
|
| 352 |
+
|
| 353 |
+
|
| 354 |
|
| 355 |
|
| 356 |
|
|
|
|
| 357 |
chatbot = Chat(introduzione())
|
| 358 |
|
| 359 |
def generate_message(message, history):
|