stuff_prompt.py — langchain Source File
Architecture documentation for stuff_prompt.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0aee237f_0528_0df0_48c0_591a038c404e["stuff_prompt.py"] 435e49bf_bb2e_2016_ead7_0afb9d57ad71["langchain_core.prompts"] 0aee237f_0528_0df0_48c0_591a038c404e --> 435e49bf_bb2e_2016_ead7_0afb9d57ad71 16c7d167_e2e4_cd42_2bc2_d182459cd93c["langchain_core.prompts.chat"] 0aee237f_0528_0df0_48c0_591a038c404e --> 16c7d167_e2e4_cd42_2bc2_d182459cd93c 19f929ef_6721_dbe8_8478_f6ed6cf3eb7d["langchain_classic.chains.prompt_selector"] 0aee237f_0528_0df0_48c0_591a038c404e --> 19f929ef_6721_dbe8_8478_f6ed6cf3eb7d style 0aee237f_0528_0df0_48c0_591a038c404e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.prompts import PromptTemplate
from langchain_core.prompts.chat import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
from langchain_classic.chains.prompt_selector import (
ConditionalPromptSelector,
is_chat_model,
)
prompt_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.
{context}
Question: {question}
Helpful Answer:""" # noqa: E501
PROMPT = PromptTemplate(
template=prompt_template, input_variables=["context", "question"]
)
system_template = """Use the following pieces of context to answer the user's question.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
----------------
{context}""" # noqa: E501
messages = [
SystemMessagePromptTemplate.from_template(system_template),
HumanMessagePromptTemplate.from_template("{question}"),
]
CHAT_PROMPT = ChatPromptTemplate.from_messages(messages)
PROMPT_SELECTOR = ConditionalPromptSelector(
default_prompt=PROMPT, conditionals=[(is_chat_model, CHAT_PROMPT)]
)
Dependencies
- langchain_classic.chains.prompt_selector
- langchain_core.prompts
- langchain_core.prompts.chat
Source
Frequently Asked Questions
What does stuff_prompt.py do?
stuff_prompt.py is a source file in the langchain codebase, written in python.
What does stuff_prompt.py depend on?
stuff_prompt.py imports 3 module(s): langchain_classic.chains.prompt_selector, langchain_core.prompts, langchain_core.prompts.chat.
Where is stuff_prompt.py in the architecture?
stuff_prompt.py is located at libs/langchain/langchain_classic/chains/question_answering/stuff_prompt.py (directory: libs/langchain/langchain_classic/chains/question_answering).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free