Skip to content
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 langfuse/api/legacy/metrics_v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by, e.g. "name", "userId", "sessionId"
Expand Down Expand Up @@ -138,7 +138,7 @@ async def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by, e.g. "name", "userId", "sessionId"
Expand Down
4 changes: 2 additions & 2 deletions langfuse/api/legacy/metrics_v1/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by, e.g. "name", "userId", "sessionId"
Expand Down Expand Up @@ -189,7 +189,7 @@ async def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "traces", "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by, e.g. "name", "userId", "sessionId"
Expand Down
32 changes: 26 additions & 6 deletions langfuse/api/metrics/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def metrics(
Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.

## V2 Differences
- Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
- Supports `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical` views only (traces view not supported)
- Direct access to tags and release fields on observations
- Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
- High cardinality dimensions are not supported and will return a 400 error (see below)
Expand Down Expand Up @@ -98,6 +98,16 @@ def metrics(
- `count` - Total number of scores
- `value` - Score value (for aggregations)

### scores-boolean
Query boolean score data. It has the same score and parent trace/observation dimensions as scores-numeric, plus:

**Dimensions:**
- `booleanValue` - Boolean value for true/false grouping and filtering

**Measures:**
- `count` - Total number of boolean scores
- `value` - Numeric 0/1 score value; `avg` returns the true-rate

### scores-categorical
Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.

Expand All @@ -115,7 +125,7 @@ def metrics(
- `sessionId` - Use sessionId filter instead
- `parentObservationId` - Use parentObservationId filter instead

**scores-numeric / scores-categorical views:**
**scores-numeric / scores-boolean / scores-categorical views:**
- `id` - Use specific filters to narrow down results
- `traceId` - Use traceId filter instead
- `userId` - Use userId filter instead
Expand All @@ -135,7 +145,7 @@ def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by (see available dimensions above)
Expand Down Expand Up @@ -233,7 +243,7 @@ async def metrics(
Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.

## V2 Differences
- Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
- Supports `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical` views only (traces view not supported)
- Direct access to tags and release fields on observations
- Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
- High cardinality dimensions are not supported and will return a 400 error (see below)
Expand Down Expand Up @@ -301,6 +311,16 @@ async def metrics(
- `count` - Total number of scores
- `value` - Score value (for aggregations)

### scores-boolean
Query boolean score data. It has the same score and parent trace/observation dimensions as scores-numeric, plus:

**Dimensions:**
- `booleanValue` - Boolean value for true/false grouping and filtering

**Measures:**
- `count` - Total number of boolean scores
- `value` - Numeric 0/1 score value; `avg` returns the true-rate

### scores-categorical
Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.

Expand All @@ -318,7 +338,7 @@ async def metrics(
- `sessionId` - Use sessionId filter instead
- `parentObservationId` - Use parentObservationId filter instead

**scores-numeric / scores-categorical views:**
**scores-numeric / scores-boolean / scores-categorical views:**
- `id` - Use specific filters to narrow down results
- `traceId` - Use traceId filter instead
- `userId` - Use userId filter instead
Expand All @@ -338,7 +358,7 @@ async def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by (see available dimensions above)
Expand Down
32 changes: 26 additions & 6 deletions langfuse/api/metrics/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def metrics(
Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.

## V2 Differences
- Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
- Supports `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical` views only (traces view not supported)
- Direct access to tags and release fields on observations
- Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
- High cardinality dimensions are not supported and will return a 400 error (see below)
Expand Down Expand Up @@ -95,6 +95,16 @@ def metrics(
- `count` - Total number of scores
- `value` - Score value (for aggregations)

### scores-boolean
Query boolean score data. It has the same score and parent trace/observation dimensions as scores-numeric, plus:

**Dimensions:**
- `booleanValue` - Boolean value for true/false grouping and filtering

**Measures:**
- `count` - Total number of boolean scores
- `value` - Numeric 0/1 score value; `avg` returns the true-rate

### scores-categorical
Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.

Expand All @@ -112,7 +122,7 @@ def metrics(
- `sessionId` - Use sessionId filter instead
- `parentObservationId` - Use parentObservationId filter instead

**scores-numeric / scores-categorical views:**
**scores-numeric / scores-boolean / scores-categorical views:**
- `id` - Use specific filters to narrow down results
- `traceId` - Use traceId filter instead
- `userId` - Use userId filter instead
Expand All @@ -132,7 +142,7 @@ def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by (see available dimensions above)
Expand Down Expand Up @@ -284,7 +294,7 @@ async def metrics(
Get metrics from the Langfuse project using a query object. V2 endpoint with optimized performance.

## V2 Differences
- Supports `observations`, `scores-numeric`, and `scores-categorical` views only (traces view not supported)
- Supports `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical` views only (traces view not supported)
- Direct access to tags and release fields on observations
- Backwards-compatible: traceName, traceRelease, traceVersion dimensions are still available on observations view
- High cardinality dimensions are not supported and will return a 400 error (see below)
Expand Down Expand Up @@ -352,6 +362,16 @@ async def metrics(
- `count` - Total number of scores
- `value` - Score value (for aggregations)

### scores-boolean
Query boolean score data. It has the same score and parent trace/observation dimensions as scores-numeric, plus:

**Dimensions:**
- `booleanValue` - Boolean value for true/false grouping and filtering

**Measures:**
- `count` - Total number of boolean scores
- `value` - Numeric 0/1 score value; `avg` returns the true-rate

### scores-categorical
Query categorical score data. Same dimensions as scores-numeric except uses `stringValue` instead of `value`.

Expand All @@ -369,7 +389,7 @@ async def metrics(
- `sessionId` - Use sessionId filter instead
- `parentObservationId` - Use parentObservationId filter instead

**scores-numeric / scores-categorical views:**
**scores-numeric / scores-boolean / scores-categorical views:**
- `id` - Use specific filters to narrow down results
- `traceId` - Use traceId filter instead
- `userId` - Use userId filter instead
Expand All @@ -389,7 +409,7 @@ async def metrics(
JSON string containing the query parameters with the following structure:
```json
{
"view": string, // Required. One of "observations", "scores-numeric", "scores-categorical"
"view": string, // Required. One of "observations", "scores-numeric", "scores-boolean", "scores-categorical"
"dimensions": [ // Optional. Default: []
{
"field": string // Field to group by (see available dimensions above)
Expand Down
4 changes: 2 additions & 2 deletions langfuse/api/unstable/dashboard_widgets/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def create(
This endpoint creates the widget only; place it on a dashboard via
`POST /dashboards/{dashboardId}/placements`.

Supported views are `observations`, `scores-numeric`, and `scores-categorical`.
Supported views are `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical`.
The legacy `traces` view is not supported by this unstable API.
Widgets are created as v2 internally.

Expand Down Expand Up @@ -446,7 +446,7 @@ async def create(
This endpoint creates the widget only; place it on a dashboard via
`POST /dashboards/{dashboardId}/placements`.

Supported views are `observations`, `scores-numeric`, and `scores-categorical`.
Supported views are `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical`.
The legacy `traces` view is not supported by this unstable API.
Widgets are created as v2 internally.

Expand Down
4 changes: 2 additions & 2 deletions langfuse/api/unstable/dashboard_widgets/raw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def create(
This endpoint creates the widget only; place it on a dashboard via
`POST /dashboards/{dashboardId}/placements`.

Supported views are `observations`, `scores-numeric`, and `scores-categorical`.
Supported views are `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical`.
The legacy `traces` view is not supported by this unstable API.
Widgets are created as v2 internally.

Expand Down Expand Up @@ -1290,7 +1290,7 @@ async def create(
This endpoint creates the widget only; place it on a dashboard via
`POST /dashboards/{dashboardId}/placements`.

Supported views are `observations`, `scores-numeric`, and `scores-categorical`.
Supported views are `observations`, `scores-numeric`, `scores-boolean`, and `scores-categorical`.
The legacy `traces` view is not supported by this unstable API.
Widgets are created as v2 internally.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
class DashboardWidgetView(enum.StrEnum):
OBSERVATIONS = "observations"
SCORES_NUMERIC = "scores-numeric"
SCORES_BOOLEAN = "scores-boolean"
SCORES_CATEGORICAL = "scores-categorical"

def visit(
self,
observations: typing.Callable[[], T_Result],
scores_numeric: typing.Callable[[], T_Result],
scores_boolean: typing.Callable[[], T_Result],
scores_categorical: typing.Callable[[], T_Result],
) -> T_Result:
if self is DashboardWidgetView.OBSERVATIONS:
return observations()
if self is DashboardWidgetView.SCORES_NUMERIC:
return scores_numeric()
if self is DashboardWidgetView.SCORES_BOOLEAN:
return scores_boolean()
if self is DashboardWidgetView.SCORES_CATEGORICAL:
return scores_categorical()
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ class DashboardWidgetViewWithLegacy(enum.StrEnum):

OBSERVATIONS = "observations"
SCORES_NUMERIC = "scores-numeric"
SCORES_BOOLEAN = "scores-boolean"
SCORES_CATEGORICAL = "scores-categorical"
TRACES = "traces"

def visit(
self,
observations: typing.Callable[[], T_Result],
scores_numeric: typing.Callable[[], T_Result],
scores_boolean: typing.Callable[[], T_Result],
scores_categorical: typing.Callable[[], T_Result],
traces: typing.Callable[[], T_Result],
) -> T_Result:
if self is DashboardWidgetViewWithLegacy.OBSERVATIONS:
return observations()
if self is DashboardWidgetViewWithLegacy.SCORES_NUMERIC:
return scores_numeric()
if self is DashboardWidgetViewWithLegacy.SCORES_BOOLEAN:
return scores_boolean()
if self is DashboardWidgetViewWithLegacy.SCORES_CATEGORICAL:
return scores_categorical()
if self is DashboardWidgetViewWithLegacy.TRACES:
Expand Down