r"""Specify the given task prompt by providing more details. Args: task_prompt (Union[str, TextPrompt]): The original task prompt. meta_dict (Dict[str, Any], optional): A dictionary containing additional information to include in the p
(
self,
task_prompt: Union[str, TextPrompt],
meta_dict: Optional[Dict[str, Any]] = None,
)
| 91 | ) |
| 92 | |
| 93 | def run( |
| 94 | self, |
| 95 | task_prompt: Union[str, TextPrompt], |
| 96 | meta_dict: Optional[Dict[str, Any]] = None, |
| 97 | ) -> TextPrompt: |
| 98 | r"""Specify the given task prompt by providing more details. |
| 99 | |
| 100 | Args: |
| 101 | task_prompt (Union[str, TextPrompt]): The original task |
| 102 | prompt. |
| 103 | meta_dict (Dict[str, Any], optional): A dictionary containing |
| 104 | additional information to include in the prompt. |
| 105 | (default: :obj:`None`) |
| 106 | |
| 107 | Returns: |
| 108 | TextPrompt: The specified task prompt. |
| 109 | """ |
| 110 | self.reset() |
| 111 | task_specify_prompt = self.task_specify_prompt.format(task=task_prompt) |
| 112 | |
| 113 | if meta_dict is not None: |
| 114 | task_specify_prompt = task_specify_prompt.format(**meta_dict) |
| 115 | task_msg = BaseMessage.make_user_message( |
| 116 | role_name="Task Specifier", content=task_specify_prompt |
| 117 | ) |
| 118 | specifier_response = self.step(task_msg) |
| 119 | |
| 120 | if specifier_response.terminated: |
| 121 | raise RuntimeError("Task specification failed.") |
| 122 | if len(specifier_response.msgs) == 0: |
| 123 | raise RuntimeError("Got no specification message.") |
| 124 | |
| 125 | specified_task_msg = specifier_response.msgs[0] |
| 126 | |
| 127 | return TextPrompt(specified_task_msg.content) |
| 128 | |
| 129 | |
| 130 | @track_agent(name="TaskPlannerAgent") |
no test coverage detected