diff --git a/docs/README.md b/docs/README.md index b3be09886..1817f31b6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -58,4 +58,4 @@ To delete cassettes for a notebook, you can run: ```bash rm cassettes/* -``` \ No newline at end of file +``` diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 3e4845dcb..4d111a55f 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -78,7 +78,7 @@ plugins: inherited_members: true selection: docstring_style: google - docstring_section_style: list + docstring_section_style: table show_root_toc_entry: false show_signature: true show_signature_annotations: true diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py index abacab49c..4da709495 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/__init__.py @@ -56,8 +56,8 @@ class PostgresSaver(BasePostgresSaver): """Create a new PostgresSaver instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): whether to use Pipeline + conn_string: The Postgres connection info string. + pipeline: whether to use Pipeline Returns: PostgresSaver: A new PostgresSaver instance. @@ -111,10 +111,10 @@ class PostgresSaver(BasePostgresSaver): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (RunnableConfig): The config to use for listing the checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. Defaults to None. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): The maximum number of checkpoints to return. Defaults to None. + config: The config to use for listing the checkpoints. + filter: Additional filtering criteria for metadata. Defaults to None. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: The maximum number of checkpoints to return. Defaults to None. Yields: Iterator[CheckpointTuple]: An iterator of checkpoint tuples. @@ -182,7 +182,7 @@ class PostgresSaver(BasePostgresSaver): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -267,10 +267,10 @@ class PostgresSaver(BasePostgresSaver): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -337,9 +337,9 @@ class PostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the Postgres database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (List[Tuple[str, Any]]): List of writes to store. - task_id (str): Identifier for the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store. + task_id: Identifier for the task creating the writes. """ query = ( self.UPSERT_CHECKPOINT_WRITES_SQL @@ -363,7 +363,7 @@ class PostgresSaver(BasePostgresSaver): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None @@ -387,7 +387,7 @@ class PostgresSaver(BasePostgresSaver): """Create a database cursor as a context manager. Args: - pipeline (bool): whether to use pipeline for the DB operations inside the context manager. + pipeline: whether to use pipeline for the DB operations inside the context manager. Will be applied regardless of whether the PostgresSaver instance was initialized with a pipeline. If pipeline mode is not supported, will fall back to using transaction context manager. """ diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py index 70faa906c..e750203de 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/aio.py @@ -61,8 +61,8 @@ class AsyncPostgresSaver(BasePostgresSaver): """Create a new AsyncPostgresSaver instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): whether to use AsyncPipeline + conn_string: The Postgres connection info string. + pipeline: whether to use AsyncPipeline Returns: AsyncPostgresSaver: A new AsyncPostgresSaver instance. @@ -116,10 +116,10 @@ class AsyncPostgresSaver(BasePostgresSaver): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: Maximum number of checkpoints to return. Yields: AsyncIterator[CheckpointTuple]: An asynchronous iterator of matching checkpoint tuples. @@ -170,7 +170,7 @@ class AsyncPostgresSaver(BasePostgresSaver): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -235,10 +235,10 @@ class AsyncPostgresSaver(BasePostgresSaver): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -295,9 +295,9 @@ class AsyncPostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. """ query = ( self.UPSERT_CHECKPOINT_WRITES_SQL @@ -320,7 +320,7 @@ class AsyncPostgresSaver(BasePostgresSaver): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None @@ -346,7 +346,7 @@ class AsyncPostgresSaver(BasePostgresSaver): """Create a database cursor as a context manager. Args: - pipeline (bool): whether to use pipeline for the DB operations inside the context manager. + pipeline: whether to use pipeline for the DB operations inside the context manager. Will be applied regardless of whether the AsyncPostgresSaver instance was initialized with a pipeline. If pipeline mode is not supported, will fall back to using transaction context manager. """ @@ -400,10 +400,10 @@ class AsyncPostgresSaver(BasePostgresSaver): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: Maximum number of checkpoints to return. Yields: Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples. @@ -439,7 +439,7 @@ class AsyncPostgresSaver(BasePostgresSaver): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -473,10 +473,10 @@ class AsyncPostgresSaver(BasePostgresSaver): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -497,10 +497,10 @@ class AsyncPostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. """ return asyncio.run_coroutine_threadsafe( self.aput_writes(config, writes, task_id, task_path), self.loop @@ -510,7 +510,7 @@ class AsyncPostgresSaver(BasePostgresSaver): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py index 9fe9bfdf8..4677f4f3d 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/shallow.py @@ -214,8 +214,8 @@ class ShallowPostgresSaver(BasePostgresSaver): """Create a new ShallowPostgresSaver instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): whether to use Pipeline + conn_string: The Postgres connection info string. + pipeline: whether to use Pipeline Returns: ShallowPostgresSaver: A new ShallowPostgresSaver instance. @@ -301,7 +301,7 @@ class ShallowPostgresSaver(BasePostgresSaver): provided config (matching the thread ID in the config). Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -372,10 +372,10 @@ class ShallowPostgresSaver(BasePostgresSaver): checkpoint and overwrites a previous checkpoint, if it exists. Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -448,9 +448,9 @@ class ShallowPostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the Postgres database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (List[Tuple[str, Any]]): List of writes to store. - task_id (str): Identifier for the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store. + task_id: Identifier for the task creating the writes. """ query = ( self.UPSERT_CHECKPOINT_WRITES_SQL @@ -475,7 +475,7 @@ class ShallowPostgresSaver(BasePostgresSaver): """Create a database cursor as a context manager. Args: - pipeline (bool): whether to use pipeline for the DB operations inside the context manager. + pipeline: whether to use pipeline for the DB operations inside the context manager. Will be applied regardless of whether the ShallowPostgresSaver instance was initialized with a pipeline. If pipeline mode is not supported, will fall back to using transaction context manager. """ @@ -565,8 +565,8 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): """Create a new AsyncShallowPostgresSaver instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): whether to use AsyncPipeline + conn_string: The Postgres connection info string. + pipeline: whether to use AsyncPipeline Returns: AsyncShallowPostgresSaver: A new AsyncShallowPostgresSaver instance. @@ -655,7 +655,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): provided config (matching the thread ID in the config). Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -708,10 +708,10 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): checkpoint and overwrites a previous checkpoint, if it exists. Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -773,9 +773,9 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. """ query = ( self.UPSERT_CHECKPOINT_WRITES_SQL @@ -801,7 +801,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): """Create a database cursor as a context manager. Args: - pipeline (bool): whether to use pipeline for the DB operations inside the context manager. + pipeline: whether to use pipeline for the DB operations inside the context manager. Will be applied regardless of whether the AsyncShallowPostgresSaver instance was initialized with a pipeline. If pipeline mode is not supported, will fall back to using transaction context manager. """ @@ -872,7 +872,7 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): provided config (matching the thread ID in the config). Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -907,10 +907,10 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): checkpoint and overwrites a previous checkpoint, if it exists. Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -931,10 +931,10 @@ class AsyncShallowPostgresSaver(BasePostgresSaver): This method saves intermediate writes associated with a checkpoint to the database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. """ return asyncio.run_coroutine_threadsafe( self.aput_writes(config, writes, task_id, task_path), self.loop diff --git a/libs/checkpoint-postgres/langgraph/store/postgres/aio.py b/libs/checkpoint-postgres/langgraph/store/postgres/aio.py index c2d670b94..7680d0154 100644 --- a/libs/checkpoint-postgres/langgraph/store/postgres/aio.py +++ b/libs/checkpoint-postgres/langgraph/store/postgres/aio.py @@ -187,12 +187,12 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con """Create a new AsyncPostgresStore instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): Whether to use AsyncPipeline (only for single connections) - pool_config (Optional[PoolConfig]): Configuration for the connection pool. + conn_string: The Postgres connection info string. + pipeline: Whether to use AsyncPipeline (only for single connections) + pool_config: Configuration for the connection pool. If provided, will create a connection pool and use it instead of a single connection. This overrides the `pipeline` argument. - index (Optional[PostgresIndexConfig]): The embedding config. + index: The embedding config. Returns: AsyncPostgresStore: A new AsyncPostgresStore instance. diff --git a/libs/checkpoint-postgres/langgraph/store/postgres/base.py b/libs/checkpoint-postgres/langgraph/store/postgres/base.py index 5636b35fe..7acc87106 100644 --- a/libs/checkpoint-postgres/langgraph/store/postgres/base.py +++ b/libs/checkpoint-postgres/langgraph/store/postgres/base.py @@ -755,12 +755,12 @@ class PostgresStore(BaseStore, BasePostgresStore[_pg_internal.Conn]): """Create a new PostgresStore instance from a connection string. Args: - conn_string (str): The Postgres connection info string. - pipeline (bool): whether to use Pipeline - pool_config (Optional[PoolArgs]): Configuration for the connection pool. + conn_string: The Postgres connection info string. + pipeline: whether to use Pipeline + pool_config: Configuration for the connection pool. If provided, will create a connection pool and use it instead of a single connection. This overrides the `pipeline` argument. - index (Optional[PostgresIndexConfig]): The index configuration for the store. + index: The index configuration for the store. Returns: PostgresStore: A new PostgresStore instance. @@ -905,7 +905,7 @@ class PostgresStore(BaseStore, BasePostgresStore[_pg_internal.Conn]): """Create a database cursor as a context manager. Args: - pipeline (bool): whether to use pipeline for the DB operations inside the context manager. + pipeline: whether to use pipeline for the DB operations inside the context manager. Will be applied regardless of whether the PostgresStore instance was initialized with a pipeline. If pipeline mode is not supported, will fall back to using transaction context manager. """ diff --git a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py index 427a38341..7102d2fbd 100644 --- a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py +++ b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/__init__.py @@ -90,7 +90,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): """Create a new SqliteSaver instance from a connection string. Args: - conn_string (str): The SQLite connection string. + conn_string: The SQLite connection string. Yields: SqliteSaver: A new SqliteSaver instance. @@ -187,7 +187,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -293,10 +293,10 @@ class SqliteSaver(BaseCheckpointSaver[str]): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (RunnableConfig): The config to use for listing the checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. Defaults to None. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): The maximum number of checkpoints to return. Defaults to None. + config: The config to use for listing the checkpoints. + filter: Additional filtering criteria for metadata. Defaults to None. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: The maximum number of checkpoints to return. Defaults to None. Yields: Iterator[CheckpointTuple]: An iterator of checkpoint tuples. @@ -380,10 +380,10 @@ class SqliteSaver(BaseCheckpointSaver[str]): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -437,10 +437,10 @@ class SqliteSaver(BaseCheckpointSaver[str]): This method saves intermediate writes associated with a checkpoint to the SQLite database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. """ query = ( "INSERT OR REPLACE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" @@ -468,7 +468,7 @@ class SqliteSaver(BaseCheckpointSaver[str]): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None diff --git a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py index 574bfafda..6a9da810e 100644 --- a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py +++ b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/aio.py @@ -126,7 +126,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): """Create a new AsyncSqliteSaver instance from a connection string. Args: - conn_string (str): The SQLite connection string. + conn_string: The SQLite connection string. Yields: AsyncSqliteSaver: A new AsyncSqliteSaver instance. @@ -143,7 +143,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -178,10 +178,10 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: Maximum number of checkpoints to return. Yields: Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples. @@ -221,10 +221,10 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -248,7 +248,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None @@ -320,7 +320,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -406,10 +406,10 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): on the provided config. The checkpoints are ordered by checkpoint ID in descending order (newest first). Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: If provided, only checkpoints before the specified checkpoint ID are returned. Defaults to None. + limit: Maximum number of checkpoints to return. Yields: AsyncIterator[CheckpointTuple]: An asynchronous iterator of matching checkpoint tuples. @@ -480,10 +480,10 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): with the provided config and its parent config (if any). Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -531,10 +531,10 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): This method saves intermediate writes associated with a checkpoint to the database. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (Sequence[Tuple[str, Any]]): List of writes to store, each as (channel, value) pair. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store, each as (channel, value) pair. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. """ query = ( "INSERT OR REPLACE INTO writes (thread_id, checkpoint_ns, checkpoint_id, task_id, idx, channel, type, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)" @@ -564,7 +564,7 @@ class AsyncSqliteSaver(BaseCheckpointSaver[str]): """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None diff --git a/libs/checkpoint/langgraph/checkpoint/base/__init__.py b/libs/checkpoint/langgraph/checkpoint/base/__init__.py index 35bc79bdc..9aa051f9a 100644 --- a/libs/checkpoint/langgraph/checkpoint/base/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/base/__init__.py @@ -232,7 +232,7 @@ class BaseCheckpointSaver(Generic[V]): """Fetch a checkpoint using the given configuration. Args: - config (RunnableConfig): Configuration specifying which checkpoint to retrieve. + config: Configuration specifying which checkpoint to retrieve. Returns: Optional[Checkpoint]: The requested checkpoint, or None if not found. @@ -244,7 +244,7 @@ class BaseCheckpointSaver(Generic[V]): """Fetch a checkpoint tuple using the given configuration. Args: - config (RunnableConfig): Configuration specifying which checkpoint to retrieve. + config: Configuration specifying which checkpoint to retrieve. Returns: Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found. @@ -265,10 +265,10 @@ class BaseCheckpointSaver(Generic[V]): """List checkpoints that match the given criteria. Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria. - before (Optional[RunnableConfig]): List checkpoints created before this configuration. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria. + before: List checkpoints created before this configuration. + limit: Maximum number of checkpoints to return. Returns: Iterator[CheckpointTuple]: Iterator of matching checkpoint tuples. @@ -288,10 +288,10 @@ class BaseCheckpointSaver(Generic[V]): """Store a checkpoint with its configuration and metadata. Args: - config (RunnableConfig): Configuration for the checkpoint. - checkpoint (Checkpoint): The checkpoint to store. - metadata (CheckpointMetadata): Additional metadata for the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: Configuration for the checkpoint. + checkpoint: The checkpoint to store. + metadata: Additional metadata for the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -311,10 +311,10 @@ class BaseCheckpointSaver(Generic[V]): """Store intermediate writes linked to a checkpoint. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (List[Tuple[str, Any]]): List of writes to store. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. Raises: NotImplementedError: Implement this method in your custom checkpoint saver. @@ -328,7 +328,7 @@ class BaseCheckpointSaver(Generic[V]): """Delete all checkpoints and writes associated with a specific thread ID. Args: - thread_id (str): The thread ID whose checkpoints should be deleted. + thread_id: The thread ID whose checkpoints should be deleted. """ raise NotImplementedError @@ -336,7 +336,7 @@ class BaseCheckpointSaver(Generic[V]): """Asynchronously fetch a checkpoint using the given configuration. Args: - config (RunnableConfig): Configuration specifying which checkpoint to retrieve. + config: Configuration specifying which checkpoint to retrieve. Returns: Optional[Checkpoint]: The requested checkpoint, or None if not found. @@ -348,7 +348,7 @@ class BaseCheckpointSaver(Generic[V]): """Asynchronously fetch a checkpoint tuple using the given configuration. Args: - config (RunnableConfig): Configuration specifying which checkpoint to retrieve. + config: Configuration specifying which checkpoint to retrieve. Returns: Optional[CheckpointTuple]: The requested checkpoint tuple, or None if not found. @@ -369,10 +369,10 @@ class BaseCheckpointSaver(Generic[V]): """Asynchronously list checkpoints that match the given criteria. Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): List checkpoints created before this configuration. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: List checkpoints created before this configuration. + limit: Maximum number of checkpoints to return. Returns: AsyncIterator[CheckpointTuple]: Async iterator of matching checkpoint tuples. @@ -393,10 +393,10 @@ class BaseCheckpointSaver(Generic[V]): """Asynchronously store a checkpoint with its configuration and metadata. Args: - config (RunnableConfig): Configuration for the checkpoint. - checkpoint (Checkpoint): The checkpoint to store. - metadata (CheckpointMetadata): Additional metadata for the checkpoint. - new_versions (ChannelVersions): New channel versions as of this write. + config: Configuration for the checkpoint. + checkpoint: The checkpoint to store. + metadata: Additional metadata for the checkpoint. + new_versions: New channel versions as of this write. Returns: RunnableConfig: Updated configuration after storing the checkpoint. @@ -416,10 +416,10 @@ class BaseCheckpointSaver(Generic[V]): """Asynchronously store intermediate writes linked to a checkpoint. Args: - config (RunnableConfig): Configuration of the related checkpoint. - writes (List[Tuple[str, Any]]): List of writes to store. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: Configuration of the related checkpoint. + writes: List of writes to store. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. Raises: NotImplementedError: Implement this method in your custom checkpoint saver. @@ -433,7 +433,7 @@ class BaseCheckpointSaver(Generic[V]): """Delete all checkpoints and writes associated with a specific thread ID. Args: - thread_id (str): The thread ID whose checkpoints should be deleted. + thread_id: The thread ID whose checkpoints should be deleted. """ raise NotImplementedError @@ -444,8 +444,8 @@ class BaseCheckpointSaver(Generic[V]): as long as they are monotonically increasing. Args: - current (Optional[V]): The current version identifier (int, float, or str). - channel (BaseChannel): The channel being versioned. + current: The current version identifier (int, float, or str). + channel: The channel being versioned. Returns: V: The next version identifier, which must be increasing. diff --git a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py index b4b263239..f475606dc 100644 --- a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py @@ -41,7 +41,7 @@ class InMemorySaver( If you are using the LangGraph Platform, no checkpointer needs to be specified. The correct managed checkpointer will be used automatically. Args: - serde (Optional[SerializerProtocol]): The serializer to use for serializing and deserializing checkpoints. Defaults to None. + serde: The serializer to use for serializing and deserializing checkpoints. Defaults to None. Examples: @@ -138,7 +138,7 @@ class InMemorySaver( for the given thread ID is retrieved. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -255,10 +255,10 @@ class InMemorySaver( on the provided criteria. Args: - config (Optional[RunnableConfig]): Base configuration for filtering checkpoints. - filter (Optional[Dict[str, Any]]): Additional filtering criteria for metadata. - before (Optional[RunnableConfig]): List checkpoints created before this configuration. - limit (Optional[int]): Maximum number of checkpoints to return. + config: Base configuration for filtering checkpoints. + filter: Additional filtering criteria for metadata. + before: List checkpoints created before this configuration. + limit: Maximum number of checkpoints to return. Yields: Iterator[CheckpointTuple]: An iterator of matching checkpoint tuples. @@ -380,10 +380,10 @@ class InMemorySaver( with the provided config. Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (dict): New versions as of this write + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New versions as of this write Returns: RunnableConfig: The updated config containing the saved checkpoint's timestamp. @@ -427,10 +427,10 @@ class InMemorySaver( with the provided config. Args: - config (RunnableConfig): The config to associate with the writes. - writes (list[tuple[str, Any]]): The writes to save. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: The config to associate with the writes. + writes: The writes to save. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. Returns: RunnableConfig: The updated config containing the saved writes' timestamp. @@ -456,7 +456,7 @@ class InMemorySaver( """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None @@ -477,7 +477,7 @@ class InMemorySaver( method in a separate thread using asyncio. Args: - config (RunnableConfig): The config to use for retrieving the checkpoint. + config: The config to use for retrieving the checkpoint. Returns: Optional[CheckpointTuple]: The retrieved checkpoint tuple, or None if no matching checkpoint was found. @@ -498,7 +498,7 @@ class InMemorySaver( method in a separate thread using asyncio. Args: - config (RunnableConfig): The config to use for listing the checkpoints. + config: The config to use for listing the checkpoints. Yields: AsyncIterator[CheckpointTuple]: An asynchronous iterator of checkpoint tuples. @@ -516,10 +516,10 @@ class InMemorySaver( """Asynchronous version of put. Args: - config (RunnableConfig): The config to associate with the checkpoint. - checkpoint (Checkpoint): The checkpoint to save. - metadata (CheckpointMetadata): Additional metadata to save with the checkpoint. - new_versions (dict): New versions as of this write + config: The config to associate with the checkpoint. + checkpoint: The checkpoint to save. + metadata: Additional metadata to save with the checkpoint. + new_versions: New versions as of this write Returns: RunnableConfig: The updated config containing the saved checkpoint's timestamp. @@ -539,10 +539,10 @@ class InMemorySaver( method in a separate thread using asyncio. Args: - config (RunnableConfig): The config to associate with the writes. - writes (List[Tuple[str, Any]]): The writes to save, each as a (channel, value) pair. - task_id (str): Identifier for the task creating the writes. - task_path (str): Path of the task creating the writes. + config: The config to associate with the writes. + writes: The writes to save, each as a (channel, value) pair. + task_id: Identifier for the task creating the writes. + task_path: Path of the task creating the writes. Returns: None @@ -553,7 +553,7 @@ class InMemorySaver( """Delete all checkpoints and writes associated with a thread ID. Args: - thread_id (str): The thread ID to delete. + thread_id: The thread ID to delete. Returns: None diff --git a/libs/checkpoint/langgraph/store/base/__init__.py b/libs/checkpoint/langgraph/store/base/__init__.py index de914a177..cc07b63eb 100644 --- a/libs/checkpoint/langgraph/store/base/__init__.py +++ b/libs/checkpoint/langgraph/store/base/__init__.py @@ -52,13 +52,13 @@ class Item: """Represents a stored item with metadata. Args: - value (dict[str, Any]): The stored data as a dictionary. Keys are filterable. - key (str): Unique identifier within the namespace. - namespace (tuple[str, ...]): Hierarchical path defining the collection in which this document resides. + value: The stored data as a dictionary. Keys are filterable. + key: Unique identifier within the namespace. + namespace: Hierarchical path defining the collection in which this document resides. Represented as a tuple of strings, allowing for nested categorization. For example: ("documents", 'user123') - created_at (datetime): Timestamp of item creation. - updated_at (datetime): Timestamp of last update. + created_at: Timestamp of item creation. + updated_at: Timestamp of last update. """ __slots__ = ("value", "key", "namespace", "created_at", "updated_at") @@ -913,12 +913,12 @@ class BaseStore(ABC): find specific collections, or navigate the namespace hierarchy. Args: - prefix (Optional[Tuple[str, ...]]): Filter namespaces that start with this path. - suffix (Optional[Tuple[str, ...]]): Filter namespaces that end with this path. - max_depth (Optional[int]): Return namespaces up to this depth in the hierarchy. + prefix: Filter namespaces that start with this path. + suffix: Filter namespaces that end with this path. + max_depth: Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated. - limit (int): Maximum number of namespaces to return (default 100). - offset (int): Number of namespaces to skip for pagination (default 0). + limit: Maximum number of namespaces to return (default 100). + offset: Number of namespaces to skip for pagination (default 0). Returns: List[Tuple[str, ...]]: A list of namespace tuples that match the criteria. @@ -1162,12 +1162,12 @@ class BaseStore(ABC): find specific collections, or navigate the namespace hierarchy. Args: - prefix (Optional[Tuple[str, ...]]): Filter namespaces that start with this path. - suffix (Optional[Tuple[str, ...]]): Filter namespaces that end with this path. - max_depth (Optional[int]): Return namespaces up to this depth in the hierarchy. + prefix: Filter namespaces that start with this path. + suffix: Filter namespaces that end with this path. + max_depth: Return namespaces up to this depth in the hierarchy. Namespaces deeper than this level will be truncated to this depth. - limit (int): Maximum number of namespaces to return (default 100). - offset (int): Number of namespaces to skip for pagination (default 0). + limit: Maximum number of namespaces to return (default 100). + offset: Number of namespaces to skip for pagination (default 0). Returns: List[Tuple[str, ...]]: A list of namespace tuples that match the criteria. diff --git a/libs/cli/langgraph_cli/templates.py b/libs/cli/langgraph_cli/templates.py index fbbc261a5..fd656ae2e 100644 --- a/libs/cli/langgraph_cli/templates.py +++ b/libs/cli/langgraph_cli/templates.py @@ -101,8 +101,8 @@ def _download_repo_with_requests(repo_url: str, path: str) -> None: """Download a ZIP archive from the given URL and extracts it to the specified path. Args: - repo_url (str): The URL of the repository to download. - path (str): The path where the repository should be extracted. + repo_url: The URL of the repository to download. + path: The path where the repository should be extracted. """ click.secho("📥 Attempting to download repository as a ZIP archive...", fg="yellow") click.secho(f"URL: {repo_url}", fg="yellow") @@ -136,7 +136,7 @@ def _get_template_url(template_name: str) -> Optional[str]: Retrieves the template URL based on the provided template name. Args: - template_name (str): The name of the template. + template_name: The name of the template. Returns: Optional[str]: The URL of the template if found, else None. @@ -166,8 +166,8 @@ def create_new(path: Optional[str], template: Optional[str]) -> None: """Create a new LangGraph project at the specified PATH using the chosen TEMPLATE. Args: - path (Optional[str]): The path where the new project will be created. - template (Optional[str]): The name of the template to use. + path: The path where the new project will be created. + template: The name of the template to use. """ # Prompt for path if not provided if not path: diff --git a/libs/langgraph/langgraph/func/__init__.py b/libs/langgraph/langgraph/func/__init__.py index 2a1f8fd6a..a951ef749 100644 --- a/libs/langgraph/langgraph/func/__init__.py +++ b/libs/langgraph/langgraph/func/__init__.py @@ -225,7 +225,7 @@ class entrypoint: as its result is cached by the checkpointer. Args: - topic (str): The subject of the essay. + topic: The subject of the essay. Returns: dict: A dictionary containing the generated essay and the human review. diff --git a/libs/langgraph/langgraph/graph/graph.py b/libs/langgraph/langgraph/graph/graph.py index f9aad0e2e..e8250ba57 100644 --- a/libs/langgraph/langgraph/graph/graph.py +++ b/libs/langgraph/langgraph/graph/graph.py @@ -79,11 +79,11 @@ class Graph: """Add a new node to the graph. Args: - node (Union[str, RunnableLike]): The function or runnable this node will run. + node: The function or runnable this node will run. If a string is provided, it will be used as the node name, and action will be used as the function or runnable. - action (Optional[RunnableLike]): The action associated with the node. (default: None) + action: The action associated with the node. (default: None) Will be used as the node function or runnable if `node` is a string (node name). - metadata (Optional[dict[str, Any]]): The metadata associated with the node. (default: None) + metadata: The metadata associated with the node. (default: None) """ if isinstance(node, str): for character in (NS_SEP, NS_END): @@ -122,8 +122,8 @@ class Graph: """Add a directed edge from the start node to the end node. Args: - start_key (str): The key of the start node of the edge. - end_key (str): The key of the end node of the edge. + start_key: The key of the start node of the edge. + end_key: The key of the end node of the edge. """ if self.compiled: logger.warning( @@ -161,14 +161,14 @@ class Graph: """Add a conditional edge from the starting node to any number of destination nodes. Args: - source (str): The starting node. This conditional edge will run when + source: The starting node. This conditional edge will run when exiting this node. - path (Union[Callable, Runnable]): The callable that determines the next + path: The callable that determines the next node or nodes. If not specifying `path_map` it should return one or more nodes. If it returns END, the graph will stop execution. - path_map (Optional[dict[Hashable, str]]): Optional mapping of paths to node + path_map: Optional mapping of paths to node names. If omitted the paths returned by `path` should be node names. - then (Optional[str]): The name of a node to execute after the nodes + then: The name of a node to execute after the nodes selected by `path`. Returns: @@ -222,12 +222,12 @@ class Graph: """Sets a conditional entry point in the graph. Args: - path (Union[Callable, Runnable]): The callable that determines the next + path: The callable that determines the next node or nodes. If not specifying `path_map` it should return one or more nodes. If it returns END, the graph will stop execution. - path_map (Optional[dict[str, str]]): Optional mapping of paths to node + path_map: Optional mapping of paths to node names. If omitted the paths returned by `path` should be node names. - then (Optional[str]): The name of a node to execute after the nodes + then: The name of a node to execute after the nodes selected by `path`. Returns: @@ -323,15 +323,15 @@ class Graph: streamed, batched, and run asynchronously. Args: - checkpointer (Optional[Union[Checkpointer, Literal[False]]]): A checkpoint saver object or flag. + checkpointer: A checkpoint saver object or flag. If provided, this Checkpointer serves as a fully versioned "short-term memory" for the graph, allowing it to be paused, resumed, and replayed from any point. If None, it may inherit the parent graph's checkpointer when used as a subgraph. If False, it will not use or inherit any checkpointer. - interrupt_before (Optional[Sequence[str]]): An optional list of node names to interrupt before. - interrupt_after (Optional[Sequence[str]]): An optional list of node names to interrupt after. - debug (bool): A flag indicating whether to enable debug mode. - name (Optional[str]): The name to use for the compiled graph. + interrupt_before: An optional list of node names to interrupt before. + interrupt_after: An optional list of node names to interrupt after. + debug: A flag indicating whether to enable debug mode. + name: The name to use for the compiled graph. Returns: CompiledGraph: The compiled graph. diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index a81e8831e..59da4e355 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -118,8 +118,8 @@ class StateGraph(Graph): The signature of a reducer function is (Value, Value) -> Value. Args: - state_schema (Type[Any]): The schema class that defines the state. - config_schema (Optional[Type[Any]]): The schema class that defines the configuration. + state_schema: The schema class that defines the state. + config_schema: The schema class that defines the configuration. Use this to expose configurable parameters in your API. Example: @@ -284,15 +284,15 @@ class StateGraph(Graph): """Add a new node to the state graph. Args: - node (Union[str, RunnableLike]): The function or runnable this node will run. + node: The function or runnable this node will run. If a string is provided, it will be used as the node name, and action will be used as the function or runnable. - action (Optional[RunnableLike]): The action associated with the node. (default: None) + action: The action associated with the node. (default: None) Will be used as the node function or runnable if `node` is a string (node name). - metadata (Optional[dict[str, Any]]): The metadata associated with the node. (default: None) - input (Optional[Type[Any]]): The input schema for the node. (default: the graph's input schema) - retry (Optional[Union[RetryPolicy, Sequence[RetryPolicy]]]): The policy for retrying the node. (default: None) + metadata: The metadata associated with the node. (default: None) + input: The input schema for the node. (default: the graph's input schema) + retry: The policy for retrying the node. (default: None) If a sequence is provided, the first matching policy will be applied. - destinations (Optional[Union[dict[str, str], tuple[str, ...]]]): Destinations that indicate where a node can route to. + destinations: Destinations that indicate where a node can route to. This is useful for edgeless graphs with nodes that return `Command` objects. If a dict is provided, the keys will be used as the target node names and the values will be used as the labels for the edges. If a tuple is provided, the values will be used as the target node names. @@ -432,8 +432,8 @@ class StateGraph(Graph): the graph will wait for ALL of the start nodes to complete before executing the end node. Args: - start_key (Union[str, list[str]]): The key(s) of the start node(s) of the edge. - end_key (str): The key of the end node of the edge. + start_key: The key(s) of the start node(s) of the edge. + end_key: The key of the end node of the edge. Raises: ValueError: If the start key is 'END' or if the start key or end key is not present in the graph. @@ -476,14 +476,14 @@ class StateGraph(Graph): """Add a conditional edge from the starting node to any number of destination nodes. Args: - source (str): The starting node. This conditional edge will run when + source: The starting node. This conditional edge will run when exiting this node. - path (Union[Callable, Runnable]): The callable that determines the next + path: The callable that determines the next node or nodes. If not specifying `path_map` it should return one or more nodes. If it returns END, the graph will stop execution. - path_map (Optional[dict[Hashable, str]]): Optional mapping of paths to node + path_map: Optional mapping of paths to node names. If omitted the paths returned by `path` should be node names. - then (Optional[str]): The name of a node to execute after the nodes + then: The name of a node to execute after the nodes selected by `path`. Returns: @@ -571,15 +571,15 @@ class StateGraph(Graph): streamed, batched, and run asynchronously. Args: - checkpointer (Optional[Union[Checkpointer, Literal[False]]]): A checkpoint saver object or flag. + checkpointer: A checkpoint saver object or flag. If provided, this Checkpointer serves as a fully versioned "short-term memory" for the graph, allowing it to be paused, resumed, and replayed from any point. If None, it may inherit the parent graph's checkpointer when used as a subgraph. If False, it will not use or inherit any checkpointer. - interrupt_before (Optional[Sequence[str]]): An optional list of node names to interrupt before. - interrupt_after (Optional[Sequence[str]]): An optional list of node names to interrupt after. - debug (bool): A flag indicating whether to enable debug mode. - name (Optional[str]): The name to use for the compiled graph. + interrupt_before: An optional list of node names to interrupt before. + interrupt_after: An optional list of node names to interrupt after. + debug: A flag indicating whether to enable debug mode. + name: The name to use for the compiled graph. Returns: CompiledStateGraph: The compiled state graph. diff --git a/libs/langgraph/langgraph/pregel/__init__.py b/libs/langgraph/langgraph/pregel/__init__.py index 9228ed34a..0663f8311 100644 --- a/libs/langgraph/langgraph/pregel/__init__.py +++ b/libs/langgraph/langgraph/pregel/__init__.py @@ -805,8 +805,8 @@ class Pregel(PregelProtocol): """Get the subgraphs of the graph. Args: - namespace (Optional[str]): The namespace to filter the subgraphs by. - recurse (bool): Whether to recurse into the subgraphs. + namespace: The namespace to filter the subgraphs by. + recurse: Whether to recurse into the subgraphs. If False, only the immediate subgraphs will be returned. Returns: @@ -844,8 +844,8 @@ class Pregel(PregelProtocol): """Get the subgraphs of the graph. Args: - namespace (Optional[str]): The namespace to filter the subgraphs by. - recurse (bool): Whether to recurse into the subgraphs. + namespace: The namespace to filter the subgraphs by. + recurse: Whether to recurse into the subgraphs. If False, only the immediate subgraphs will be returned. Returns: diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index 1cfe02d9d..1dad60a9e 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -263,8 +263,8 @@ class Send: Initialize a new instance of the Send class. Args: - node (str): The name of the target node to send the message to. - arg (Any): The state or message to send to the target node. + node: The name of the target node to send the message to. + arg: The state or message to send to the target node. """ self.node = node self.arg = arg diff --git a/libs/langgraph/langgraph/utils/config.py b/libs/langgraph/langgraph/utils/config.py index fc39a4cff..520ab444a 100644 --- a/libs/langgraph/langgraph/utils/config.py +++ b/libs/langgraph/langgraph/utils/config.py @@ -34,7 +34,7 @@ def recast_checkpoint_ns(ns: str) -> str: """Remove task IDs from checkpoint namespace. Args: - ns (str): The checkpoint namespace with task IDs. + ns: The checkpoint namespace with task IDs. Returns: str: The checkpoint namespace without task IDs. @@ -79,7 +79,7 @@ def merge_configs(*configs: Optional[RunnableConfig]) -> RunnableConfig: """Merge multiple configs into one. Args: - *configs (Optional[RunnableConfig]): The configs to merge. + *configs: The configs to merge. Returns: RunnableConfig: The merged config. @@ -159,15 +159,15 @@ def patch_config( """Patch a config with new values. Args: - config (Optional[RunnableConfig]): The config to patch. - callbacks (Optional[BaseCallbackManager], optional): The callbacks to set. + config: The config to patch. + callbacks: The callbacks to set. Defaults to None. - recursion_limit (Optional[int], optional): The recursion limit to set. + recursion_limit: The recursion limit to set. Defaults to None. - max_concurrency (Optional[int], optional): The max concurrency to set. + max_concurrency: The max concurrency to set. Defaults to None. - run_name (Optional[str], optional): The run name to set. Defaults to None. - configurable (Optional[Dict[str, Any]], optional): The configurable to set. + run_name: The run name to set. Defaults to None. + configurable: The configurable to set. Defaults to None. Returns: @@ -199,7 +199,7 @@ def get_callback_manager_for_config( """Get a callback manager for a config. Args: - config (RunnableConfig): The config. + config: The config. Returns: CallbackManager: The callback manager. @@ -237,7 +237,7 @@ def get_async_callback_manager_for_config( """Get an async callback manager for a config. Args: - config (RunnableConfig): The config. + config: The config. Returns: AsyncCallbackManager: The async callback manager. diff --git a/libs/langgraph/langgraph/utils/runnable.py b/libs/langgraph/langgraph/utils/runnable.py index a36acb41b..76699c947 100644 --- a/libs/langgraph/langgraph/utils/runnable.py +++ b/libs/langgraph/langgraph/utils/runnable.py @@ -67,7 +67,7 @@ def _set_config_context( """Set the child Runnable config + tracing context. Args: - config (RunnableConfig): The config to set. + config: The config to set. """ config_token = var_child_runnable_config.set(config) if run is not None: @@ -83,7 +83,7 @@ def _unset_config_context( """Set the child Runnable config + tracing context. Args: - config (RunnableConfig): The config to set. + config: The config to set. """ var_child_runnable_config.reset(token) if run is not None: @@ -108,7 +108,7 @@ def set_config_context( """Set the child Runnable config + tracing context. Args: - config (RunnableConfig): The config to set. + config: The config to set. """ ctx = copy_context() config_token = ctx.run(_set_config_context, config, run) diff --git a/libs/prebuilt/langgraph/prebuilt/tool_node.py b/libs/prebuilt/langgraph/prebuilt/tool_node.py index 0d1e514f7..b4ec0a569 100644 --- a/libs/prebuilt/langgraph/prebuilt/tool_node.py +++ b/libs/prebuilt/langgraph/prebuilt/tool_node.py @@ -543,10 +543,10 @@ class ToolNode(RunnableCallable): tool calls for tool invocation. Args: - tool_call (ToolCall): The tool call to inject state and store into. - input (Union[list[AnyMessage], dict[str, Any], BaseModel]): The input state + tool_call: The tool call to inject state and store into. + input: The input state to inject. - store (Optional[BaseStore]): The store to inject. + store: The store to inject. Returns: ToolCall: The tool call with injected state and store. @@ -625,7 +625,7 @@ def tools_condition( has tool calls. Otherwise, route to the end. Args: - state (Union[list[AnyMessage], dict[str, Any], BaseModel]): The state to check for + state: The state to check for tool calls. Must have a list of messages (MessageGraph) or have the "messages" key (StateGraph). diff --git a/libs/sdk-py/langgraph_sdk/auth/__init__.py b/libs/sdk-py/langgraph_sdk/auth/__init__.py index e0dff9c49..01dfd9143 100644 --- a/libs/sdk-py/langgraph_sdk/auth/__init__.py +++ b/libs/sdk-py/langgraph_sdk/auth/__init__.py @@ -195,7 +195,7 @@ class Auth: - authorization (str | None): The Authorization header value (e.g., "Bearer ") Args: - fn (Callable): The authentication handler function to register. + fn: The authentication handler function to register. Must return a representation of the user. This could be a: - string (the user id) - dict containing {"identity": str, "permissions": list[str]} diff --git a/libs/sdk-py/langgraph_sdk/auth/exceptions.py b/libs/sdk-py/langgraph_sdk/auth/exceptions.py index cd3019259..8dc0311a9 100644 --- a/libs/sdk-py/langgraph_sdk/auth/exceptions.py +++ b/libs/sdk-py/langgraph_sdk/auth/exceptions.py @@ -10,11 +10,10 @@ class HTTPException(Exception): Since this is defined in the auth module, we default to a 401 status code. Args: - status_code (int, optional): HTTP status code for the error. Defaults to 401 "Unauthorized". - detail (str | None, optional): Detailed error message. If None, uses a default + status_code: HTTP status code for the error. Defaults to 401 "Unauthorized". + detail: Detailed error message. If None, uses a default message based on the status code. - headers (typing.Mapping[str, str] | None, optional): Additional HTTP headers to - include in the error response. + headers: Additional HTTP headers to include in the error response. Example: Default: