EmbedClient#

EmbedClient’s core function is to convert text or a list of texts into feature vectors through an Embedding model

Overview#

The EmbedClient module provides a unified interface for calling local SentenceTransformer embedding models or OpenAI embedding models.

Characteristics#

  • Unified Interface: All clients inherit from EmbedClientBase, providing a consistent calling method.

  • Multi-text Support: Can create Embedding features of multiple texts in a single concurrent operation.

  • Local mode: Supports using SentenceTransformerEmbed to connect to locally deployed embedding models

Basic Usage#

from evofabric.core.clients import OpenAIEmbedClient, SentenceTransformerEmbed

# OpenAIEmbedClient
embed_client = OpenAIEmbedClient(
    api_key="your-api-key",
    base_url="your-base-url",
    model="qwen3_0.6B:latest",
)
res = embed_client.embed_query("hello")

# SentenceTransformerEmbed
embed_client = SentenceTransformerEmbed(
        device="cpu",
        model="hf_models/sentence-transformers/all-MiniLM-L6-v2",
    )
res = embed_client.embed_query("hello")

Use in vectorstore#

from evofabric.core.clients import OpenAIEmbedClient
from evofabric.core.vectorstore import ChromaDB

embed_client = OpenAIEmbedClient(
    api_key="your-api-key",
    base_url="your-base-url",
    model="qwen3_0.6B:latest",
)

# embed_client is implicitly called as a component of vectorstore
vectorstore = ChromaDB(
    collection_name="demo_collection",
    persist_directory="./demo_collection",
    embedding=embed_client,
)