Skip to content

Commit

Permalink
Add arg in create_example (#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Sep 9, 2024
1 parent 3e741d7 commit 1940e7e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.1.51",
"version": "0.1.52",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"packageManager": "[email protected]",
"files": [
Expand Down Expand Up @@ -276,4 +276,4 @@
},
"./package.json": "./package.json"
}
}
}
11 changes: 10 additions & 1 deletion js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,20 @@ type RecordStringAny = Record<string, any>;
export type FeedbackSourceType = "model" | "api" | "app";

export type CreateExampleOptions = {
/** The ID of the dataset to create the example in. */
datasetId?: string;
/** The name of the dataset to create the example in (if dataset ID is not provided). */
datasetName?: string;
/** The creation date of the example. */
createdAt?: Date;
/** A unique identifier for the example. */
exampleId?: string;

/** Additional metadata associated with the example. */
metadata?: KVMap;
/** The split(s) to assign the example to. */
split?: string | string[];
/** The ID of the source run associated with this example. */
sourceRunId?: string;
};

type AutoBatchQueueItem = {
Expand Down Expand Up @@ -2288,6 +2295,7 @@ export class Client {
exampleId,
metadata,
split,
sourceRunId,
}: CreateExampleOptions
): Promise<Example> {
let datasetId_ = datasetId;
Expand All @@ -2309,6 +2317,7 @@ export class Client {
id: exampleId,
metadata,
split,
source_run_id: sourceRunId,
};

const response = await this.caller.call(fetch, `${this.apiUrl}/examples`, {
Expand Down
2 changes: 1 addition & 1 deletion js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export type {
export { RunTree, type RunTreeConfig } from "./run_trees.js";

// Update using yarn bump-version
export const __version__ = "0.1.51";
export const __version__ = "0.1.52";
1 change: 1 addition & 0 deletions js/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface BaseExample {
inputs: KVMap;
outputs?: KVMap;
metadata?: KVMap;
source_run_id?: string;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3307,6 +3307,7 @@ def create_example(
metadata: Optional[Mapping[str, Any]] = None,
split: Optional[str | List[str]] = None,
example_id: Optional[ID_TYPE] = None,
source_run_id: Optional[ID_TYPE] = None,
) -> ls_schemas.Example:
"""Create a dataset example in the LangSmith API.
Expand All @@ -3330,9 +3331,11 @@ def create_example(
split : str or List[str] or None, default=None
The splits for the example, which are divisions
of your dataset such as 'train', 'test', or 'validation'.
exemple_id : UUID or None, default=None
example_id : UUID or None, default=None
The ID of the example to create. If not provided, a new
example will be created.
source_run_id : UUID or None, default=None
The ID of the source run associated with this example.
Returns:
Example: The created example.
Expand All @@ -3346,6 +3349,7 @@ def create_example(
"dataset_id": dataset_id,
"metadata": metadata,
"split": split,
"source_run_id": source_run_id,
}
if created_at:
data["created_at"] = created_at.isoformat()
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.1.116"
version = "0.1.117"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 1940e7e

Please sign in to comment.