mirror of
https://github.com/Cinnamon/kotaemon.git
synced 2025-12-16 19:57:48 +01:00
fix: update test case
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from openai.types.create_embedding_response import CreateEmbeddingResponse
|
from openai.types.create_embedding_response import CreateEmbeddingResponse
|
||||||
|
|
||||||
@@ -159,18 +159,14 @@ def test_fastembed_embeddings():
|
|||||||
assert_embedding_result(output)
|
assert_embedding_result(output)
|
||||||
|
|
||||||
|
|
||||||
|
voyage_output_mock = Mock()
|
||||||
|
voyage_output_mock.embeddings = [[1.0, 2.1, 3.2]]
|
||||||
|
|
||||||
|
|
||||||
@skip_when_voyageai_not_installed
|
@skip_when_voyageai_not_installed
|
||||||
@patch(
|
@patch("voyageai.Client.embed", return_value=voyage_output_mock)
|
||||||
"voyageai.Client.embed",
|
@patch("voyageai.AsyncClient.embed", return_value=voyage_output_mock)
|
||||||
side_effect=lambda *args, **kwargs: [[1.0, 2.1, 3.2]],
|
def test_voyageai_embeddings(sync_call, async_call):
|
||||||
)
|
model = VoyageAIEmbeddings(api_key="test")
|
||||||
@patch(
|
|
||||||
"voyageai.AsyncClient.embed",
|
|
||||||
side_effect=lambda *args, **kwargs: [[1.0, 2.1, 3.2]],
|
|
||||||
)
|
|
||||||
def test_voyageai_embeddings():
|
|
||||||
model = VoyageAIEmbeddings()
|
|
||||||
output = model("Hello, world!")
|
output = model("Hello, world!")
|
||||||
assert isinstance(output, list) and all(
|
assert all(isinstance(doc, DocumentWithEmbedding) for doc in output)
|
||||||
isinstance(doc, DocumentWithEmbedding) for doc in output
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user