Skip to content

Commit

Permalink
Update TS types (#331)
Browse files Browse the repository at this point in the history
Update the types of the objects
  • Loading branch information
hinthornw authored Dec 18, 2023
1 parent 3e67717 commit 407ebef
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 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.51",
"version": "0.0.52",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
"files": [
"dist/",
Expand Down
8 changes: 8 additions & 0 deletions js/src/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
export interface TracerSession {
// The ID of the tenant, or organization
tenant_id: string;
// The ID of the project (alias for session)
id: string;
// The start time of the project
start_time: number;
// The end time of the project
end_time?: number;
// A description of the project
description?: string;
// The name of the project
name?: string;
}

Expand Down
18 changes: 18 additions & 0 deletions python/langsmith/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ class TracerSession(BaseModel):
"""The ID of the project."""
start_time: datetime = Field(default_factory=datetime.utcnow)
"""The time the project was created."""
end_time: Optional[datetime] = None
"""The time the project was ended."""
description: Optional[str] = None
"""The description of the project."""
name: Optional[str] = None
"""The name of the session."""
extra: Optional[Dict[str, Any]] = None
Expand All @@ -400,6 +404,20 @@ def url(self) -> Optional[str]:
return f"{self._host_url}/o/{self.tenant_id}/projects/p/{self.id}"
return None

@property
def metadata(self) -> dict[str, Any]:
"""Retrieve the metadata (if any)."""
if self.extra is None or "metadata" not in self.extra:
return {}
return self.extra["metadata"]

@property
def tags(self) -> List[str]:
"""Retrieve the tags (if any)."""
if self.extra is None or "tags" not in self.extra:
return []
return self.extra["tags"]


class TracerSessionResult(TracerSession):
"""TracerSession schema returned when reading a project
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.71"
version = "0.0.72"
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 407ebef

Please sign in to comment.