haive.core.config.auth_runnableΒΆ
Haive-specific extension of runnable config management with PostgreSQL integration.
from typing import Any This module extends RunnableConfigManager to provide both Supabase authentication integration and PostgreSQL persistence support for the Haive framework. It creates a unified configuration system that handles authentication, session management, and database persistence in a cohesive manner.
The HaiveRunnableConfigManager inherits all functionality from the base RunnableConfigManager while adding specialized methods for Supabase user authentication, thread persistence, and PostgreSQL integration. This design ensures proper user context is maintained throughout conversation threads and persisted correctly in PostgreSQL.
- Classes:
HaiveRunnableConfigManager: Extended config manager with Supabase auth and PostgreSQL integration
Example:
Examples
>>> # Create a config with Supabase authentication
>>> config = HaiveRunnableConfigManager.create_with_auth(
>>> supabase_user_id="auth0|1234567890",
>>> username="john.doe",
>>> email="john.doe@example.com"
>>> )
>>>
>>> # Add PostgreSQL persistence information
>>> config = HaiveRunnableConfigManager.add_persistence_info(
>>> config,
>>> db_session_id="pgsql-session-123",
>>> persistence_type="postgres"
>>> )
>>>
>>> # Add engine-specific configuration
>>> config = HaiveRunnableConfigManager.add_engine_config(
>>> config,
>>> "my_llm_engine",
>>> temperature=0.7
>>> )
ClassesΒΆ
Enhanced runnable config manager with Supabase authentication and PostgreSQL integration. |
Module ContentsΒΆ
- class haive.core.config.auth_runnable.HaiveRunnableConfigManager[source]ΒΆ
Bases:
haive.core.config.runnable.RunnableConfigManager
Enhanced runnable config manager with Supabase authentication and PostgreSQL integration.
Extends the base RunnableConfigManager with methods for Supabase user authentication, enhanced session management, and PostgreSQL persistence configuration. This class provides a unified interface for managing authentication context and database persistence throughout the Haive framework.
Key capabilities: - Authentication context management with Supabase user IDs - Session tracking with user-agent associations - Thread persistence configuration for PostgreSQL - Permission and authorization management - Serialization utilities for database storage
- static add_engine_by_id(config, engine_id, **params)[source]ΒΆ
Add configuration specifically targeting an engine by ID.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to update
engine_id (str) β Engine ID to target
**params β Parameters for the engine
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static add_permissions(config, *permissions)[source]ΒΆ
Add permissions to the configuration.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to update
*permissions (str) β Permissions to add
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static add_persistence_info(config, db_session_id=None, persistence_type='postgres', db_pool_id=None, checkpoint_ns='', **persistence_params)[source]ΒΆ
Add PostgreSQL persistence information to a config.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β Existing RunnableConfig to update
db_session_id (str | None) β Optional database session identifier
persistence_type (str) β Type of persistence (postgres, memory, etc.)
db_pool_id (str | None) β Optional connection pool identifier
checkpoint_ns (str) β Checkpoint namespace for organizing checkpoints
**persistence_params β Additional persistence parameters
- Returns:
Updated RunnableConfig with persistence information
- Return type:
langchain_core.runnables.RunnableConfig
- static create_agent_session(supabase_user_id, agent_id, agent_type=None, session_data=None, thread_id=None, **kwargs)[source]ΒΆ
Create a session configuration for agent interaction.
- Parameters:
supabase_user_id (str) β The Supabase/Auth0 user ID
agent_id (str) β Unique identifier for the agent
agent_type (str | None) β Optional type of agent
session_data (dict[str, Any] | None) β Optional additional session data
thread_id (str | None) β Optional thread ID (generated if not provided)
**kwargs β Additional parameters
- Returns:
RunnableConfig with session information
- Return type:
langchain_core.runnables.RunnableConfig
- static create_thread_checkpoint_config(thread_id, checkpoint_id=None, checkpoint_ns='', **kwargs)[source]ΒΆ
Create a minimal config for checkpoint operations with thread ID.
- Parameters:
- Returns:
RunnableConfig suitable for checkpoint operations
- Return type:
langchain_core.runnables.RunnableConfig
- static create_with_auth(supabase_user_id, username=None, email=None, tenant_id=None, permissions=None, thread_id=None, **kwargs)[source]ΒΆ
Create a RunnableConfig with Supabase authentication information.
- Parameters:
supabase_user_id (str) β The Supabase/Auth0 user ID
username (str | None) β Optional username for user identification
email (str | None) β Optional email address for user identification
tenant_id (str | None) β Optional tenant/organization ID for multi-tenant systems
permissions (list[str] | None) β Optional list of user permissions
thread_id (str | None) β Optional thread ID for persistence (generated if not provided)
**kwargs β Additional parameters to include in configurable section
- Returns:
A properly structured RunnableConfig with authentication information
- Return type:
langchain_core.runnables.RunnableConfig
- static create_with_postgres(thread_id=None, user_id=None, db_connection_info=None, checkpoint_ns='', **kwargs)[source]ΒΆ
Create a config with PostgreSQL persistence configuration.
- Parameters:
thread_id (str | None) β Optional thread ID (generated if not provided)
user_id (str | None) β Optional user ID for authentication context
db_connection_info (dict[str, Any] | None) β Optional database connection parameters
checkpoint_ns (str) β Checkpoint namespace for organizing checkpoints
**kwargs β Additional parameters to include in configurable section
- Returns:
RunnableConfig with PostgreSQL persistence configuration
- Return type:
langchain_core.runnables.RunnableConfig
- static deserialize_from_json(json_str)[source]ΒΆ
Deserialize a RunnableConfig from a JSON string.
- Parameters:
json_str (str) β JSON string to deserialize
- Returns:
Deserialized RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static get_checkpoint_id(config)[source]ΒΆ
Extract checkpoint ID from a RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to extract from
- Returns:
Checkpoint ID if present, otherwise None
- Return type:
str | None
- static get_checkpoint_ns(config)[source]ΒΆ
Extract checkpoint namespace from a RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to extract from
- Returns:
Checkpoint namespace or empty string if not found
- Return type:
- static get_persistence_info(config)[source]ΒΆ
Extract persistence information from a RunnableConfig.
- static get_supabase_user_id(config)[source]ΒΆ
Extract Supabase user ID from a RunnableConfig.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to extract from
- Returns:
Supabase user ID if present, otherwise None
- Return type:
str | None
- static has_permission(config, permission)[source]ΒΆ
Check if the configuration has a specific permission.
- static is_postgres_persistence(config)[source]ΒΆ
Check if a config is using PostgreSQL persistence.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to check
- Returns:
True if PostgreSQL persistence is configured, False otherwise
- Return type:
- static serialize_to_json(config)[source]ΒΆ
Serialize a RunnableConfig to a JSON string.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to serialize
- Returns:
JSON string representation
- Return type:
- static update_auth_info(config, **auth_updates)[source]ΒΆ
Update authentication information in an existing config.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β Existing RunnableConfig to update
**auth_updates β Authentication information to update
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static update_checkpoint_id(config, checkpoint_id)[source]ΒΆ
Update the checkpoint ID in a config.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to update
checkpoint_id (str) β New checkpoint ID
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig
- static update_session_status(config, status)[source]ΒΆ
Update session status in the configuration.
- Parameters:
config (langchain_core.runnables.RunnableConfig) β RunnableConfig to update
status (str) β New session status
- Returns:
Updated RunnableConfig
- Return type:
langchain_core.runnables.RunnableConfig