| 13 | |
| 14 | |
| 15 | def interaction(agent: AgentClient): |
| 16 | try: |
| 17 | history = [] |
| 18 | while True: |
| 19 | print("================= USER ===================") |
| 20 | user = input(">>> ") |
| 21 | history.append({"role": "user", "content": user}) |
| 22 | try: |
| 23 | agent_response = agent.inference(history) |
| 24 | print("================ AGENT ====================") |
| 25 | print(agent_response) |
| 26 | history.append({"role": "agent", "content": agent_response}) |
| 27 | except Exception as e: |
| 28 | print(e) |
| 29 | exit(0) |
| 30 | except KeyboardInterrupt: |
| 31 | print("\n[Exit] KeyboardInterrupt") |
| 32 | exit(0) |
| 33 | |
| 34 | |
| 35 | if __name__ == '__main__': |