Source code for langchain_experimental.autonomous_agents.autogpt.prompt_generator
import json
from typing import List
from langchain.tools.base import BaseTool
FINISH_NAME = "finish"
[docs]class PromptGenerator:
    """A class for generating custom prompt strings.
    Does this based on constraints, commands, resources, and performance evaluations.
    """
[docs]    def __init__(self) -> None:
        """Initialize the PromptGenerator object.
        Starts with empty lists of constraints, commands, resources,
        and performance evaluations.
        """
        self.constraints: List[str] = []
        self.commands: List[BaseTool] = []
        self.resources: List[str] = []
        self.performance_evaluation: List[str] = []
        self.response_format = {
            "thoughts": {
                "text": "thought",
                "reasoning": "reasoning",
                "plan": "- short bulleted\n- list that conveys\n- long-term plan",
                "criticism": "constructive self-criticism",
                "speak": "thoughts summary to say to user",
            },
            "command": {"name": "command name", "args": {"arg name": "value"}},
        }
[docs]    def add_constraint(self, constraint: str) -> None:
        """
        Add a constraint to the constraints list.
        Args:
            constraint (str): The constraint to be added.
        """
        self.constraints.append(constraint)
[docs]    def add_tool(self, tool: BaseTool) -> None:
        self.commands.append(tool)
    def _generate_command_string(self, tool: BaseTool) -> str:
        output = f"{tool.name}: {tool.description}"