You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EmbeddingDistance raises NameError for euclidean, manhattan, chebyshev and hamming metrics #23
langsmith at f6b73d8374b30b6dd69b703d4c1e3617ed2fb6e6 (main), numpy installed. Python 3.14 was used but the bug is not version-specific. No network access is involved.
Reproduction
numpy is imported only under TYPE_CHECKING in _embedding_distance.py. Only evaluate() and cosine_similarity() import it locally, so the four static methods that use np (lines 141-190) fail with NameError.
Public entry point:
fromlangsmithimportexpectexpect.embedding_distance(
"a", "b",
config={"metric": "euclidean", "encoder": lambdat: [[1.0, 2.0], [2.0, 4.0]]},
)
# NameError: name 'np' is not defined
Same thing directly on the class, for every metric:
cosine 2.220446049250313e-16
euclidean NameError name 'np' is not defined
manhattan NameError name 'np' is not defined
chebyshev NameError name 'np' is not defined
hamming NameError name 'np' is not defined
Expected behavior
Each metric listed in the EmbeddingConfigLiteral returns a float, as cosine does.
A possible fix is to import numpy as np inside each of the four static methods (the module already lazy-imports numpy to keep it optional), plus a unit test per metric.
Activity
thibautlehmann commentedon Oct 16, 2026
Hey Muneeb Ullah (@moneebullah25), langsmith-sdk is archived, so I moved this issue to langchain-ai/langsmith-python, where the SDK now lives 🙏