diff --git a/libs/sdk-js/package.json b/libs/sdk-js/package.json index 726f83bce..0f93a1cc9 100644 --- a/libs/sdk-js/package.json +++ b/libs/sdk-js/package.json @@ -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", diff --git a/libs/sdk-js/src/client.ts b/libs/sdk-js/src/client.ts index 0f804b6a8..85d5ede1d 100644 --- a/libs/sdk-js/src/client.ts +++ b/libs/sdk-js/src/client.ts @@ -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 { return this.fetch("/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[]> { return this.fetch[]>("/threads/search", { method: "POST", diff --git a/libs/sdk-js/src/schema.ts b/libs/sdk-js/src/schema.ts index 72d15aaa1..b77ec30bb 100644 --- a/libs/sdk-js/src/schema.ts +++ b/libs/sdk-js/src/schema.ts @@ -301,3 +301,14 @@ export interface CronCreateForThreadResponse extends Omit { 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"; diff --git a/libs/sdk-py/langgraph_sdk/client.py b/libs/sdk-py/langgraph_sdk/client.py index 85193c398..466530da3 100644 --- a/libs/sdk-py/langgraph_sdk/client.py +++ b/libs/sdk-py/langgraph_sdk/client.py @@ -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. diff --git a/libs/sdk-py/langgraph_sdk/schema.py b/libs/sdk-py/langgraph_sdk/schema.py index 213dfdaa3..b6849e543 100644 --- a/libs/sdk-py/langgraph_sdk/schema.py +++ b/libs/sdk-py/langgraph_sdk/schema.py @@ -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.""" diff --git a/libs/sdk-py/pyproject.toml b/libs/sdk-py/pyproject.toml index 0726192d6..d1d321d24 100644 --- a/libs/sdk-py/pyproject.toml +++ b/libs/sdk-py/pyproject.toml @@ -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"