Chat bug fix #40

Merged
Berack96 merged 3 commits from chat_bug_fix into main 2025-10-20 17:12:30 +02:00

View File

@@ -15,6 +15,7 @@ class ChatManager:
def __init__(self):
self.history: list[tuple[str, str]] = []
self.inputs = PipelineInputs()
def save_chat(self, filename: str = "chat.json") -> None:
"""
Salva la chat corrente in src/saves/<filename>.
@@ -49,16 +50,10 @@ class ChatManager:
# Funzioni Gradio
########################################
def gradio_respond(self, message: str, history: list[tuple[str, str]]) -> str:
'''
self.send_message(message)
self.inputs.user_query = message
self.receive_message(response)
return response
'''
pipeline = Pipeline(self.inputs)
response = pipeline.interact()
self.history.append((message, response))
return response
@@ -66,12 +61,12 @@ class ChatManager:
self.save_chat("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")
history = self.get_history()
return history, history
def gradio_clear(self) -> str:
def gradio_clear(self) -> tuple[list[str], list[str]]:
self.reset_chat()
return [], []