Source code for langchain_core.example_selectors.base

"""用于选择包含在提示中的示例的接口。"""
from abc import ABC, abstractmethod
from typing import Any, Dict, List

from langchain_core.runnables import run_in_executor


[docs]class BaseExampleSelector(ABC): """用于选择包含在提示中的示例的接口。"""
[docs] @abstractmethod def add_example(self, example: Dict[str, str]) -> Any: """添加新的示例到存储。"""
[docs] async def aadd_example(self, example: Dict[str, str]) -> Any: """添加新的示例到存储。""" return await run_in_executor(None, self.add_example, example)
[docs] @abstractmethod def select_examples(self, input_variables: Dict[str, str]) -> List[dict]: """根据输入选择要使用的示例。"""
[docs] async def aselect_examples(self, input_variables: Dict[str, str]) -> List[dict]: """根据输入选择要使用的示例。""" return await run_in_executor(None, self.select_examples, input_variables)