MCPcopy
hub / github.com/OpenBMB/ChatDev / start_workflow

Method start_workflow

server/services/workflow_run_service.py:56–134  ·  view source on GitHub ↗
(
        self,
        session_id: str,
        yaml_file: str,
        task_prompt: str,
        websocket_manager,
        *,
        attachments: Optional[List[str]] = None,
        log_level: Optional[LogLevel] = None,
    )

Source from the content-addressed store, hash-verified

54 return True
55
56 async def start_workflow(
57 self,
58 session_id: str,
59 yaml_file: str,
60 task_prompt: str,
61 websocket_manager,
62 *,
63 attachments: Optional[List[str]] = None,
64 log_level: Optional[LogLevel] = None,
65 ) -> None:
66 normalized_yaml_name = (yaml_file or "").strip()
67 try:
68 yaml_path = self._resolve_yaml_path(normalized_yaml_name)
69 normalized_yaml_name = yaml_path.name
70
71 attachments = attachments or []
72 if (not task_prompt or not task_prompt.strip()) and not attachments:
73 raise ValidationError(
74 "Task prompt cannot be empty",
75 details={"task_prompt_provided": bool(task_prompt)},
76 )
77
78 self.attachment_service.prepare_session_workspace(session_id)
79 self.session_store.create_session(
80 yaml_file=normalized_yaml_name,
81 task_prompt=task_prompt,
82 session_id=session_id,
83 attachments=attachments,
84 )
85 self.session_store.update_session_status(session_id, SessionStatus.RUNNING)
86
87 await websocket_manager.send_message(
88 session_id,
89 {
90 "type": "workflow_started",
91 "data": {"yaml_file": normalized_yaml_name, "task_prompt": task_prompt},
92 },
93 )
94
95 await self._execute_workflow_async(
96 session_id,
97 yaml_path,
98 task_prompt,
99 websocket_manager,
100 attachments,
101 log_level,
102 )
103 except ValidationError as exc:
104 self.logger.error(str(exc))
105 logger = get_server_logger()
106 logger.error(
107 "Workflow validation error",
108 log_type=LogType.WORKFLOW,
109 session_id=session_id,
110 yaml_file=normalized_yaml_name,
111 validation_details=getattr(exc, "details", None),
112 )
113 self.session_store.set_session_error(session_id, str(exc))

Callers 1

execute_workflowFunction · 0.80

Calls 11

_resolve_yaml_pathMethod · 0.95
ValidationErrorClass · 0.90
get_server_loggerFunction · 0.90
create_sessionMethod · 0.80
update_session_statusMethod · 0.80
send_messageMethod · 0.80
set_session_errorMethod · 0.80
log_exceptionMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected