cli.py 532 B

12345678910111213141516171819202122
  1. from .chain import create_chat_agent
  2. from .config import load_config
  3. def run_chat() -> None:
  4. config = load_config()
  5. agent = create_chat_agent(config)
  6. while True:
  7. question = input("请输入: ").strip()
  8. if not question:
  9. continue
  10. if question.lower() in ["exit", "quit", "q"]:
  11. break
  12. result = agent.invoke(
  13. {"messages": [{"role": "user", "content": question}]}
  14. )
  15. answer = result["messages"][-1].content
  16. print(f"AI: {answer}")