MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / worker

Function worker

server/routes/execute_sync.py:209–240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

207 event_queue.put((event_type, data))
208
209 def worker() -> None:
210 try:
211 enqueue(
212 "started",
213 {"yaml_file": request.yaml_file, "task_prompt": request.task_prompt},
214 )
215 final_message, meta = _run_workflow_with_logger(
216 yaml_file=request.yaml_file,
217 task_prompt=request.task_prompt,
218 attachments=request.attachments,
219 session_name=request.session_name,
220 variables=request.variables,
221 log_level=resolved_log_level,
222 log_callback=enqueue,
223 )
224 enqueue(
225 "completed",
226 {
227 "status": "completed",
228 "final_message": final_message.text_content() if final_message else "",
229 "token_usage": meta["token_usage"],
230 "output_dir": str(meta["output_dir"].resolve()),
231 },
232 )
233 except (FileNotFoundError, ValidationError) as exc:
234 enqueue("error", {"message": str(exc)})
235 except Exception as exc:
236 logger = get_server_logger()
237 logger.log_exception(exc, "Failed to run workflow via streaming API")
238 enqueue("error", {"message": f"Failed to run workflow: {exc}"})
239 finally:
240 done_event.set()
241
242 threading.Thread(target=worker, daemon=True).start()
243

Callers

nothing calls this directly

Calls 6

get_server_loggerFunction · 0.90
enqueueFunction · 0.85
text_contentMethod · 0.80
resolveMethod · 0.80
log_exceptionMethod · 0.80

Tested by

no test coverage detected