haive.core.config.runnable¶
Configuration management for Haive runnables.
This module provides utilities for creating, managing, and manipulating runtime configurations for Haive engines and runnables. It handles parameter management, metadata tracking, and configuration merging.
The main class RunnableConfigManager provides a comprehensive set of static methods for working with RunnableConfig objects, which are used to configure the behavior of engines at runtime.
- Classes:
RunnableConfigManager: Static utility class for managing runnable configurations
Example:
Examples
>>> # Create a basic config with thread tracking
>>> config = RunnableConfigManager.create(
>>> thread_id="123",
>>> user_id="user_456"
>>> )
>>>
>>> # Add engine-specific configuration
>>> config = RunnableConfigManager.add_engine_config(
>>> config,
>>> "my_llm",
>>> temperature=0.7,
>>> max_tokens=100
>>> )
Classes¶
Enhanced manager for creating and manipulating RunnableConfig objects. |
Module Contents¶
- class haive.core.config.runnable.RunnableConfigManager[source]¶
Enhanced manager for creating and manipulating RunnableConfig objects.
Provides methods for creating standardized configs, extracting values, and managing engine-specific configurations.
- static add_engine(config, engine)[source]¶
Add an engine’s parameters to the RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to add to
engine (Any) – Engine to add
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static add_engine_config(config, engine_name, **params)[source]¶
Add engine-specific configuration.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to add to
engine_name (str) – Name of the engine to add config for
**params – Configuration parameters for the engine
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static create(thread_id=None, user_id=None, **kwargs)[source]¶
Create a standardized RunnableConfig with common parameters.
- Parameters:
- Returns:
A properly structured RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static create_with_engine(engine, thread_id=None, user_id=None, **kwargs)[source]¶
Create a RunnableConfig with engine parameters auto-populated.
- Parameters:
- Returns:
RunnableConfig with engine parameters
- Return type:
langchain_core.runnables.RunnableConfig
- static create_with_metadata(metadata, thread_id=None, user_id=None, **kwargs)[source]¶
Create a RunnableConfig with metadata.
Useful for tracing, logging, and debugging.
- Parameters:
- Returns:
RunnableConfig with metadata section
- Return type:
langchain_core.runnables.RunnableConfig
- static extract_engine_type_config(config, engine_type)[source]¶
Extract configuration for a specific engine type.
- static extract_value(config, key, default=None)[source]¶
Extract a value from RunnableConfig’s configurable section.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from
key (str) – Key to extract
default (Any) – Default value if key not found
- Returns:
Extracted value or default
- Return type:
Any
- static from_model(model)[source]¶
Create a RunnableConfig from a Pydantic model.
- Parameters:
model (pydantic.BaseModel) – Pydantic model to convert
- Returns:
Properly structured RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static get_thread_id(config)[source]¶
Extract thread_id from a RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from
- Returns:
thread_id if present, otherwise None
- Return type:
str | None
- static get_user_id(config)[source]¶
Extract user_id from a RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to extract from
- Returns:
user_id if present, otherwise None
- Return type:
str | None
- static merge(base, override)[source]¶
Merge two RunnableConfigs, with override taking precedence.
- Parameters:
base (langchain_core.runnables.RunnableConfig) – Base configuration
override (langchain_core.runnables.RunnableConfig) – Configuration that takes precedence
- Returns:
Merged configuration
- Return type:
langchain_core.runnables.RunnableConfig
- static to_model(config, model_cls)[source]¶
Convert a RunnableConfig to a Pydantic model.
- Parameters:
config (langchain_core.runnables.RunnableConfig) – RunnableConfig to convert
model_cls (type[pydantic.BaseModel]) – Pydantic model class to convert to
- Returns:
Instantiated model
- Return type:
pydantic.BaseModel