spec: using typed version of ComputeAttributes for compute_attributes - #247
Conversation
Hand-type the compute_attributes query param as Dict[str, ComputeAttributes] using the apigen union in custom.py, across namespace_query_params, namespace_explain_query_params, and namespace_multi_query_params. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ComputeAttributes for compute_attributes
…float]) The committed custom.py carried a stale ComputeAttributesVectorDist using Vector; current apigen emits Sequence[float] (per the inline VectorDist spec change). Regenerated via scripts/gen so 'supplemental generated code' is current.
compute_attributes is now Dict[str, ComputeAttributes], so the generated
{"foo": "bar"} mocks no longer typecheck. Use the Highlight tuple
("Highlight", "bar"), mirroring how aggregate_by uses ("Sum", "bar").
Exercises every variant of the ComputeAttributes union (VectorDist, Highlight, HighlightWithConfig, RankBy) through the request-body serialization path (maybe_transform over NamespaceQueryParams) and asserts the JSON wire form for each. Placed in a non-skipped module so it runs in CI (the generated api_resources tests and test_transform.py are skipped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6c9d176. Configure here.
| # to normalize tuples -> lists, then assert structural equality. | ||
| assert json.loads(json.dumps(serialized)) == expected_wire, ( | ||
| f"variant {variant!r} serialized to {serialized!r}, expected {expected_wire!r}" | ||
| ) |
There was a problem hiding this comment.
Test JSON dumps tuples
Medium Severity
The new compute_attributes serialization test fails with a TypeError because it uses stdlib json.dumps to round-trip values. maybe_transform returns tuples, which stdlib json.dumps cannot serialize, preventing the test from verifying the wire format that orjson correctly produces for client requests.
Reviewed by Cursor Bugbot for commit 6c9d176. Configure here.
There was a problem hiding this comment.
uh, no it doesn't, tests are passing


Wiring in the codegen
ComputeAttributestype as stainless won't handle the custom type (from apigen) on its own.