Home / Function/ create_prompt() — langchain Function Reference

create_prompt() — langchain Function Reference

Architecture documentation for the create_prompt() function in base.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  51288a9b_4b41_be4d_9859_e166250304c2["create_prompt()"]
  f260a2f9_1c69_1831_630e_d202f4a07d55["ZeroShotAgent"]
  51288a9b_4b41_be4d_9859_e166250304c2 -->|defined in| f260a2f9_1c69_1831_630e_d202f4a07d55
  0bb7cfa7_8dd3_1957_b3c5_9fcf35a6d6f2["from_llm_and_tools()"]
  0bb7cfa7_8dd3_1957_b3c5_9fcf35a6d6f2 -->|calls| 51288a9b_4b41_be4d_9859_e166250304c2
  style 51288a9b_4b41_be4d_9859_e166250304c2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/mrkl/base.py lines 83–111

    def create_prompt(
        cls,
        tools: Sequence[BaseTool],
        prefix: str = PREFIX,
        suffix: str = SUFFIX,
        format_instructions: str = FORMAT_INSTRUCTIONS,
        input_variables: list[str] | None = None,
    ) -> PromptTemplate:
        """Create prompt in the style of the zero shot agent.

        Args:
            tools: List of tools the agent will have access to, used to format the
                prompt.
            prefix: String to put before the list of tools.
            suffix: String to put after the list of tools.
            format_instructions: Instructions on how to use the tools.
            input_variables: List of input variables the final prompt will expect.


        Returns:
            A PromptTemplate with the template assembled from the pieces here.
        """
        tool_strings = render_text_description(list(tools))
        tool_names = ", ".join([tool.name for tool in tools])
        format_instructions = format_instructions.format(tool_names=tool_names)
        template = f"{prefix}\n\n{tool_strings}\n\n{format_instructions}\n\n{suffix}"
        if input_variables:
            return PromptTemplate(template=template, input_variables=input_variables)
        return PromptTemplate.from_template(template)

Subdomains

Frequently Asked Questions

What does create_prompt() do?
create_prompt() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/mrkl/base.py.
Where is create_prompt() defined?
create_prompt() is defined in libs/langchain/langchain_classic/agents/mrkl/base.py at line 83.
What calls create_prompt()?
create_prompt() is called by 1 function(s): from_llm_and_tools.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free