sdk-py: add if_exists to threads.create (#1009)

This commit is contained in:
Vadym Barda
2024-07-15 12:15:43 -04:00
committed by GitHub
parent 9e7695085e
commit 647c5737f0
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -29,6 +29,7 @@ from langgraph_sdk.schema import (
GraphSchema,
Metadata,
MultitaskStrategy,
OnConflictBehavior,
Run,
StreamMode,
Thread,
@@ -344,6 +345,7 @@ class ThreadsClient:
*,
metadata: Metadata = None,
thread_id: Optional[str] = None,
if_exists: Optional[OnConflictBehavior] = None,
) -> Thread:
"""Create a new thread."""
payload: Dict[str, Any] = {}
@@ -351,6 +353,8 @@ class ThreadsClient:
payload["thread_id"] = thread_id
if metadata:
payload["metadata"] = metadata
if if_exists:
payload["if_exists"] = if_exists
return await self.http.post("/threads", json=payload)
async def update(self, thread_id: str, *, metadata: dict[str, Any]) -> Thread:
+2
View File
@@ -11,6 +11,8 @@ StreamMode = Literal["values", "messages", "updates", "events", "debug"]
MultitaskStrategy = Literal["reject", "interrupt", "rollback", "enqueue"]
OnConflictBehavior = Literal["raise", "do_nothing"]
All = Literal["*"]