BaseExampleSelector Class — langchain Architecture
Architecture documentation for the BaseExampleSelector class in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3["BaseExampleSelector"] 45bfa5b0_0ddc_1128_a846_ff383c907bd7["base.py"] 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3 -->|defined in| 45bfa5b0_0ddc_1128_a846_ff383c907bd7 1baef3a2_ba60_5ff3_e3a1_0e99d8c26569["add_example()"] 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3 -->|method| 1baef3a2_ba60_5ff3_e3a1_0e99d8c26569 345ad429_48a3_8c03_0dcc_21d87a4f5398["aadd_example()"] 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3 -->|method| 345ad429_48a3_8c03_0dcc_21d87a4f5398 eab49c52_bd0e_12e1_acc7_d44b8da90731["select_examples()"] 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3 -->|method| eab49c52_bd0e_12e1_acc7_d44b8da90731 287e8836_455b_93f1_34df_e000ca0f1c9f["aselect_examples()"] 74ffd8a3_9e55_a6a9_c38a_f187a794f1a3 -->|method| 287e8836_455b_93f1_34df_e000ca0f1c9f
Relationship Graph
Source Code
libs/core/langchain_core/example_selectors/base.py lines 9–58
class BaseExampleSelector(ABC):
"""Interface for selecting examples to include in prompts."""
@abstractmethod
def add_example(self, example: dict[str, str]) -> Any:
"""Add new example to store.
Args:
example: A dictionary with keys as input variables
and values as their values.
Returns:
Any return value.
"""
async def aadd_example(self, example: dict[str, str]) -> Any:
"""Async add new example to store.
Args:
example: A dictionary with keys as input variables
and values as their values.
Returns:
Any return value.
"""
return await run_in_executor(None, self.add_example, example)
@abstractmethod
def select_examples(self, input_variables: dict[str, str]) -> list[dict]:
"""Select which examples to use based on the inputs.
Args:
input_variables: A dictionary with keys as input variables
and values as their values.
Returns:
A list of examples.
"""
async def aselect_examples(self, input_variables: dict[str, str]) -> list[dict]:
"""Async select which examples to use based on the inputs.
Args:
input_variables: A dictionary with keys as input variables
and values as their values.
Returns:
A list of examples.
"""
return await run_in_executor(None, self.select_examples, input_variables)
Source
Frequently Asked Questions
What is the BaseExampleSelector class?
BaseExampleSelector is a class in the langchain codebase, defined in libs/core/langchain_core/example_selectors/base.py.
Where is BaseExampleSelector defined?
BaseExampleSelector is defined in libs/core/langchain_core/example_selectors/base.py at line 9.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free