Skip to content

Commit

Permalink
Model differential response support.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwaterdev committed Jul 9, 2024
1 parent 20579ef commit 499aa97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 12 additions & 2 deletions lidya/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@
sys.path.append("./")

# Load configuration
print('[*] Loading config... ')
CONF = config.Config("./config")

# Init STT & TTS
print('[*] Loading STT & TTS... ')
r = sr.Recognizer()
tts = tts.TTS(CONF.get_lang(), CONF.get_tts_model())

# Load plugins:
print('[*] Loading plugins... ')
pm = pluginmanager.PluginManager()
pm.load_plugins()

# Init LLM
print('[*] Loading LLM... ')
llm = llm_con.Connector(
CONF.get_main_model(),
CONF.get_main_service(),
Expand All @@ -41,6 +46,7 @@
)

# Main func
print('[*] Starting... ')
def listen_and_repeat(last_communication):
"""Main listen & repeat function"""
with sr.Microphone() as source:
Expand All @@ -49,7 +55,7 @@ def listen_and_repeat(last_communication):

#user_message = "ok lydia execute la commande 'weather' pour récupérer la météo."

if (time.time() - last_communication) < 5:
if (time.time() - last_communication) < 10:
present = True
message = user_message
else:
Expand Down Expand Up @@ -96,7 +102,11 @@ def listen_and_repeat(last_communication):
)

print("[*] Generating audio... ")
tts.play_generate_audio(llm_result["message"])
if type(llm_result) == dict and "message" in llm_result.keys():
tts.play_generate_audio(llm_result["message"])
else:
playsound('./lidya/ressources/sounds/fail_blip.mp3')
tts.play_generate_audio(llm_result)

print("[*] Process finished. ")
last_communication = time.time()
Expand Down
4 changes: 0 additions & 4 deletions lidya/libs/pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ def process_actions(self, actions):
if action["args"] == {}:
result = self.execute_plugin_action(action_name)
else:
print(action)
mapping = {action['name']: action['value']}

print(mapping)
result = self.execute_plugin_action(action_name, args=mapping)

if result is not None:
Expand All @@ -59,6 +57,4 @@ def load_plugins(self):

plugin_manager_json.append(plugin_json_conf)

print(plugin_manager_json)

return plugin_manager_json

0 comments on commit 499aa97

Please sign in to comment.