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(factory.py): handle missing 'content' in cohere assistant messages
miraclebakelaser97f714d2b02d
diff --git a/litellm/llms/prompt_templates/factory.py b/litellm/llms/prompt_templates/factory.pyindex 0786f1ec3cc..8dbab29adb3 100644--- a/litellm/llms/prompt_templates/factory.py+++ b/litellm/llms/prompt_templates/factory.py@@ -1781,7 +1781,7 @@ def cohere_messages_pt_v2(assistant_tool_calls: List[ToolCallObject] = []## MERGE CONSECUTIVE ASSISTANT CONTENT ##while msg_i < len(messages) and messages[msg_i]["role"] == "assistant":- if isinstance(messages[msg_i]["content"], list):+ if messages[msg_i].get("content", None) is not None and isinstance(messages[msg_i]["content"], list):for m in messages[msg_i]["content"]:if m.get("type", "") == "text":assistant_content += m["text"]