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 428fd0bf_f575_d9ce_a33a_03b23d9eb0f0["create_prompt()"] 93ed7b23_f0e4_5732_b3ed_dccef0049b97["OpenAIFunctionsAgent"] 428fd0bf_f575_d9ce_a33a_03b23d9eb0f0 -->|defined in| 93ed7b23_f0e4_5732_b3ed_dccef0049b97 4e43f07b_4dcb_07be_cdea_d96f79d80f79["from_llm_and_tools()"] 4e43f07b_4dcb_07be_cdea_d96f79d80f79 -->|calls| 428fd0bf_f575_d9ce_a33a_03b23d9eb0f0 style 428fd0bf_f575_d9ce_a33a_03b23d9eb0f0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/openai_functions_agent/base.py lines 214–246
def create_prompt(
cls,
system_message: SystemMessage | None = _NOT_SET, # type: ignore[assignment]
extra_prompt_messages: list[BaseMessagePromptTemplate] | None = None,
) -> ChatPromptTemplate:
"""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)
Domain
Subdomains
Called By
Source
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_agent/base.py.
Where is create_prompt() defined?
create_prompt() is defined in libs/langchain/langchain_classic/agents/openai_functions_agent/base.py at line 214.
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