Commit Graph

92 Commits

Author SHA1 Message Date
YutaSaito 7aba0f738a Revert "Litellm staging 01 15 2026" 2026-01-17 06:31:34 +09:00
Sameer Kankute 84974d5745 Fix boto3 conflicting dependency 2026-01-16 16:55:12 +05:30
Sameer Kankute f3ca05112e Merge pull request #19206 from BerriAI/main
merge main
2026-01-16 15:22:16 +05:30
Yuta Saito 9e1235c0aa chore: add jaraco liccheck 2026-01-16 14:55:14 +09:00
burnerburnerburnerman 5676c6c135 Chore: bump boto3 version (#19090) 2026-01-16 02:39:30 +05:30
Alexsander Hamir 15c3bc219b [Refactor] Add CI enforcement for O(1) operations in _get_model_cost_key to prevent performance regressions (#19052)
* Optimize _get_model_cost_key to avoid expensive scans

- Remove expensive O(n) scan fallback that was causing 42.87% CPU overhead
- Only scan when size mismatch detected (O(1) check)
- Add warning in docstring: Only O(1) lookup operations are acceptable
- Clean up comments to be more concise
- Keep stale entry rebuild for pop() case (only triggers when stale entry found)

This fixes the performance issue where the scan was being triggered on every
failed lookup, causing severe CPU overhead during router operations.

* Add code quality check to enforce O(1) operations in _get_model_cost_key

- Add check_get_model_cost_key_performance.py to statically analyze _get_model_cost_key
- Detects O(n) operations (loops, comprehensions, problematic function calls)
- Recursively checks called functions to find nested O(n) operations
- Allows conditional O(n) rebuilds in helper functions (_rebuild_model_cost_lowercase_map, _handle_stale_map_entry_rebuild, _handle_new_key_with_scan)

* Integrate _get_model_cost_key performance check into CI pipeline

- Add check_get_model_cost_key_performance.py to check_code_and_doc_quality job
- Ensures O(1) requirement is enforced in CI to prevent performance regressions

* Remove unused performance test and clean up utils.py

- Remove test_get_model_info_performance.py (no longer needed)
- Remove extra blank line in utils.py

* Document allowed helper functions and exception process in _get_model_cost_key

- Add documentation listing allowed helper functions with O(n) operations
- Explain why these are acceptable (conditionally called)
- Add instructions for adding new exceptions to check_get_model_cost_key_performance.py

* Fix docstring detection and type checker error in performance check

- Add proper docstring tracking to skip docstring content (fixes false positive for 'map' in docstring)
- Add None check for docstring_quote to fix type checker error
- Restore _handle_new_key_with_scan to allowed_helpers list

* Remove check_get_model_cost_key_performance from CI pipeline

- Temporarily remove the performance check from CI to avoid blocking builds

* Restore performance check and remove memory leak tests from CI

- Add back check_get_model_cost_key_performance.py to CI pipeline
- Remove memory_leak_tests job that was causing port conflicts

* Remove extra blank line in CI config
2026-01-13 17:08:03 -08:00
Ishaan Jaffer e3fe02148d _mask_sequence 2026-01-10 13:20:43 -08:00
Krish Dholakia 80ead21c3a Litellm improve endpoint discovery (#18762)
* docs: document all endpoints in .json and add consistency checks against docs + providers.json

* docs: add more tests + improve coverage
2026-01-07 17:35:01 +05:30
Ishaan Jaffer a5332a6d51 fix code qa check 2026-01-07 14:54:00 +05:30
Ishaan Jaff b5d74722ba Revert "Litellm fixes a2a sdk (#18748)" (#18752)
This reverts commit 1661707492.
2026-01-07 14:04:10 +05:30
Ishaan Jaff 1661707492 Litellm fixes a2a sdk (#18748)
* add a2a SDK to req

* fix
2026-01-07 13:31:45 +05:30
Alexsander Hamir e2f3eaefab Add UnboundedDataStructurePattern to memory test detector (#18590) 2026-01-02 11:49:32 -08:00
Alexsander Hamir b732710ed0 Add memory pattern detection test and fix bad memory patterns (#18589) 2026-01-02 10:52:25 -08:00
Alexsander Hamir a7da4833da [Fix] CI/CD - check_code_and_doc_quality (#18560) 2026-01-01 11:18:59 -08:00
Alexsander Hamir 852bf63698 [Fix] CI/CD - check_code_and_doc_quality (#18309) 2025-12-20 17:34:08 -08:00
Ishaan Jaffer b0db9d6bb7 code qa check 2025-12-19 19:00:44 +05:30
Alexsander Hamir 28821427ce [Fix] CI/CD #1 - mypy | check_code_and_doc_quality | guardrails_testing (#18195) 2025-12-18 06:31:01 -08:00
Alexsander Hamir 892d7e8d70 [Fix] CI/CD - Fix Bedrock tool calling test failures with non-serializable objects and internal parameters (#17930)
* fix(bedrock): filter non-serializable objects from request params

- Enhanced filter_exceptions_from_params() to filter callable objects (functions) and Logging objects
- Applied filtering in Bedrock's _prepare_request_params() before deepcopy
- Applied filtering to additional_request_params before JSON serialization
- Prevents TypeError during deepcopy (APIConnectionError objects) and JSON serialization (functions, Logging objects)
- Fixes test_bedrock_tool_calling test failures

Root cause: MCP-related functions (handle_chat_completion_with_mcp, completion_callable) and litellm_logging_obj were incorrectly added to optional_params via add_provider_specific_params_to_optional_params(), which then ended up in additional_request_params. These objects should be in litellm_params, not optional_params.

* fix(bedrock): filter internal MCP parameters from API requests

Filter out LiteLLM internal/MCP-related parameters (skip_mcp_handler,
mcp_handler_context, _skip_mcp_handler) from additional_request_params
before sending to Bedrock API to prevent 'extraneous key' errors.

- Added filter_internal_params() helper function in core_helpers.py
- Applied filtering in Bedrock's _prepare_request_params() method
- Fixes test_bedrock_completion.py::test_bedrock_tool_calling

* fix: mypy type error

* fix: add filter_exceptions_from_params to recursive function ignore list

- Add filter_exceptions_from_params to IGNORE_FUNCTIONS in recursive_detector.py
- Function is safe: has max_depth parameter (default 20) to prevent infinite recursion
2025-12-13 12:38:07 -08:00
Sameer Kankute b39c21d90c fix: Add _delete_nested_value_custom to recursive function ignore list
The _delete_nested_value_custom function is recursive but has bounded depth
(limited by the number of path segments), preventing infinite recursion.
This is necessary for nested field removal in additional_drop_params.
2025-12-09 17:56:13 +05:30
Ishaan Jaff 38ddd50628 [Bug fix] Vector Store List Endpoint Returns 404 (#17229)
* fix vector store management

* fix: add vector_store_management_router

* TestVectorStoreManagementEndpointsExist

* fix pass_through
2025-11-27 12:51:51 -08:00
Ishaan Jaff 5c192a23c3 [Feat] Add new RAG API on LiteLLM AI Gateway (#17109)
* init RAG api types

* add RAG endpoints

* init main.py for RAG ingest API

* init RecursiveCharacterTextSplitter

* add BaseRAGIngestion

* fix OpenAIRAGIngestion

* fix img handler

* init OpenAIRAGIngestion

* init BedrockRAGIngestion

* init BedrockRAGIngestion

* init rag tests

* init BedrockVectorStoreOptions

* implement BedrockRAGIngestion

* add BaseRAGAPI

* add endpoint for RAG ingest

* add ingest RAG endpoints

* add test doc

* add parse_rag_ingest_request

* update endpoints

* docs add docs for new RAG API

* fix qa check

* fix linting

* docs ficx

* docs

* add max depth checks

* docs anthropic
2025-11-25 17:54:29 -08:00
Ishaan Jaffer badbadba0d fix img URL for tests 2025-11-22 09:41:15 -08:00
yuneng-jiang 4b25398afe [Infra] CI/CD Fixes (#16937)
* Attempt CI/CD Fix

* Adding test for coverage

* Adding max depth to copilot and vertex

* Fixing mypy lint and docker database

* Fixing UI build issues

* Update playwright test
2025-11-21 13:58:19 -08:00
Ishaan Jaffer 8e73e11fc8 SEARCH_PROVIDERS 2025-11-06 17:07:53 -08:00
Ishaan Jaffer d32890ba55 fix _redact_base64 2025-10-28 17:38:16 -07:00
Ishaan Jaff ad62a6d3d1 [Feat] Add DataforSEO Search API (#15817)
* docs google PSE

* add SearchProviders

* add search providers

* add PSE search

* add SearchProviders

* get_provider_search_config

* add Search

* init Search

* add get_http_method on BaseSearch

* fixes for Google PSE

* TestGooglePSESearch

* add DATAFORSEO

* add DataForSEOSearchConfig

* TestDataForSEOSearch

* add DataForSEO

* fix base transform

* fix search

* fix dataforSEO

* docs fix

* fix linting

* fix linting
2025-10-22 16:00:40 -07:00
Ishaan Jaffer 8590646b84 fix code QA check 2025-10-07 17:49:57 -07:00
Ishaan Jaff f8f4207994 [Security Fix] fix: don't log JWT SSO token on .info() log (#15145)
* fix: get_redirect_response_from_openid

* fix info log check

* fix: forward_upstream_to_client
2025-10-02 15:07:37 -07:00
Ishaan Jaffer 81765bba17 fix fastuuid 2025-09-26 18:20:32 -07:00
Alex Shoop b6247d0d77 code cov test script check_fastuuid_usage.py 2025-09-24 10:27:22 +09:00
Ishaan Jaffer 725cf3627d fix: license check.ini 2025-09-18 19:28:07 -07:00
Alexsander Hamir 59409429d4 fix: reduced __inits__ overhead in 7% (#14689)
* fix: avoid redundant __init__ calls on hot path

Previously, imports on the request hot path caused __init__ to run
excessively for every request. This change ensures initialization
happens once, reducing cpu overhead.

* fix: remove redundant __init__ import

The current implementation no longer requires an import at the top of the function.

* fix: placed on core utils for future reuse

* test: add coverage & remove inline import

A general import-checking tool across all endpoints would be a large PR.
This commit focuses on a smaller, targeted fix for the discussed case.

* added import check to CI
2025-09-18 17:18:05 -07:00
Ishaan Jaff 555efd60b5 [Security] Fix: Ensure .info() logs are not used for request/responses + Add code QA check for possible violations (#14386)
* test: info log

* fixes for debug

* add info_log_check

* fix: debug level

* fix: debug level

* fix: use .debug

* fix info statements

* fix info log check

* fix: fix emit_standard_logging_payload

* fix RequestBody

* Potential fix for code scanning alert no. 3339: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix check

* fix code qa check

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-09-09 13:55:56 -07:00
Ishaan Jaff f1699d4cbf fix IGNORE_FUNCTIONS 2025-09-08 17:33:36 -07:00
Ishaan Jaff 6400552308 fix lic check 2025-09-08 17:18:42 -07:00
Ishaan Jaff 4c7b3e10ed [Bug Fix] Gemini Tool Calling - fix gemini empty enum property (#14155)
* fix: _convert_schema_types

* fix recursive detector

* test_convert_schema_types_type_array_conversion

* fix: DEFAULT_NUM_WORKERS_LITELLM_PROXY

* add _fix_enum_empty_strings

* test_tool_call_with_empty_enum_property

* test_fix_enum_empty_strings

* fix _fix_enum_empty_strings
2025-09-01 17:05:01 -07:00
Ishaan Jaff 2331fb45d5 [Bug]: Gemini 2.5 Pro – schema validation fails with OpenAI-style type arrays in tools (#14154)
* fix: _convert_schema_types

* fix recursive detector

* test_convert_schema_types_type_array_conversion

* fix: DEFAULT_NUM_WORKERS_LITELLM_PROXY
2025-09-01 16:53:20 -07:00
0x-fang 9f17bedb48 bump up boto3 and aioboto3 versions (#13665) 2025-08-15 17:06:08 -07:00
Ishaan Jaff f5a1c14929 Revert "update boto3 version to 1.37.38 (#13656)"
This reverts commit 6f2264a13d.
2025-08-15 11:24:59 -07:00
0x-fang 6f2264a13d update boto3 version to 1.37.38 (#13656) 2025-08-15 11:06:54 -07:00
Ishaan Jaff 621b3dca7b [Bug Fix] Mistral Tool Calling - Grammar error: at 3(11): failed to compile JSON schema (#13389)
* test_claude_tool_use_with_gemini

* add _remove_json_schema_refs

* add _clean_tool_schema_for_mistral

* fixes mistral tool calls

* _remove_json_schema_refs

* fix - vertex, remove hardcoded test
2025-08-07 13:50:22 -07:00
Krish Dholakia c7e4435bdc Fix - using managed files w/ OTEL + UI - add model group alias on UI (#13171)
* fix(router.py): safe deep copy kwargs

OTEL adds a parent_otel_span which cannot be deepcopied

* fix: use safe deep copy in other places as well

* test: add script to check and ban copy.deepcopy of kwargs

enforce safe_deep_copy usage

* build(ui/): new component for adding model group alias on UI

* fix(proxy_server.py): support updating model_group_alias via /config/update

allows ui component to work

* fix(router.py): update model_group_alias in router settings based on db value

* fix: fix code qa error
2025-07-31 21:22:04 -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 537b67288798731a119d811f643b682086377ee9.
2025-07-24 18:32:56 -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 57b0b4edf3 [Bug fix] [Bug]: Verbose log is enabled by default (#12596)
* test find_set_verbose_assignments

* fix set verbose

* test set verbose

* fix unused import
2025-07-14 20:06:16 -07:00
Krish Dholakia e7f1fa26ab UI - Azure Content Guardrails (#12341)
* build(model_prices_and_context_window.json): remove 'supports_tool_choice' for specific mistral models

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

* feat: initial commit adding cleaner ui for azure text moderation guardrails

* feat(guardrail_endpoints.py): add discoverable guardrail configs and improve converting base model to dict with types

* fix(guardrail_provider_fields.tsx): render from api endpoint correctly

* fix(guardrail_provider_fields.tsx): cleanup

* refactor(guardrail_endpoints.py): refactor to handle dictionaries with literal - allows multiselect

* feat(ui/): render dictionary with known keys correctly

* feat(ui/): render optional params on separate page

* style(ui/): style improvements to rendering optional params on the UI

* feat(azure/prompt_shield.py): add azure prompt shield back on UI

* fix(add_guardrail_form.tsx): fix form to handle updated api

* fix(guardrail_optional_params.tsx): ensure values are nested correctly for writing to api

* fix: fix linting error

* feat(text_moderation.py): handle str to int conversion

* fix(guardrail_info.tsx): only render pii settings if guardrail is presidio

* fix(guardrail_info.tsx): add guardrail specific fields to update settings

allows updating guardrail fields (e.g. severity threshold) post-create

* fix(guardrail_endpoints.py): set guardrail_id in guardrail object

ensures duplicate objects not created on guardrail update

* fix(guardrail_endpoints.py): allow provider specific fields to be updated on patch update

* refactor(guardrail_endpoints.py): remove duplicate info endpoint

* fix(guardrail_endpoints.py): mask sensitive keys on returning via guardrail `/info`

Prevent leaking keys

* fix(guardrail_optional_params.tsx): return numerical input when numerical component used

fixes issue where output was a str

* fix(guardrail_optional_params.tsx): render dict keys correctly

* fix(text_moderation.py): fix severity by category check

* fix(proxy/utils.py): check if guardrail should run for post call streaming hook

Prevents invalid guardrails from running if not requested

* test: fix import

* fix: fix linting error

* test: update test

* fix: fix tests

* fix: fix code qa errors

* fix(guardrail_endpoints.py): set max depth for function

* test: update recursive_detector.py

* test: update list

* build: merge main

* fix: fix ruff check errors
2025-07-05 10:19:29 -07:00
Ishaan Jaff b4f45e838a add test 2025-07-04 10:06:40 -07:00
Ishaan Jaff ab13edd155 check_for_litellm_module_deletion 2025-07-04 10:06:40 -07:00
Ishaan Jaff 0c19414b36 [️ Python SDK import] - reduce python sdk import time by .3s (#12140)
* use 1 file for KeyManagementSystem

* move key management settings

* fix import locs

* test_proxy_types_not_imported

* test the import loc

* fix import item

* fix imports

* fix import loc

* fix imports
2025-06-28 14:57:10 -07:00
Ishaan Jaff f1c7024e70 [Feat] Add Bridge from generateContent <> /chat/completions (#12081)
* add GenerateContentToCompletionHandler

* working - non streaming bridge

* add GoogleGenAIAdapter

* add google gen ai adapter

* working streaming bridge

* working streaming usage for adapter

* tool calling transform for generate content to openai

* fixes for accumulating tool calls

* fix code qa checks

* Best Practices for Production

* fix code qa checks

* test_streaming_partial_tool_calls_accumulation

* linting fixes

* add supported_openai_chat_completion_params

* fix translate_generate_content_to_completion

* test_google_genai_adapter.py
2025-06-27 11:08:55 -07:00