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

Merge Main into SYN-165 #18

Merged
merged 8 commits into from
Dec 20, 2024
Merged
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
4 changes: 2 additions & 2 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
"Classes"
],
"summary": "abstractions.TrainingQuestion",
"description": "A training question is a question that an agent (system_id) is trying to answer.\nIt contains an intent and criteria that the agent is trying to meet.\n\n[View source on GitHub](https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py)",
"description": "A training question is a question that an agent (system_instance_id) is trying to answer.\nIt contains an intent and criteria that the agent is trying to meet.\n\n[View source on GitHub](https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py)",
"externalDocs": {
"description": "View source on GitHub",
"url": "https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py"
Expand Down Expand Up @@ -235,7 +235,7 @@
"Classes"
],
"summary": "abstractions.RewardSignal",
"description": "A reward signal tells us how well an agent (system_id) is doing on a particular question (question_id).\n\n[View source on GitHub](https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py)",
"description": "A reward signal tells us how well an agent (system_instance_id) is doing on a particular question (question_id).\n\n[View source on GitHub](https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py)",
"externalDocs": {
"description": "View source on GitHub",
"url": "https://github.com/synth-laboratories/synth-sdk/blob/main/synth_sdk/tracing/abstractions.py"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "synth-sdk"
version = "0.2.97"
version = "0.2.103"
description = ""
authors = [{name = "Synth AI", email = "[email protected]"}]
license = {text = "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="synth-sdk",
version="0.2.97",
version="0.2.103",
packages=find_packages(),
install_requires=[
"opentelemetry-api",
Expand Down
61 changes: 39 additions & 22 deletions synth_sdk/tracing/abstractions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
from dataclasses import dataclass
from typing import Any, List, Dict, Optional, Union
from datetime import datetime
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel
import logging
from synth_sdk.tracing.config import VALID_TYPES

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -39,13 +39,15 @@ class ComputeStep:
def to_dict(self):
# Serialize compute_input
serializable_input = [
input_item.__dict__ for input_item in self.compute_input
input_item.__dict__
for input_item in self.compute_input
if isinstance(input_item, (MessageInputs, ArbitraryInputs))
]

# Serialize compute_output
serializable_output = [
output_item.__dict__ for output_item in self.compute_output
output_item.__dict__
for output_item in self.compute_output
if isinstance(output_item, (MessageOutputs, ArbitraryOutputs))
]

Expand All @@ -59,8 +61,12 @@ def to_dict(self):

return {
"event_order": self.event_order,
"compute_ended": self.compute_ended.isoformat() if isinstance(self.compute_ended, datetime) else self.compute_ended,
"compute_began": self.compute_began.isoformat() if isinstance(self.compute_began, datetime) else self.compute_began,
"compute_ended": self.compute_ended.isoformat()
if isinstance(self.compute_ended, datetime)
else self.compute_ended,
"compute_began": self.compute_began.isoformat()
if isinstance(self.compute_began, datetime)
else self.compute_began,
"compute_input": serializable_input,
"compute_output": serializable_output,
}
Expand All @@ -86,7 +92,7 @@ class EnvironmentComputeStep(ComputeStep):

@dataclass
class Event:
system_id: str
system_instance_id: str
event_type: str
opened: Any # timestamp
closed: Any # timestamp
Expand All @@ -97,8 +103,12 @@ class Event:
def to_dict(self):
return {
"event_type": self.event_type,
"opened": self.opened.isoformat() if isinstance(self.opened, datetime) else self.opened,
"closed": self.closed.isoformat() if isinstance(self.closed, datetime) else self.closed,
"opened": self.opened.isoformat()
if isinstance(self.opened, datetime)
else self.opened,
"closed": self.closed.isoformat()
if isinstance(self.closed, datetime)
else self.closed,
"partition_index": self.partition_index,
"agent_compute_steps": [
step.to_dict() for step in self.agent_compute_steps
Expand All @@ -123,25 +133,30 @@ def to_dict(self):

@dataclass
class SystemTrace:
system_name: str
system_id: str
system_instance_id: str
metadata: Optional[Dict[str, Any]]
partition: List[EventPartitionElement]
current_partition_index: int = 0 # Track current partition

def to_dict(self):
return {
"system_name": self.system_name,
"system_id": self.system_id,
"system_instance_id": self.system_instance_id,
"partition": [element.to_dict() for element in self.partition],
"current_partition_index": self.current_partition_index,
"metadata": self.metadata if self.metadata else None
"metadata": self.metadata if self.metadata else None,
}


class TrainingQuestion(BaseModel):
'''
A training question is a question that an agent (system_id) is trying to answer.
"""
A training question is a question that an agent (system_instance_id) is trying to answer.
It contains an intent and criteria that the agent is trying to meet.
'''
"""

id: str
intent: str
criteria: str
Expand All @@ -155,28 +170,30 @@ def to_dict(self):


class RewardSignal(BaseModel):
'''
A reward signal tells us how well an agent (system_id) is doing on a particular question (question_id).
'''
"""
A reward signal tells us how well an agent (system_instance_id) is doing on a particular question (question_id).
"""

question_id: str
system_id: str
system_instance_id: str
reward: Union[float, int, bool]
annotation: Optional[str] = None

def to_dict(self):
return {
"question_id": self.question_id,
"system_id": self.system_id,
"system_instance_id": self.system_instance_id,
"reward": self.reward,
"annotation": self.annotation,
}


class Dataset(BaseModel):
'''
A dataset is a collection of training questions and reward signals.
"""
A dataset is a collection of training questions and reward signals.
This better represents the data that is used to train a model, and gives us more information about the data.
'''
"""

questions: List[TrainingQuestion]
reward_signals: List[RewardSignal]

Expand Down
Loading
Loading