diff --git a/main.py b/main.py index e55b514..c530ddf 100644 --- a/main.py +++ b/main.py @@ -1,48 +1,61 @@ import asyncio +import os +from dotenv import load_dotenv from agent import Agent from util.logger import get_logger -print("MAIN FILE STARTED") + +load_dotenv() + +# Konfiguration +AWS_REGION = os.getenv("AWS_REGION") +AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") +AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") +BEDROCK_MODEL = os.getenv("BEDROCK_MODEL") +MCP_URL = os.getenv("MCP_URL") + async def main(): - log = get_logger("NORA") - print("\n==============================") + print("\n" + "="*40) print(" N.O.R.A START") - print("==============================\n") + print("="*40 + "\n") agent = Agent() - log.info("Connecting MCP...") - await agent.mcp.connect() + try: + log.info("Connecting to MCP...") + await agent.mcp.connect() - log.info("Loading tools...") - await agent.load_tools() + log.info("Loading tools...") + await agent.load_tools() - print("\nN.O.R.A bereit. (exit zum Beenden)\n") + print("N.O.R.A ist bereit. (Schreibe 'exit' oder 'quit' zum Beenden)\n") - while True: + while True: + try: + user = input("Du: ").strip() - try: - user = input("Du: ").strip() + if user.lower() in ["exit", "quit", "bye"]: + break - if user.lower() in ["exit", "quit"]: + if not user: + continue + + response = await agent.run(user) + print(f"\nN.O.R.A: {response}\n") + + except KeyboardInterrupt: break + except Exception as e: + log.error(f"Fehler in Main-Loop: {e}") + print("Ein Fehler ist aufgetreten. Bitte versuche es erneut.") - if not user: - continue + finally: + await agent.mcp.close() + log.info("Shutdown complete") - response = await agent.run(user) - print(f"\nN.O.R.A: {response}\n") - - except KeyboardInterrupt: - break - - except Exception as e: - log.error(str(e)) - - await agent.mcp.close() - - log.info("Shutdown complete") \ No newline at end of file +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file