mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-07 23:28:30 +00:00
* Add @persist decorator with SQLite persistence - Add FlowPersistence abstract base class - Implement SQLiteFlowPersistence backend - Add @persist decorator for flow state persistence - Add tests for flow persistence functionality Co-Authored-By: Joe Moura <joao@crewai.com> * Fix remaining merge conflicts in uv.lock - Remove stray merge conflict markers - Keep main's comprehensive platform-specific resolution markers - Preserve all required dependencies for persistence functionality Co-Authored-By: Joe Moura <joao@crewai.com> * Fix final CUDA dependency conflicts in uv.lock - Resolve NVIDIA CUDA solver dependency conflicts - Use main's comprehensive platform checks - Ensure all merge conflict markers are removed - Preserve persistence-related dependencies Co-Authored-By: Joe Moura <joao@crewai.com> * Fix nvidia-cusparse-cu12 dependency conflicts in uv.lock - Resolve NVIDIA CUSPARSE dependency conflicts - Use main's comprehensive platform checks - Complete systematic check of entire uv.lock file - Ensure all merge conflict markers are removed Co-Authored-By: Joe Moura <joao@crewai.com> * Fix triton filelock dependency conflicts in uv.lock - Resolve triton package filelock dependency conflict - Use main's comprehensive platform checks - Complete final systematic check of entire uv.lock file - Ensure TOML file structure is valid Co-Authored-By: Joe Moura <joao@crewai.com> * Fix merge conflict in crew_test.py - Remove duplicate assertion in test_multimodal_agent_live_image_analysis - Clean up conflict markers - Preserve test functionality Co-Authored-By: Joe Moura <joao@crewai.com> * Clean up trailing merge conflict marker in crew_test.py - Remove remaining conflict marker at end of file - Preserve test functionality - Complete conflict resolution Co-Authored-By: Joe Moura <joao@crewai.com> * Improve type safety in persistence implementation and resolve merge conflicts Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Add explicit type casting in _create_initial_state method Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Improve type safety in flow state handling with proper validation Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Improve type system with proper TypeVar scoping and validation Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Improve state restoration logic and add comprehensive tests Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Initialize FlowState instances without passing id to constructor Co-Authored-By: Joe Moura <joao@crewai.com> * feat: Add class-level flow persistence decorator with SQLite default - Add class-level @persist decorator support - Set SQLiteFlowPersistence as default backend - Use db_storage_path for consistent database location - Improve async method handling and type safety - Add comprehensive docstrings and examples Co-Authored-By: Joe Moura <joao@crewai.com> * fix: Sort imports in decorators.py to fix lint error Co-Authored-By: Joe Moura <joao@crewai.com> * style: Organize imports according to PEP 8 standard Co-Authored-By: Joe Moura <joao@crewai.com> * style: Format typing imports with line breaks for better readability Co-Authored-By: Joe Moura <joao@crewai.com> * style: Simplify import organization to fix lint error Co-Authored-By: Joe Moura <joao@crewai.com> * style: Fix import sorting using Ruff auto-fix Co-Authored-By: Joe Moura <joao@crewai.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Joe Moura <joao@crewai.com> Co-authored-by: João Moura <joaomdmoura@gmail.com>
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""Base class for flow state persistence."""
|
|
|
|
import abc
|
|
from typing import Any, Dict, Optional, Union
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class FlowPersistence(abc.ABC):
|
|
"""Abstract base class for flow state persistence.
|
|
|
|
This class defines the interface that all persistence implementations must follow.
|
|
It supports both structured (Pydantic BaseModel) and unstructured (dict) states.
|
|
"""
|
|
|
|
@abc.abstractmethod
|
|
def init_db(self) -> None:
|
|
"""Initialize the persistence backend.
|
|
|
|
This method should handle any necessary setup, such as:
|
|
- Creating tables
|
|
- Establishing connections
|
|
- Setting up indexes
|
|
"""
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def save_state(
|
|
self,
|
|
flow_uuid: str,
|
|
method_name: str,
|
|
state_data: Union[Dict[str, Any], BaseModel]
|
|
) -> None:
|
|
"""Persist the flow state after method completion.
|
|
|
|
Args:
|
|
flow_uuid: Unique identifier for the flow instance
|
|
method_name: Name of the method that just completed
|
|
state_data: Current state data (either dict or Pydantic model)
|
|
"""
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def load_state(self, flow_uuid: str) -> Optional[Dict[str, Any]]:
|
|
"""Load the most recent state for a given flow UUID.
|
|
|
|
Args:
|
|
flow_uuid: Unique identifier for the flow instance
|
|
|
|
Returns:
|
|
The most recent state as a dictionary, or None if no state exists
|
|
"""
|
|
pass
|