Spaces:
Runtime error
Runtime error
| # File Objective : Interactive CLI for the Vantage agent. | |
| # Scope : Dev script β verify routing, multi-hop, and multi-turn memory. | |
| # What it does : 1. REPL loop; one thread_id keeps conversation memory across turns. | |
| # 2. Streams LangGraph updates to log each ReAct step live. | |
| # 3. Support --graph argument to output Mermaid markup. | |
| # What it does not: Expose HTTP or persist memory beyond the process. | |
| from __future__ import annotations | |
| import sys | |
| import time | |
| from vantage_core.agent.graph import build_agent | |
| from vantage_core.agent.trace import log_step | |
| from vantage_core.log import get_logger | |
| log = get_logger("agent_cli") | |
| _CONFIG = {"configurable": {"thread_id": "cli"}} # stable id β memory persists across turns | |
| def main() -> None: | |
| agent = build_agent() | |
| if "--graph" in sys.argv: | |
| print("\nββ LangGraph Agent Mermaid Export ββββββββββββββββββββββββββββββ") | |
| print(agent.get_graph().draw_mermaid()) | |
| print("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n") | |
| return | |
| print("\nββ Vantage Market Intelligence Agent ββββββββββββββββββββββββββββ") | |
| print(" Ready for multi-turn research chat. Type 'exit' to quit.\n") | |
| while True: | |
| try: | |
| question = input("You: ").strip() | |
| except (KeyboardInterrupt, EOFError): | |
| print() | |
| break | |
| if question.lower() in {"exit", "quit", ""}: | |
| break | |
| log.info("ββ turn start q=%r", question[:120]) | |
| t0 = time.perf_counter() | |
| final = "" | |
| for chunk in agent.stream( | |
| {"messages": [("user", question)]}, _CONFIG, stream_mode="updates" | |
| ): | |
| for _node, update in chunk.items(): | |
| _tools, step_final = log_step(update) | |
| if step_final: | |
| final = step_final | |
| log.info("ββ turn done elapsed=%.2fs", time.perf_counter() - t0) | |
| print(f"\nVantage: {final}\n") | |
| if __name__ == "__main__": | |
| main() | |