Python utilities to serialize/deserialize session JSON fields and convert raw session dicts to typed session objects.
# Source: https://github.com/Upsonic/Upsonic | License: MIT | Copyright 2024 Upsonic Teknoloji A.Ş
# Provided via justclaw.it.com; keep this notice with the code.
"""Common utility functions for storage operations."""
from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any, Dict, List, Optional
if TYPE_CHECKING:
from upsonic.session.base import Session, SessionType
# JSON fields in SESSION_TABLE_SCHEMA that need serialization/deserialization
SESSION_JSON_FIELDS: List[str] = [
"session_data",
"agent_data",
"team_data",
"workflow_data",
"metadata",
"runs",
"messages",
]
def serialize_session_json_fields(session_dict: Dict[str, Any]) -> Dict[str, Any]:
"""
Serialize JSON fields in a session dictionary for database stora
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key