(data)
| 76 | # Main socket |
| 77 | @socketio.on('user-message') |
| 78 | def handle_message(data): |
| 79 | logger.info(f"User message: {data}") |
| 80 | message = data.get('message') |
| 81 | base_model = data.get('base_model') |
| 82 | project_name = data.get('project_name') |
| 83 | search_engine = data.get('search_engine').lower() |
| 84 | |
| 85 | agent = Agent(base_model=base_model, search_engine=search_engine) |
| 86 | |
| 87 | state = AgentState.get_latest_state(project_name) |
| 88 | if not state: |
| 89 | thread = Thread(target=lambda: agent.execute(message, project_name)) |
| 90 | thread.start() |
| 91 | else: |
| 92 | if AgentState.is_agent_completed(project_name): |
| 93 | thread = Thread(target=lambda: agent.subsequent_execute(message, project_name)) |
| 94 | thread.start() |
| 95 | else: |
| 96 | emit_agent("info", {"type": "warning", "message": "previous agent doesn't completed it's task."}) |
| 97 | last_state = AgentState.get_latest_state(project_name) |
| 98 | if last_state["agent_is_active"] or not last_state["completed"]: |
| 99 | thread = Thread(target=lambda: agent.execute(message, project_name)) |
| 100 | thread.start() |
| 101 | else: |
| 102 | thread = Thread(target=lambda: agent.subsequent_execute(message, project_name)) |
| 103 | thread.start() |
| 104 | |
| 105 | @app.route("/api/is-agent-active", methods=["POST"]) |
| 106 | @route_logger(logger) |
nothing calls this directly
no test coverage detected