Feat : better print of think process and answer
This commit is contained in:
+11
-4
@@ -3,7 +3,7 @@ from sources.text_to_speech import Speech
|
||||
from sources.utility import pretty_print
|
||||
|
||||
class Interaction:
|
||||
def __init__(self, agents, tts_enabled: bool = False):
|
||||
def __init__(self, agents, tts_enabled: bool = False, recover_last_session: bool = False):
|
||||
self.tts_enabled = tts_enabled
|
||||
self.agents = agents
|
||||
self.speech = Speech()
|
||||
@@ -12,6 +12,12 @@ class Interaction:
|
||||
self.last_answer = None
|
||||
if tts_enabled:
|
||||
self.speech.speak("Hello Sir, we are online and ready. What can I do for you ?")
|
||||
if recover_last_session:
|
||||
self.recover_last_session()
|
||||
|
||||
def recover_last_session(self):
|
||||
for agent in self.agents:
|
||||
agent.memory.load_memory()
|
||||
|
||||
def is_active(self):
|
||||
return self.is_active
|
||||
@@ -32,15 +38,16 @@ class Interaction:
|
||||
query = self.read_stdin()
|
||||
if query is None:
|
||||
self.is_active = False
|
||||
return
|
||||
self.last_query = "Goodbye (exit requested by user, dont think, make answer very short)"
|
||||
return None
|
||||
self.last_query = query
|
||||
return query
|
||||
|
||||
def think(self):
|
||||
self.last_answer, _ = self.agents[0].answer(self.last_query, self.speech)
|
||||
self.last_answer, _ = self.agents[0].process(self.last_query, self.speech)
|
||||
|
||||
def show_answer(self):
|
||||
pretty_print(self.last_answer, color="output")
|
||||
self.agents[0].show_answer()
|
||||
if self.tts_enabled:
|
||||
self.speech.speak(self.last_answer)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user