few_shot_with_templates.py — langchain Source File
Architecture documentation for few_shot_with_templates.py, a python file in the langchain codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5b0211c9_fbcc_94a9_d100_7d26aec78d95["few_shot_with_templates.py"] b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8["pathlib"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> b6ee5de5_719a_eeb5_1e11_e9c63bc22ef8 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> 91721f45_4909_e489_8c1f_084f8bd87145 a4804e3f_4fa3_c9fc_7121_e057c2daa7e3["langchain_core.example_selectors"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> a4804e3f_4fa3_c9fc_7121_e057c2daa7e3 c17bcf07_a2ef_b992_448f_5088d46a1e79["langchain_core.prompts.prompt"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> c17bcf07_a2ef_b992_448f_5088d46a1e79 e10bb307_3784_1031_cf6b_680e7c362c93["langchain_core.prompts.string"] 5b0211c9_fbcc_94a9_d100_7d26aec78d95 --> e10bb307_3784_1031_cf6b_680e7c362c93 style 5b0211c9_fbcc_94a9_d100_7d26aec78d95 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""Prompt template that contains few shot examples."""
from pathlib import Path
from typing import Any
from pydantic import ConfigDict, model_validator
from typing_extensions import Self
from langchain_core.example_selectors import BaseExampleSelector
from langchain_core.prompts.prompt import PromptTemplate
from langchain_core.prompts.string import (
DEFAULT_FORMATTER_MAPPING,
PromptTemplateFormat,
StringPromptTemplate,
)
class FewShotPromptWithTemplates(StringPromptTemplate):
"""Prompt template that contains few shot examples."""
examples: list[dict] | None = None
"""Examples to format into the prompt.
Either this or `example_selector` should be provided.
"""
example_selector: BaseExampleSelector | None = None
"""`ExampleSelector` to choose the examples to format into the prompt.
Either this or `examples` should be provided.
"""
example_prompt: PromptTemplate
"""`PromptTemplate` used to format an individual example."""
suffix: StringPromptTemplate
"""A `PromptTemplate` to put after the examples."""
example_separator: str = "\n\n"
"""String separator used to join the prefix, the examples, and suffix."""
prefix: StringPromptTemplate | None = None
"""A `PromptTemplate` to put before the examples."""
template_format: PromptTemplateFormat = "f-string"
"""The format of the prompt template.
Options are: `'f-string'`, `'jinja2'`, `'mustache'`.
"""
validate_template: bool = False
"""Whether or not to try validating the template."""
@classmethod
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the LangChain object.
Returns:
`["langchain", "prompts", "few_shot_with_templates"]`
"""
// ... (171 more lines)
Domain
Subdomains
Classes
Dependencies
- langchain_core.example_selectors
- langchain_core.prompts.prompt
- langchain_core.prompts.string
- pathlib
- pydantic
- typing
- typing_extensions
Source
Frequently Asked Questions
What does few_shot_with_templates.py do?
few_shot_with_templates.py is a source file in the langchain codebase, written in python. It belongs to the PromptManagement domain, ExampleSelection subdomain.
What does few_shot_with_templates.py depend on?
few_shot_with_templates.py imports 7 module(s): langchain_core.example_selectors, langchain_core.prompts.prompt, langchain_core.prompts.string, pathlib, pydantic, typing, typing_extensions.
Where is few_shot_with_templates.py in the architecture?
few_shot_with_templates.py is located at libs/core/langchain_core/prompts/few_shot_with_templates.py (domain: PromptManagement, subdomain: ExampleSelection, directory: libs/core/langchain_core/prompts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free