mirror of
https://github.com/tiennm99/litellm.git
synced 2026-06-29 19:04:28 +00:00
Add filtering at handler level
This commit is contained in:
@@ -58,6 +58,9 @@ from litellm.types.utils import (
|
||||
|
||||
from ...base import BaseLLM
|
||||
from ..common_utils import AnthropicError, process_anthropic_headers
|
||||
from litellm.anthropic_beta_headers_manager import (
|
||||
update_headers_with_filtered_beta,
|
||||
)
|
||||
from .transformation import AnthropicConfig
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -333,6 +336,10 @@ class AnthropicChatCompletion(BaseLLM):
|
||||
litellm_params=litellm_params,
|
||||
)
|
||||
|
||||
headers = update_headers_with_filtered_beta(
|
||||
headers=headers, provider=custom_llm_provider
|
||||
)
|
||||
|
||||
config = ProviderConfigManager.get_provider_chat_config(
|
||||
model=model,
|
||||
provider=LlmProviders(custom_llm_provider),
|
||||
|
||||
@@ -13,7 +13,9 @@ from litellm.llms.custom_httpx.http_handler import (
|
||||
)
|
||||
from litellm.types.utils import ModelResponse
|
||||
from litellm.utils import CustomStreamWrapper
|
||||
|
||||
from litellm.anthropic_beta_headers_manager import (
|
||||
update_headers_with_filtered_beta,
|
||||
)
|
||||
from ..base_aws_llm import BaseAWSLLM, Credentials
|
||||
from ..common_utils import BedrockError
|
||||
from .invoke_handler import AWSEventStreamDecoder, MockResponseIterator, make_call
|
||||
@@ -337,7 +339,11 @@ class BedrockConverseLLM(BaseAWSLLM):
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if extra_headers is not None:
|
||||
headers = {"Content-Type": "application/json", **extra_headers}
|
||||
|
||||
|
||||
# Filter beta headers in HTTP headers before making the request
|
||||
headers = update_headers_with_filtered_beta(
|
||||
headers=headers, provider="bedrock_converse"
|
||||
)
|
||||
### ROUTING (ASYNC, STREAMING, SYNC)
|
||||
if acompletion:
|
||||
if isinstance(client, HTTPHandler):
|
||||
|
||||
@@ -81,6 +81,9 @@ from litellm.types.llms.anthropic_skills import (
|
||||
ListSkillsResponse,
|
||||
Skill,
|
||||
)
|
||||
from litellm.anthropic_beta_headers_manager import (
|
||||
update_headers_with_filtered_beta,
|
||||
)
|
||||
from litellm.types.llms.openai import (
|
||||
CreateBatchRequest,
|
||||
CreateFileRequest,
|
||||
@@ -1858,6 +1861,13 @@ class BaseLLMHTTPHandler:
|
||||
api_key=api_key,
|
||||
api_base=api_base,
|
||||
)
|
||||
|
||||
print( "🔥headers before filtering", headers )
|
||||
print( "🔥custom_llm_provider", custom_llm_provider )
|
||||
headers = update_headers_with_filtered_beta(
|
||||
headers=headers, provider=custom_llm_provider
|
||||
)
|
||||
print( "🔥headers after filtering", headers )
|
||||
|
||||
logging_obj.update_environment_variables(
|
||||
model=model,
|
||||
|
||||
Reference in New Issue
Block a user