mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-08 02:37:52 +02:00
sdk-py: add if_exists to threads.create (#1009)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -11,6 +11,8 @@ StreamMode = Literal["values", "messages", "updates", "events", "debug"]
|
||||
|
||||
MultitaskStrategy = Literal["reject", "interrupt", "rollback", "enqueue"]
|
||||
|
||||
OnConflictBehavior = Literal["raise", "do_nothing"]
|
||||
|
||||
All = Literal["*"]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user