The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: transform_rerank_response
Ishaan Jaffer8e7c593f51a8
diff --git a/litellm/llms/jina_ai/rerank/transformation.py b/litellm/llms/jina_ai/rerank/transformation.pyindex 3bd5a4847f3..3ba24680fd4 100644--- a/litellm/llms/jina_ai/rerank/transformation.py+++ b/litellm/llms/jina_ai/rerank/transformation.py@@ -98,9 +98,26 @@ class JinaAIRerankConfig(BaseRerankConfig):if _results is None:raise ValueError(f"No results found in the response={_json_response}")+ # Transform Jina AI's response format to match LiteLLM's expected format+ # Jina AI returns: {"index": 0, "relevance_score": 0.72, "document": "hello"}+ # LiteLLM expects: {"index": 0, "relevance_score": 0.72, "document": {"text": "hello"}}+ transformed_results = []+ for result in _results:+ transformed_result = {+ "index": result["index"],+ "relevance_score": result["relevance_score"],+ }+ # Convert document from string to dict format if it exists+ if "document" in result and isinstance(result["document"], str):+ transformed_result["document"] = {"text": result["document"]}+ elif "document" in result:+ # If it's already a dict, keep it as is+ transformed_result["document"] = result["document"]+ transformed_results.append(transformed_result)+return RerankResponse(id=_json_response.get("id") or str(uuid.uuid4()),- results=_results, # type: ignore+ results=transformed_results, # type: ignoremeta=rerank_meta,) # Return response