From 770132dd79ff86a6f0687064e37e573d95635e3c Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Fri, 30 Aug 2024 14:23:10 -0700 Subject: [PATCH] sdk-py: Add values to get/list threads --- libs/sdk-py/langgraph_sdk/client.py | 15 +++++++++------ libs/sdk-py/langgraph_sdk/schema.py | 12 ++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libs/sdk-py/langgraph_sdk/client.py b/libs/sdk-py/langgraph_sdk/client.py index 79ac0b3e8..5d6779c5d 100644 --- a/libs/sdk-py/langgraph_sdk/client.py +++ b/libs/sdk-py/langgraph_sdk/client.py @@ -27,7 +27,7 @@ Cron, DisconnectMode, GraphSchema, - Metadata, + Json, MultitaskStrategy, OnCompletionBehavior, OnConflictBehavior, @@ -414,7 +414,7 @@ async def create( graph_id: Optional[str], config: Optional[Config] = None, *, - metadata: Metadata = None, + metadata: Json = None, assistant_id: Optional[str] = None, if_exists: Optional[OnConflictBehavior] = None, ) -> Assistant: @@ -462,7 +462,7 @@ async def update( *, graph_id: Optional[str] = None, config: Optional[Config] = None, - metadata: Metadata = None, + metadata: Json = None, ) -> Assistant: """Update an assistant. @@ -524,7 +524,7 @@ async def delete( async def search( self, *, - metadata: Metadata = None, + metadata: Json = None, graph_id: Optional[str] = None, limit: int = 10, offset: int = 0, @@ -600,7 +600,7 @@ async def get(self, thread_id: str) -> Thread: async def create( self, *, - metadata: Metadata = None, + metadata: Json = None, thread_id: Optional[str] = None, if_exists: Optional[OnConflictBehavior] = None, ) -> Thread: @@ -675,7 +675,8 @@ async def delete(self, thread_id: str) -> None: async def search( self, *, - metadata: Metadata = None, + metadata: Json = None, + values: Json = None, status: Optional[ThreadStatus] = None, limit: int = 10, offset: int = 0, @@ -708,6 +709,8 @@ async def search( } if metadata: payload["metadata"] = metadata + if values: + payload["values"] = values if status: payload["status"] = status return await self.http.post( diff --git a/libs/sdk-py/langgraph_sdk/schema.py b/libs/sdk-py/langgraph_sdk/schema.py index 7007a9ad1..5f58f02c2 100644 --- a/libs/sdk-py/langgraph_sdk/schema.py +++ b/libs/sdk-py/langgraph_sdk/schema.py @@ -1,7 +1,7 @@ from datetime import datetime from typing import Any, Literal, Optional, Sequence, TypedDict, Union -Metadata = Optional[dict[str, Any]] +Json = Optional[dict[str, Any]] RunStatus = Literal["pending", "running", "error", "success", "timeout", "interrupted"] @@ -70,7 +70,7 @@ class Assistant(TypedDict): """The time the assistant was created.""" updated_at: datetime """The last time the assistant was updated.""" - metadata: Metadata + metadata: Json """The assistant metadata.""" @@ -81,11 +81,11 @@ class Thread(TypedDict): """The time the thread was created.""" updated_at: datetime """The last time the thread was updated.""" - metadata: Metadata + metadata: Json """The thread metadata.""" status: ThreadStatus """The status of the thread, one of 'idle', 'busy', 'interrupted'.""" - values: dict + values: Json """The current state of the thread.""" @@ -97,7 +97,7 @@ class ThreadState(TypedDict): received.""" checkpoint_id: str """The ID of the checkpoint.""" - metadata: Metadata + metadata: Json """Metadata for this state""" created_at: Optional[str] """Timestamp of state creation""" @@ -118,7 +118,7 @@ class Run(TypedDict): """The last time the run was updated.""" status: RunStatus """The status of the run. One of 'pending', 'running', "error", 'success', "timeout", "interrupted".""" - metadata: Metadata + metadata: Json """The run metadata.""" multitask_strategy: MultitaskStrategy """Strategy to handle concurrent runs on the same thread."""