Chat bug fix (#40)
* Update chat.py * fixed chat not sending message & types Co-authored-by: Nunzi99 <claudionunziante@gmail.com>
This commit was merged in pull request #40.
This commit is contained in:
committed by
GitHub
parent
06c660b659
commit
885a70d748
@@ -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 [], []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user