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

Update list repos #1187

Open
wants to merge 2 commits 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
60 changes: 42 additions & 18 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Client for interacting with the LangSmith API.

Check notice on line 1 in python/langsmith/client.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

......................................... create_5_000_run_trees: Mean +- std dev: 611 ms +- 43 ms ......................................... create_10_000_run_trees: Mean +- std dev: 1.18 sec +- 0.06 sec ......................................... create_20_000_run_trees: Mean +- std dev: 1.18 sec +- 0.06 sec ......................................... dumps_class_nested_py_branch_and_leaf_200x400: Mean +- std dev: 706 us +- 15 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: 105 ms +- 3 ms ......................................... dumps_dataclass_nested_50x100: Mean +- std dev: 25.7 ms +- 0.4 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (16.2 ms) is 24% of the mean (67.0 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: 67.0 ms +- 16.2 ms ......................................... WARNING: the benchmark result may be unstable * the standard deviation (31.3 ms) is 14% of the mean (221 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_pydanticv1_nested_50x100: Mean +- std dev: 221 ms +- 31 ms

Check notice on line 1 in python/langsmith/client.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+------------------------------------+----------+------------------------+ | Benchmark | main | changes | +====================================+==========+========================+ | dumps_pydantic_nested_50x100 | 71.7 ms | 67.0 ms: 1.07x faster | +------------------------------------+----------+------------------------+ | create_20_000_run_trees | 1.21 sec | 1.18 sec: 1.03x faster | +------------------------------------+----------+------------------------+ | create_5_000_run_trees | 625 ms | 611 ms: 1.02x faster | +------------------------------------+----------+------------------------+ | create_10_000_run_trees | 1.20 sec | 1.18 sec: 1.01x faster | +------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_50x100 | 25.5 ms | 25.3 ms: 1.01x faster | +------------------------------------+----------+------------------------+ | dumps_dataclass_nested_50x100 | 25.9 ms | 25.7 ms: 1.01x faster | +------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_100x200 | 104 ms | 105 ms: 1.01x slower | +------------------------------------+----------+------------------------+ | Geometric mean | (ref) | 1.02x faster | +------------------------------------+----------+------------------------+ Benchmark hidden because not significant (2): dumps_pydanticv1_nested_50x100, dumps_class_nested_py_branch_and_leaf_200x400

Use the client to customize API keys / workspace ocnnections, SSl certs,
etc. for tracing.
Expand Down Expand Up @@ -5186,44 +5186,68 @@
def list_prompts(
self,
*,
limit: int = 100,
with_latest_manifest: bool = False,
limit: int = 20,
offset: int = 0,
is_public: Optional[bool] = None,
is_archived: Optional[bool] = False,
sort_field: ls_schemas.PromptSortField = ls_schemas.PromptSortField.updated_at,
sort_direction: Literal["desc", "asc"] = "desc",
tenant_handle: Optional[str] = None,
tenant_id: Optional[str] = None,
query: Optional[str] = None,
has_commits: Optional[bool] = None,
tags: Optional[list[str]] = None,
is_archived: Optional[str] = None,
is_public: Optional[str] = None,
upstream_repo_owner: Optional[str] = None,
upstream_repo_handle: Optional[str] = None,
match_prefix: bool = False,
tag_value_id: Optional[list[str]] = None,
sort_field: Optional[str] = None,
sort_direction: Optional[Literal["asc", "desc"]] = None,
) -> ls_schemas.ListPromptsResponse:
"""List prompts with pagination.

Args:
limit (int): The maximum number of prompts to return. Defaults to 100.
with_latest_manifest (bool): Include latest manifest. Defaults to False.
limit (int): The maximum number of prompts to return. Defaults to 20.
offset (int): The number of prompts to skip. Defaults to 0.
is_public (Optional[bool]): Filter prompts by if they are public.
is_archived (Optional[bool]): Filter prompts by if they are archived.
sort_field (ls_schemas.PromptsSortField): The field to sort by.
Defaults to "updated_at".
sort_direction (Literal["desc", "asc"]): The order to sort by.
Defaults to "desc".
tenant_handle (Optional[str]): Filter by tenant handle.
tenant_id (Optional[str]): Filter by tenant ID.
query (Optional[str]): Filter prompts by a search query.
has_commits (Optional[bool]): Filter prompts by whether they have commits.
tags (Optional[list[str]]): Filter prompts by tags.
is_archived (Optional[str]): Filter prompts by archived status.
is_public (Optional[str]): Filter prompts by public status.
upstream_repo_owner (Optional[str]): Filter by upstream repo owner.
upstream_repo_handle (Optional[str]): Filter by upstream repo handle.
match_prefix (bool): Whether to match prefix in query. Defaults to False.
tag_value_id (Optional[list[str]]): Filter by tag value IDs.
sort_field (Optional[str]): The field to sort by.
sort_direction (Optional[Literal["asc", "desc"]]): The order to sort by.

Returns:
ls_schemas.ListPromptsResponse: A response object containing
the list of prompts.
"""
params = {
"with_latest_manifest": str(with_latest_manifest).lower(),
"limit": limit,
"offset": offset,
"is_public": (
"true" if is_public else "false" if is_public is not None else None
),
"is_archived": "true" if is_archived else "false",
"tenant_handle": tenant_handle,
"tenant_id": tenant_id,
"query": query,
"has_commits": has_commits,
"tags": tags,
"is_archived": is_archived,
"is_public": is_public,
"upstream_repo_owner": upstream_repo_owner,
"upstream_repo_handle": upstream_repo_handle,
"match_prefix": str(match_prefix).lower(),
"tag_value_id": tag_value_id,
"sort_field": sort_field,
"sort_direction": sort_direction,
"query": query,
"match_prefix": "true" if query else None,
}

params = {k: v for k, v in params.items() if v is not None}

response = self.request_with_retries("GET", "/repos/", params=params)
return ls_schemas.ListPromptsResponse(**response.json())

Expand Down
4 changes: 3 additions & 1 deletion python/langsmith/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ class Prompt(BaseModel):
"""The number of downloads."""
num_views: int
"""The number of views."""
liked_by_auth_user: bool
liked_by_auth_user: bool = False
"""Whether the prompt is liked by the authenticated user."""
last_commit_hash: Optional[str] = None
"""The hash of the last commit."""
Expand All @@ -897,6 +897,8 @@ class Prompt(BaseModel):
"""The full name of the original prompt, if forked."""
upstream_repo_full_name: Optional[str] = None
"""The full name of the upstream prompt, if forked."""
latest_commit_manifest: Optional[dict] = None
"""The latest commit manifest response."""


class ListPromptsResponse(BaseModel):
Expand Down
Loading