MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / compose

Method compose

camel/tasks/task.py:247–282  ·  view source on GitHub ↗

r"""compose task result by the sub-tasks. Args: agent (ChatAgent): An agent that used to compose the task result. template (TextPrompt, optional): The prompt template to compose task. If not provided, the default template will be used. res

(
        self,
        agent: ChatAgent,
        template: TextPrompt = TASK_COMPOSE_PROMPT,
        result_parser: Optional[Callable[[str], str]] = None,
    )

Source from the content-addressed store, hash-verified

245 return tasks
246
247 def compose(
248 self,
249 agent: ChatAgent,
250 template: TextPrompt = TASK_COMPOSE_PROMPT,
251 result_parser: Optional[Callable[[str], str]] = None,
252 ):
253 r"""compose task result by the sub-tasks.
254
255 Args:
256 agent (ChatAgent): An agent that used to compose the task result.
257 template (TextPrompt, optional): The prompt template to compose
258 task. If not provided, the default template will be used.
259 result_parser (Callable[[str, str], List[Task]], optional): A
260 function to extract Task from response.
261 """
262
263 if not self.subtasks:
264 return
265
266 sub_tasks_result = self.get_result()
267
268 role_name = agent.role_name
269 content = template.format(
270 role_name=role_name,
271 content=self.content,
272 additional_info=self.additional_info,
273 other_results=sub_tasks_result,
274 )
275 msg = BaseMessage.make_user_message(
276 role_name=role_name, content=content
277 )
278 response = agent.step(msg)
279 result = response.msg.content
280 if result_parser:
281 result = result_parser(result)
282 self.update_result(result)
283
284 def get_depth(self) -> int:
285 r"""Get current task depth."""

Callers 1

_post_ready_tasksMethod · 0.45

Calls 5

get_resultMethod · 0.95
update_resultMethod · 0.95
formatMethod · 0.45
make_user_messageMethod · 0.45
stepMethod · 0.45

Tested by

no test coverage detected