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
  15e14e95_cbcf_22f8_6cc5_e15ae3dbcff0["create_prompt()"]
  37cb2b60_9ae1_7f39_46a1_1f7d0156c75f["OpenAIMultiFunctionsAgent"]
  15e14e95_cbcf_22f8_6cc5_e15ae3dbcff0 -->|defined in| 37cb2b60_9ae1_7f39_46a1_1f7d0156c75f
  a48ce0cf_92fc_c84b_b28d_0ea9f75501f7["from_llm_and_tools()"]
  a48ce0cf_92fc_c84b_b28d_0ea9f75501f7 -->|calls| 15e14e95_cbcf_22f8_6cc5_e15ae3dbcff0
  style 15e14e95_cbcf_22f8_6cc5_e15ae3dbcff0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py lines 267–299

    def create_prompt(
        cls,
        system_message: SystemMessage | None = _NOT_SET,  # type: ignore[assignment]
        extra_prompt_messages: list[BaseMessagePromptTemplate] | None = None,
    ) -> BasePromptTemplate:
        """Create prompt for this agent.

        Args:
            system_message: Message to use as the system message that will be the
                first in the prompt.
            extra_prompt_messages: Prompt messages that will be placed between the
                system message and the new human input.

        Returns:
            A prompt template to pass into this agent.
        """
        _prompts = extra_prompt_messages or []
        system_message_ = (
            system_message
            if system_message is not _NOT_SET
            else SystemMessage(content="You are a helpful AI assistant.")
        )
        messages: list[BaseMessagePromptTemplate | BaseMessage]
        messages = [system_message_] if system_message_ else []

        messages.extend(
            [
                *_prompts,
                HumanMessagePromptTemplate.from_template("{input}"),
                MessagesPlaceholder(variable_name="agent_scratchpad"),
            ],
        )
        return ChatPromptTemplate(messages=messages)

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/openai_functions_multi_agent/base.py.
Where is create_prompt() defined?
create_prompt() is defined in libs/langchain/langchain_classic/agents/openai_functions_multi_agent/base.py at line 267.
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