mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix format and lint
This commit is contained in:
parent
25edb2f228
commit
ecd72752d5
5 changed files with 50 additions and 38 deletions
|
|
@ -5632,9 +5632,10 @@ def emit_standard_logging_payload(payload: StandardLoggingPayload):
|
|||
try:
|
||||
print(json.dumps(payload, indent=4, default=str)) # noqa
|
||||
except Exception as e:
|
||||
print(
|
||||
"Error serializing standard logging payload for debug output:",
|
||||
str(e),
|
||||
verbose_logger.exception(
|
||||
"Error serializing standard logging payload for debug output: {}".format(
|
||||
str(e)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -147,9 +147,7 @@ async def get_access_token_async(
|
|||
)
|
||||
|
||||
scope = scope or litellm_params.get("gigachat_scope") or _get_scope()
|
||||
auth_url = (
|
||||
auth_url or litellm_params.get("gigachat_auth_url") or _get_auth_url()
|
||||
)
|
||||
auth_url = auth_url or litellm_params.get("gigachat_auth_url") or _get_auth_url()
|
||||
|
||||
# Check cache
|
||||
cache_key = f"gigachat_token:{credentials[:16]}"
|
||||
|
|
|
|||
|
|
@ -76,7 +76,11 @@ class GigaChatModelResponseIterator:
|
|||
usage_data = chunk.get("usage", {})
|
||||
if usage_data:
|
||||
usage = convert_usage(usage_data)
|
||||
usage_block = ChatCompletionUsageBlock(**usage.dict())
|
||||
usage_block = ChatCompletionUsageBlock(
|
||||
prompt_tokens=usage.prompt_tokens,
|
||||
completion_tokens=usage.completion_tokens,
|
||||
total_tokens=usage.total_tokens,
|
||||
)
|
||||
|
||||
if finish_reason is not None:
|
||||
is_finished = True
|
||||
|
|
|
|||
|
|
@ -93,44 +93,50 @@ class GigaChatPassthroughConfig(BasePassthroughConfig):
|
|||
if provider_chat_config is None:
|
||||
raise ValueError(f"No provider config found for model: {model}")
|
||||
|
||||
litellm_model_response: ModelResponse = provider_chat_config.transform_response(
|
||||
model=model,
|
||||
messages=request_data.get("messages", []),
|
||||
raw_response=httpx_response,
|
||||
model_response=ModelResponse(),
|
||||
logging_obj=logging_obj,
|
||||
optional_params={},
|
||||
litellm_params={},
|
||||
api_key="",
|
||||
request_data=request_data,
|
||||
encoding=encoding,
|
||||
litellm_model_response: ModelResponse = (
|
||||
provider_chat_config.transform_response(
|
||||
model=model,
|
||||
messages=request_data.get("messages", []),
|
||||
raw_response=httpx_response,
|
||||
model_response=ModelResponse(),
|
||||
logging_obj=logging_obj,
|
||||
optional_params={},
|
||||
litellm_params={},
|
||||
api_key="",
|
||||
request_data=request_data,
|
||||
encoding=encoding,
|
||||
)
|
||||
)
|
||||
|
||||
return litellm_model_response
|
||||
|
||||
|
||||
if "embeddings" in endpoint:
|
||||
|
||||
provider_embedding_config = ProviderConfigManager.get_provider_embedding_config(
|
||||
provider=LlmProviders(custom_llm_provider),
|
||||
model=model,
|
||||
|
||||
provider_embedding_config = (
|
||||
ProviderConfigManager.get_provider_embedding_config(
|
||||
provider=LlmProviders(custom_llm_provider),
|
||||
model=model,
|
||||
)
|
||||
)
|
||||
|
||||
if provider_embedding_config is None:
|
||||
raise ValueError(f"No provider config found for model: {model}")
|
||||
|
||||
litellm_embedding_response: EmbeddingResponse = provider_embedding_config.transform_embedding_response(
|
||||
model=model,
|
||||
raw_response=httpx_response,
|
||||
model_response=EmbeddingResponse(),
|
||||
logging_obj=logging_obj,
|
||||
optional_params={},
|
||||
api_key="",
|
||||
request_data=request_data,
|
||||
litellm_params={},
|
||||
litellm_embedding_response: EmbeddingResponse = (
|
||||
provider_embedding_config.transform_embedding_response(
|
||||
model=model,
|
||||
raw_response=httpx_response,
|
||||
model_response=EmbeddingResponse(),
|
||||
logging_obj=logging_obj,
|
||||
optional_params={},
|
||||
api_key="",
|
||||
request_data=request_data,
|
||||
litellm_params={},
|
||||
)
|
||||
)
|
||||
|
||||
return litellm_embedding_response
|
||||
|
||||
|
||||
return None
|
||||
|
||||
def handle_logging_collected_chunks(
|
||||
|
|
|
|||
|
|
@ -2461,7 +2461,7 @@ async def gigachat_proxy_route(
|
|||
is_router_model = False
|
||||
|
||||
model = request_body.get("model")
|
||||
if model:
|
||||
if model:
|
||||
is_router_model = is_passthrough_request_using_router_model(
|
||||
request_body, llm_router
|
||||
)
|
||||
|
|
@ -2470,7 +2470,6 @@ async def gigachat_proxy_route(
|
|||
status_code=400, detail={"error": "Model is required in request body"}
|
||||
)
|
||||
|
||||
|
||||
# If router model, use dedicated router passthrough handler
|
||||
# This uses the same common processing path as non-router models
|
||||
if model and is_router_model and llm_router:
|
||||
|
|
@ -2582,8 +2581,6 @@ async def handle_gigachat_passthrough_router_model(
|
|||
Returns:
|
||||
Response or StreamingResponse depending on endpoint type
|
||||
"""
|
||||
from fastapi import Response as FastAPIResponse
|
||||
|
||||
from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing
|
||||
|
||||
# Detect streaming based on request body
|
||||
|
|
@ -2628,7 +2625,13 @@ async def handle_gigachat_passthrough_router_model(
|
|||
data["custom_llm_provider"] = "gigachat"
|
||||
|
||||
# Remove sensitive keys from data
|
||||
keys = ["gigachat_auth_url", "gigachat_access_token", "gigachat_scope", "api_base", "api_key"]
|
||||
keys = [
|
||||
"gigachat_auth_url",
|
||||
"gigachat_access_token",
|
||||
"gigachat_scope",
|
||||
"api_base",
|
||||
"api_key",
|
||||
]
|
||||
for key in keys:
|
||||
data.pop(key, None)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue