LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
PythonlangsmithclientClientsimilar_examples
Method●Since v0.1

similar_examples

Retrieve the dataset examples whose inputs best match the current inputs.

Note

Must have few-shot indexing enabled for the dataset. See client.index_dataset().

Copy
similar_examples(
  self,
  inputs: dict,
  ,
  *,
  limit: int,
  dataset_id: ID_TYPE,
  filter: Optional[str] = None,
  **kwargs: Any = {}
) -> list[ls_schemas.ExampleSearch]

Parameters

NameTypeDescription
inputs*dict

The inputs to use as a search query. Must match the dataset input schema. Must be JSON serializable.

limit*int

The maximum number of examples to return.

dataset_id*Union[UUID, str]

The ID of the dataset to search over.

filterOptional[str]
Default:None

A filter string to apply to the search results. Uses the same syntax as the filter parameter in list_runs(). Only a subset of operations are supported.

For example, you can use and(eq(metadata.some_tag, 'some_value'), neq(metadata.env, 'dev')) to filter only examples where some_tag has some_value, and the environment is not dev.

**kwargsAny
Default:{}

Additional keyword arguments to pass as part of request body.

View source on GitHub