Skip to content

feat: add filter parameter to ScoreV2 client get methods#1522

Open
langfuse-bot wants to merge 1 commit intomainfrom
api-spec-bot-9b531c0
Open

feat: add filter parameter to ScoreV2 client get methods#1522
langfuse-bot wants to merge 1 commit intomainfrom
api-spec-bot-9b531c0

Conversation

@langfuse-bot
Copy link
Collaborator

@langfuse-bot langfuse-bot commented Feb 11, 2026

Important

Adds metadata filtering to get() in ScoreV2Client and AsyncScoreV2Client using a JSON stringified array of filter objects.

  • Behavior:
    • Adds filter parameter to get() in ScoreV2Client and AsyncScoreV2Client to filter scores by metadata using JSON stringified array of filter objects.
    • Supports filtering by score metadata using stringObject type with operators: =, contains, does not contain, starts with, ends with.
  • Documentation:
    • Updates reference.md to include new filter parameter details for client.score_v_2.get().
  • Misc:
    • No changes to existing functionality, only adds new filtering capability.

This description was created by Ellipsis for 55ae027. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Overview

Greptile Summary

This PR updates the generated ScoreV2 API client to accept an additional optional filter parameter on both sync and async get() methods, forwarding it as the filter query parameter on GET /api/public/v2/scores. It also updates the API reference documentation to describe the new parameter and give an example filter object format.

Main items to address before merge are around API ergonomics and correctness of the docs: the new argument name filter can easily shadow Python’s built-in filter() in user code, and the docs currently describe the value as a JSON-stringified array while showing an unquoted JSON array example (string vs object mismatch).

Confidence Score: 4/5

  • This PR is likely safe to merge after addressing a couple of API/docs correctness issues.
  • Changes are small and localized (one new optional query param in generated client + docs). The remaining concerns are user-facing: the filter argument name shadows Python’s built-in and the docs are ambiguous about string vs JSON array, which can lead to broken integrations.
  • langfuse/api/resources/score_v_2/client.py, langfuse/api/reference.md

Important Files Changed

Filename Overview
langfuse/api/resources/score_v_2/client.py Added optional filter query param to sync/async get() methods and documented it in docstrings; main concern is naming the argument filter (shadows built-in).
langfuse/api/reference.md Documented new filter parameter for client.score_v_2.get(); example/wording currently ambiguous about whether callers should pass JSON string vs JSON array.

Sequence Diagram

sequenceDiagram
    participant U as User Code
    participant C as ScoreV2Client/AsyncScoreV2Client
    participant W as ClientWrapper (httpx_client)
    participant API as Langfuse API

    U->>C: get(..., filter=<json string>, ...)
    C->>W: request("api/public/v2/scores", method=GET, params{..., filter})
    W->>API: GET /api/public/v2/scores?filter=...
    API-->>W: 2xx GetScoresResponse | 4xx Error
    W-->>C: httpx Response
    C-->>U: Parsed GetScoresResponse
Loading

@ellipsis-dev ellipsis-dev bot changed the title feat(api): update API spec from langfuse/langfuse 9b531c0 feat: add filter parameter to ScoreV2 client get methods Feb 11, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 7207 to +7213
<dl>
<dd>

**filter:** `typing.Optional[str]` — A JSON stringified array of filter objects. Each object requires type, column, operator, and value. Supports filtering by score metadata using the stringObject type. Example: [{"type":"stringObject","column":"metadata","key":"user_id","operator":"=","value":"abc123"}]. Supported types: stringObject (metadata key-value filtering), string, number, datetime, stringOptions, arrayOptions. Supported operators for stringObject: =, contains, does not contain, starts with, ends with.

</dd>
</dl>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ambiguous filter format

The docs say filter is a “JSON stringified array” but the example is shown as a raw JSON array ([{...}]). That mismatch will confuse users and leads to incorrect requests (passing an array instead of a string, or vice versa). Please either (a) show the example as a quoted string (e.g. '[{"type":...}]') or (b) change the type/wording to indicate it accepts an array/object rather than a string.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 11, 2026

Additional Comments (1)

langfuse/api/resources/score_v_2/client.py
Reserved keyword parameter

Using filter as a keyword argument name is a footgun because it shadows Python’s built-in filter() in the local scope and can easily break user code that expects filter to remain callable in the same function. Consider renaming the parameter to something like filters/filter_ while still sending the API field as "filter".

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants