Main interactive loop
()
| 42 | |
| 43 | |
| 44 | def main(): |
| 45 | """Main interactive loop""" |
| 46 | try: |
| 47 | # Validate configuration |
| 48 | Config.validate() |
| 49 | |
| 50 | # Print banner |
| 51 | print_banner() |
| 52 | |
| 53 | # Initialize agent |
| 54 | print("Initializing AI agent...") |
| 55 | agent = LogAnalyzerAgent() |
| 56 | print("Ready!\n") |
| 57 | |
| 58 | # Main loop |
| 59 | while True: |
| 60 | try: |
| 61 | # Get user input |
| 62 | user_input = input("You: ").strip() |
| 63 | |
| 64 | # Handle empty input |
| 65 | if not user_input: |
| 66 | continue |
| 67 | |
| 68 | # Handle commands |
| 69 | if user_input.lower() in ['quit', 'exit', 'q']: |
| 70 | print("\nGoodbye!") |
| 71 | break |
| 72 | |
| 73 | if user_input.lower() == 'clear': |
| 74 | agent.clear_history() |
| 75 | print("\nConversation history cleared.\n") |
| 76 | continue |
| 77 | |
| 78 | if user_input.lower() == 'help': |
| 79 | print_help() |
| 80 | continue |
| 81 | |
| 82 | # Process query |
| 83 | response = agent.process_query(user_input) |
| 84 | print(f"\nAgent: {response}\n") |
| 85 | |
| 86 | except KeyboardInterrupt: |
| 87 | print("\n\nInterrupted. Type 'quit' to exit.\n") |
| 88 | continue |
| 89 | except EOFError: |
| 90 | print("\n\nGoodbye!") |
| 91 | break |
| 92 | |
| 93 | except ValueError as e: |
| 94 | print(f"\nConfiguration Error: {e}") |
| 95 | print("Please check your .env file and ensure GEMINI_API_KEY is set.") |
| 96 | sys.exit(1) |
| 97 | except Exception as e: |
| 98 | print(f"\nUnexpected Error: {e}") |
| 99 | import traceback |
| 100 | traceback.print_exc() |
| 101 | sys.exit(1) |
no test coverage detected