Skip to content

Commit

Permalink
Handle missing version errors (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Sep 27, 2024
1 parent 22903fe commit a374216
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1930,8 +1930,10 @@ def get_run_url(
str
The URL for the run.
"""
if hasattr(run, "session_id") and run.session_id is not None:
session_id = run.session_id
if session_id := getattr(run, "session_id", None):
pass
elif session_name := getattr(run, "session_name", None):
session_id = self.read_project(project_name=session_name).id
elif project_id is not None:
session_id = project_id
elif project_name is not None:
Expand Down Expand Up @@ -5269,9 +5271,15 @@ def pull_prompt_commit(
owner, prompt_name, commit_hash = ls_utils.parse_prompt_identifier(
prompt_identifier
)
use_optimization = ls_utils.is_version_greater_or_equal(
self.info.version, "0.5.23"
)
try:
use_optimization = ls_utils.is_version_greater_or_equal(
self.info.version, "0.5.23"
)
except ValueError:
logger.exception(
"Failed to parse LangSmith API version. Defaulting to using optimization."
)
use_optimization = True

if not use_optimization and commit_hash == "latest":
latest_commit_hash = self._get_latest_commit_hash(f"{owner}/{prompt_name}")
Expand Down Expand Up @@ -5320,7 +5328,7 @@ def list_prompt_commits(
owner, prompt_name, _ = ls_utils.parse_prompt_identifier(prompt_identifier)

params = {
"limit": limit if limit is not None else 100,
"limit": min(100, limit) if limit is not None else limit,
"offset": offset,
"include_model": include_model,
}
Expand All @@ -5339,12 +5347,12 @@ def list_prompt_commits(
if not items:
break
for it in items:
i += 1
if limit is not None and i >= limit:
return # Stop iteration if we've reached the limit
yield ls_schemas.ListedPromptCommit(
**{"owner": owner, "repo": prompt_name, **it}
)
if limit is not None and i >= limit:
break
i += 1

offset += len(items)
if offset >= total:
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.128"
version = "0.1.129"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down

0 comments on commit a374216

Please sign in to comment.