prompts.py — langchain Source File
Architecture documentation for prompts.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR eca6bfa0_5185_88eb_2dac_40de1829cc94["prompts.py"] 83d7c7fd_1989_762c_9cf3_cecb50ada22b["langchain_core.output_parsers"] eca6bfa0_5185_88eb_2dac_40de1829cc94 --> 83d7c7fd_1989_762c_9cf3_cecb50ada22b e6b4f61e_7b98_6666_3641_26b069517d4a["langchain_core.prompts"] eca6bfa0_5185_88eb_2dac_40de1829cc94 --> e6b4f61e_7b98_6666_3641_26b069517d4a 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] eca6bfa0_5185_88eb_2dac_40de1829cc94 --> 91721f45_4909_e489_8c1f_084f8bd87145 style eca6bfa0_5185_88eb_2dac_40de1829cc94 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.output_parsers import BaseOutputParser
from langchain_core.prompts import PromptTemplate
from typing_extensions import override
class FinishedOutputParser(BaseOutputParser[tuple[str, bool]]):
"""Output parser that checks if the output is finished."""
finished_value: str = "FINISHED"
"""Value that indicates the output is finished."""
@override
def parse(self, text: str) -> tuple[str, bool]:
cleaned = text.strip()
finished = self.finished_value in cleaned
return cleaned.replace(self.finished_value, ""), finished
PROMPT_TEMPLATE = """\
Respond to the user message using any relevant context. \
If context is provided, you should ground your answer in that context. \
Once you're done responding return FINISHED.
>>> CONTEXT: {context}
>>> USER INPUT: {user_input}
>>> RESPONSE: {response}\
"""
PROMPT = PromptTemplate(
template=PROMPT_TEMPLATE,
input_variables=["user_input", "context", "response"],
)
QUESTION_GENERATOR_PROMPT_TEMPLATE = """\
Given a user input and an existing partial response as context, \
ask a question to which the answer is the given term/entity/phrase:
>>> USER INPUT: {user_input}
>>> EXISTING PARTIAL RESPONSE: {current_response}
The question to which the answer is the term/entity/phrase "{uncertain_span}" is:"""
QUESTION_GENERATOR_PROMPT = PromptTemplate(
template=QUESTION_GENERATOR_PROMPT_TEMPLATE,
input_variables=["user_input", "current_response", "uncertain_span"],
)
Domain
Subdomains
Classes
Dependencies
- langchain_core.output_parsers
- langchain_core.prompts
- typing_extensions
Source
Frequently Asked Questions
What does prompts.py do?
prompts.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What does prompts.py depend on?
prompts.py imports 3 module(s): langchain_core.output_parsers, langchain_core.prompts, typing_extensions.
Where is prompts.py in the architecture?
prompts.py is located at libs/langchain/langchain_classic/chains/flare/prompts.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/chains/flare).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free