group-wbl/.venv/lib/python3.13/site-packages/langgraph/managed/base.py
2026-01-09 09:12:25 +08:00

32 lines
639 B
Python

from abc import ABC, abstractmethod
from inspect import isclass
from typing import (
Any,
Generic,
TypeGuard,
TypeVar,
)
from langgraph._internal._scratchpad import PregelScratchpad
V = TypeVar("V")
U = TypeVar("U")
__all__ = ("ManagedValueSpec", "ManagedValueMapping")
class ManagedValue(ABC, Generic[V]):
@staticmethod
@abstractmethod
def get(scratchpad: PregelScratchpad) -> V: ...
ManagedValueSpec = type[ManagedValue]
def is_managed_value(value: Any) -> TypeGuard[ManagedValueSpec]:
return isclass(value) and issubclass(value, ManagedValue)
ManagedValueMapping = dict[str, ManagedValueSpec]