haive.core.engine.embedding.config

Embedding configuration factory and utilities.

Classes

EmbeddingConfigFactory

Factory class for creating embedding configurations.

Functions

create_embedding_config(provider, model[, name])

Create an embedding configuration using the factory.

get_embedding_provider_info(provider)

Get information about an embedding provider.

list_embedding_providers()

List all available embedding providers.

validate_embedding_provider(provider)

Check if an embedding provider is available.

Module Contents

class haive.core.engine.embedding.config.EmbeddingConfigFactory[source]

Factory class for creating embedding configurations.

This factory provides a convenient way to create embedding configurations without needing to import specific provider classes.

Examples

Create OpenAI configuration:

factory = EmbeddingConfigFactory()
config = factory.create(
    provider="OpenAI",
    model="text-embedding-3-large",
    name="my_embeddings"
)

List available providers:

factory = EmbeddingConfigFactory()
providers = factory.list_providers()

Get provider information:

factory = EmbeddingConfigFactory()
info = factory.get_provider_info("OpenAI")
static create(provider, model, name='default_embedding', **kwargs)[source]

Create an embedding configuration.

Parameters:
Returns:

Configured embedding instance

Raises:

ValueError – If provider is not found or configuration is invalid

Return type:

haive.core.engine.embedding.base.BaseEmbeddingConfig

Examples

Create OpenAI config:

config = EmbeddingConfigFactory.create(
    provider="OpenAI",
    model="text-embedding-3-large",
    api_key="sk-..."
)

Create HuggingFace config:

config = EmbeddingConfigFactory.create(
    provider="HuggingFace",
    model="sentence-transformers/all-MiniLM-L6-v2",
    use_cache=True
)
static get_provider_info(provider)[source]

Get information about a specific provider.

Parameters:

provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum

Returns:

Dictionary with provider information

Return type:

dict[str, Any]

static list_providers()[source]

List all available embedding providers.

Returns:

List of provider names

Return type:

list[str]

static validate_provider(provider)[source]

Check if a provider is available.

Parameters:

provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum

Returns:

True if provider is available, False otherwise

Return type:

bool

haive.core.engine.embedding.config.create_embedding_config(provider, model, name='default_embedding', **kwargs)[source]

Create an embedding configuration using the factory.

This is a convenience function that wraps EmbeddingConfigFactory.create().

Parameters:
Returns:

Configured embedding instance

Return type:

haive.core.engine.embedding.base.BaseEmbeddingConfig

Examples

Create OpenAI config:

config = create_embedding_config(
    provider="OpenAI",
    model="text-embedding-3-large"
)

Create with custom parameters:

config = create_embedding_config(
    provider="HuggingFace",
    model="sentence-transformers/all-MiniLM-L6-v2",
    use_cache=True,
    cache_folder="./my_cache"
)
haive.core.engine.embedding.config.get_embedding_provider_info(provider)[source]

Get information about an embedding provider.

Parameters:

provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum

Returns:

Dictionary with provider information

Return type:

dict[str, Any]

Examples

Get provider info:

info = get_embedding_provider_info("OpenAI")
print(f"Default model: {info['default_model']}")
print(f"Supported models: {info['supported_models']}")
haive.core.engine.embedding.config.list_embedding_providers()[source]

List all available embedding providers.

Returns:

List of provider names

Return type:

list[str]

Examples

List providers:

providers = list_embedding_providers()
print(f"Available: {providers}")
haive.core.engine.embedding.config.validate_embedding_provider(provider)[source]

Check if an embedding provider is available.

Parameters:

provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum

Returns:

True if provider is available, False otherwise

Return type:

bool

Examples

Check provider availability:

if validate_embedding_provider("OpenAI"):
    print("OpenAI provider is available")
else:
    print("OpenAI provider not found")