-
Notifications
You must be signed in to change notification settings - Fork 225
feat(api): update API spec from langfuse/langfuse 41f064c #1492
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,31 @@ | |
| class BaseScore(pydantic_v1.BaseModel): | ||
| id: str | ||
| trace_id: typing.Optional[str] = pydantic_v1.Field(alias="traceId", default=None) | ||
| """ | ||
| The trace ID associated with the score | ||
| """ | ||
|
|
||
| session_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="sessionId", default=None | ||
| ) | ||
| """ | ||
| The session ID associated with the score | ||
| """ | ||
|
|
||
| observation_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="observationId", default=None | ||
| ) | ||
| """ | ||
| The observation ID associated with the score | ||
| """ | ||
|
|
||
| dataset_run_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="datasetRunId", default=None | ||
| ) | ||
| """ | ||
| The dataset run ID associated with the score | ||
| """ | ||
|
|
||
| name: str | ||
| source: ScoreSource | ||
| timestamp: dt.datetime | ||
|
|
@@ -28,8 +44,20 @@ class BaseScore(pydantic_v1.BaseModel): | |
| author_user_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="authorUserId", default=None | ||
| ) | ||
| comment: typing.Optional[str] = None | ||
| metadata: typing.Optional[typing.Any] = None | ||
| """ | ||
| The user ID of the author | ||
| """ | ||
|
|
||
| comment: typing.Optional[str] = pydantic_v1.Field(default=None) | ||
| """ | ||
| Comment on the score | ||
| """ | ||
|
|
||
| metadata: typing.Any = pydantic_v1.Field() | ||
| """ | ||
| Metadata associated with the score | ||
| """ | ||
|
|
||
| config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) | ||
| """ | ||
| Reference a score config on a score. When set, config and score name must be equal and value must comply to optionally defined numerical range | ||
|
|
@@ -40,7 +68,7 @@ class BaseScore(pydantic_v1.BaseModel): | |
| The annotation queue referenced by the score. Indicates if score was initially created while processing annotation queue. | ||
| """ | ||
|
|
||
| environment: typing.Optional[str] = pydantic_v1.Field(default=None) | ||
| environment: str = pydantic_v1.Field() | ||
| """ | ||
| The environment from which this score originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. | ||
| """ | ||
|
Comment on lines
+71
to
74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/base_score.py
Line: 71:74
Comment:
**logic:** Changed from `Optional[str]` with `default=None` to required `str` without default. Will fail validation if `environment` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,17 +11,35 @@ | |
| class DatasetItem(pydantic_v1.BaseModel): | ||
| id: str | ||
| status: DatasetStatus | ||
| input: typing.Optional[typing.Any] = None | ||
| expected_output: typing.Optional[typing.Any] = pydantic_v1.Field( | ||
| alias="expectedOutput", default=None | ||
| ) | ||
| metadata: typing.Optional[typing.Any] = None | ||
| input: typing.Any = pydantic_v1.Field() | ||
| """ | ||
| Input data for the dataset item | ||
| """ | ||
|
|
||
| expected_output: typing.Any = pydantic_v1.Field(alias="expectedOutput") | ||
| """ | ||
| Expected output for the dataset item | ||
| """ | ||
|
|
||
| metadata: typing.Any = pydantic_v1.Field() | ||
| """ | ||
| Metadata associated with the dataset item | ||
| """ | ||
|
Comment on lines
+14
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/dataset_item.py
Line: 14:27
Comment:
**logic:** Changed `input`, `expected_output`, and `metadata` from optional to required without defaults. These fields now must be present in all API responses or deserialization will fail.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| source_trace_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="sourceTraceId", default=None | ||
| ) | ||
| """ | ||
| The trace ID that sourced this dataset item | ||
| """ | ||
|
|
||
| source_observation_id: typing.Optional[str] = pydantic_v1.Field( | ||
| alias="sourceObservationId", default=None | ||
| ) | ||
| """ | ||
| The observation ID that sourced this dataset item | ||
| """ | ||
|
|
||
| dataset_id: str = pydantic_v1.Field(alias="datasetId") | ||
| dataset_name: str = pydantic_v1.Field(alias="datasetName") | ||
| created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |||||||||||
|
|
||||||||||||
| from ....core.datetime_utils import serialize_datetime | ||||||||||||
| from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 | ||||||||||||
| from .map_value import MapValue | ||||||||||||
| from .observation_level import ObservationLevel | ||||||||||||
| from .usage import Usage | ||||||||||||
|
|
||||||||||||
|
|
@@ -55,14 +54,12 @@ class Observation(pydantic_v1.BaseModel): | |||||||||||
| The model used for the observation | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| model_parameters: typing.Optional[typing.Dict[str, MapValue]] = pydantic_v1.Field( | ||||||||||||
| alias="modelParameters", default=None | ||||||||||||
| ) | ||||||||||||
| model_parameters: typing.Any = pydantic_v1.Field(alias="modelParameters") | ||||||||||||
| """ | ||||||||||||
| The parameters of the model used for the observation | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+57
to
60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from
Suggested change
Does the API always return modelParameters, metadata, input, output, usage, usageDetails, costDetails, and environment fields in observation responses? Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 57:60
Comment:
**logic:** Changed from `Optional[typing.Dict[str, MapValue]]` with `default=None` to required `typing.Any` field. If the API response doesn't include `modelParameters`, Pydantic validation will fail during deserialization.
```suggestion
model_parameters: typing.Any = pydantic_v1.Field(default=None, alias="modelParameters")
```
Does the API always return modelParameters, metadata, input, output, usage, usageDetails, costDetails, and environment fields in observation responses?
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| input: typing.Optional[typing.Any] = pydantic_v1.Field(default=None) | ||||||||||||
| input: typing.Any = pydantic_v1.Field() | ||||||||||||
| """ | ||||||||||||
| The input data of the observation | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+62
to
65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required field without default value. This will cause validation errors if API responses don't include Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 62:65
Comment:
**logic:** Changed from optional to required field without default value. This will cause validation errors if API responses don't include `input`.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
@@ -72,17 +69,17 @@ class Observation(pydantic_v1.BaseModel): | |||||||||||
| The version of the observation | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| metadata: typing.Optional[typing.Any] = pydantic_v1.Field(default=None) | ||||||||||||
| metadata: typing.Any = pydantic_v1.Field() | ||||||||||||
| """ | ||||||||||||
| Additional metadata of the observation | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+72
to
75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 72:75
Comment:
**logic:** Changed from optional to required without default. Will fail validation if `metadata` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| output: typing.Optional[typing.Any] = pydantic_v1.Field(default=None) | ||||||||||||
| output: typing.Any = pydantic_v1.Field() | ||||||||||||
| """ | ||||||||||||
| The output data of the observation | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+77
to
80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 77:80
Comment:
**logic:** Changed from optional to required without default. Will fail validation if `output` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| usage: typing.Optional[Usage] = pydantic_v1.Field(default=None) | ||||||||||||
| usage: Usage = pydantic_v1.Field() | ||||||||||||
| """ | ||||||||||||
| (Deprecated. Use usageDetails and costDetails instead.) The usage data of the observation | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+82
to
85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if deprecated Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 82:85
Comment:
**logic:** Changed from optional to required without default. Will fail validation if deprecated `usage` field is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
@@ -111,21 +108,17 @@ class Observation(pydantic_v1.BaseModel): | |||||||||||
| The prompt ID associated with the observation | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| usage_details: typing.Optional[typing.Dict[str, int]] = pydantic_v1.Field( | ||||||||||||
| alias="usageDetails", default=None | ||||||||||||
| ) | ||||||||||||
| usage_details: typing.Dict[str, int] = pydantic_v1.Field(alias="usageDetails") | ||||||||||||
| """ | ||||||||||||
| The usage details of the observation. Key is the name of the usage metric, value is the number of units consumed. The total key is the sum of all (non-total) usage metrics or the total value ingested. | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+111
to
114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 111:114
Comment:
**logic:** Changed from optional to required without default. Will fail validation if `usageDetails` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| cost_details: typing.Optional[typing.Dict[str, float]] = pydantic_v1.Field( | ||||||||||||
| alias="costDetails", default=None | ||||||||||||
| ) | ||||||||||||
| cost_details: typing.Dict[str, float] = pydantic_v1.Field(alias="costDetails") | ||||||||||||
| """ | ||||||||||||
| The cost details of the observation. Key is the name of the cost metric, value is the cost in USD. The total key is the sum of all (non-total) cost metrics or the total value ingested. | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+116
to
119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 116:119
Comment:
**logic:** Changed from optional to required without default. Will fail validation if `costDetails` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| environment: typing.Optional[str] = pydantic_v1.Field(default=None) | ||||||||||||
| environment: str = pydantic_v1.Field() | ||||||||||||
| """ | ||||||||||||
| The environment from which this observation originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'. | ||||||||||||
| """ | ||||||||||||
|
Comment on lines
+121
to
124
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed from optional to required without default. Will fail validation if Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/observation.py
Line: 121:124
Comment:
**logic:** Changed from optional to required without default. Will fail validation if `environment` is missing from API response.
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,10 +32,10 @@ class Score_Numeric(pydantic_v1.BaseModel): | |
| alias="authorUserId", default=None | ||
| ) | ||
| comment: typing.Optional[str] = None | ||
| metadata: typing.Optional[typing.Any] = None | ||
| metadata: typing.Any | ||
| config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) | ||
| queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) | ||
| environment: typing.Optional[str] = None | ||
| environment: str | ||
|
Comment on lines
+35
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Changed Prompt To Fix With AIThis is a comment left during a code review.
Path: langfuse/api/resources/commons/types/score.py
Line: 35:38
Comment:
**logic:** Changed `metadata` from `Optional[typing.Any] = None` to required `typing.Any` without default, and `environment` from `Optional[str] = None` to required `str` without default. This pattern is repeated in all three Score variants (Numeric, Categorical, Boolean). API responses missing these fields will fail validation.
How can I resolve this? If you propose a fix, please make it concise. |
||
| data_type: typing.Literal["NUMERIC"] = pydantic_v1.Field( | ||
| alias="dataType", default="NUMERIC" | ||
| ) | ||
|
|
@@ -97,10 +97,10 @@ class Score_Categorical(pydantic_v1.BaseModel): | |
| alias="authorUserId", default=None | ||
| ) | ||
| comment: typing.Optional[str] = None | ||
| metadata: typing.Optional[typing.Any] = None | ||
| metadata: typing.Any | ||
| config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) | ||
| queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) | ||
| environment: typing.Optional[str] = None | ||
| environment: str | ||
| data_type: typing.Literal["CATEGORICAL"] = pydantic_v1.Field( | ||
| alias="dataType", default="CATEGORICAL" | ||
| ) | ||
|
|
@@ -162,10 +162,10 @@ class Score_Boolean(pydantic_v1.BaseModel): | |
| alias="authorUserId", default=None | ||
| ) | ||
| comment: typing.Optional[str] = None | ||
| metadata: typing.Optional[typing.Any] = None | ||
| metadata: typing.Any | ||
| config_id: typing.Optional[str] = pydantic_v1.Field(alias="configId", default=None) | ||
| queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) | ||
| environment: typing.Optional[str] = None | ||
| environment: str | ||
| data_type: typing.Literal["BOOLEAN"] = pydantic_v1.Field( | ||
| alias="dataType", default="BOOLEAN" | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Changed from
Optional[typing.Any]withdefault=Noneto requiredtyping.Anywithout default. Will fail validation ifmetadatais missing from API response.Prompt To Fix With AI