feat(api): update API spec from langfuse/langfuse dee644d #1398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important
Add
filterparameter tolist()inTraceClientandAsyncTraceClientfor complex JSON-based filtering, updatingreference.mdaccordingly.filterparameter tolist()inTraceClientandAsyncTraceClientinclient.pyfor complex filtering using JSON string.filtertakes precedence over legacy parameters (userId, name, sessionId, etc.).reference.mdto includefilterparameter details forclient.trace.list()method.This description was created by
for e8cc2d9. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Updated On: 2025-10-08 08:35:04 UTC
Summary
This PR introduces a new advanced filtering system for the trace list API in the Langfuse Python SDK. The change adds an optional `filter` parameter to both synchronous and asynchronous `list` methods in the `TraceClient` class, allowing users to specify complex filter conditions using a JSON-based approach.The new filter parameter accepts a JSON string containing an array of filter conditions, each with a specific structure that includes type, column, operator, value, and optionally a key field. It supports various data types including datetime, string, number, boolean, array options, and nested object filtering. The system provides multiple operators for each data type (equality, comparison, containment, null checks, etc.) and includes special handling for filtering on nested fields like metadata.
This enhancement represents a significant evolution from the existing individual filter parameters (userId, name, sessionId, tags, etc.) to a more sophisticated and flexible filtering mechanism. The new filter takes precedence over legacy parameters when provided, indicating this is part of a broader API modernization effort. The change maintains backward compatibility by keeping existing parameters optional and functional.
The implementation includes comprehensive documentation with detailed JSON schema examples, making it clear how to construct complex filter conditions. This fits into the broader Langfuse ecosystem by providing more granular control over trace retrieval, which is essential for observability and debugging workflows where users need to query traces based on complex criteria.
Important Files Changed
Changed Files
Confidence score: 5/5
Sequence Diagram
sequenceDiagram participant User participant Client as "Client Application" participant HTTPClient as "HTTP Client" participant API as "Langfuse API" %% Get Trace User->>Client: "Request trace by ID" Client->>HTTPClient: "GET /api/public/traces/{trace_id}" HTTPClient->>API: "HTTP GET Request" alt Success (200-299) API->>HTTPClient: "TraceWithFullDetails response" HTTPClient->>Client: "Parse JSON response" Client->>User: "Return trace details" else Error (400) API->>HTTPClient: "Bad Request Error" HTTPClient->>Client: "Raise Error exception" Client->>User: "Error response" else Error (401) API->>HTTPClient: "Unauthorized Error" HTTPClient->>Client: "Raise UnauthorizedError" Client->>User: "Unauthorized response" else Error (403) API->>HTTPClient: "Access Denied Error" HTTPClient->>Client: "Raise AccessDeniedError" Client->>User: "Access denied response" else Error (404) API->>HTTPClient: "Not Found Error" HTTPClient->>Client: "Raise NotFoundError" Client->>User: "Not found response" else Error (405) API->>HTTPClient: "Method Not Allowed Error" HTTPClient->>Client: "Raise MethodNotAllowedError" Client->>User: "Method not allowed response" else JSON Decode Error HTTPClient->>Client: "JSONDecodeError" Client->>Client: "Raise ApiError with status and body" Client->>User: "API error response" end %% Delete Trace User->>Client: "Request trace deletion by ID" Client->>HTTPClient: "DELETE /api/public/traces/{trace_id}" HTTPClient->>API: "HTTP DELETE Request" alt Success (200-299) API->>HTTPClient: "DeleteTraceResponse" HTTPClient->>Client: "Parse JSON response" Client->>User: "Return deletion response" else Error responses Note over API,User: "Same error handling pattern as GET" end %% List Traces User->>Client: "Request trace list with filters" Client->>HTTPClient: "GET /api/public/traces with query params" HTTPClient->>API: "HTTP GET Request with filters" alt Success (200-299) API->>HTTPClient: "Traces response" HTTPClient->>Client: "Parse JSON response" Client->>User: "Return traces list" else Error responses Note over API,User: "Same error handling pattern as GET" end %% Delete Multiple Traces User->>Client: "Request multiple trace deletion" Client->>HTTPClient: "DELETE /api/public/traces with trace_ids array" HTTPClient->>API: "HTTP DELETE Request with JSON body" alt Success (200-299) API->>HTTPClient: "DeleteTraceResponse" HTTPClient->>Client: "Parse JSON response" Client->>User: "Return deletion response" else Error responses Note over API,User: "Same error handling pattern as GET" end