Skip to content

Commit

Permalink
feat(js): Add method to get size of annotation queue (#1377)
Browse files Browse the repository at this point in the history
This PR introduces functionality to use the LangSmith JS SDK to retrieve
the total number of runs in an annotation queue.

I came across the following endpoints in the LangSmith API documentation
(Redoc link) but am unsure which one is appropriate for this purpose:

/api/v1/annotation-queues/{queue_id}/total_size
/api/v1/annotation-queues/{queue_id}/size
  • Loading branch information
tendev-liam authored Jan 7, 2025
1 parent 9a2e496 commit bd48aeb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3648,6 +3648,27 @@ export class Client implements LangSmithTracingClientInterface {
return await response.json();
}

/**
* Get the size of an annotation queue.
* @param queueId - The ID of the annotation queue
*/
public async getSizeFromAnnotationQueue(
queueId: string
): Promise<Record<"size", number>> {
const response = await this.caller.call(
_getFetchImplementation(),
`${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/size`,
{
method: "GET",
headers: this.headers,
signal: AbortSignal.timeout(this.timeout_ms),
...this.fetchOptions,
}
);
await raiseForStatus(response, "get size from annotation queue");
return await response.json();
}

protected async _currentTenantIsOwner(owner: string): Promise<boolean> {
const settings = await this._getSettings();
return owner == "-" || settings.tenant_handle === owner;
Expand Down

0 comments on commit bd48aeb

Please sign in to comment.