initial commit
This commit is contained in:
3
venv/Lib/site-packages/langgraph/managed/__init__.py
Normal file
3
venv/Lib/site-packages/langgraph/managed/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from langgraph.managed.is_last_step import IsLastStep, RemainingSteps
|
||||
|
||||
__all__ = ("IsLastStep", "RemainingSteps")
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
31
venv/Lib/site-packages/langgraph/managed/base.py
Normal file
31
venv/Lib/site-packages/langgraph/managed/base.py
Normal file
@@ -0,0 +1,31 @@
|
||||
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]
|
||||
24
venv/Lib/site-packages/langgraph/managed/is_last_step.py
Normal file
24
venv/Lib/site-packages/langgraph/managed/is_last_step.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import Annotated
|
||||
|
||||
from langgraph._internal._scratchpad import PregelScratchpad
|
||||
from langgraph.managed.base import ManagedValue
|
||||
|
||||
__all__ = ("IsLastStep", "RemainingStepsManager")
|
||||
|
||||
|
||||
class IsLastStepManager(ManagedValue[bool]):
|
||||
@staticmethod
|
||||
def get(scratchpad: PregelScratchpad) -> bool:
|
||||
return scratchpad.step == scratchpad.stop - 1
|
||||
|
||||
|
||||
IsLastStep = Annotated[bool, IsLastStepManager]
|
||||
|
||||
|
||||
class RemainingStepsManager(ManagedValue[int]):
|
||||
@staticmethod
|
||||
def get(scratchpad: PregelScratchpad) -> int:
|
||||
return scratchpad.stop - scratchpad.step
|
||||
|
||||
|
||||
RemainingSteps = Annotated[int, RemainingStepsManager]
|
||||
Reference in New Issue
Block a user