Simply embedders

This commit is contained in:
Yiorgis Gozadinos 2025-07-17 13:17:47 +03:00
parent 859860318a
commit 0f8124fd98
No known key found for this signature in database
4 changed files with 5 additions and 13 deletions

View file

@ -1,6 +1,9 @@
from haiku.rag.config import Config
class EmbedderBase:
_model: str = ""
_vector_dim: int = 0
_model: str = Config.EMBEDDINGS_MODEL
_vector_dim: int = Config.EMBEDDINGS_VECTOR_DIM
def __init__(self, model: str, vector_dim: int):
self._model = model

View file

@ -5,9 +5,6 @@ from haiku.rag.embeddings.base import EmbedderBase
class Embedder(EmbedderBase):
_model: str = Config.EMBEDDINGS_MODEL
_vector_dim: int = 1024
async def embed(self, text: str) -> list[float]:
client = AsyncClient(host=Config.OLLAMA_BASE_URL)
res = await client.embeddings(model=self._model, prompt=text)

View file

@ -1,13 +1,9 @@
try:
from openai import AsyncOpenAI
from haiku.rag.config import Config
from haiku.rag.embeddings.base import EmbedderBase
class Embedder(EmbedderBase):
_model: str = Config.EMBEDDINGS_MODEL
_vector_dim: int = 1536
async def embed(self, text: str) -> list[float]:
client = AsyncOpenAI()
response = await client.embeddings.create(

View file

@ -1,13 +1,9 @@
try:
from voyageai.client import Client # type: ignore
from haiku.rag.config import Config
from haiku.rag.embeddings.base import EmbedderBase
class Embedder(EmbedderBase):
_model: str = Config.EMBEDDINGS_MODEL
_vector_dim: int = 1024
async def embed(self, text: str) -> list[float]:
client = Client()
res = client.embed([text], model=self._model, output_dtype="float")