Commit Graph

3606 Commits

Author SHA1 Message Date
Alexsander Hamir ddb90c9ad7 [Fix] - Router: add model_name index for O(1) deployment lookups (#15113)
* perf(router): add model_name index for O(1) deployment lookups

Add model_name_to_deployment_indices mapping to optimize _get_all_deployments()
from O(n) to O(1) + O(k) lookups.

- Add model_name_to_deployment_indices: Dict[str, List[int]]
- Add _build_model_name_index() to build/maintain the index
- Update _add_model_to_list_and_index_map() to maintain both indices
- Refactor to use idx = len(self.model_list) before append (cleaner)
- Optimize _get_all_deployments() to use index instead of linear scan

* test(router): add test coverage for _build_model_name_index

Add single comprehensive test for _build_model_name_index() function to fix
code coverage CI failure.

The test verifies:
- Index correctly maps model_name to deployment indices
- Handles multiple deployments per model_name
- Clears and rebuilds index correctly

Fixes: CI code coverage error for _build_model_name_index
2025-10-06 08:14:11 -07:00
Javier de la Torre df232a71f1 feat(snowflake): add function calling support for Snowflake Cortex REST API
Add support for function calling (tools) with Snowflake Cortex models that support it (e.g., Claude 3.5 Sonnet).

Changes:
- Add 'tools' and 'tool_choice' to supported OpenAI parameters
- Implement request transformation: OpenAI function format → Snowflake tool_spec format
- Implement response transformation: Snowflake content_list with tool_use → OpenAI tool_calls
- Add tool_choice transformation: OpenAI nested format → Snowflake array format

Request transformation:
- Transform tools from nested {"type": "function", "function": {...}} to Snowflake's {"tool_spec": {"type": "generic", "name": "...", "input_schema": {...}}}
- Transform tool_choice from {"type": "function", "function": {"name": "..."}} to {"type": "tool", "name": ["..."]}

Response transformation:
- Parse Snowflake's content_list array containing tool_use objects
- Extract tool calls with tool_use_id, name, and input
- Convert to OpenAI's tool_calls format with proper JSON serialization

Testing:
- Add 7 unit tests covering request/response transformations
- Add integration test for Responses API with tool calling
- All tests passing

Fixes issue #15218

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-05 13:08:33 +02:00
Krrish Dholakia 63cb2764fe test: fix raise 2025-10-04 16:11:22 -07:00
Krrish Dholakia 2d1000c461 test: update tests 2025-10-04 15:31:25 -07:00
Krish Dholakia a9037ab61f Merge branch 'main' into litellm_dev_10_03_2025_p1 2025-10-04 15:23:31 -07:00
Krish Dholakia 75e3f4e10d Merge pull request #15120 from BerriAI/litellm_dev_10_01_2025_p2
(feat) Support 'guaranteed_throughput' when setting limits on keys belonging to a team
2025-10-04 15:22:47 -07:00
Krish Dholakia b188f76dbe Merge pull request #15201 from BerriAI/litellm_staging_10_04_2025_p2
(security) prevent user key from updating other user keys + don't return all keys with blank key alias on /v2/key/info
2025-10-04 14:58:00 -07:00
Krrish Dholakia bb5011597c test: fix minor test 2025-10-04 14:55:04 -07:00
Krrish Dholakia 814e49df06 test: update tests 2025-10-04 14:39:50 -07:00
Ishaan Jaff ec9cdf783a Revert "Add streamGenerateContent cost tracking in passthrough (#15199)" (#15202)
This reverts commit 8095de506a.
2025-10-04 14:37:02 -07:00
Sameer Kankute 8095de506a Add streamGenerateContent cost tracking in passthrough (#15199)
* Add streamgenerate cost tracking for gemini provider

* add cost tracking test
2025-10-04 12:31:25 -07:00
Ishaan Jaffer 3d6342f852 test_twelvelabs_missing_input_type_error 2025-10-04 12:28:09 -07:00
Ishaan Jaffer be7ab0b3e3 test_gemini_url_context 2025-10-04 12:23:43 -07:00
Ishaan Jaffer c38c5d20cc test dynamic rate limiter 3 2025-10-04 12:06:13 -07:00
Ishaan Jaffer 7a41c09529 test bedrock embedding tests marengo 2025-10-04 11:27:29 -07:00
Ishaan Jaffer 44db58c8df test_e2e_bedrock_async_invoke_embedding_async_twelvelabs_marengo 2025-10-04 11:13:39 -07:00
Ishaan Jaffer 53503828b2 test fix 2025-10-04 10:57:02 -07:00
Ishaan Jaffer 6f298cf5f0 test_azure_openai_assistants_e2e_operations_stream 2025-10-04 10:53:46 -07:00
Ishaan Jaff f78608082c [Feat] Dynamic Rate Limiter v3 - fixes for detecting saturation + fixes for post saturation behavior (#15192)
* fix: test case 1, model hits saturation

* fix: _check_rate_limits test case 2

* fix: _get_priority_allocation

* test_default_priority_shared_pool

* fix: No Rate Limiting when low saturatation

* fix: correctly use  model_saturation_check

* fixes priority_descriptors

* fix: tune default PriorityReservationSettings
2025-10-04 10:45:17 -07:00
Ishaan Jaffer ee36c30217 fix LF tests 2025-10-04 10:39:17 -07:00
Ishaan Jaffer 00f44861ea fix: gooogle GenAI route tests 2025-10-04 10:18:25 -07:00
Ishaan Jaffer 1655a9aea8 fix lf tests 2025-10-04 10:02:56 -07:00
Ishaan Jaffer eb417ed774 fix lf logging 2025-10-04 10:00:10 -07:00
Ishaan Jaffer 4400a6c189 test bedrock guardrails 2025-10-04 09:18:26 -07:00
Krish Dholakia ad2270fe13 Merge pull request #14764 from daily-kim/litellm_fix_bearer_capitalization
Fix: Authorization header to use correct "Bearer" capitalization
2025-10-03 22:02:46 -07:00
Krish Dholakia 206f67a11e Merge pull request #15183 from uc4w6c/fix/test_mcp_server
test: fix test_mcp_server.py
2025-10-03 21:44:52 -07:00
Krrish Dholakia 3816d3b36f test: add unit testing 2025-10-03 17:27:49 -07:00
Krrish Dholakia c043ad6c2b fix: replace list in for set in
faster
2025-10-03 17:17:20 -07:00
Krrish Dholakia 69edc546c0 fix(mcp_server_manager.py): don't return an invalid server id on list servers
Prevents user from hitting 'server not found' error, even when they see it being listed on litellm ui
2025-10-03 17:15:15 -07:00
Yuta Saito 359aaa947f test: fix test_mcp_server.py 2025-10-04 08:18:15 +09:00
Ishaan Jaff 10d6d72ae3 [Feat] VertexAI - Support googlemap grounding in vertex ai (#15179)
* add VertexToolName

* test_vertex_tool_params

* fix: working maps grounding

* test_gemini_google_maps_tool_simple

* test_vertex_ai_map_google_maps_tool_with_location

* fix  # noqa: PLR0915

* _extract_google_maps_retrieval_config

* fixes for linting

* docs: **Google Maps**
2025-10-03 16:07:51 -07:00
Krish Dholakia 3095f43e92 Merge pull request #15007 from TobiMayr/feature/add-max-requests-env-var
feature/add max requests env var
2025-10-03 15:30:15 -07:00
Krish Dholakia 343eeaf53f Merge pull request #15102 from BerriAI/litellm_message_api_cost_tracking
(Feat) Add cost tracking for /v1/messages
2025-10-03 15:27:49 -07:00
rishiganesh2002 d36c8d6bbe [Feat] MCP Gateway Fine-grained Tools Addition (#15153)
* feat: UI to add specific tools under creating MCP connection

* chore: pydantic + prisma changes

* feat: adding specific MCP tools now works

* fix: allowed tools filtering

* chore: filtered list to mcp server cost config

* chore: update Readme

* chore: refactor the filtering

* test: Added tests

When the allowed_tests is null, empty list or populated

* chore: resolve the proxy issue

* feat: updating MCP tool filtering
2025-10-03 10:16:29 -07:00
Ishaan Jaff efa782d6d2 [Feat] Add Nvidia NIM Rerank Support (#15152)
* feat: add NvidiaNimRerankConfig

* fix: NvidiaNimRerankConfig

* fix: NvidiaNimRerankConfig

* fix routing to nvidia nim

* docs nvidia nim rerank

* TestNvidiaNim

* nvidia nim rerank fixes

* fix rerank

* transform_rerank_response

* Usage with LiteLLM Proxy

* fixes linting

* NvidiaNimRerankConfig.DEFAULT_NIM_RERANK_API_BASE

* fix Custom API Base URL

* fix rerank base

* fix main.py

* fix transform

* fix linting

* map_cohere_rerank_params

* ruff fix

* linting fixes

* ruff fix
2025-10-02 18:58:52 -07:00
Sameer Kankute 544db8d140 (feat)Litellm x twelvelabs bedrock[Async Invoke Support] (#14871)
* Add async invoke support

* Add docs and correct embedding response

* fix cicd erros

* fix cicd erros

* fix mypy error

* Add litellm param input_type

* Update the docs
2025-10-02 18:52:33 -07:00
Ishaan Jaffer 9c29f35c4b test_end_user_jwt_auth 2025-10-02 18:48:11 -07:00
Krish Dholakia 54095a256a Merge pull request #15015 from anthony-liner/fix/langfuse-total-tokens
fix: set usage_details.total in langfuse integration
2025-10-02 17:33:43 -07:00
Georg Wölflein dbfa8ec921 Fix end user cost tracking in the responses API (#15124)
#13860
2025-10-02 15:13: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
Krish Dholakia f6b67fd9bd Merge pull request #14799 from tyler-liner/chore/generation-name-opentelemetry
fix (opentelemetry): use generation_name for span naming in logging method
2025-10-01 21:39:38 -07:00
Krish Dholakia 93e347b3d8 Merge pull request #15106 from plafleur/ISSUE-15105
Guardrails - Don't run post_call guardrail if no text returned from Bedrock
2025-10-01 21:29:14 -07:00
Ishaan Jaff d538cf489a [Feat] Fixes to dynamic rate limiter v3 - add saturatation detection (#15119)
* test cases dynamic rate limits

* fix _handle_generous_mode

* docs add readme

* use configs for vars

* fix debug

* add comment

* test_dynamic_rate_limiter_v3.py

* test_concurrent_pre_call_hooks_stress
2025-10-01 18:35:34 -07:00
Ishaan Jaffer 2bc5d93f23 use_callback_in_llm_call 2025-10-01 18:32:37 -07:00
Deepanshu Lulla 68adca04c8 Gitlab based Prompt manager (#14988)
* add prompt

* add prompt

* add prompt

* add prompt

* add prompt management via gitlab

* gitlab client

* gitlab client

* gitlab client

* fix lint issues

* fix lint issues

* remove router changes

---------

Co-authored-by: deepanshu <deepanshu.lulla@hq.bill.com>
2025-10-01 18:13:11 -07:00
Krrish Dholakia 757436f302 test: add unit test 2025-10-01 17:51:10 -07:00
Krrish Dholakia a83238a2db test: add unit tests 2025-10-01 17:02:05 -07:00
Ishaan Jaff 388761f52d [Fix] LiteLLM UI - Ensure OTEL settings are saved in DB after set on UI (#15118)
* fix: fix _add_callback_from_db_to_in_memory_litellm_callbacks

* test_add_callback_from_db_to_in_memory_litellm_callbacks

* fix otel

* fix: fix _add_callback_from_db_to_in_memory_litellm_callbacks
2025-10-01 15:33:22 -07:00
Ishaan Jaff e73d053de3 [Fix] Proxy Auth - Ensure LLM_API_KEYs can access pass through routes (#15115)
* test_virtual_key_llm_api_routes_allows_registered_pass_through_endpoints

* fix: is_registered_pass_through_route

* docs fix
2025-10-01 14:09:01 -07:00
Patrick Lafleur 8e5efd29df Fix comment 2025-10-01 16:39:26 -04:00