""" Chatbot entry point — interactive terminal loop. Imports the compiled graph from graph.py (which in turn loads all artifacts and creates the agents). Then starts an infinite loop that: 1. Reads the user input 2. Sends it to the graph as a HumanMessage 3. Prints the response of the last agent Type 'q', 'quit' or 'exit' to quit. """ import os os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" from langchain_core.messages import HumanMessage from utils.config import DEFAULT_THREAD_ID from graph import app # Session configuration — the thread_id identifies the conversation # and lets the MemorySaver keep the history across turns config = {"configurable": {"thread_id": DEFAULT_THREAD_ID}} print("\n--- SYSTEM READY ---") while True: try: user_input = input("You: ") if user_input.lower() in ["q", "quit", "exit"]: break # Send the message to the graph and get the final state result = app.invoke({"messages": [HumanMessage(content=user_input)]}, config=config) # The last message in the list is the agent's response print(f"Bot: {result['messages'][-1].content}\n") except Exception as e: print(f"SYSTEM ERROR: {e}")