Skip to content

Commit

Permalink
sdk-py: Add values to get/list threads
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Aug 30, 2024
1 parent 3943637 commit 770132d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 9 additions & 6 deletions libs/sdk-py/langgraph_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Cron,
DisconnectMode,
GraphSchema,
Metadata,
Json,
MultitaskStrategy,
OnCompletionBehavior,
OnConflictBehavior,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions libs/sdk-py/langgraph_sdk/schema.py
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down Expand Up @@ -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."""


Expand All @@ -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."""


Expand All @@ -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"""
Expand All @@ -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."""
Expand Down

0 comments on commit 770132d

Please sign in to comment.