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
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_expect_Expect
Class●Since v0.1

_Expect

A class for setting expectations on test results.

Copy
_Expect( self, *, client: Optional[ls_client.Client] = None, )

Constructors

Attributes

Methods

View source on GitHub
constructor
__init__
NameType
clientOptional[ls_client.Client]
attribute
executor
method
embedding_distance
method
edit_distance
method
value
method
score

Compute the embedding distance between the prediction and reference.

This logs the embedding distance to LangSmith and returns a _Matcher instance for making assertions on the distance value.

By default, this uses the OpenAI API for computing embeddings.

Compute the string distance between the prediction and reference.

This logs the string distance (Damerau-Levenshtein) to LangSmith and returns a _Matcher instance for making assertions on the distance value.

This depends on the rapidfuzz package for string distance computation.

Create a _Matcher instance for making assertions on the given value.

Log a numeric score to LangSmith.