Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPIK-1377] add guardrails to trace #1736

Open
wants to merge 19 commits into
base: ido/opik-1386-guardrails-ingestion
Choose a base branch
from

Conversation

idoberko2
Copy link
Contributor

Details

This PR adds guardrails to the Trace object. Served in both getTraceById logic as well as findTraces.

Issues

OPIK-1377

Testing

Added two E2E tests covering the new logic.

@idoberko2 idoberko2 self-assigned this Apr 3, 2025
@idoberko2 idoberko2 requested a review from a team as a code owner April 3, 2025 13:16
Copy link
Contributor

github-actions bot commented Apr 3, 2025

Test Results

3 326 tests  +1   3 323 ✅ +1   13m 43s ⏱️ -20s
  161 suites ±0       3 💤 ±0 
  161 files   ±0       0 ❌ ±0 

Results for commit b20afd9. ± Comparison against base commit 4addcae.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@andrescrz andrescrz left a comment

Choose a reason for hiding this comment

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

We're pending the discussions as well. Some minor guidance on the rest of the implementation.

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record Item(double score) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: let's align the precision with the Guardrails backend, but probably a float should be enough and more performant (including storage space).

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record GuardrailTopicDetails(Map<String, Double> scores) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here.

@Builder(toBuilder = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public record Item(@NonNull String name, double score) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same about double.

@Schema(accessMode = Schema.AccessMode.READ_ONLY) Instant lastUpdatedAt,
@Schema(accessMode = Schema.AccessMode.READ_ONLY) String createdBy,
@Schema(accessMode = Schema.AccessMode.READ_ONLY) String lastUpdatedBy) {
@NonNull List<Item> items) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

These items overlap with the model above, but I'd say you need polymorphic types for config and details fields here.

@@ -47,6 +47,8 @@ public record Trace(
Trace.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) List<FeedbackScore> feedbackScores,
@JsonView({
Trace.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) List<Comment> comments,
@JsonView({
Trace.View.Public.class}) @Schema(accessMode = Schema.AccessMode.READ_ONLY) List<GuardrailsCheck> guardrailsChecks,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to the main open discussion: this response model won't be able to return top level fields, only the granular validations. As the Guardrails service is likely the source of truth for that determination, we don't have a way to track it in the opik-backend.

@idoberko2 idoberko2 force-pushed the ido/opik-1386-guardrails-ingestion branch 2 times, most recently from cb5a88a to 631b369 Compare April 6, 2025 10:25
@idoberko2 idoberko2 force-pushed the ido/opik-1386-guardrails-ingestion branch 2 times, most recently from ccec599 to 11378e4 Compare April 7, 2025 09:35
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.

None yet

2 participants