feat: threads sorting sdk spec (#4362)

This commit is contained in:
lc-arjun
2025-04-21 14:42:43 -07:00
committed by GitHub
parent c7306f7aed
commit 90f7f776cf
4 changed files with 35 additions and 19 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@langchain/langgraph-sdk",
"version": "0.0.68",
"version": "0.0.69",
"description": "Client library for interacting with the LangGraph API",
"type": "module",
"packageManager": "yarn@1.22.19",
+27 -17
View File
@@ -1,42 +1,41 @@
import {
Assistant,
AssistantGraph,
AssistantVersion,
CancelAction,
Checkpoint,
Config,
Cron,
CronCreateForThreadResponse,
CronCreateResponse,
DefaultValues,
GraphSchema,
Item,
ListNamespaceResponse,
Metadata,
Run,
RunStatus,
SearchItemsResponse,
Subgraphs,
Thread,
ThreadState,
Cron,
AssistantVersion,
Subgraphs,
Checkpoint,
SearchItemsResponse,
ListNamespaceResponse,
Item,
ThreadStatus,
CronCreateResponse,
CronCreateForThreadResponse,
} from "./schema.js";
import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
import { IterableReadableStream } from "./utils/stream.js";
import type {
Command,
CronsCreatePayload,
OnConflictBehavior,
RunsCreatePayload,
RunsStreamPayload,
RunsWaitPayload,
StreamEvent,
CronsCreatePayload,
OnConflictBehavior,
Command,
} from "./types.js";
import { mergeSignals } from "./utils/signals.js";
import type { StreamMode, TypedAsyncGenerator } from "./types.stream.js";
import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
import { getEnvironmentVariable } from "./utils/env.js";
import { _getFetchImplementation } from "./singletons/fetch.js";
import type { TypedAsyncGenerator, StreamMode } from "./types.stream.js";
import { mergeSignals } from "./utils/signals.js";
import { BytesLineDecoder, SSEDecoder } from "./utils/sse.js";
import { IterableReadableStream } from "./utils/stream.js";
/**
* Get the API key from the environment.
* Precedence:
@@ -619,6 +618,15 @@ export class ThreadsClient<
* Must be one of 'idle', 'busy', 'interrupted' or 'error'.
*/
status?: ThreadStatus;
/**
* Sort by.
*/
sortBy?: "id" | "status" | "created_at" | "updated_at";
/**
* Sort order.
* Must be one of 'asc' or 'desc'.
*/
sortOrder?: "asc" | "desc";
}): Promise<Thread<ValuesType>[]> {
return this.fetch<Thread<ValuesType>[]>("/threads/search", {
method: "POST",
@@ -627,6 +635,8 @@ export class ThreadsClient<
limit: query?.limit ?? 10,
offset: query?.offset ?? 0,
status: query?.status,
sort_by: query?.sortBy,
sort_order: query?.sortOrder,
},
});
}
+6
View File
@@ -1043,6 +1043,8 @@ class ThreadsClient:
status: Optional[ThreadStatus] = None,
limit: int = 10,
offset: int = 0,
sort_by: Literal["id", "status", "created_at", "updated_at"] = "created_at",
sort_order: Literal["asc", "desc"] = "asc",
headers: Optional[dict[str, str]] = None,
) -> list[Thread]:
"""Search for threads.
@@ -1079,6 +1081,10 @@ class ThreadsClient:
payload["values"] = values
if status:
payload["status"] = status
if sort_by:
payload["sort_by"] = sort_by
if sort_order:
payload["sort_order"] = sort_order
return await self.http.post(
"/threads/search",
json=payload,
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-sdk"
version = "0.1.61"
version = "0.1.62"
description = "SDK for interacting with LangGraph API"
authors = []
license = "MIT"