A class for generating custom prompt strings. Does this based on constraints, commands, resources, and performance evaluations.
| 7 | |
| 8 | |
| 9 | class PromptGenerator: |
| 10 | """A class for generating custom prompt strings. |
| 11 | |
| 12 | Does this based on constraints, commands, resources, and performance evaluations. |
| 13 | """ |
| 14 | |
| 15 | def __init__(self) -> None: |
| 16 | """Initialize the PromptGenerator object. |
| 17 | |
| 18 | Starts with empty lists of constraints, commands, resources, |
| 19 | and performance evaluations. |
| 20 | """ |
| 21 | self.constraints: List[str] = [] |
| 22 | self.commands: List[BaseTool] = [] |
| 23 | self.resources: List[str] = [] |
| 24 | self.performance_evaluation: List[str] = [] |
| 25 | self.response_format = { |
| 26 | "thoughts": { |
| 27 | "text": "thought", |
| 28 | "reasoning": "reasoning", |
| 29 | }, |
| 30 | "command": {"name": "command name", "args": {"goal": "the detailed description and necessary information of the subtask that you hope current command can achieve"}}, |
| 31 | } |
| 32 | |
| 33 | def add_constraint(self, constraint: str) -> None: |
| 34 | """ |
| 35 | Add a constraint to the constraints list. |
| 36 | |
| 37 | Args: |
| 38 | constraint (str): The constraint to be added. |
| 39 | """ |
| 40 | self.constraints.append(constraint) |
| 41 | |
| 42 | def add_tool(self, tool: BaseTool) -> None: |
| 43 | self.commands.append(tool) |
| 44 | |
| 45 | def _generate_command_string(self, tool: BaseTool) -> str: |
| 46 | output = f"{tool.name}: {tool.description}" |
| 47 | # json_args = json.dumps(tool.args) if "tool_input" not in tool.args else tool.args[ |
| 48 | # "tool_input" |
| 49 | # ] |
| 50 | # output += f", args json schema: {json_args}" |
| 51 | return output |
| 52 | |
| 53 | def add_resource(self, resource: str) -> None: |
| 54 | """ |
| 55 | Add a resource to the resources list. |
| 56 | |
| 57 | Args: |
| 58 | resource (str): The resource to be added. |
| 59 | """ |
| 60 | self.resources.append(resource) |
| 61 | |
| 62 | def add_performance_evaluation(self, evaluation: str) -> None: |
| 63 | """ |
| 64 | Add a performance evaluation item to the performance_evaluation list. |
| 65 | |
| 66 | Args: |