mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
core,langchain,community[patch]: allow langsmith 0.2 (#28598)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import math
|
||||
import os
|
||||
import tempfile
|
||||
from typing import List
|
||||
from typing import List, cast
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
@@ -60,13 +60,13 @@ class RandomEmbeddings(Embeddings):
|
||||
"""Fake embeddings with random vectors. For testing purposes."""
|
||||
|
||||
def embed_documents(self, texts: List[str]) -> List[List[float]]:
|
||||
return [np.random.rand(100).tolist() for _ in texts]
|
||||
return [cast(list[float], np.random.rand(100).tolist()) for _ in texts]
|
||||
|
||||
def embed_query(self, text: str) -> List[float]:
|
||||
return np.random.rand(100).tolist()
|
||||
return cast(list[float], np.random.rand(100).tolist())
|
||||
|
||||
def embed_image(self, uris: List[str]) -> List[List[float]]:
|
||||
return [np.random.rand(100).tolist() for _ in uris]
|
||||
return [cast(list[float], np.random.rand(100).tolist()) for _ in uris]
|
||||
|
||||
|
||||
class IncrementalEmbeddings(Embeddings):
|
||||
|
@@ -1,5 +1,7 @@
|
||||
"""Test vector store utility functions."""
|
||||
|
||||
from typing import cast
|
||||
|
||||
import numpy as np
|
||||
from langchain_core.documents import Document
|
||||
|
||||
@@ -53,7 +55,7 @@ def test_maximal_marginal_relevance() -> None:
|
||||
def test_maximal_marginal_relevance_query_dim() -> None:
|
||||
query_embedding = np.random.random(size=5)
|
||||
query_embedding_2d = query_embedding.reshape((1, 5))
|
||||
embedding_list = np.random.random(size=(4, 5)).tolist()
|
||||
embedding_list = cast(list[list[float]], np.random.random(size=(4, 5)).tolist())
|
||||
first = maximal_marginal_relevance(query_embedding, embedding_list)
|
||||
second = maximal_marginal_relevance(query_embedding_2d, embedding_list)
|
||||
assert first == second
|
||||
|
Reference in New Issue
Block a user