langchain_experimental.autonomous_agents.autogpt.prompt.AutoGPTPrompt¶

class langchain_experimental.autonomous_agents.autogpt.prompt.AutoGPTPrompt(*, input_variables: List[str], output_parser: Optional[BaseOutputParser] = None, partial_variables: Mapping[str, Union[str, Callable[[], str]]] = None, ai_name: str, ai_role: str, tools: List[BaseTool], token_counter: Callable[[str], int], send_token_limit: int = 4196)[source]¶

Bases: BaseChatPromptTemplate, BaseModel

Prompt for AutoGPT.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param ai_name: str [Required]¶
param ai_role: str [Required]¶
param input_variables: List[str] [Required]¶

A list of the names of the variables the prompt template expects.

param output_parser: Optional[BaseOutputParser] = None¶

How to parse the output of calling an LLM on this formatted prompt.

param partial_variables: Mapping[str, Union[str, Callable[[], str]]] [Optional]¶
param send_token_limit: int = 4196¶
param token_counter: Callable[[str], int] [Required]¶
param tools: List[langchain.tools.base.BaseTool] [Required]¶
construct_full_prompt(goals: List[str]) str[source]¶
dict(**kwargs: Any) Dict¶

Return dictionary representation of prompt.

format(**kwargs: Any) str¶

Format the chat template into a string.

Parameters

**kwargs – keyword arguments to use for filling in template variables in all the template messages in this chat template.

Returns

formatted string

format_messages(**kwargs: Any) List[BaseMessage][source]¶

Format kwargs into a list of messages.

format_prompt(**kwargs: Any) PromptValue¶

Format prompt. Should return a PromptValue. :param **kwargs: Keyword arguments to use for formatting.

Returns

PromptValue.

invoke(input: Dict, config: langchain.schema.runnable.RunnableConfig | None = None) PromptValue¶
partial(**kwargs: Union[str, Callable[[], str]]) BasePromptTemplate¶

Return a partial of the prompt template.

save(file_path: Union[Path, str]) None¶

Save the prompt.

Parameters

file_path – Path to directory to save prompt to.

Example: .. code-block:: python

prompt.save(file_path=”path/prompt.yaml”)

to_json() Union[SerializedConstructor, SerializedNotImplemented]¶
to_json_not_implemented() SerializedNotImplemented¶
validator validate_variable_names  »  all fields¶

Validate variable names do not include restricted names.

property lc_attributes: Dict¶

Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor.

property lc_namespace: List[str]¶

Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”]

property lc_secrets: Dict[str, str]¶

Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”}

property lc_serializable: bool¶

Return whether or not the class is serializable.

model Config¶

Bases: object

Configuration for this pydantic object.

arbitrary_types_allowed = True¶