feat: assistants sorting sdk spec (#4484)

This commit is contained in:
lc-arjun
2025-04-30 17:05:37 -04:00
committed by GitHub
parent 536c1c2bba
commit 03c34bf2cf
6 changed files with 52 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@langchain/langgraph-sdk",
"version": "0.0.72",
"version": "0.0.73",
"description": "Client library for interacting with the LangGraph API",
"type": "module",
"packageManager": "yarn@1.22.19",
+9 -2
View File
@@ -1,6 +1,7 @@
import {
Assistant,
AssistantGraph,
AssistantSortBy,
AssistantVersion,
CancelAction,
Checkpoint,
@@ -16,8 +17,10 @@ import {
Run,
RunStatus,
SearchItemsResponse,
SortOrder,
Subgraphs,
Thread,
ThreadSortBy,
ThreadState,
ThreadStatus,
} from "./schema.js";
@@ -423,6 +426,8 @@ export class AssistantsClient extends BaseClient {
metadata?: Metadata;
limit?: number;
offset?: number;
sortBy?: AssistantSortBy;
sortOrder?: SortOrder;
}): Promise<Assistant[]> {
return this.fetch<Assistant[]>("/assistants/search", {
method: "POST",
@@ -431,6 +436,8 @@ export class AssistantsClient extends BaseClient {
metadata: query?.metadata ?? undefined,
limit: query?.limit ?? 10,
offset: query?.offset ?? 0,
sort_by: query?.sortBy ?? undefined,
sort_order: query?.sortOrder ?? undefined,
},
});
}
@@ -621,12 +628,12 @@ export class ThreadsClient<
/**
* Sort by.
*/
sortBy?: "thread_id" | "status" | "created_at" | "updated_at";
sortBy?: ThreadSortBy;
/**
* Sort order.
* Must be one of 'asc' or 'desc'.
*/
sortOrder?: "asc" | "desc";
sortOrder?: SortOrder;
}): Promise<Thread<ValuesType>[]> {
return this.fetch<Thread<ValuesType>[]>("/threads/search", {
method: "POST",
+11
View File
@@ -301,3 +301,14 @@ export interface CronCreateForThreadResponse
extends Omit<CronCreateResponse, "thread_id"> {
thread_id: string;
}
export type AssistantSortBy =
| "assistant_id"
| "graph_id"
| "name"
| "created_at"
| "updated_at";
export type ThreadSortBy = "thread_id" | "status" | "created_at" | "updated_at";
export type SortOrder = "asc" | "desc";
+13 -4
View File
@@ -33,6 +33,7 @@ import langgraph_sdk
from langgraph_sdk.schema import (
All,
Assistant,
AssistantSortBy,
AssistantVersion,
CancelAction,
Checkpoint,
@@ -52,10 +53,12 @@ from langgraph_sdk.schema import (
RunCreate,
RunStatus,
SearchItemsResponse,
SortOrder,
StreamMode,
StreamPart,
Subgraphs,
Thread,
ThreadSortBy,
ThreadState,
ThreadStatus,
ThreadUpdateStateResponse,
@@ -767,6 +770,8 @@ class AssistantsClient:
graph_id: Optional[str] = None,
limit: int = 10,
offset: int = 0,
sort_by: Optional[AssistantSortBy] = None,
sort_order: Optional[SortOrder] = None,
headers: Optional[dict[str, str]] = None,
) -> list[Assistant]:
"""Search for assistants.
@@ -777,6 +782,8 @@ class AssistantsClient:
The graph ID is normally set in your langgraph.json configuration.
limit: The maximum number of results to return.
offset: The number of results to skip.
sort_by: The field to sort by.
sort_order: The order to sort by.
headers: Optional custom headers to include with the request.
Returns:
@@ -799,6 +806,10 @@ class AssistantsClient:
payload["metadata"] = metadata
if graph_id:
payload["graph_id"] = graph_id
if sort_by:
payload["sort_by"] = sort_by
if sort_order:
payload["sort_order"] = sort_order
return await self.http.post(
"/assistants/search",
json=payload,
@@ -1043,10 +1054,8 @@ class ThreadsClient:
status: Optional[ThreadStatus] = None,
limit: int = 10,
offset: int = 0,
sort_by: Optional[
Literal["thread_id", "status", "created_at", "updated_at"]
] = None,
sort_order: Optional[Literal["asc", "desc"]] = None,
sort_by: Optional[ThreadSortBy] = None,
sort_order: Optional[SortOrder] = None,
headers: Optional[dict[str, str]] = None,
) -> list[Thread]:
"""Search for threads.
+17
View File
@@ -95,6 +95,23 @@ Action to take when cancelling the run.
- "rollback": Cancel the run. Then delete the run and associated checkpoints.
"""
AssistantSortBy = Literal[
"assistant_id", "graph_id", "name", "created_at", "updated_at"
]
"""
The field to sort by.
"""
ThreadSortBy = Literal["thread_id", "status", "created_at", "updated_at"]
"""
The field to sort by.
"""
SortOrder = Literal["asc", "desc"]
"""
The order to sort by.
"""
class Config(TypedDict, total=False):
"""Configuration options for a call."""
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-sdk"
version = "0.1.64"
version = "0.1.65"
description = "SDK for interacting with LangGraph API"
authors = []
license = "MIT"