feat(library): update Fiddler Guardrails API to match new specification#1619
Conversation
Greptile OverviewGreptile SummaryUpdated Fiddler Guardrails API integration to match the new specification. The changes simplify the request format by using strings instead of lists and add support for the new Key changes:
The changes are well-tested with three new unit tests that mock the API calls and verify the exact structure of the outgoing requests, ensuring backward compatibility is broken intentionally to match the new API spec.
|
| Filename | Overview |
|---|---|
| nemoguardrails/library/fiddler/actions.py | Updates API request format from 'prompt' (list) to 'input' (string) for safety checks and from lists to strings for faithfulness checks; adds fdl_roleplaying safety category |
| tests/test_fiddler_rails.py | Adds fdl_roleplaying to existing test mocks and includes comprehensive unit tests verifying the new request payload format for safety and faithfulness endpoints |
Sequence Diagram
sequenceDiagram
participant Client as NeMo Guardrails
participant SafetyAction as call_fiddler_safety_user/bot
participant FaithAction as call_fiddler_faithfulness
participant API as Fiddler API
Note over Client,API: Safety Guardrail Flow (User/Bot Message)
Client->>SafetyAction: context with user_message or bot_message
SafetyAction->>SafetyAction: Extract message from context
SafetyAction->>SafetyAction: Build payload: {"data": {"input": message}}
SafetyAction->>API: POST /v3/guardrails/ftl-safety
API-->>SafetyAction: Response with safety scores (fdl_harmful, fdl_violent, etc., fdl_roleplaying)
SafetyAction->>SafetyAction: Calculate max score across all categories
SafetyAction->>SafetyAction: Compare score >= threshold
SafetyAction-->>Client: Return boolean result
Note over Client,API: Faithfulness Guardrail Flow
Client->>FaithAction: context with bot_message and relevant_chunks
FaithAction->>FaithAction: Extract bot_message and relevant_chunks
FaithAction->>FaithAction: Build payload: {"data": {"context": relevant_chunks, "response": bot_message}}
FaithAction->>API: POST /v3/guardrails/ftl-response-faithfulness
API-->>FaithAction: Response with fdl_faithful_score
FaithAction->>FaithAction: Compare score <= threshold
FaithAction-->>Client: Return boolean result
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@Pouyanpi Can you take a look? |
|
Thank you @kevinfiddlerai, lgtm! Just need to run pre-commits and push to resolve the Lint job failure. |
|
Thank you @Pouyanpi, I just re-pushed above |
There was a problem hiding this comment.
Looks good! Thanks for the update 🚀
p.s. @kevinfiddlerai unfortunately the commits are not signed. Please make sure those are gpg signed.
|
@kevinfiddlerai unfortunately the commits are not signed. Would you please make sure those are gpg signed? |
0e34a02 to
5a31441
Compare
- Change Safety API from 'prompt' to 'input' field - Change Faithfulness API to use strings instead of lists - Add fdl_roleplaying category to safety detection - Add unit tests to verify request payload format Signed-off-by: Kevin Truong kevin@fiddler.ai
5a31441 to
622223d
Compare
|
@Pouyanpi I ran a push command to gpg sign my previous commits, but I ran into an "Error: Process completed with exit code 132" that I am not sure is related to my push. Are you able to re-run? |
Signed-off-by: Kevin Truong kevin@fiddler.ai
Description
Made changes to account for new Fiddler Guardrail API formatting and fdl_roleplaying category
Related Issue(s)
None
Fiddler Reviewer: @copperstick6
Checklist