MCPcopy
hub / github.com/stitionai/devika / handle_message

Function handle_message

devika.py:78–103  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

76# Main socket
77@socketio.on('user-message')
78def 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)

Callers

nothing calls this directly

Calls 8

executeMethod · 0.95
subsequent_executeMethod · 0.95
AgentClass · 0.90
emit_agentFunction · 0.90
infoMethod · 0.80
get_latest_stateMethod · 0.80
startMethod · 0.80
is_agent_completedMethod · 0.80

Tested by

no test coverage detected