babylon.rag.lifecycle
Object lifecycle management for the RAG system.
This module provides lifecycle state tracking for RAG objects, allowing monitoring of object states through their lifetime.
Classes
Manages the lifecycle of RAG objects. |
|
|
Possible states for RAG objects in their lifecycle. |
|
Performance metrics for RAG operations. |
- class babylon.rag.lifecycle.ObjectState(*values)[source]
Bases:
EnumPossible states for RAG objects in their lifecycle.
- CREATED = 'created'
- PREPROCESSED = 'preprocessed'
- CHUNKED = 'chunked'
- EMBEDDED = 'embedded'
- STORED = 'stored'
- RETRIEVED = 'retrieved'
- REMOVED_FROM_CONTEXT = 'removed_from_context'
- ARCHIVED = 'archived'
- ERROR = 'error'
- class babylon.rag.lifecycle.PerformanceMetrics(hot_objects=<factory>, cache_hit_rate=<factory>, avg_token_usage=0.0, latency_stats=<factory>, memory_profile=<factory>)[source]
Bases:
objectPerformance metrics for RAG operations.
- Parameters:
- __init__(hot_objects=<factory>, cache_hit_rate=<factory>, avg_token_usage=0.0, latency_stats=<factory>, memory_profile=<factory>)
- class babylon.rag.lifecycle.LifecycleManager[source]
Bases:
objectManages the lifecycle of RAG objects.
Tracks object states, transitions, and provides metrics for monitoring system health.
- register_object(object_id, initial_state=ObjectState.CREATED)[source]
Register a new object for lifecycle tracking.
- Parameters:
object_id (
str) – Unique identifier for the objectinitial_state (
ObjectState) – Initial state for the object
- Return type:
- update_object_state(object_id, new_state)[source]
Update the state of a tracked object.
- Parameters:
object_id (
str) – Unique identifier for the objectnew_state (
ObjectState|str) – New state for the object (ObjectState enum or string)
- Return type:
- get_object_state(object_id)[source]
Get the current state of an object.
- Parameters:
object_id (
str) – Unique identifier for the object- Return type:
ObjectState|str|None- Returns:
Current state or None if object not found
- get_state_history(object_id)[source]
Get the state transition history for an object.
- Parameters:
object_id (
str) – Unique identifier for the object- Return type:
- Returns:
List of (state, timestamp) tuples
- get_objects_in_state(state)[source]
Get all objects currently in a given state.
- Parameters:
state (
ObjectState) – The state to filter by- Return type:
- Returns:
List of object IDs in the specified state