Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_constants.py132 linesDownload Raw Back to _internal
1"""Constants used for Pregel operations."""2 3import sys4from typing import Literal, cast5 6# --- Reserved write keys ---7INPUT = sys.intern("__input__")8# for values passed as input to the graph9INTERRUPT = sys.intern("__interrupt__")10# for dynamic interrupts raised by nodes11RESUME = sys.intern("__resume__")12# for values passed to resume a node after an interrupt13ERROR = sys.intern("__error__")14# for errors raised by nodes15ERROR_SOURCE_NODE = sys.intern("__error_source_node__")16# failed source node name for node-level error handlers17# value format in pending writes: `(task_id, ERROR_SOURCE_NODE, node_name: str)`18NO_WRITES = sys.intern("__no_writes__")19# marker to signal node didn't write anything20TASKS = sys.intern("__pregel_tasks")21# for Send objects returned by nodes/edges, corresponds to PUSH below22RETURN = sys.intern("__return__")23# for writes of a task where we simply record the return value24PREVIOUS = sys.intern("__previous__")25# the implicit branch that handles each node's Control values26 27 28# --- Reserved cache namespaces ---29CACHE_NS_WRITES = sys.intern("__pregel_ns_writes")30# cache namespace for node writes31 32# --- Reserved config.configurable keys ---33CONFIG_KEY_SEND = sys.intern("__pregel_send")34# holds the `write` function that accepts writes to state/edges/reserved keys35CONFIG_KEY_READ = sys.intern("__pregel_read")36# holds the `read` function that returns a copy of the current state37CONFIG_KEY_CALL = sys.intern("__pregel_call")38# holds the `call` function that accepts a node/func, args and returns a future39CONFIG_KEY_CHECKPOINTER = sys.intern("__pregel_checkpointer")40# holds a `BaseCheckpointSaver` passed from parent graph to child graphs41CONFIG_KEY_STREAM = sys.intern("__pregel_stream")42# holds a `StreamProtocol` passed from parent graph to child graphs43CONFIG_KEY_CACHE = sys.intern("__pregel_cache")44# holds a `BaseCache` made available to subgraphs45CONFIG_KEY_RESUMING = sys.intern("__pregel_resuming")46# holds a boolean indicating if subgraphs should resume from a previous checkpoint47CONFIG_KEY_REPLAY_STATE = sys.intern("__pregel_replay_state")48# holds a ReplayState tracking the parent checkpoint_id upper bound and which49# subgraph namespaces have already loaded their pre-replay checkpoint50CONFIG_KEY_TASK_ID = sys.intern("__pregel_task_id")51# holds the task ID for the current task52CONFIG_KEY_THREAD_ID = sys.intern("thread_id")53# holds the thread ID for the current invocation54CONFIG_KEY_CHECKPOINT_MAP = sys.intern("checkpoint_map")55# holds a mapping of checkpoint_ns -> checkpoint_id for parent graphs56CONFIG_KEY_CHECKPOINT_ID = sys.intern("checkpoint_id")57# holds the current checkpoint_id, if any58CONFIG_KEY_CHECKPOINT_NS = sys.intern("checkpoint_ns")59# holds the current checkpoint_ns, "" for root graph60CONFIG_KEY_NODE_FINISHED = sys.intern("__pregel_node_finished")61# holds a callback to be called when a node is finished62CONFIG_KEY_TIMED_ATTEMPT_OBSERVER = sys.intern("__pregel_timed_attempt_observer")63# holds a callback to be called when an idle-timed node attempt starts or finishes64CONFIG_KEY_SCRATCHPAD = sys.intern("__pregel_scratchpad")65# holds a mutable dict for temporary storage scoped to the current task66CONFIG_KEY_RUNNER_SUBMIT = sys.intern("__pregel_runner_submit")67# holds a function that receives tasks from runner, executes them and returns results68CONFIG_KEY_DURABILITY = sys.intern("__pregel_durability")69# holds the durability mode, one of "sync", "async", or "exit"70CONFIG_KEY_RUNTIME = sys.intern("__pregel_runtime")71# holds a `Runtime` instance with context, store, stream writer, etc.72CONFIG_KEY_RESUME_MAP = sys.intern("__pregel_resume_map")73# holds a mapping of task ns -> resume value for resuming tasks74CONFIG_KEY_STREAM_MESSAGES_V2 = sys.intern("__pregel_stream_messages_v2")75# when True, attach StreamMessagesHandlerV2 so content-block (v2) events76# flow through stream_mode="messages"; set by StreamingHandler only.77CONFIG_KEY_NODE_ERROR = sys.intern("__pregel_node_error")78# holds a `NodeError` (failed source node + exception) for the current79# node-level error handler invocation, injected when handler signature80# requests `error: NodeError`81 82# --- Other constants ---83PUSH = sys.intern("__pregel_push")84# denotes push-style tasks, ie. those created by Send objects85PULL = sys.intern("__pregel_pull")86# denotes pull-style tasks, ie. those triggered by edges87NS_SEP = sys.intern("|")88# for checkpoint_ns, separates each level (ie. graph|subgraph|subsubgraph)89NS_END = sys.intern(":")90# for checkpoint_ns, for each level, separates the namespace from the task_id91CONF = cast(Literal["configurable"], sys.intern("configurable"))92# key for the configurable dict in RunnableConfig93NULL_TASK_ID = sys.intern("00000000-0000-0000-0000-000000000000")94# the task_id to use for writes that are not associated with a task95OVERWRITE = sys.intern("__overwrite__")96# dict key for the overwrite value, used as `{'__overwrite__': value}`97 98# redefined to avoid circular import with langgraph.constants99_TAG_HIDDEN = sys.intern("langsmith:hidden")100 101RESERVED = {102    _TAG_HIDDEN,103    # reserved write keys104    INPUT,105    INTERRUPT,106    RESUME,107    ERROR,108    ERROR_SOURCE_NODE,109    NO_WRITES,110    # reserved config.configurable keys111    CONFIG_KEY_SEND,112    CONFIG_KEY_READ,113    CONFIG_KEY_CHECKPOINTER,114    CONFIG_KEY_STREAM,115    CONFIG_KEY_CHECKPOINT_MAP,116    CONFIG_KEY_RESUMING,117    CONFIG_KEY_REPLAY_STATE,118    CONFIG_KEY_TASK_ID,119    CONFIG_KEY_CHECKPOINT_MAP,120    CONFIG_KEY_CHECKPOINT_ID,121    CONFIG_KEY_CHECKPOINT_NS,122    CONFIG_KEY_TIMED_ATTEMPT_OBSERVER,123    CONFIG_KEY_RESUME_MAP,124    CONFIG_KEY_STREAM_MESSAGES_V2,125    # other constants126    PUSH,127    PULL,128    NS_SEP,129    NS_END,130    CONF,131}132 
codekingpro/portable-devtools · Team Ai