-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix: Use valid CallTypes enum value in embeddings endpoint #16328
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
Merged
krrishdholakia
merged 3 commits into
BerriAI:main
from
Chesars:fix/embeddings-call-type-typo
Nov 7, 2025
Merged
fix: Use valid CallTypes enum value in embeddings endpoint #16328
krrishdholakia
merged 3 commits into
BerriAI:main
from
Chesars:fix/embeddings-call-type-typo
Nov 7, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixed bug where the `/embeddings` endpoint was passing `call_type="embeddings"` to guardrail hooks, but "embeddings" is not a valid value in the CallTypes enum. Changed to use `call_type="aembedding"` (async embedding) which is the correct CallTypes enum value and matches the route_type used in the same function. Added unit tests to verify: - "embeddings" is not a valid CallTypes enum value - "aembedding" is the correct valid value - The fix prevents ValueError when guardrails are enabled Fixes BerriAI#16240
|
@Chesars is attempting to deploy a commit to the CLERKIEAI Team on Vercel. A member of the Team first needs to authorize it. |
Chesars
added a commit
to Chesars/litellm
that referenced
this pull request
Nov 7, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods: - pre_call_hook overloads (lines 872, 893, 913) - during_call_hook (line 1052) - _process_guardrail_callback (line 803) Add type: ignore comments where ProxyLogging calls CustomLogger callbacks (lines 1021, 1106) to handle type mismatch between ProxyLogging's broader Literal (includes "aembedding") and CustomLogger's narrower Literal (doesn't include "aembedding"). Related to PR BerriAI#16328 which changed embeddings endpoint to use call_type="aembedding" for async operations.
This was referenced Nov 7, 2025
ishaan-jaff
pushed a commit
that referenced
this pull request
Nov 7, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods: - pre_call_hook overloads (lines 872, 893, 913) - during_call_hook (line 1052) - _process_guardrail_callback (line 803) Add type: ignore comments where ProxyLogging calls CustomLogger callbacks (lines 1021, 1106) to handle type mismatch between ProxyLogging's broader Literal (includes "aembedding") and CustomLogger's narrower Literal (doesn't include "aembedding"). Related to PR #16328 which changed embeddings endpoint to use call_type="aembedding" for async operations.
yashwantbezawada
added a commit
to yashwantbezawada/litellm
that referenced
this pull request
Nov 8, 2025
…erriAI#16362) ## Problem The `call_type` parameter's Literal type hint was duplicated across 36+ files (CustomLogger subclasses), causing: 1. **DRY violation**: Adding new call types required editing 36+ files 2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive types than the base class 3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals ## Solution Created centralized TypeAliases in `litellm/types/callbacks.py`: - `PreCallHookCallType`: For async_pre_call_hook methods - `ModerationHookCallType`: For async_moderation_hook methods Updated 36 files to use these TypeAliases instead of duplicating Literal definitions. ## Benefits - ✅ Single source of truth for call_type values - ✅ Easier maintenance: new types added in one place - ✅ Fixes LSP violations: all subclasses accept same types as base - ✅ Consistent type checking across all CustomLogger implementations - ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328 ## Files Changed - New: `litellm/types/callbacks.py` (TypeAlias definitions) - Updated: `litellm/integrations/custom_logger.py` (base class) - Updated: 35 CustomLogger subclass files across: - `litellm/proxy/guardrails/guardrail_hooks/` - `litellm/proxy/hooks/` - `enterprise/` Fixes BerriAI#16362 Related: BerriAI#16240, BerriAI#16328
6 tasks
yashwantbezawada
added a commit
to yashwantbezawada/litellm
that referenced
this pull request
Nov 8, 2025
…erriAI#16362) ## Problem The `call_type` parameter's Literal type hint was duplicated across 36+ files (CustomLogger subclasses), causing: 1. **DRY violation**: Adding new call types required editing 36+ files 2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive types than the base class 3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals ## Solution Created centralized TypeAliases in `litellm/types/callbacks.py`: - `PreCallHookCallType`: For async_pre_call_hook methods - `ModerationHookCallType`: For async_moderation_hook methods Updated 36 files to use these TypeAliases instead of duplicating Literal definitions. ## Benefits - ✅ Single source of truth for call_type values - ✅ Easier maintenance: new types added in one place - ✅ Fixes LSP violations: all subclasses accept same types as base - ✅ Consistent type checking across all CustomLogger implementations - ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328 ## Files Changed - New: `litellm/types/callbacks.py` (TypeAlias definitions) - Updated: `litellm/integrations/custom_logger.py` (base class) - Updated: 35 CustomLogger subclass files across: - `litellm/proxy/guardrails/guardrail_hooks/` - `litellm/proxy/hooks/` - `enterprise/` Fixes BerriAI#16362 Related: BerriAI#16240, BerriAI#16328
yashwantbezawada
added a commit
to yashwantbezawada/litellm
that referenced
this pull request
Nov 8, 2025
…erriAI#16362) ## Problem The `call_type` parameter's Literal type hint was duplicated across 36+ files (CustomLogger subclasses), causing: 1. **DRY violation**: Adding new call types required editing 36+ files 2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive types than the base class 3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals ## Solution Created centralized TypeAliases in `litellm/types/callbacks.py`: - `PreCallHookCallType`: For async_pre_call_hook methods - `ModerationHookCallType`: For async_moderation_hook methods Updated 36 files to use these TypeAliases instead of duplicating Literal definitions. ## Benefits - ✅ Single source of truth for call_type values - ✅ Easier maintenance: new types added in one place - ✅ Fixes LSP violations: all subclasses accept same types as base - ✅ Consistent type checking across all CustomLogger implementations - ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328 ## Files Changed - New: `litellm/types/callbacks.py` (TypeAlias definitions) - Updated: `litellm/integrations/custom_logger.py` (base class) - Updated: 35 CustomLogger subclass files across: - `litellm/proxy/guardrails/guardrail_hooks/` - `litellm/proxy/hooks/` - `enterprise/` Fixes BerriAI#16362 Related: BerriAI#16240, BerriAI#16328
LingXuanYin
pushed a commit
to talesofai/litellm
that referenced
this pull request
Nov 14, 2025
…6328) * Fix embeddings endpoint call_type to use valid CallTypes enum value Fixed bug where the `/embeddings` endpoint was passing `call_type="embeddings"` to guardrail hooks, but "embeddings" is not a valid value in the CallTypes enum. Changed to use `call_type="aembedding"` (async embedding) which is the correct CallTypes enum value and matches the route_type used in the same function. Added unit tests to verify: - "embeddings" is not a valid CallTypes enum value - "aembedding" is the correct valid value - The fix prevents ValueError when guardrails are enabled Fixes BerriAI#16240 * Inline embeddings call type regression check * Ensure embedding test preserves proxy metadata
LingXuanYin
pushed a commit
to talesofai/litellm
that referenced
this pull request
Nov 14, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods: - pre_call_hook overloads (lines 872, 893, 913) - during_call_hook (line 1052) - _process_guardrail_callback (line 803) Add type: ignore comments where ProxyLogging calls CustomLogger callbacks (lines 1021, 1106) to handle type mismatch between ProxyLogging's broader Literal (includes "aembedding") and CustomLogger's narrower Literal (doesn't include "aembedding"). Related to PR BerriAI#16328 which changed embeddings endpoint to use call_type="aembedding" for async operations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Title
fix: Use valid CallTypes enum value in embeddings endpoint
Relevant issues
Fixes #16240
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-unitType
🐛 Bug Fix
Summary
'embeddings' is not a valid CallTypeserror when guardrails are enabled.Changes
call_type="embeddings"tocall_type="aembedding"in embeddings endpoint (proxy_server.pylines 5084, 5092)Root Cause
The embeddings endpoint used
call_type="embeddings"(invalid) instead ofcall_type="aembedding"(valid CallTypes enum value).Bug only appeared with guardrails enabled because guardrails validate the call_type against the CallTypes enum.
Test Plan
tests/proxy_unit_tests/test_embeddings_call_type.py