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

Function parse_response

camel/tasks/task.py:32–53  ·  view source on GitHub ↗

r"""Parse Tasks from a response. Args: response (str): The model response. task_id (str, optional): a parent task id, the default value is "0" Returns: List[Task]: A list of tasks which is :obj:`Task` instance.

(
    response: str, task_id: Optional[str] = None
)

Source from the content-addressed store, hash-verified

30
31
32def parse_response(
33 response: str, task_id: Optional[str] = None
34) -> List["Task"]:
35 r"""Parse Tasks from a response.
36
37 Args:
38 response (str): The model response.
39 task_id (str, optional): a parent task id,
40 the default value is "0"
41
42 Returns:
43 List[Task]: A list of tasks which is :obj:`Task` instance.
44 """
45 pattern = "<task>(.*?)</task>"
46 tasks_content = re.findall(pattern, response, re.DOTALL)
47
48 tasks = []
49 if task_id is None:
50 task_id = "0"
51 for i, content in enumerate(tasks_content):
52 tasks.append(Task(content=content.strip(), id=f"{task_id}.{i}"))
53 return tasks
54
55
56class TaskState(str, Enum):

Callers

nothing calls this directly

Calls 1

TaskClass · 0.70

Tested by

no test coverage detected