refine_prompts.py — langchain Source File
Architecture documentation for refine_prompts.py, a python file in the langchain codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR cd5387f9_a2e4_ad5f_f790_ad1a3dc9d0d6["refine_prompts.py"] 435e49bf_bb2e_2016_ead7_0afb9d57ad71["langchain_core.prompts"] cd5387f9_a2e4_ad5f_f790_ad1a3dc9d0d6 --> 435e49bf_bb2e_2016_ead7_0afb9d57ad71 style cd5387f9_a2e4_ad5f_f790_ad1a3dc9d0d6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from langchain_core.prompts import PromptTemplate
DEFAULT_REFINE_PROMPT_TMPL = (
"The original question is as follows: {question}\n"
"We have provided an existing answer, including sources: {existing_answer}\n"
"We have the opportunity to refine the existing answer"
"(only if needed) with some more context below.\n"
"------------\n"
"{context_str}\n"
"------------\n"
"Given the new context, refine the original answer to better "
"answer the question. "
"If you do update it, please update the sources as well. "
"If the context isn't useful, return the original answer."
)
DEFAULT_REFINE_PROMPT = PromptTemplate(
input_variables=["question", "existing_answer", "context_str"],
template=DEFAULT_REFINE_PROMPT_TMPL,
)
DEFAULT_TEXT_QA_PROMPT_TMPL = (
"Context information is below. \n"
"---------------------\n"
"{context_str}"
"\n---------------------\n"
"Given the context information and not prior knowledge, "
"answer the question: {question}\n"
)
DEFAULT_TEXT_QA_PROMPT = PromptTemplate(
input_variables=["context_str", "question"], template=DEFAULT_TEXT_QA_PROMPT_TMPL
)
EXAMPLE_PROMPT = PromptTemplate(
template="Content: {page_content}\nSource: {source}",
input_variables=["page_content", "source"],
)
Dependencies
- langchain_core.prompts
Source
Frequently Asked Questions
What does refine_prompts.py do?
refine_prompts.py is a source file in the langchain codebase, written in python.
What does refine_prompts.py depend on?
refine_prompts.py imports 1 module(s): langchain_core.prompts.
Where is refine_prompts.py in the architecture?
refine_prompts.py is located at libs/langchain/langchain_classic/chains/qa_with_sources/refine_prompts.py (directory: libs/langchain/langchain_classic/chains/qa_with_sources).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free