Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
fzliu committed Oct 21, 2024
1 parent 192edba commit 3c3359d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 1 addition & 7 deletions libs/kotaemon/kotaemon/embeddings/voyageai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
"""

import importlib
from typing import TYPE_CHECKING

from kotaemon.base import Document, DocumentWithEmbedding, Param

from .base import BaseEmbeddings

if TYPE_CHECKING:
from voyageai import Client
from voyageai import AsyncClient

vo = None

Expand All @@ -36,8 +32,7 @@ def _format_output(texts: list[str], embeddings: list[list]):


class VoyageAIEmbeddings(BaseEmbeddings):
"""Voyage AI provides best-in-class embedding models and rerankers.
"""
"""Voyage AI provides best-in-class embedding models and rerankers."""

api_key: str = Param(None, help="Voyage API key", required=False)
model_name: str = Param(
Expand Down Expand Up @@ -68,4 +63,3 @@ async def ainvoke(
texts = [t.content for t in self.prepare_input(text)]
embeddings = await self._aclient.embed(texts, model=self.model_name).embeddings
return _format_output(texts, embeddings)

2 changes: 1 addition & 1 deletion libs/kotaemon/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def if_llama_cpp_not_installed():

def if_voyageai_not_installed():
try:
import voyageai
import voyageai # noqa: F401
except ImportError:
return True
else:
Expand Down
8 changes: 8 additions & 0 deletions libs/kotaemon/tests/test_embedding_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def test_fastembed_embeddings():


@skip_when_voyageai_not_installed
@patch(
"voyageai.Client.embed",
side_effect=lambda *args, **kwargs: [[1.0, 2.1, 3.2]],
)
@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!")
Expand Down

0 comments on commit 3c3359d

Please sign in to comment.