-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[Feat] Main : Add provider dispatcher with 24x performance improvement #15238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Replace linear if-else provider routing with O(1) dispatcher lookup. Migrate 12 providers to new architecture, achieving significant speedup.
…ST 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 <[email protected]>
) * 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
Replace linear if-else provider routing with O(1) dispatcher lookup. Migrate 12 providers to new architecture, achieving significant speedup. update docs update docs
…itellm into litellm_cleanup_main_2
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need a new 'dispatch' here vs. just using the providerconfig.get_chat_provider_config?
Line 6888 in 27c64c9
def get_provider_chat_config( # noqa: PLR0915 |
Reference implementation on rerank:
litellm/litellm/rerank_api/main.py
Line 130 in 27c64c9
rerank_provider_config: BaseRerankConfig = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 can we just re-use the existing OpenaI config file to implement the dispatcher ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, I hadn't seen that on the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 can we just re-use the existing OpenaI config file to implement the dispatcher ?
Title
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🧹 Refactoring
Changes
Test Results