max_headroom/main.py
2024-10-03 22:30:31 -04:00

42 lines
1.0 KiB
Python

from modules import agent
import asyncio
import environ
import os
env = environ.Env()
environ.Env.read_env()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
if os.name == "nt":
op = "windows"
elif os.name == "posix":
# Further check to differentiate between Linux and macOS
if 'linux' in os.uname().sysname.lower():
print("linux")
op = "linux"
elif 'darwin' in os.uname().sysname.lower():
op = "macos"
else:
exit("Unknown operating system.")
else:
exit("Unknown operating system.")
graph = agent.Agent(env,op)
while True:
text = graph.spk.listen(int(env("TIME_LISTEN")))
# if text:
# print(f"User: {text}")
if text and "hey" in text.lower() and env("CHARACTER").lower() in text.lower():
if "exit" in text.lower():
break
print("agent invoked")
response = loop.run_until_complete(graph.invoke_agent(text))
if response:
graph.spk.glitch_stream_output(response)
# graph.spk.stream(response)