Skip to content

Commit

Permalink
fix return type for GoogleGenerativeAIEmbeddings (langchain-ai#248)
Browse files Browse the repository at this point in the history
* fix return type for GoogleGenerativeAIEmbeddings
  • Loading branch information
adamvig96 authored May 23, 2024
1 parent 3fb9667 commit 7586813
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/genai/langchain_google_genai/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def embed_documents(
)
except Exception as e:
raise GoogleGenerativeAIError(f"Error embedding content: {e}") from e
return [e.values for e in result.embeddings]
return [list(e.values) for e in result.embeddings]

def embed_query(
self,
Expand Down
6 changes: 6 additions & 0 deletions libs/genai/tests/integration_tests/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_embed_query_different_lengths(query: str) -> None:
model = GoogleGenerativeAIEmbeddings(model=_MODEL)
result = model.embed_query(query)
assert len(result) == 768
assert isinstance(result, list)


@pytest.mark.parametrize(
Expand All @@ -35,6 +36,7 @@ async def test_aembed_query_different_lengths(query: str) -> None:
model = GoogleGenerativeAIEmbeddings(model=_MODEL)
result = await model.aembed_query(query)
assert len(result) == 768
assert isinstance(result, list)


def test_embed_documents() -> None:
Expand All @@ -46,6 +48,8 @@ def test_embed_documents() -> None:
assert len(result) == 2
assert len(result[0]) == 768
assert len(result[1]) == 768
assert isinstance(result, list)
assert isinstance(result[0], list)


async def test_aembed_documents() -> None:
Expand All @@ -57,6 +61,8 @@ async def test_aembed_documents() -> None:
assert len(result) == 2
assert len(result[0]) == 768
assert len(result[1]) == 768
assert isinstance(result, list)
assert isinstance(result[0], list)


def test_invalid_model_error_handling() -> None:
Expand Down

0 comments on commit 7586813

Please sign in to comment.