Commit graph

8121 commits

Author SHA1 Message Date
Timothy Lowrimore
94273dc8b7
Merge branch 'main' into heroku-llms 2025-07-25 16:46:01 -06:00
Andrei Darashenka
ddac3d5386 honor OLLAMA_API_KEY for ollama_chat 2025-07-26 00:16:14 +02:00
Jugal D. Bhatt
c66b288bcf
[LLM Translation] fix query params for realtime api intent (#12838)
* fix query params for realtime api intent

* fix my py

* Add typed dict

* remove typed dict

* fix comments

* add test

* add test

* added proxt log revert

* add real time q params
2025-07-25 10:09:53 -07:00
Jugal D. Bhatt
c2833e693e
clean and verify key before inserting (#12840)
* clean and verify key

* change checking logic

* Add unit test
2025-07-25 10:09:28 -07:00
Timothy Lowrimore
da6eac4aac passing tests
added necessary provider models to model prices and context window files
2025-07-25 09:18:54 -06:00
Ishaan Jaff
20450bfe94 fix mapped test 2025-07-25 07:24:42 -07:00
Krish Dholakia
6d3ce76e1c
Guardrails - support model-level guardrails (#12968)
* fix(custom_guardrail.py): initial logic for model level guardrails

* feat(custom_guardrail.py): working pre call guardrails

* fix(custom_guardrails.py): check if custom guardrails set before running event hook

* test(test_custom_guardrail.py): add unit tests for async pre call deployment hook on custom guardrail

* feat(custom_guardrail.py): add post call processing support for guardrails

allows model based guardrails to run on the post call event for that model only

* fix(utils.py): only run if call type is in enum

* test: update unit tests to work
2025-07-24 22:38:03 -07:00
Dmitriy Alergant
0cc320cc0a
GuardrailsAI: use validatedOutput to allow usage of "fix" guards. Previously "fix" guards had no effect in llmOutput mode. (#12891) 2025-07-24 22:07:06 -07:00
Gaston
6cfaf674e4
Fix: Shorten Gemini tool_call_id for Azure compatibility (#12941) 2025-07-24 21:52:16 -07:00
Santosh Dhaladhuli
d9d53466e8
[Feat] Add inpainting support and corresponding tests for Amazon Nova Canvas (#12949) 2025-07-24 21:46:06 -07:00
Ishaan Jaff
106a298f0a
[Feat] UI - Allow Adding LiteLLM Auto Router on UI (#12960)
* add router.json

* test_router_auto_router

* async_pre_routing_hook

* fixes for auto router

* add async_pre_routing_hook

* add LiteLLMRouterEncoder

* update test auto_router_embedding_model

* add auto_router_embedding_model

* add AutoRouter

* fix async_pre_routing_hook

* update async_pre_routing_hook

* fix auto router

* fix router.json

* working router init

* working embedding encoder

* working auto router

* test_router_auto_router

* test auto router

* add semantic-router as optional for litellm

* add extras

* semantic_router==0.1.10

* ruff fix

* use aiohttp==3.10.11

* python-dotenv==1.0.1

* test auto router

* test_router_auto_router

* semantic_router

* test_is_auto_router_deployment

* fix check

* fix docker build step

* add semantic_router

* UI  - Add auto router on litellm

* working utterances config

* fix route config builder

* kind of working add automodel router

* move loc of add deployment

* fixes for AutoRouter

* add auto_router_config in types.py

* fixes for init_auto_router_deployment

* fix adding auto router models

* working auto-router with dB

* Revert "add semantic_router"

This reverts commit 537b672887.

* TestAutoRouter

* fix linting

* add semantic router to docker

* test fix

* fix router config builder

* remove export button
2025-07-24 19:58:49 -07:00
Ishaan Jaff
b8e404dd95
[Feat] Backend Router - Add Auto-Router powered by semantic-router (#12955)
* add router.json

* test_router_auto_router

* async_pre_routing_hook

* fixes for auto router

* add async_pre_routing_hook

* add LiteLLMRouterEncoder

* update test auto_router_embedding_model

* add auto_router_embedding_model

* add AutoRouter

* fix async_pre_routing_hook

* update async_pre_routing_hook

* fix auto router

* fix router.json

* working router init

* working embedding encoder

* working auto router

* test_router_auto_router

* test auto router

* add semantic-router as optional for litellm

* add extras

* semantic_router==0.1.10

* ruff fix

* use aiohttp==3.10.11

* python-dotenv==1.0.1

* test auto router

* test_router_auto_router

* semantic_router

* test_is_auto_router_deployment

* fix check

* fix docker build step

* add semantic_router

* Revert "add semantic_router"

This reverts commit 537b672887.
2025-07-24 18:32:56 -07:00
Krish Dholakia
1a57875d24
Proxy - specify key_type - allows specifying if key can call LLM API routes vs. Management routes only (#12909)
* feat(key_management_endpoints.py): Support new 'key_type' field

allow user to specify if key should be 'management' or 'llm api' key

Security fix

* test(test_route_checks.py): add unit tests

* fix(create_key_button.tsx): add ui component to select key type

allows specifying if key can call llm api vs. management routes

* feat(create_key_button.tsx): add specifying key type to ui

* fix(route_checks.py): add sensitive data masker for user id on not allowed error message

prevent leaking sensitive information
2025-07-24 16:40:40 -07:00
Ishaan Jaff
e3b752d3dc
[Feat] LiteLLM CloudZero Integration updates - using LiteLLM_SpendLogs Table (#12922)
* use spend logs in transform.py

* fixes for using spend logs

* get_usage_data

* update get_usage_data_for_hour

* fix CloudZeroLogger

* fixes for cloudzero_dry_run_export

* working DB read

* fix _aggregate_to_hourly

* update cloudzero endpoints

* fix cloudzero_export

* fixes for CBF transformer

* use init_background_job on saving cz settings

* add is_cloudzero_setup_in_db

* init cz on startup

* fixes for CZ transform

* fix ruff check

* fix LOC violation
2025-07-23 18:46:50 -07:00
Timothy Lowrimore
9a9f882693 adds test for chat tranformation 2025-07-23 17:06:11 -06:00
Ishaan Jaff
2d0187824c test_proxy_model_resolution_with_custom_names_documentation 2025-07-23 13:13:46 -07:00
Ishaan Jaff
99ad24c683
[Feat] LiteLLM x Cloudzero integration - Allow exporting spend to cloudzero (#12908)
* add cz init

* add DataAnalyzer

* add CZRNGenerator -> LiteLLM resource generator

* add CloudZeroStreamer

* add CBFTransformer

* add cloudzero DB connection

* add config

* add cli.py

* cleanup

* add CloudZeroLogger

* add CloudZeroLogger

* update CloudZeroLogger

* add cloudzero_router to litellm proxy

* add CloudZeroInitRequest

* add cloudzero spend endpoints

* simple dry run endpoint

* refactor dir structure

* add well types CBFRecord

* TestCBFTransformer

* TestCloudZeroStreamer

* ruff fix

* add polars pip + docker requirements.txt

* _group_by_date

* update code qa check

* docs for CZ params
2025-07-23 13:00:58 -07:00
Ishaan Jaff
00fd020291 fix test 2025-07-23 09:04:09 -07:00
Murad Khafizov
a6ddf5c744
feat: extended /v1/models endpoint, now it returns with fallbacks on demand (#12811)
* Extended `/v1/model` endpoint to support fallbacks

* unit tests reworked

* linting fixes

* fix lining error

* fix linting
2025-07-22 23:16:46 -07:00
Krish Dholakia
d26f74ade5
Request Headers - support x-litellm-num-retries + Usage - support usage by model group (#12890)
* feat(litellm_pre_call_utils.py): add num_retries to litellm data for backend call

allow user to pass in num retries via request headers

* test(test_litellm_pre_call_utils.py): add unit test

* docs(request_headers.md): document new request header

* fix(common_daily_activity.py): show spend breakdown by model group

Partial fix for https://github.com/BerriAI/litellm/issues/12887

* feat(new_usage.tsx): new tab switcher for viewing usage by model group vs. received model

Closes https://github.com/BerriAI/litellm/issues/12887
2025-07-22 23:09:36 -07:00
Krish Dholakia
8cd6c25e1e
Fix async retryer on .acompletion() + forward clientside headers - filter out content-type from clientside request (causes llm api call to hang) (#12886)
* fix(main.py): fix async retryer

Fixes https://github.com/BerriAI/litellm/issues/12830

* fix(forward_clientside_headers_by_model_group.py): filter out 'content-type' from forwardable headers

clientside content-type != proxy content type, can cause requests to hang
2025-07-22 19:50:05 -07:00
Ishaan Jaff
b41ce5c92f
[Feat] - Track cost + add tags for health checks done by LiteLLM Proxy (#12880)
* refactor to use add_user_api_key_auth_to_request_metadata

* add get_litellm_internal_health_check_user_api_key_auth

* add get_litellm_internal_health_check_user_api_key_auth

* add _update_model_params_with_health_check_tracking_information

* add HealthCheckHelpers

* refactor to use clean helpers

* test_update_model_params_with_health_check_tracking_information

* test_get_litellm_internal_health_check_user_api_key_auth

* test_add_user_api_key_auth_to_request_metadata

* fix _update_model_params_with_health_check_tracking_information
2025-07-22 18:45:57 -07:00
Ishaan Jaff
bf300f8ca7 Revert "Litellm dev 07 21 2025 p1 (#12848)"
This reverts commit e4e10aa4ed.
2025-07-22 18:28:36 -07:00
Ishaan Jaff
d5ee93aa0c
[Feat] Add Recraft API - Image Edits Support (#12874)
* test_recraft_image_edit_api

* add RecraftImageEditConfig

* complete RecraftImageEditConfig

* add RecraftImageEditRequestParams in types

* update RecraftImageEditRequestParams

* working

* transform_image_edit_request

* Image Edit docs recraft

* working transform_image_edit_request

* TestRecraftImageEditTransformation
2025-07-22 15:03:08 -07:00
Adam Holmberg
2ce03d9735 fix: make gemini and openai responses return reasoning by default
This aligns the proxy experience with other models that think
automatically (e.g. Deepseek R1 and grok3). It does so by setting
the necessary request input to return thinking, but not specifying
a budget or effort (thus defaulting to the internal automatic level).
2025-07-22 10:41:29 -05:00
Ishaan Jaff
03baf23ad1 [Feat] Add Recraft Image Generation API Support - New LLM Provider (#12832)
* add recraft

* init RecraftImageGenerationConfig

* add get_complete_url + validate_environment

* add image_generation_handler in llm http clas

* fixes for transform

* working recraft request

* fixed img gen transform

* fixes for llm http handler

* test: TestRecraftImageGeneration

* fixes for llm_http_handler

* fix RecraftImageGenerationConfig

* TestRecraftImageGenerationTransformation

* add recraft API

* docs recraft API

* fix code QA

* map_openai_params

* fix recraft

* cost tracking for recraft/recraftv3

* fix code qa check
2025-07-21 22:19:58 -07:00
Krish Dholakia
e5251e7188
Openrouter - filter out cache_control flag for non-anthropic models (allows usage with claude code) (#12850)
* fix(gpt_transformation.py): remove 'cache_control' flag for openai/openai-compatible calls

Fixes https://github.com/BerriAI/litellm/issues/12787

* fix(openrouter/chat/transformation.py): allow passing openrouter cache control flag for claude models

* fix(gpt_transformation.py): fix import

* fix: fix adding tools
2025-07-21 22:15:48 -07:00
Krish Dholakia
e4e10aa4ed
Litellm dev 07 21 2025 p1 (#12848)
* fix(main.py): fix async retryer

Fixes https://github.com/BerriAI/litellm/issues/12830

* fix(forward_clientside_headers_by_model_group.py): filter out 'content-type' from forwardable headers

clientside content-type != proxy content type, can cause requests to hang

* test(tests/): update tests
2025-07-21 22:09:39 -07:00
Krish Dholakia
db498c1805
Fix team_member_budget update logic (#12843)
* fix(team_endpoints.py): always remove team member budget from updated_kv

this is not a field for the litellm team table

Prevents startup issue

* test(test_team_endpoints.py): add unit test to ensure 'team_member_budget' is never in update to table - separate logic

* refactor: cleanup
2025-07-21 22:06:29 -07:00
Ishaan Jaff
133c26c015
[Azure OpenAI Feature] - Support DefaultAzureCredential without hard-coded environment variables (#12841)
* DefaultAzureCredential

* update get_azure_ad_token_provider

* fixes for get_azure_ad_token_provider

* test_get_azure_ad_token_provider_with_default_azure_credential

* test_get_azure_ad_token_fallback_to_default_azure_credential

* docs DefaultAzureCredential

* fix linting
2025-07-21 18:04:16 -07:00
Ishaan Jaff
2941a555a8
[Feat] Add Recraft Image Generation API Support - New LLM Provider (#12832)
* add recraft

* init RecraftImageGenerationConfig

* add get_complete_url + validate_environment

* add image_generation_handler in llm http clas

* fixes for transform

* working recraft request

* fixed img gen transform

* fixes for llm http handler

* test: TestRecraftImageGeneration

* fixes for llm_http_handler

* fix RecraftImageGenerationConfig

* TestRecraftImageGenerationTransformation

* add recraft API

* docs recraft API

* fix code QA

* map_openai_params

* fix recraft

* cost tracking for recraft/recraftv3

* fix code qa check
2025-07-21 15:01:32 -07:00
Jugal D. Bhatt
b653aed603
added dynamic endpoint support (#12827) 2025-07-21 12:38:53 -07:00
tanjiro
a752d7acc9
Fix SSO Logout | Create Unified Login Page with SSO and Username/Password Options (#12703) 2025-07-20 20:24:38 -07:00
Eric Chen
0a7c9a7231 Fix anyof corner cases for BerriAI/litellm#11164 2025-07-20 22:10:02 -05:00
Krish Dholakia
0c461b2719
Litellm fix proxy unit testing p2 (#12779)
* test: update tests

* test: update test

* test: update unit tests
2025-07-19 16:35:05 -07:00
Ishaan Jaff
311d356520 test_qdrant_semantic_cache_async_set_cache 2025-07-19 15:59:56 -07:00
Cole McIntosh
b04b456bc2
fix(proxy): Fix Model Armor project_id initialization order (#12766)
When using Model Armor guardrail with explicit project_id in config,
the project_id was being overwritten to None due to incorrect
initialization order between ModelArmorGuardrail and VertexBase parent class.

This fix ensures that user-provided project_id is preserved by initializing
parent classes before setting instance attributes.

Fixes #12757
2025-07-19 15:20:40 -07:00
Krish Dholakia
a89a49f1e1
Allow forwarding clientside headers by model group (#12753)
* feat: initial commit for forwarding client headers by model group

* fix(router.py): support new forwarclientsideheadersbymodelgroup class

enables headers to be forwarded to backend model, by model group

* fix(proxy_server.py): load in model group settings from config correctly

* refactor(litellm_pre_call_utils.py): litellm_pre_call_utils.py

introduce new 'secret_fields' field

includes raw request headers (not the sanitized ones used for logging) - needed to support forwarding clientside headers to llm api

* feat(router.py): log the deployment model name as well

allows wildcard models to support forward_client_headers_to_llm_api

* test(test_router.py): add more unit testing

* feat(router.py): specify the model group alias in metadata kwargs

allows usage for internal routing logic

* fix: fix ruff check errors

* fix(router.py): refactor to cleanup optional pre-call checks

* fix: fix ruff check

* test: add missing unit test
2025-07-19 15:17:13 -07:00
Jugal D. Bhatt
b443817a56
[Key Access] Litellm disabled callbacks for UI (#12769)
* add disabled callbacks to ui

* added body

* update edit settings

* add tests
2025-07-19 14:32:05 -07:00
Krish Dholakia
ab09d0621d
Litellm gemini grounding metadata stream (#12673)
* fix(prompt_templates/factory.py): handle anthropic cache control on individual tool results

Fixes issue where cache control on individual tool result was being ignored

* test(test_vertex_And_google_ai_studio_gemini.py): initial unit test covering translation for grounding metadata on streaming chunk

* fix(vertex_and_google_ai_studio.py): ensure grounding metadata is preserved on streaming

Closes https://github.com/BerriAI/litellm/issues/10237

* fix(core_helpers.py): include usage in expected openai keys
2025-07-19 11:52:12 -07:00
Ishaan Jaff
06574a72b5
[Feat] Backend - Add support for disabling callbacks in request body (#12762)
* allow using standard_callback_dynamic_params to disable callbacks

* fix is_callback_disabled_dynamically

* test_callback_disabled_via_request_body_multiple
2025-07-19 10:10:30 -07:00
Ishaan Jaff
81eb2fdd30
[Feat] UI Vector Stores - Allow adding Vertex RAG Engine, OpenAI, Azure (#12752)
* fix _pass_through_endpoint_without_required_model

* add get_litellm_managed_vector_store_from_registry

* undo router change

* fix for using router + vector search methods

* add simple helper for _update_request_data_with_litellm_managed_vector_store_registry

* add vector_stores routes

* test_router_avector_store_search_passes_correct_args

* [Feat] UI - Allow clicking into Vector Stores (#12741)

* Add View Vector Store

* add /info for vector store

* fix updated_at

* allow easily testing the KB on litellm

* fix

* rename test

* test_init_vector_store_api_endpoints

* add get_vertex_ai_project

* fixes to vertex transformation for RAG Engine

* fix vectorStoreProviderFields

* Add Vertex Rag engine

* add oai, azure

* fix validate_environment

* fix provider name

* fix tester

* working vertex vector store
2025-07-18 18:25:26 -07:00
Ishaan Jaff
5802a5bbe3
[Feat] LLM API Endpoint - Expose OpenAI Compatible /vector_stores/{vector_store_id}/search endpoint (#12749)
* fix _pass_through_endpoint_without_required_model

* add get_litellm_managed_vector_store_from_registry

* undo router change

* fix for using router + vector search methods

* add simple helper for _update_request_data_with_litellm_managed_vector_store_registry

* add vector_stores routes

* test_router_avector_store_search_passes_correct_args

* [Feat] UI - Allow clicking into Vector Stores (#12741)

* Add View Vector Store

* add /info for vector store

* fix updated_at

* allow easily testing the KB on litellm

* fix

* rename test

* test_init_vector_store_api_endpoints

* test_update_request_data_with_litellm_managed_vector_store_registry
2025-07-18 18:18:53 -07:00
Jugal D. Bhatt
8d35a00974
[LLM Translation] Added model name formats (#12745)
* Added model supports

* invert logic

* Added gpt 35 turbo check

* add test check

* fix ruff check
2025-07-18 17:08:35 -07:00
Jugal D. Bhatt
c3c6255689
[LLM Translation] Change System prompts to assistant prompts as a workaround for GH Copilot (#12742)
* add changes for copilot

* Add test

* reverse flag settings

* add settings

* utils changes

* fix tests
2025-07-18 15:48:27 -07:00
Cole McIntosh
d4f5180212
fix(lowest_latency.py): Handle ZeroDivisionError with zero completion tokens (#12734)
* fix(lowest_latency.py): Handle ZeroDivisionError with zero completion tokens (#12641)

Fixes ZeroDivisionError when LLM responses have zero completion tokens, which can
occur with Gemini models on very long contexts that only use tool calls.

Changes:
- Add check for completion_tokens > 0 before division in log_success_event
- Handle both timedelta and float types for response times (supporting both time.time() and datetime)
- Apply fix to both occurrences of the division operation in the file
- Add comprehensive tests for zero completion token scenarios

This ensures the lowest latency routing continues to work properly even when
models return responses with no completion tokens.

* test: Move lowest_latency zero tokens test to test_litellm for CI execution

* refactor: Use safe_divide helper to eliminate code duplication

- Added safe_divide utility function to litellm_core_utils.core_helpers
- Handles both timedelta and float types for numerator
- Prevents ZeroDivisionError and negative denominator issues
- Replaced duplicated division logic in lowest_latency.py
- Added comprehensive unit tests for safe_divide function

This improves code quality by reducing duplication and centralizing the
division safety logic in a reusable helper function.

* refactor: Rename to safe_divide_seconds for clarity

- Renamed safe_divide to safe_divide_seconds to better indicate it handles time durations
- Simplified implementation with single-line ternary for seconds conversion
- Updated all references and tests accordingly

The function name now clearly indicates it's specifically for dividing
time durations (in seconds) by a denominator.

* refactor: Simplify safe_divide_seconds to only accept float arguments

- Changed safe_divide_seconds to accept only float parameters for consistency
- Callers now handle timedelta to seconds conversion explicitly
- Removed timedelta-specific test cases

* fix: Remove unused timedelta import

* fix: Remove Union[timedelta, float] type annotations

Since safe_divide_seconds now only accepts floats, we handle the
timedelta conversion explicitly in the code. The type annotations
are no longer needed and can be simplified.

* Revert "fix: Remove Union[timedelta, float] type annotations"

This reverts commit 19c6c62154.

* fix: Clean up implementation

- Remove unnecessary type annotations
- Use safe_divide_seconds utility for zero-division protection
- Handle both timedelta and float types explicitly
- Maintain compatibility with both datetime and time.time() usage
2025-07-18 15:19:47 -07:00
Ryan Richard
474ac2dd6a
add project_id from auth metadata to credentials cache if a user does not specify a project_id (#12661)
add unit tests for new cached credentials with project_id

Co-authored-by: Ryan Richard <ryanirichard07@gmail.com>
2025-07-18 13:33:09 -07:00
Cole McIntosh
506dc80b15
feat: integrate Google Cloud Model Armor guardrails (#12492)
* feat: integrate Google Cloud Model Armor guardrails (LIT-298)

- Add ModelArmorGuardrail class that extends CustomGuardrail and VertexBase
- Support for both pre-call (sanitizeUserPrompt) and post-call (sanitizeModelResponse) sanitization
- Integrate with existing Vertex AI authentication using VertexBase
- Add configuration model for Model Armor in guardrail types
- Register Model Armor in guardrail initializers and registry
- Include comprehensive test suite for Model Armor functionality
- Support content masking for both requests and responses
- Handle streaming responses with content sanitization

This integration allows LiteLLM to use Google Cloud Model Armor API for
content moderation and sanitization, providing similar functionality to
Bedrock Guards but using Google Cloud's security infrastructure.

* fix: remove unused imports flagged by ruff linter

- Remove unused asyncio import at top level (moved to local import where needed)
- Remove unused TextCompletionResponse import

* fix: remove additional unused imports

- Remove unused TextChoices import from line 34
- Remove duplicate asyncio import from line 384
- Replace asyncio.iscoroutine() with hasattr check for __await__

* fix: remove final unused imports

- Remove unused 'import sys' from line 9
- Remove unused 'StreamingChoices' from imports

* fix: remove unused import from model_armor.py

- Remove unused 'import os' from the top of the file

* fix: remove commented-out header from model_armor.py

- Eliminate unnecessary comments at the top of the file to improve code clarity.

* feat(guardrails): Add Model Armor UI support

- Convert model_armor.py to a directory structure with __init__.py for dynamic discovery
- Add get_config_model() method to ModelArmorGuardrail class for UI integration
- Add ui_friendly_name() to ModelArmorConfigModel returning "Google Cloud Model Armor"
- Remove manual registration from guardrail_registry.py to use dynamic discovery
- Model Armor now appears in the UI guardrails dropdown with proper configuration fields

This enables users to configure Model Armor guardrails through the LiteLLM UI interface.

* fix(guardrails): Fix undefined name 'GuardrailConfigModel' in Model Armor

- Import TYPE_CHECKING and GuardrailConfigModel from base module
- Fixes F821 linting error for undefined name in type annotation
- Follows same pattern as other guardrail implementations

* fix(guardrails): Fix Model Armor type errors and config model inheritance

- Create ModelArmorGuardrailConfigModel that properly inherits from GuardrailConfigModel base class
- Move config model to litellm/types/proxy/guardrails/guardrail_hooks/model_armor.py following convention
- Update get_config_model() to return the properly typed config model
- Remove ModelArmorConfigModel from LitellmParams inheritance chain
- Add template_id field to BaseLitellmParams instead

This fixes the mypy type errors and follows the same pattern as other guardrail implementations.

* fix(guardrails): Add missing Model Armor fields to BaseLitellmParams

- Add location, credentials, api_endpoint, and fail_on_error fields
- Fixes mypy errors about missing attributes in LitellmParams
- All Model Armor configuration parameters are now properly defined

* fix: Apply PR review feedback for Model Armor guardrail

- Move test file to tests/test_litellm/ for GitHub Actions
- Extract only last consecutive user messages to avoid context limits
- Use get_content_from_model_response helper for response extraction
- Handle non-ModelResponse types (e.g., TTS) gracefully
- Maintain newline separation for multi-part content

* refactor: Simplify message content extraction in ModelArmorGuardrail

- Removed the custom _extract_content_from_messages method.
- Integrated get_last_user_message helper for improved content extraction.
- Updated test to reflect changes in content formatting.

* refactor: Remove unused import in model_armor.py

- Deleted the unused import of AllMessageValues to clean up the codebase.

* Add unit tests for Model Armor guardrail functionality

- Implement tests for pre-call and post-call hooks, including content sanitization and blocking behavior.
- Validate error handling for API responses and credential management.
- Test streaming responses and handling of list content in user messages.
- Ensure proper assertions for API interactions and response sanitization.

* Add comprehensive test coverage for Model Armor guardrail

- Add test for requests with no messages field
- Add test for empty message content handling
- Add test for system/assistant-only messages
- Add test for fail_on_error=False behavior
- Add test for custom API endpoint configuration
- Add test for dictionary credentials (non-file path)
- Add test for action=NONE response handling
- Add test for missing sanitized_text field fallback
- Add test for non-text response types (TTS/image)
- Add test for auth token refresh behavior

All tests ensure robust edge case handling and proper error management.

* feat: improve Model Armor handling of non-ModelResponse types

- Add debug logging when skipping non-text responses (TTS, images, etc.)
- Improve docstring to clarify behavior for non-text responses
- Add test coverage for non-ModelResponse handling
- Ensure guardrail gracefully skips processing for response types it cannot handle
2025-07-18 12:51:09 -07:00
Jugal D. Bhatt
a46b9d376f
[Prometheus] Move Prometheus to enterprise folder (#12659)
* fix tools fetch for keys

* add promethues to enterprise

* remove old prom

* remove old prom

* fix tests

* safe imports

* add if

* fix enterprise test

* rename imports

* added label import

* added label import

* move tests to enterprise

* fix tests

* add log

* build: update versions

---------

Co-authored-by: Krrish Dholakia <krrishdholakia@gmail.com>
2025-07-18 11:54:47 -07:00
Krish Dholakia
5004b915d1
Guardrails AI - support llmOutput based guardrails as pre-call hooks (#12674)
* build: move build_and_test to use prisma migrate

* fix(guardrails_ai.py): default to guardrail accepting 'llmOutput' as the input param

enables same guardrail to work for pre call and post call

* fix(__init__.py): set default value

* fix(guardrails_ai.py): updates

* fix: fix linting error
2025-07-18 11:31:30 -07:00