feat: add filter parameter to ScoreV2 client get methods#1522
feat: add filter parameter to ScoreV2 client get methods#1522langfuse-bot wants to merge 1 commit intomainfrom
Conversation
| <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> |
There was a problem hiding this comment.
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.
Additional Comments (1)
Using 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! |
Important
Adds metadata filtering to
get()inScoreV2ClientandAsyncScoreV2Clientusing a JSON stringified array of filter objects.filterparameter toget()inScoreV2ClientandAsyncScoreV2Clientto filter scores by metadata using JSON stringified array of filter objects.stringObjecttype with operators:=,contains,does not contain,starts with,ends with.reference.mdto include newfilterparameter details forclient.score_v_2.get().This description was created by
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
filterparameter on both sync and asyncget()methods, forwarding it as thefilterquery parameter onGET /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
filtercan easily shadow Python’s built-infilter()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
filterargument name shadows Python’s built-in and the docs are ambiguous about string vs JSON array, which can lead to broken integrations.Important Files Changed
filterquery param to sync/asyncget()methods and documented it in docstrings; main concern is naming the argumentfilter(shadows built-in).filterparameter forclient.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