Skip to content

Commit

Permalink
add js methods and types
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 committed Sep 12, 2024
1 parent af91bd8 commit 40464a3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libs/sdk-js/src/client.mts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,30 @@ export class AssistantsClient extends BaseClient {
},
});
}

/**
* List all versions of an assistant.
*
* @param assistantId ID of the assistant.
* @returns List of assistant versions.
*/
async getVersions(assistantId: string): Promise<Assistant[]> {
return this.fetch<Assistant[]>(`/assistants/${assistantId}/versions`);
}

/**
* Change the version of an assistant.
*
* @param assistantId ID of the assistant.
* @param version The version to change to.
* @returns The updated assistant.
*/
async changeVersion(assistantId: string, version: number): Promise<Assistant> {
return this.fetch<Assistant>(`/assistants/${assistantId}/change_version`, {
method: "POST",
json: { version },
});
}
}

export class ThreadsClient extends BaseClient {
Expand Down
2 changes: 2 additions & 0 deletions libs/sdk-js/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export interface Assistant {
created_at: string;
updated_at: string;
metadata: Metadata;
version: number;
name: string;
}
export type AssistantGraph = Record<string, Array<Record<string, unknown>>>;

Expand Down
4 changes: 4 additions & 0 deletions libs/sdk-py/langgraph_sdk/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class Assistant(TypedDict):
"""The last time the assistant was updated."""
metadata: Json
"""The assistant metadata."""
version: int
"""The version of the assistant"""
name: str
"""The name of the assistant"""


class Thread(TypedDict):
Expand Down

0 comments on commit 40464a3

Please sign in to comment.