haive.core.engine.embedding.config¶
Embedding configuration factory and utilities.
Classes¶
Factory class for creating embedding configurations. |
Functions¶
|
Create an embedding configuration using the factory. |
|
Get information about an embedding provider. |
List all available embedding providers. |
|
|
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:
provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum
model (str) – Model name for the provider
name (str) – Configuration name
**kwargs – Additional provider-specific parameters
- Returns:
Configured embedding instance
- Raises:
ValueError – If provider is not found or configuration is invalid
- Return type:
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:
- 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:
- 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:
provider (str | haive.core.engine.embedding.types.EmbeddingType) – Provider name or EmbeddingType enum
model (str) – Model name for the provider
name (str) – Configuration name
**kwargs – Additional provider-specific parameters
- Returns:
Configured embedding instance
- Return type:
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:
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.
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:
Examples
Check provider availability:
if validate_embedding_provider("OpenAI"): print("OpenAI provider is available") else: print("OpenAI provider not found")