Commit graph

4746 commits

Author SHA1 Message Date
Ishaan Jaffer
d4ae3c8370 ui new build 2026-02-19 15:57:19 -08:00
Ishaan Jaff
655973e8c8
feat(ui): show latency overhead for AI-suggested policy templates (#21620)
* feat(policy): add estimated_latency_ms to all policy templates

* feat(policy): add estimated_latency_ms to backup templates

* feat(ui): show latency overhead badge in AI policy suggestions
2026-02-19 15:45:07 -08:00
Ishaan Jaff
c9cdce96fa
feat(policy): test playground for AI policy suggestions (#21608)
* fix aviation safety topic filter: remove overly broad exceptions, add cockpit access block words

* fix airline brand protection filter: add identifier words, competitor/ops block words, tighten exceptions

* feat(policy): add POST /policy/templates/test endpoint for testing guardrails before creating them

* feat(ui): add testPolicyTemplate networking function

* feat(ui): add test playground to AI policy suggestion modal

* test(policy): add tests for POST /policy/templates/test endpoint
2026-02-19 14:09:20 -08:00
Ishaan Jaff
cd95e54c10
Add OpenAPI-to-MCP support via API and UI (#21575)
* add spec_path column to LiteLLM_MCPServerTable schema

* add spec_path to MCP request types and table model

* wire spec_path through build_mcp_server_from_table

* add openapi transport type constant

* add OpenAPI Spec as first-class transport option in create form

* add OpenAPI transport support to edit form with auto-detection

* support spec_path in connection status component

* support spec_path in tool configuration component

* support OpenAPI transport in test connection hook

* register OpenAPI tools on server add/update/reload

* preview OpenAPI tools in test/tools/list endpoint
2026-02-19 12:23:24 -08:00
Ishaan Jaff
b209b11522
feat: AI policy template suggestions (#21589)
* fix aviation safety topic filter: remove overly broad exceptions, add cockpit access block words

* fix airline brand protection filter: add identifier words, competitor/ops block words, tighten exceptions

* add example_sentences to all policy templates + topic-filtering and prompt-injection templates

* add policy_endpoints package with AI policy suggester

* update test patch targets for policy_endpoints package move

* add unit tests for AI policy suggester

* add suggestPolicyTemplates networking function

* add AI suggestion modal component

* add Use AI button and template loading callback to PolicyTemplates

* wire up AI suggestion modal in policies page

* fix policy_templates_backup.json path after package move

* add estimated_latency field to all policy templates

* use llm_router and accept model parameter in ai_policy_suggester

* add model param to suggest templates endpoint

* pass model param in suggestPolicyTemplates

* polish ai suggestion modal: model selector, auto-growing textareas, latency badges

* add template queue for processing multiple AI-suggested templates

* show template progress badge in guardrail selection modal
2026-02-19 12:00:26 -08:00
yuneng-jiang
c911cfbabf Merge remote-tracking branch 'origin' into litellm_key_last_active_tracking 2026-02-19 10:27:48 -08:00
Sameer Kankute
f2393fc9cb Merge main into litellm_passthrough_endpoint_method
Resolved conflicts in pass_through_endpoints.py by:
- Accepting main's formatting and mypy fixes
- Preserving branch's method support feature
- Preserving branch's default_query_params feature

Combined changes include:
- Method filtering for passthrough endpoints
- Default query parameters support
- Updated route key format to include methods
- Code formatting improvements from main
- Fixed type annotations

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-19 19:22:41 +05:30
Sameer Kankute
36e21830db
Merge pull request #21550 from BerriAI/litellm_add_global_usage
[Feat] Add Default usage data configuration
2026-02-19 19:10:35 +05:30
Sameer Kankute
0eb2a0c014 Add Default usage data configuration 2026-02-19 14:04:07 +05:30
Sameer Kankute
1ceb7d8e29 Add default query param in UI 2026-02-19 12:48:27 +05:30
yuneng-jiang
6097905e55 [Feature] Track key last active timestamp
Virtual keys only track created_at and updated_at, which don't indicate
when a key was last used. This adds a last_active field that gets updated
during the async batch spend update, giving admins visibility into which
keys are actively being used.

Changes:
- Add last_active DateTime? to VerificationToken and
  DeletedVerificationToken in all 3 schema files and Python types
- Set last_active in the batch key spend update alongside spend increment
- Add Last Active column to virtual keys UI table with info popover
  and hover tooltip showing full date/time with timezone

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 23:11:58 -08:00
Sameer Kankute
26c3d7debc Update Ui for adding method to passthrough endpoints 2026-02-19 11:59:36 +05:30
yuneng-jiang
70d5281b52
Merge pull request #21537 from BerriAI/litellm_team_member_usage_permission
[Feature] Allow team members to view entire team usage
2026-02-18 22:01:13 -08:00
Ishaan Jaff
1a5133f229
Competitor guardrails: streaming discovery, variations, pre/post split (#21533)
* fix aviation safety topic filter: remove overly broad exceptions, add cockpit access block words

* fix airline brand protection filter: add identifier words, competitor/ops block words, tighten exceptions

* update policy templates with competitor pre/post guardrails and streaming enrichment

* sync policy_templates_backup.json with policy_templates.json

* add streaming enrichment endpoint, competitor variations, and model selection

* add streaming enrichPolicyTemplate networking function

* rewrite template parameter modal with streaming tags, AI/manual toggle, model selector

* update policies panel to pass enrichment options and show discovered competitors

* show discovered competitors as tags in guardrail selection modal

* use llm_router instead of litellm.acompletion, extract helpers, move constants

* validate competitors list size, cap variation prompt input

* add refinement instruction support for competitor discovery

* add instruction and existingCompetitors params to streaming enrichment

* add refinement input for iterating on competitor list with AI

* emit status events during variation generation so UI shows progress

* add onStatus callback to streaming enrichment

* show status spinner during variation generation, widen modal to 700px

* add tests for competitor enrichment helper functions
2026-02-18 21:39:19 -08:00
yuneng-jiang
528b21ad1d [Feature] Allow team members to view entire team usage
Add a new team member permission `/team/daily/activity` that allows
non-admin team members to see all team usage data, not just their own.

## Changes
- Add `TEAM_DAILY_ACTIVITY` to `KeyManagementRoutes` enum and available
  team member permissions
- Add `_team_member_has_permission` helper in `common_utils.py`
- Modify `/team/daily/activity` endpoint to skip API key filtering when
  the member has this permission
- Add permission description and method detection in the UI
- Add backend and frontend tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 21:38:40 -08:00
jquinter
1e372ebc82
Merge pull request #20909 from jquinter/fix/ui-tagsSpendLogsCall-double-url
fix(ui): remove duplicate URL in tagsSpendLogsCall query string
2026-02-19 02:22:33 -03:00
yuneng-jiang
a717f3624d
Merge pull request #21516 from BerriAI/litellm_model_settings_modal
[Feature] UI - Models & Endpoints: Add Model Settings Modal
2026-02-18 21:02:31 -08:00
Ishaan Jaff
0486161bea
feat(ui): add CSV dataset upload to compliance playground (#21526) 2026-02-19 03:33:18 +00:00
Ishaan Jaff
91fd2b4621
Add aviation and UAE policy templates with tag-based filtering (#21518)
* add aviation and UAE regex patterns (PNR, Skywards, Emirates ID, UAE phone, flight number)

* add aviation safety topics category yaml

* add airline brand protection category yaml

* add UAE cultural sensitivity category yaml

* add UAE anti-discrimination category yaml

* add aviation, UAE, and competitor policy templates + migrate region/type to tags

* sync policy_templates_backup.json

* add /policy/templates/enrich endpoint for LLM competitor discovery

* add enrichPolicyTemplate networking call

* add TemplateParameterModal component

* handle parameterized templates and LLM enrichment in policies index

* replace region/type radio filters with tag sidebar checkboxes
2026-02-18 18:26:24 -08:00
Krish Dholakia
a385126a7c Litellm dev compliance UI (#21457)
* feat(ui/): initial commit adding a compliance testing playground

allow proxy admins to test policies and guardrails against datasets

* feat(ui/): make score more friendly

* feat(policy_endpoints.py): new helper function for testing policies

* feat(policy_endpoints.py): expose new endpoint for testing policies and guardrails

enables compliance playground to work as expected

* feat(complianceui.tsx): show returned text
2026-02-18 18:22:43 -08:00
yuneng-jiang
f1cbaac124 Add unit tests for ModelSettingsModal and useStoreModelInDB hook
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-18 18:11:07 -08:00
yuneng-jiang
876c4cfd0f adjusting hook to use /config/field/update 2026-02-18 18:06:02 -08:00
yuneng-jiang
b0973b3ac8 Add model setting modal 2026-02-18 18:01:09 -08:00
yuneng-jiang
66a33d13a3
Merge pull request #21364 from BerriAI/litellm_ui_key_type_label
[Refactor] UI - Keys: Change Key Type Label
2026-02-18 08:54:41 -08:00
Ishaan Jaff
371cabfebd
Add MCP Security guardrail to block unregistered MCP servers (#21429)
* Add MCP_SECURITY enum to SupportedGuardrailIntegrations

* Add MCP security guardrail initializer

* Add MCPSecurityGuardrail implementation

* Add MCP Security policy template

* Add Type filter to policy templates UI

* Add unit tests for MCP security guardrail

* fix(lint): remove unused Dict import from mcp_security_guardrail

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Add French language support for EU AI Act Article 5 guardrail (#21427)

* Add French language support for EU AI Act Article 5 template

- Create eu_ai_act_article5_fr.yaml with comprehensive French keywords
- Includes identifier words: concevoir, créer, développer, noter, classer, etc.
- Includes block words: crédit social, comportement social, émotion des employés, etc.
- Includes always-block keywords for explicit prohibited practices
- Includes exceptions for research, compliance, and legitimate use cases
- Catches circumvention attempts with phrase variations

* Add comprehensive tests for French EU AI Act guardrail

- Test 3 critical scenarios: blocked query, circumvention attempt, safe query
- Test edge cases: case-insensitive, mixed language, research exceptions
- All 7 tests passing
- Validates both blocking and allowing behavior

* Fix content filter to support conditional matching without inherit_from

- Enable conditional matching when identifier_words + additional_block_words are present
- Previously required inherit_from, but EU AI Act templates are self-contained
- Fixes Greptile feedback: conditional matching now works as documented

* Add pure conditional matching test for French guardrail

- Test identifier + block word combinations not in always_block_keywords
- Verifies conditional matching works independently
- Addresses Greptile feedback about test coverage gap

* Fix exception word bypass risk in French template

- Replace short words (film, jeu, juste) with context-specific phrases
- Prevents substring matching bypasses (e.g., enjeu matching jeu)
- Add tests for bypass prevention and legitimate game context
- Addresses Greptile security feedback

* Make conditional match assertion more robust

- Use getattr to safely access exception detail field
- Check if detail is dict before calling .get()
- Addresses Greptile feedback about brittle string assertion

* Add French EU AI Act Article 5 policy template to registry

- Add eu-ai-act-article5-fr template for French language support
- Includes French description and guardrail info
- Matches structure of English template

* Address greptile review feedback (greploop iteration 1)

- Use status_code=400 instead of 403 to match guardrail logging convention
- Use prefix stripping instead of split('/')[-1] for robust server name extraction

* remove French EU AI Act template from policy_templates.json

---------

Co-authored-by: Julio Quinteros Pro <jquinter@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17 21:19:13 -08:00
Ishaan Jaff
5946a933a0
Add compliance checker endpoints + UI panel (#21432)
* eu_ai_act_article5_prohibited_practices_fr

* add backend for checkers

* test checker

* checkEuAiActCompliance

* register compliance router in proxy_server.py

* add compliance check functions to networking.tsx

* fix useEffect dependency array in CompliancePanel

* ui fixes
2026-02-17 18:22:26 -08:00
Ishaan Jaffer
e4752f4f9d ui fix 2026-02-17 18:02:33 -08:00
Ishaan Jaff
5a3a0210cb
feat(ui): add guardrail jump link in log detail view (#21437)
* feat(ui): add guardrail jump link at top of log detail

* fix(ui): align guardrail jump link to the left

* fix(ui): move guardrail jump link to trace sidebar

* fix(ui): move guardrail pill above event rows in sidebar
2026-02-17 17:33:06 -08:00
Ishaan Jaffer
f329294005 fix(ui): show category count badge in guardrail selection modal
Category-based guardrails (like EU AI Act) now display an orange
tag showing how many categories they contain, matching the existing
pattern count tag for pattern-based guardrails.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 16:57:31 -08:00
yuneng-jiang
ec19005942 refactor - change key type label 2026-02-16 21:08:13 -08:00
Ishaan Jaff
0f96b5a1b7
feat: guardrail tracing UI - policy, detection method, match details (#21349)
* feat: add GuardrailTracingDetail TypedDict and tracing fields to StandardLoggingGuardrailInformation

* feat: add policy_template field to Guardrail config TypedDict

* feat: accept GuardrailTracingDetail in base guardrail logging method

* feat: populate tracing fields in content filter guardrail

* test: add tracing fields tests for custom guardrail base class

* test: add tracing fields e2e tests for content filter guardrail

* feat: add guardrail tracing UI - policy badges, match details, timeline

* feat: redesign GuardrailViewer to Guardrails & Policy Compliance layout

Two-column layout with request lifecycle timeline on the left
and compact evaluation detail cards on the right. Header shows
guardrail count, pass/fail status, total overhead, policy info,
and an export button.

* feat: add clickable guardrail link in metrics + show policy names

* feat: add risk_score field to StandardLoggingGuardrailInformation

* feat: compute risk_score in content filter guardrail

* feat: display backend risk_score badge on evaluation cards

* fix: fallback to frontend risk score when backend doesn't provide one
2026-02-16 18:44:27 -08:00
yuneng-jiang
df5e8d01a6 address greptile review feedback (greploop iteration 2)
- Default user_id to caller's own ID for non-admins instead of 403 when
  omitted, preserving backward compatibility for API consumers
- Apply same fix to aggregated endpoint
- Update test to verify defaulting behavior instead of expecting 403
- Add useEffect to sync selectedUserId when auth state settles in
  UsagePageView to handle async auth initialization

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-16 17:37:18 -08:00
yuneng-jiang
0d2aac6928 allow filtering by user in global usage 2026-02-16 16:46:09 -08:00
Ishaan Jaff
1a8525d02a
Add GDPR Art. 32 EU PII Protection Policy Template (#21340)
* Add 6 new EU PII patterns for GDPR compliance

- fr_nir: French Social Security Number (NIR/INSEE) with validation
- eu_iban_enhanced: Enhanced IBAN detection with specific format
- fr_phone: French phone numbers (+33, 0033, 0 formats)
- eu_vat: EU VAT identification numbers (all 27 member states)
- eu_passport_generic: Generic EU passport format
- fr_postal_code: French postal codes with contextual keywords

* Add GDPR Art. 32 EU PII Protection policy template

- Comprehensive GDPR Article 32 compliance policy
- 4 guardrail groups: National IDs, Financial, Contact Info, Business IDs
- Masks French NIR/INSEE, EU IBANs, French phones, EU VAT numbers
- Includes EU passport numbers and email addresses
- Medium complexity template with indigo icon

* Add comprehensive tests for EU PII patterns

- Test French NIR validation (sex digit, month range)
- Test enhanced IBAN detection (French, German)
- Test French phone number formats
- Test EU VAT numbers
- Test generic EU passport format
- Test French postal code pattern

* Add EU pattern loading and category validation tests

- Verify all 6 EU PII patterns are loaded correctly
- Verify patterns are categorized as 'EU PII Patterns'
- Ensure pattern loading consistency

* Add end-to-end tests for GDPR policy template

- 4 tests for PII that should be masked (NIR, IBAN, phone, VAT)
- 4 tests for text that should pass through (invalid patterns, no PII)
- 1 bonus test for multiple PII types in same message
- All tests verify correct masking behavior

* Add region field to policy templates

- Added region field to all 6 templates (EU, AU, Global)
- Updated both main and backup JSON files
- Enables region-based filtering in UI

* Add region filter to policy templates UI

- Added Radio.Group filter for regions (All, AU, EU, Global)
- Efficient filtering with useMemo hooks
- Clean button-based UI matching existing design
- Defaults missing regions to Global

* Apply suggestion from @greptile-apps[bot]

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Address Greptile review: add contextual guards and negative tests

- Added keyword_pattern to eu_vat (VAT, tax number, fiscal code, etc.)
- Added keyword_pattern to eu_passport_generic (passport, travel document, etc.)
- Added 3 negative unit tests for false positive prevention
- Added 2 E2E tests verifying no masking without keyword context
- All patterns now require contextual keywords to prevent false positives

* address greptile review feedback (greploop iteration 1)

- Remove unused HTTPException import from test file
- Add keyword_pattern to eu_vat for contextual VAT matching
- Add allow_word_numbers: false to eu_passport_generic
- Add negative test cases for EU VAT false positives
- All 5 Greptile comments addressed

* Address Greptile feedback: fix patterns and sync backup

- Fix fr_phone pattern: use negative lookbehind (?<!\d) to prevent false matches in longer digit strings
- Add keyword_pattern to eu_passport_generic to reduce false positives on version strings/SKUs
- Sync policy_templates_backup.json with main file (add GDPR template)
- Add keyword_pattern to eu_vat (was auto-added by formatter)

All pattern tests passing

* address greptile review feedback (greploop iteration 2)

- Update test to document that eu_vat raw pattern is intentionally broad
- Test verifies pattern DOES match common words (by design)
- Documents that keyword_pattern guard prevents false positives in production
- Addresses Greptile's false positive risk concern

* address greptile review feedback (greploop iteration 3)

- Fix test_eu_vat_masked: change gap from 2 words to 1 word (VAT number: FR...)
- This ensures keyword matching works within MAX_KEYWORD_VALUE_GAP_WORDS=1 limit
- fr_phone pattern already works correctly (verified with tests)
- test_pattern_requires_keyword_context already updated in iteration 2

Addresses final issues from Greptile 2/5 review

* fix: remove country-specific passport patterns from GDPR template

- Remove passport_france, passport_germany, passport_netherlands from template
- These patterns lack keyword guards and cause false positives
- Only eu_passport_generic remains (has keyword_pattern guard)
- Sync policy_templates_backup.json with main file
- Update test setup to match template

All 11 E2E tests now passing 

* Update tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_gdpr_policy_e2e.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* Update litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/content_filter.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

---------

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-16 15:28:46 -08:00
yuneng-jiang
51716866cc
Merge pull request #21007 from atapia27/feat/playground-test-fallbacks
Feat/playground test fallbacks
2026-02-16 14:56:59 -08:00
Alejandro Tapia
c9e15005b1 differentiate solely by model_Id 2026-02-16 12:37:53 -08:00
Alejandro Tapia
a36d7dcb81 Tooltip removed and replaced with Popover (triggered by icon only), including url to router settings 2026-02-16 12:05:56 -08:00
Krish Dholakia
45690db820
UI - Content Filters, help edit/view categories and 1-click add categories + go to next page (#21223)
* feat(ui/): allow viewing content filter categories on guardrail info

* fix(add_guardrail_form.tsx): add validation check to prevent adding empty content filter guardrails

* feat(ui/): improve ux around adding new content filter categories

easy to skip adding a category, so make it a 1-click thing
2026-02-16 09:11:16 -08:00
Harshit Jain
56b53cb502
Merge branch 'main' into litellm_fix-virtual-key-grace-period 2026-02-15 08:09:13 +05:30
yuneng-jiang
ac648af78e add timeout to long running tests 2026-02-14 18:05:27 -08:00
yuneng-jiang
1c1807df45 defensive checks for null 2026-02-14 17:30:58 -08:00
yuneng-jiang
b3fd76a713 adding access groups on keys and teams 2026-02-14 17:01:29 -08:00
yuneng-jiang
27fe16be4b Merge remote-tracking branch 'origin/main' into litellm_ui_access_groups 2026-02-14 16:33:44 -08:00
yuneng-jiang
3e97c0d5d6 temp commit for merge 2026-02-14 16:33:35 -08:00
yuneng-jiang
55f169aa69
Merge pull request #21190 from BerriAI/litellm_access_groups_inte
[Feature] Access Group Checks
2026-02-14 16:28:09 -08:00
yuneng-jiang
0d6fcee23e injecting localstorage values to hide usageIndicator, prompts, and new badges 2026-02-14 15:49:27 -08:00
yuneng-jiang
5cf91e573e Merge remote-tracking branch 'origin' into litellm_access_groups_inte 2026-02-14 13:27:36 -08:00
Krish Dholakia
644f66a7d3
Agent Guardrails - on streaming output (#21206)
* fix(ui/): add mcp input as an example for custom code guardrails

* feat(a2a/): ensure a2a guardrails works on response output

* feat(a2a/): support streaming guardrails

* fix(ui/): add mcp input as an example for custom code guardrails
2026-02-14 11:36:52 -08:00
Ishaan Jaffer
977d1f90d2 test fixes 2026-02-14 11:33:45 -08:00
Krish Dholakia
e41ecc7a71
Guardrails - add nsfw policy template, toxic keywords in multiple languages, child safety content filter, json content viewer (#21205)
* fix(content_filter.py): fix filter on toxic keywords

* feat: improve toxic/abusive language detection

* fix: additional improvements to nsfw filters

* feat: more improvements to nsfw filter

* feat(content_filter.json): add new australia specific nsfw content filter

ensure complete coverage for australia nsfw

* fix: cleanup policy templates

* fix(index.tsx): alert notice

* fix(index.tsx): add disclaimer notice

* feat(harmful_child_safety.yaml): new child safety content filter

ensure we catch inappropriate, child-specific content

* feat(policy_templates.json): add child safety and self harm filters

* fix(content_filter.py): improve racial bias filter to use a similar identifier + block word pattern and cover a wider range of ethnicities

* feat(policy_templates.json): add racial bias to nsfw policy template

* feat: add json content viewer
2026-02-14 09:41:55 -08:00