mirror of
https://github.com/langchain-ai/langgraphjs.git
synced 2026-07-21 08:35:23 -04:00
feat: Add name parameter to assistants count API (#1805)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@langchain/langgraph-api": patch
|
||||
"@langchain/langgraph-sdk": patch
|
||||
---
|
||||
|
||||
Add name parameter to assistants count API.
|
||||
@@ -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.");
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>;
|
||||
|
||||
|
||||
@@ -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" });
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user