mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
chore(cloudflare): satisfy type-discipline and complexity gates
This commit is contained in:
parent
000ec81170
commit
30fdb6226b
2 changed files with 8 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
from collections.abc import Mapping, Sequence
|
||||
from typing import Final
|
||||
|
||||
import httpx
|
||||
from typing_extensions import NotRequired, ReadOnly, TypedDict
|
||||
|
|
@ -32,11 +33,6 @@ class CohereRerankParams(TypedDict):
|
|||
return_documents: NotRequired[ReadOnly[bool]]
|
||||
|
||||
|
||||
class CloudflareHeaders(TypedDict):
|
||||
Authorization: str
|
||||
accept: str
|
||||
|
||||
|
||||
class LoggingAdditionalArgs(TypedDict):
|
||||
complete_input_dict: ReadOnly[Mapping[str, object]]
|
||||
|
||||
|
|
@ -122,13 +118,12 @@ class CloudflareRerankConfig(BaseRerankConfig):
|
|||
api_key = api_key or get_secret_str("CLOUDFLARE_API_KEY")
|
||||
if api_key is None:
|
||||
raise ValueError("Missing Cloudflare API Key - set CLOUDFLARE_API_KEY or pass api_key explicitly")
|
||||
cloudflare_headers = CloudflareHeaders(
|
||||
Authorization=f"Bearer {api_key}",
|
||||
accept="application/json",
|
||||
)
|
||||
cloudflare_headers["content-type"] = "application/json"
|
||||
cloudflare_headers.update(headers)
|
||||
return cloudflare_headers
|
||||
default_headers: Final = {
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
}
|
||||
return {**default_headers, **headers}
|
||||
|
||||
def get_complete_url(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -8495,7 +8495,7 @@ class ProviderConfigManager:
|
|||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_provider_rerank_config(
|
||||
def get_provider_rerank_config( # noqa: C901 # provider dispatch; one branch per rerank provider
|
||||
model: str,
|
||||
provider: LlmProviders,
|
||||
api_base: str | None,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue