Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support annotation queue params #1304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion js/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as uuid from "uuid";

Check notice on line 1 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

........... WARNING: the benchmark result may be unstable * the standard deviation (101 ms) is 14% of the mean (713 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. create_5_000_run_trees: Mean +- std dev: 713 ms +- 101 ms ........... WARNING: the benchmark result may be unstable * the standard deviation (199 ms) is 14% of the mean (1.41 sec) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. create_10_000_run_trees: Mean +- std dev: 1.41 sec +- 0.20 sec ........... WARNING: the benchmark result may be unstable * the standard deviation (267 ms) is 18% of the mean (1.47 sec) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. create_20_000_run_trees: Mean +- std dev: 1.47 sec +- 0.27 sec ........... dumps_class_nested_py_branch_and_leaf_200x400: Mean +- std dev: 696 us +- 4 us ........... dumps_class_nested_py_leaf_50x100: Mean +- std dev: 25.3 ms +- 0.4 ms ........... dumps_class_nested_py_leaf_100x200: Mean +- std dev: 104 ms +- 2 ms ........... dumps_dataclass_nested_50x100: Mean +- std dev: 25.9 ms +- 0.3 ms ........... WARNING: the benchmark result may be unstable * the standard deviation (19.2 ms) is 25% of the mean (78.1 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. dumps_pydantic_nested_50x100: Mean +- std dev: 78.1 ms +- 19.2 ms ........... dumps_pydanticv1_nested_50x100: Mean +- std dev: 203 ms +- 3 ms

Check notice on line 1 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------------+----------+------------------------+ | Benchmark | main | changes | +===============================================+==========+========================+ | dumps_pydanticv1_nested_50x100 | 221 ms | 203 ms: 1.09x faster | +-----------------------------------------------+----------+------------------------+ | create_5_000_run_trees | 724 ms | 713 ms: 1.02x faster | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_branch_and_leaf_200x400 | 705 us | 696 us: 1.01x faster | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_100x200 | 105 ms | 104 ms: 1.01x faster | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_50x100 | 25.1 ms | 25.3 ms: 1.01x slower | +-----------------------------------------------+----------+------------------------+ | create_10_000_run_trees | 1.40 sec | 1.41 sec: 1.01x slower | +-----------------------------------------------+----------+------------------------+ | dumps_dataclass_nested_50x100 | 25.6 ms | 25.9 ms: 1.01x slower | +-----------------------------------------------+----------+------------------------+ | create_20_000_run_trees | 1.39 sec | 1.47 sec: 1.06x slower | +-----------------------------------------------+----------+------------------------+ | dumps_pydantic_nested_50x100 | 66.2 ms | 78.1 ms: 1.18x slower | +-----------------------------------------------+----------+------------------------+ | Geometric mean | (ref) | 1.01x slower | +-----------------------------------------------+----------+------------------------+

import { AsyncCaller, AsyncCallerParams } from "./utils/async_caller.js";
import {
Expand Down Expand Up @@ -417,7 +417,7 @@
// If there is an item on the queue we were unable to pop,
// just return it as a single batch.
if (popped.length === 0 && this.items.length > 0) {
const item = this.items.shift()!;

Check warning on line 420 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Forbidden non-null assertion
popped.push(item);
poppedSizeBytes += item.size;
this.sizeBytes -= item.size;
Expand Down Expand Up @@ -833,7 +833,7 @@
if (this._serverInfo === undefined) {
try {
this._serverInfo = await this._getServerInfo();
} catch (e) {

Check warning on line 836 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

'e' is defined but never used. Allowed unused args must match /^_/u
console.warn(
`[WARNING]: LangSmith failed to fetch info on supported operations. Falling back to batch operations and default limits.`
);
Expand Down Expand Up @@ -1551,7 +1551,7 @@
treeFilter?: string;
isRoot?: boolean;
dataSourceType?: string;
}): Promise<any> {

Check warning on line 1554 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
let projectIds_ = projectIds || [];
if (projectNames) {
projectIds_ = [
Expand Down Expand Up @@ -1839,7 +1839,7 @@
`Failed to list shared examples: ${response.status} ${response.statusText}`
);
}
return result.map((example: any) => ({

Check warning on line 1842 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
...example,
_hostUrl: this.getHostUrl(),
}));
Expand Down Expand Up @@ -1976,7 +1976,7 @@
}
// projectId querying
return true;
} catch (e) {

Check warning on line 1979 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

'e' is defined but never used. Allowed unused args must match /^_/u
return false;
}
}
Expand Down Expand Up @@ -3316,7 +3316,7 @@
async _logEvaluationFeedback(
evaluatorResponse: EvaluationResult | EvaluationResults,
run?: Run,
sourceInfo?: { [key: string]: any }

Check warning on line 3319 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
): Promise<[results: EvaluationResult[], feedbacks: Feedback[]]> {
const evalResults: Array<EvaluationResult> =
this._selectEvalResults(evaluatorResponse);
Expand Down Expand Up @@ -3355,7 +3355,7 @@
public async logEvaluationFeedback(
evaluatorResponse: EvaluationResult | EvaluationResults,
run?: Run,
sourceInfo?: { [key: string]: any }

Check warning on line 3358 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
): Promise<EvaluationResult[]> {
const [results] = await this._logEvaluationFeedback(
evaluatorResponse,
Expand Down Expand Up @@ -3418,18 +3418,60 @@
* @param options.name - The name of the annotation queue
* @param options.description - The description of the annotation queue
* @param options.queueId - The ID of the annotation queue
* @param options.defaultDatasetId - The ID of the default dataset for the queue
* @param options.defaultDatasetName - The name of the default dataset for the queue
* @param options.numReviewersPerItem - Number of reviewers per item
* @param options.enableReservations - Whether to enable reservations
* @param options.reservationMinutes - Number of minutes for reservations
* @param options.rubricItems - List of rubric items for the queue
* @param options.rubricInstructions - Instructions for the rubric
* @returns The created AnnotationQueue object
*/
public async createAnnotationQueue(options: {
name: string;
description?: string;
queueId?: string;
defaultDatasetId?: string;
defaultDatasetName?: string;
numReviewersPerItem?: number;
enableReservations?: boolean;
reservationMinutes?: number;
rubricItems?: Array<Record<string, any>>;

Check warning on line 3439 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
rubricInstructions?: string;
}): Promise<AnnotationQueue> {
const { name, description, queueId } = options;
const {
name,
description,
queueId,
defaultDatasetId,
defaultDatasetName,
numReviewersPerItem,
enableReservations = true,
reservationMinutes,
rubricItems,
rubricInstructions,
} = options;

let defaultDataset: string | undefined;
if (defaultDatasetId) {
defaultDataset = assertUuid(defaultDatasetId, "defaultDatasetId");
} else if (defaultDatasetName) {
const dataset = await this.readDataset({
datasetName: defaultDatasetName,
});
defaultDataset = dataset.id;
}

const body = {
name,
description,
id: queueId || uuid.v4(),
default_dataset: defaultDataset,
num_reviewers_per_item: numReviewersPerItem,
enable_reservations: enableReservations,
reservation_minutes: reservationMinutes,
rubric_items: rubricItems,
rubric_instructions: rubricInstructions,
};

const response = await this.caller.call(
Expand Down Expand Up @@ -3805,7 +3847,7 @@

public async createCommit(
promptIdentifier: string,
object: any,

Check warning on line 3850 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
options?: {
parentCommitHash?: string;
}
Expand Down Expand Up @@ -3856,7 +3898,7 @@
isPublic?: boolean;
isArchived?: boolean;
}
): Promise<Record<string, any>> {

Check warning on line 3901 in js/src/client.ts

View workflow job for this annotation

GitHub Actions / Check linting

Unexpected any. Specify a different type
if (!(await this.promptExists(promptIdentifier))) {
throw new Error("Prompt does not exist, you must create it first.");
}
Expand Down
32 changes: 32 additions & 0 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4889,6 +4889,13 @@ def create_annotation_queue(
name: str,
description: Optional[str] = None,
queue_id: Optional[ID_TYPE] = None,
default_dataset_id: Optional[ID_TYPE] = None,
default_dataset_name: Optional[str] = None,
num_reviewers_per_item: Optional[int] = None,
enable_reservations: Optional[bool] = True,
reservation_minutes: Optional[int] = None,
rubric_items: Optional[Sequence[Mapping[str, Any]]] = None,
rubric_instructions: Optional[str] = None,
) -> ls_schemas.AnnotationQueue:
"""Create an annotation queue on the LangSmith API.

Expand All @@ -4899,15 +4906,40 @@ def create_annotation_queue(
The description of the annotation queue.
queue_id : str or UUID, optional
The ID of the annotation queue.
default_dataset : str, optional
The default dataset for the queue.
num_reviewers_per_item : int, optional
Number of reviewers per item.
enable_reservations : bool, optional
Whether to enable reservations. Defaults to True.
reservation_minutes : int, optional
Number of minutes for reservations.
rubric_items : List[Dict[str, Any]], optional
List of rubric items for the queue.
rubric_instructions : str, optional
Instructions for the rubric.

Returns:
AnnotationQueue
The created annotation queue object.
"""
if default_dataset_id is not None:
default_dataset = _as_uuid(default_dataset_id, "default_dataset_id")
elif default_dataset_name is not None:
default_dataset = self.read_dataset(dataset_name=default_dataset_name).id
else:
default_dataset = None

body = {
"name": name,
"description": description,
"id": queue_id or str(uuid.uuid4()),
"default_dataset": default_dataset,
"num_reviewers_per_item": num_reviewers_per_item,
"enable_reservations": enable_reservations,
"reservation_minutes": reservation_minutes,
"rubric_items": rubric_items,
"rubric_instructions": rubric_instructions,
}
response = self.request_with_retries(
"POST",
Expand Down
Loading