| """Main entry point for running the LangGraph agent.""" |
|
|
| import sys |
| from pathlib import Path |
|
|
| |
| sys.path.insert(0, str(Path(__file__).parent)) |
|
|
| from agents.process_aware_agent import run_agent |
|
|
|
|
| def main(): |
| """Run the agent in interactive mode.""" |
| print("=" * 60) |
| print("LangGraph Agent - Interactive Mode") |
| print("=" * 60) |
| print("Type 'exit' or 'quit' to end the conversation") |
| print("=" * 60) |
| print() |
| |
| while True: |
| try: |
| |
| user_input = input("You: ").strip() |
| |
| |
| if user_input.lower() in ["exit", "quit", "q"]: |
| print("\nGoodbye!") |
| break |
| |
| |
| if not user_input: |
| continue |
| |
| |
| print("\nAgent: ", end="", flush=True) |
| response = run_agent(user_input) |
| print(response) |
| print() |
| |
| except KeyboardInterrupt: |
| print("\n\nGoodbye!") |
| break |
| except Exception as e: |
| print(f"\nError: {e}") |
| print("Please try again.\n") |
|
|
|
|
| def run_single_query(query: str): |
| """Run a single query and print the response.""" |
| try: |
| response = run_agent(query) |
| print(f"Query: {query}") |
| print(f"Response: {response}") |
| except Exception as e: |
| print(f"Error: {e}") |
| sys.exit(1) |
|
|
|
|
| if __name__ == "__main__": |
| |
| if len(sys.argv) > 1: |
| query = " ".join(sys.argv[1:]) |
| run_single_query(query) |
| else: |
| main() |
|
|
| |
|
|