From 5c13008ebbd56edc2bc4635b0e3aa4f5912cb2e1 Mon Sep 17 00:00:00 2001 From: Bahtya Date: Mon, 27 Apr 2026 12:23:23 +0800 Subject: [PATCH] style: apply black formatting to predibase and xecguard modules Bahtya --- litellm/llms/predibase/chat/transformation.py | 13 ++++++++++--- .../guardrails/guardrail_hooks/xecguard/xecguard.py | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/litellm/llms/predibase/chat/transformation.py b/litellm/llms/predibase/chat/transformation.py index 8a2652adb64..3d251d24b0d 100644 --- a/litellm/llms/predibase/chat/transformation.py +++ b/litellm/llms/predibase/chat/transformation.py @@ -175,7 +175,10 @@ class PredibaseConfig(BaseConfig): completion_response["generated_text"] ) - if "details" in completion_response and "tokens" in completion_response["details"]: + if ( + "details" in completion_response + and "tokens" in completion_response["details"] + ): model_response.choices[0].finish_reason = map_finish_reason( completion_response["details"]["finish_reason"] ) @@ -203,7 +206,9 @@ class PredibaseConfig(BaseConfig): and "best_of_sequences" in completion_response["details"] ): choices_list = [] - for idx, item in enumerate(completion_response["details"]["best_of_sequences"]): + for idx, item in enumerate( + completion_response["details"]["best_of_sequences"] + ): sum_logprob = 0 for token in item["tokens"]: if token["logprob"] is not None: @@ -342,7 +347,9 @@ class PredibaseConfig(BaseConfig): base_url = os.getenv("PREDIBASE_API_BASE", "") completion_url = f"{base_url}/{tenant_id}/deployments/v2/llms/{model}" - should_stream = stream if stream is not None else optional_params.get("stream", False) + should_stream = ( + stream if stream is not None else optional_params.get("stream", False) + ) if should_stream is True: completion_url += "/generate_stream" else: diff --git a/litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py b/litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py index 2ec7efc3045..03d14bebdca 100644 --- a/litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py +++ b/litellm/proxy/guardrails/guardrail_hooks/xecguard/xecguard.py @@ -212,8 +212,11 @@ class XecGuardGuardrail(CustomGuardrail): isinstance(kwargs, dict) and "litellm_params" in kwargs and "metadata" in kwargs["litellm_params"] - and "standard_logging_guardrail_information"in kwargs["litellm_params"]["metadata"] - and kwargs["litellm_params"]["metadata"]["standard_logging_guardrail_information"] + and "standard_logging_guardrail_information" + in kwargs["litellm_params"]["metadata"] + and kwargs["litellm_params"]["metadata"][ + "standard_logging_guardrail_information" + ] ): return kwargs, result @@ -585,4 +588,4 @@ class XecGuardGuardrail(CustomGuardrail): return ( f"Blocked by XecGuard grounding: rules=[{rules_str}] " f"trace_id={trace_id} rationale={rationale}" - ) \ No newline at end of file + )