haive.core.config.runnable ========================== .. py:module:: haive.core.config.runnable .. autoapi-nested-parse:: 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: .. rubric:: 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 ------- .. autoapisummary:: haive.core.config.runnable.RunnableConfigManager Module Contents --------------- .. py:class:: RunnableConfigManager Enhanced manager for creating and manipulating RunnableConfig objects. Provides methods for creating standardized configs, extracting values, and managing engine-specific configurations. .. py:method:: add_engine(config, engine) :staticmethod: Add an engine's parameters to the RunnableConfig. :param config: RunnableConfig to add to :param engine: Engine to add :returns: Updated RunnableConfig .. py:method:: add_engine_config(config, engine_name, **params) :staticmethod: Add engine-specific configuration. :param config: RunnableConfig to add to :param engine_name: Name of the engine to add config for :param \*\*params: Configuration parameters for the engine :returns: Updated RunnableConfig .. py:method:: create(thread_id = None, user_id = None, **kwargs) :staticmethod: Create a standardized RunnableConfig with common parameters. :param thread_id: Optional thread ID for persistence (generated if not provided) :param user_id: Optional user ID for attribution and permissions :param \*\*kwargs: Additional parameters to include in configurable section :returns: A properly structured RunnableConfig .. py:method:: create_with_engine(engine, thread_id = None, user_id = None, **kwargs) :staticmethod: Create a RunnableConfig with engine parameters auto-populated. :param engine: Engine object to extract params from :param thread_id: Optional thread ID :param user_id: Optional user ID :param \*\*kwargs: Additional configurable parameters :returns: RunnableConfig with engine parameters .. py:method:: create_with_metadata(metadata, thread_id = None, user_id = None, **kwargs) :staticmethod: Create a RunnableConfig with metadata. Useful for tracing, logging, and debugging. :param metadata: Dictionary of metadata values :param thread_id: Optional thread ID :param user_id: Optional user ID :param \*\*kwargs: Additional configurable parameters :returns: RunnableConfig with metadata section .. py:method:: extract_engine_config(config, engine_name) :staticmethod: Extract engine-specific configuration. :param config: RunnableConfig to extract from :param engine_name: Name of the engine to extract config for :returns: Engine-specific configuration dictionary .. py:method:: extract_engine_type_config(config, engine_type) :staticmethod: Extract configuration for a specific engine type. :param config: RunnableConfig to extract from :param engine_type: The engine type (e.g., "llm", "retriever") :returns: Configuration for the engine type .. py:method:: extract_value(config, key, default = None) :staticmethod: Extract a value from RunnableConfig's configurable section. :param config: RunnableConfig to extract from :param key: Key to extract :param default: Default value if key not found :returns: Extracted value or default .. py:method:: from_dict(input_dict) :staticmethod: Create a RunnableConfig from a dictionary. :param input_dict: Dictionary to convert :returns: Properly structured RunnableConfig .. py:method:: from_model(model) :staticmethod: Create a RunnableConfig from a Pydantic model. :param model: Pydantic model to convert :returns: Properly structured RunnableConfig .. py:method:: get_thread_id(config) :staticmethod: Extract thread_id from a RunnableConfig. :param config: RunnableConfig to extract from :returns: thread_id if present, otherwise None .. py:method:: get_user_id(config) :staticmethod: Extract user_id from a RunnableConfig. :param config: RunnableConfig to extract from :returns: user_id if present, otherwise None .. py:method:: merge(base, override) :staticmethod: Merge two RunnableConfigs, with override taking precedence. :param base: Base configuration :param override: Configuration that takes precedence :returns: Merged configuration .. py:method:: to_model(config, model_cls) :staticmethod: Convert a RunnableConfig to a Pydantic model. :param config: RunnableConfig to convert :param model_cls: Pydantic model class to convert to :returns: Instantiated model