Chat bug fix #40
@@ -15,6 +15,7 @@ class ChatManager:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.history: list[tuple[str, str]] = []
|
self.history: list[tuple[str, str]] = []
|
||||||
self.inputs = PipelineInputs()
|
self.inputs = PipelineInputs()
|
||||||
|
|
||||||
def save_chat(self, filename: str = "chat.json") -> None:
|
def save_chat(self, filename: str = "chat.json") -> None:
|
||||||
"""
|
"""
|
||||||
Salva la chat corrente in src/saves/<filename>.
|
Salva la chat corrente in src/saves/<filename>.
|
||||||
@@ -49,16 +50,10 @@ class ChatManager:
|
|||||||
# Funzioni Gradio
|
# Funzioni Gradio
|
||||||
########################################
|
########################################
|
||||||
def gradio_respond(self, message: str, history: list[tuple[str, str]]) -> str:
|
def gradio_respond(self, message: str, history: list[tuple[str, str]]) -> str:
|
||||||
'''
|
|
||||||
self.send_message(message)
|
|
||||||
|
|
||||||
self.inputs.user_query = message
|
self.inputs.user_query = message
|
||||||
|
|
||||||
self.receive_message(response)
|
|
||||||
return response
|
|
||||||
'''
|
|
||||||
pipeline = Pipeline(self.inputs)
|
pipeline = Pipeline(self.inputs)
|
||||||
response = pipeline.interact()
|
response = pipeline.interact()
|
||||||
|
|
||||||
self.history.append((message, response))
|
self.history.append((message, response))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@@ -66,12 +61,12 @@ class ChatManager:
|
|||||||
self.save_chat("chat.json")
|
self.save_chat("chat.json")
|
||||||
return "💾 Chat salvata in chat.json"
|
return "💾 Chat salvata in chat.json"
|
||||||
|
|
||||||
def gradio_load(self) -> str:
|
def gradio_load(self) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]:
|
||||||
self.load_chat("chat.json")
|
self.load_chat("chat.json")
|
||||||
history = self.get_history()
|
history = self.get_history()
|
||||||
return history, history
|
return history, history
|
||||||
|
|
||||||
def gradio_clear(self) -> str:
|
def gradio_clear(self) -> tuple[list[str], list[str]]:
|
||||||
self.reset_chat()
|
self.reset_chat()
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user