feat: Add name parameter to assistants count API (#1805)

This commit is contained in:
Andrew Nguonly
2025-12-03 06:44:41 -08:00
committed by GitHub
parent e19e76c053
commit 35e8fc7813
6 changed files with 24 additions and 2 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@langchain/langgraph-api": patch
"@langchain/langgraph-sdk": patch
---
Add name parameter to assistants count API.
+1
View File
@@ -317,6 +317,7 @@ export const AssistantCountRequest = z
.describe("Metadata to search for.")
.optional(),
graph_id: z.string().describe("Filter by graph ID.").optional(),
name: z.string().describe("Filter by name.").optional(),
})
.describe("Payload for counting assistants.");
+8 -1
View File
@@ -609,7 +609,7 @@ export class FileSystemAssistants implements AssistantsRepo {
}
async count(
options: { graph_id?: string; metadata?: Metadata },
options: { graph_id?: string; name?: string; metadata?: Metadata },
auth: AuthContext | undefined
): Promise<number> {
const [filters] = await handleAuthEvent(auth, "assistants:search", {
@@ -628,6 +628,13 @@ export class FileSystemAssistants implements AssistantsRepo {
return false;
}
if (
options.name != null &&
!assistant["name"].toLowerCase().includes(options.name.toLowerCase())
) {
return false;
}
if (
options.metadata != null &&
!isJsonbContained(assistant["metadata"], options.metadata)
+1 -1
View File
@@ -462,7 +462,7 @@ export interface AssistantsRepo {
): Promise<string[]>;
count(
options: { graph_id?: string; metadata?: Metadata },
options: { graph_id?: string; name?: string; metadata?: Metadata },
auth: AuthContext | undefined
): Promise<number>;
+5
View File
@@ -218,6 +218,11 @@ describe("assistants", () => {
expect(search[0].name.toLowerCase().includes("PLE_run".toLowerCase()));
});
it("count assistants", async () => {
let count = await client.assistants.count();
expect(count).toEqual(9);
});
it("get assistant versions", async () => {
const assistant = await client.assistants.create({ graphId: "agent" });
+3
View File
@@ -686,17 +686,20 @@ export class AssistantsClient extends BaseClient {
*
* @param query.metadata Metadata to filter by. Exact match for each key/value.
* @param query.graphId Optional graph id to filter by.
* @param query.name Optional name to filter by.
* @returns Number of assistants matching the criteria.
*/
async count(query?: {
metadata?: Metadata;
graphId?: string;
name?: string;
}): Promise<number> {
return this.fetch<number>(`/assistants/count`, {
method: "POST",
json: {
metadata: query?.metadata ?? undefined,
graph_id: query?.graphId ?? undefined,
name: query?.name ?? undefined,
},
});
}