You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[OPIK-5845] [BE] fix: fix dataset expansion for test suites and all LLM providers (#6277)
* [OPIK-5845] [BE] fix: fix dataset expansion for test suites and all LLM providers
- Add maxCompletionTokens (4000) to expansion requests, fixing Anthropic
models that require this field
- Re-throw ClientErrorException/ServerErrorException with original
messages instead of wrapping in generic BadRequestException
- Skip _generated/_generation_model metadata for test suite expansions
so synthetic fields don't pollute data passed to agents in local
runner scenarios
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(expansion): use proper HTTP status codes for error handling
- Catch BadRequestException separately to preserve validation errors
- Rethrow ClientErrorException/ServerErrorException from LLM providers
- Use InternalServerErrorException for unexpected failures instead of
mapping everything to 400 BadRequest
- Use generic message for 500s, log full details server-side
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(expansion): address PR review comments
- Use lighter getById() instead of findById() to avoid unnecessary
dataset enrichment when only the type is needed
- Extract buildDatasetItem() to DRY the duplicated item construction
- Make maxCompletionTokens provider-aware: only set for Anthropic by
default (4000), skip for other providers to avoid impacting results
- Allow users to override maxCompletionTokens via the API request
- Inject LlmProviderFactory to resolve provider from model name
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test(expansion): add unit tests and @min validation for maxCompletionTokens
Add DatasetExpansionServiceTest covering maxCompletionTokens resolution,
dataset item building (metadata for regular vs test suite), and error
handling. Add @min(100) validation on maxCompletionTokens field.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: apps/opik-backend/src/main/java/com/comet/opik/api/DatasetExpansion.java
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,9 @@ public record DatasetExpansion(
25
25
@JsonView({
26
26
DatasetExpansion.View.Write.class}) @Schema(description = "Additional instructions for data variation", example = "Create variations that test edge cases") StringvariationInstructions,
27
27
@JsonView({
28
-
DatasetExpansion.View.Write.class}) @Schema(description = "Custom prompt to use for generation instead of auto-generated one") StringcustomPrompt){
28
+
DatasetExpansion.View.Write.class}) @Schema(description = "Custom prompt to use for generation instead of auto-generated one") StringcustomPrompt,
29
+
@JsonView({
30
+
DatasetExpansion.View.Write.class}) @Min(100) @Schema(description = "Maximum number of tokens for the LLM response. Required by Anthropic, used as maxOutputTokens for Gemini. If not provided, defaults to 4000 for Anthropic models only.") IntegermaxCompletionTokens){
0 commit comments