Compare commits

..
Author SHA1 Message Date
William Fu-Hinthorn 8dadeddb35 Update headers type 2025-09-02 19:40:44 -07:00
6 changed files with 6 additions and 83 deletions
+1 -20
View File
@@ -5261,30 +5261,11 @@
"type": "object",
"title": "Metadata",
"description": "Metadata to merge with existing thread metadata."
},
"ttl": {
"type": "object",
"title": "TTL",
"description": "The time-to-live for the thread.",
"properties": {
"strategy": {
"type": "string",
"enum": [
"delete"
],
"description": "The TTL strategy. 'delete' removes the entire thread.",
"default": "delete"
},
"ttl": {
"type": "number",
"description": "The time-to-live in minutes from now until thread should be swept."
}
}
}
},
"type": "object",
"title": "ThreadPatch",
"description": "Payload for updating a thread."
"description": "Payload for creating a thread."
},
"ThreadStateCheckpointRequest": {
"properties": {
+1 -1
View File
@@ -112,7 +112,7 @@ auth = Auth()
@auth.authenticate
async def authenticate(headers: dict) -> Auth.types.MinimalUserDict:
# Validate credentials (e.g., API key, JWT token)
api_key = headers.get("x-api-key")
api_key = headers.get(b"x-api-key")
if not api_key or not is_valid_key(api_key):
raise Auth.exceptions.HTTPException(
status_code=401,
+1 -1
View File
@@ -43,7 +43,7 @@ To leverage custom authentication and access user-level metadata in your deploym
@auth.authenticate # (1)!
async def authenticate(headers: dict) -> Auth.types.MinimalUserDict:
api_key = headers.get("x-api-key")
api_key = headers.get(b"x-api-key")
if not api_key or not is_valid_key(api_key):
raise Auth.exceptions.HTTPException(status_code=401, detail="Invalid API key")
+1 -1
View File
@@ -1,6 +1,6 @@
from langgraph_sdk.auth import Auth
from langgraph_sdk.client import get_client, get_sync_client
__version__ = "0.2.6"
__version__ = "0.2.5"
__all__ = ["Auth", "get_client", "get_sync_client"]
-17
View File
@@ -400,20 +400,6 @@ class AuthContext(BaseAuthContext):
"""
class ThreadTTL(typing.TypedDict, total=False):
"""Time-to-live configuration for a thread.
Matches the OpenAPI schema where TTL is represented as an object with
an optional strategy and a time value in minutes.
"""
strategy: typing.Literal["delete"]
"""TTL strategy. Currently only 'delete' is supported."""
ttl: int
"""Time-to-live in minutes from now until the thread should be swept."""
class ThreadsCreate(typing.TypedDict, total=False):
"""Parameters for creating a new thread.
@@ -436,9 +422,6 @@ class ThreadsCreate(typing.TypedDict, total=False):
if_exists: OnConflictBehavior
"""Behavior when a thread with the same ID already exists."""
ttl: ThreadTTL
"""Optional TTL configuration for the thread."""
class ThreadsRead(typing.TypedDict, total=False):
"""Parameters for reading thread state or run information.
+2 -43
View File
@@ -1179,7 +1179,6 @@ class ThreadsClient:
if_exists: OnConflictBehavior | None = None,
supersteps: Sequence[dict[str, Sequence[dict[str, Any]]]] | None = None,
graph_id: str | None = None,
ttl: int | Mapping[str, Any] | None = None,
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None,
) -> Thread:
@@ -1194,9 +1193,6 @@ class ThreadsClient:
supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
graph_id: Optional graph ID to associate with the thread.
ttl: Optional time-to-live in minutes for the thread. You can pass an
integer (minutes) or a mapping with keys `ttl` and optional
`strategy` (defaults to "delete").
headers: Optional custom headers to include with the request.
params: Optional query parameters to include with the request.
@@ -1238,11 +1234,6 @@ class ThreadsClient:
}
for s in supersteps
]
if ttl is not None:
if isinstance(ttl, (int, float)):
payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
else:
payload["ttl"] = ttl
return await self.http.post(
"/threads", json=payload, headers=headers, params=params
@@ -1253,7 +1244,6 @@ class ThreadsClient:
thread_id: str,
*,
metadata: Mapping[str, Any],
ttl: int | Mapping[str, Any] | None = None,
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None,
) -> Thread:
@@ -1262,9 +1252,6 @@ class ThreadsClient:
Args:
thread_id: ID of thread to update.
metadata: Metadata to merge with existing thread metadata.
ttl: Optional time-to-live in minutes for the thread. You can pass an
integer (minutes) or a mapping with keys `ttl` and optional
`strategy` (defaults to "delete").
headers: Optional custom headers to include with the request.
params: Optional query parameters to include with the request.
@@ -1278,19 +1265,12 @@ class ThreadsClient:
thread = await client.threads.update(
thread_id="my-thread-id",
metadata={"number":1},
ttl=43_200,
)
```
""" # noqa: E501
payload: dict[str, Any] = {"metadata": metadata}
if ttl is not None:
if isinstance(ttl, (int, float)):
payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
else:
payload["ttl"] = ttl
return await self.http.patch(
f"/threads/{thread_id}",
json=payload,
json={"metadata": metadata},
headers=headers,
params=params,
)
@@ -4352,7 +4332,6 @@ class SyncThreadsClient:
if_exists: OnConflictBehavior | None = None,
supersteps: Sequence[dict[str, Sequence[dict[str, Any]]]] | None = None,
graph_id: str | None = None,
ttl: int | Mapping[str, Any] | None = None,
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None,
) -> Thread:
@@ -4367,9 +4346,6 @@ class SyncThreadsClient:
supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
graph_id: Optional graph ID to associate with the thread.
ttl: Optional time-to-live in minutes for the thread. You can pass an
integer (minutes) or a mapping with keys `ttl` and optional
`strategy` (defaults to "delete").
headers: Optional custom headers to include with the request.
Returns:
@@ -4411,11 +4387,6 @@ class SyncThreadsClient:
}
for s in supersteps
]
if ttl is not None:
if isinstance(ttl, (int, float)):
payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
else:
payload["ttl"] = ttl
return self.http.post("/threads", json=payload, headers=headers, params=params)
@@ -4424,7 +4395,6 @@ class SyncThreadsClient:
thread_id: str,
*,
metadata: Mapping[str, Any],
ttl: int | Mapping[str, Any] | None = None,
headers: Mapping[str, str] | None = None,
params: QueryParamTypes | None = None,
) -> Thread:
@@ -4433,11 +4403,7 @@ class SyncThreadsClient:
Args:
thread_id: ID of thread to update.
metadata: Metadata to merge with existing thread metadata.
ttl: Optional time-to-live in minutes for the thread. You can pass an
integer (minutes) or a mapping with keys `ttl` and optional
`strategy` (defaults to "delete").
headers: Optional custom headers to include with the request.
params: Optional query parameters to include with the request.
Returns:
Thread: The created thread.
@@ -4449,19 +4415,12 @@ class SyncThreadsClient:
thread = client.threads.update(
thread_id="my-thread-id",
metadata={"number":1},
ttl=43_200,
)
```
""" # noqa: E501
payload: dict[str, Any] = {"metadata": metadata}
if ttl is not None:
if isinstance(ttl, (int, float)):
payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
else:
payload["ttl"] = ttl
return self.http.patch(
f"/threads/{thread_id}",
json=payload,
json={"metadata": metadata},
headers=headers,
params=params,
)