Skip to content

Commit

Permalink
Add eager flag; bump (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Oct 20, 2023
1 parent 3e88476 commit 97f835f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "langsmith",
"version": "0.0.43",
"version": "0.0.44",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"files": [
"dist/",
Expand Down
5 changes: 4 additions & 1 deletion js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ export class Client {
feedbackSourceType = "api",
sourceRunId,
feedbackId,
eager = false,
}: {
score?: ScoreType;
value?: ValueType;
Expand All @@ -1253,6 +1254,7 @@ export class Client {
feedbackSourceType?: FeedbackSourceType;
sourceRunId?: string;
feedbackId?: string;
eager?: boolean;
}
): Promise<Feedback> {
const feedback_source: feedback_source = {
Expand All @@ -1276,7 +1278,8 @@ export class Client {
comment,
feedback_source: feedback_source,
};
const response = await this.caller.call(fetch, `${this.apiUrl}/feedback`, {
const url = `${this.apiUrl}/feedback` + (eager ? "/eager" : "");
const response = await this.caller.call(fetch, url, {
method: "POST",
headers: { ...this.headers, "Content-Type": "application/json" },
body: JSON.stringify(feedback),
Expand Down
25 changes: 24 additions & 1 deletion python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,23 @@ def list_shared_examples(
for dataset in response.json()
]

def list_shared_projects(
self,
*,
dataset_share_token: Optional[str] = None,
project_ids: Optional[List[ID_TYPE]] = None,
name: Optional[str] = None,
name_contains: Optional[str] = None,
) -> Iterator[ls_schemas.TracerSession]:
params = {"id": project_ids, "name": name, "name_contains": name_contains}
yield from [
ls_schemas.TracerSession(**dataset, _host_url=self._host_url)
for dataset in self._get_paginated_list(
f"/public/{dataset_share_token}/datasets/sessions",
params=params,
)
]

def create_project(
self,
project_name: str,
Expand Down Expand Up @@ -1935,6 +1952,7 @@ def create_feedback(
] = ls_schemas.FeedbackSourceType.API,
source_run_id: Optional[ID_TYPE] = None,
feedback_id: Optional[ID_TYPE] = None,
eager: bool = False,
) -> ls_schemas.Feedback:
"""Create a feedback in the LangSmith API.
Expand Down Expand Up @@ -1962,6 +1980,11 @@ def create_feedback(
feedback_id : str or UUID or None, default=None
The ID of the feedback to create. If not provided, a random UUID will be
generated.
eager : bool, default=False
Whether to skip the write queue when creating the feedback. This means
that the feedback will be immediately available for reading, but may
cause the write to fail if the API is under heavy load, since the target
run_id may have not been created yet.
"""
if not isinstance(feedback_source_type, ls_schemas.FeedbackSourceType):
feedback_source_type = ls_schemas.FeedbackSourceType(feedback_source_type)
Expand Down Expand Up @@ -1992,7 +2015,7 @@ def create_feedback(
)
self.request_with_retries(
"POST",
self.api_url + "/feedback",
self.api_url + "/feedback" + ("/eager" if eager else ""),
request_kwargs={
"data": json.dumps(
feedback.dict(exclude_none=True), default=_serialize_json
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.0.47"
version = "0.0.48"
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 97f835f

Please sign in to comment.