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 handle user message
Ishaan Jaff0f24f339f3cf
diff --git a/litellm/llms/OpenAI/o1_reasoning.py b/litellm/llms/OpenAI/o1_reasoning.pyindex 6d15319bbde..bcab17660d7 100644--- a/litellm/llms/OpenAI/o1_reasoning.py+++ b/litellm/llms/OpenAI/o1_reasoning.py@@ -15,6 +15,7 @@ import typesfrom typing import Any, List, Optional, Unionimport litellm+from litellm.types.llms.openai import AllMessageValues, ChatCompletionUserMessagefrom .openai import OpenAIConfig@@ -78,16 +79,19 @@ class OpenAIO1Config(OpenAIConfig):return Truereturn False- def o1_prompt_factory(self, messages: List[Any]):+ def o1_prompt_factory(self, messages: List[AllMessageValues]):"""Handles limitations of O-1 model family.- modalities: image => drop param (if user opts in to dropping param)- role: system ==> translate to role 'user'"""- for message in messages:+ for i, message in enumerate(messages):if message["role"] == "system":- message["role"] = "user"+ new_message = ChatCompletionUserMessage(+ content=message["content"], role="user"+ )+ messages[i] = new_message # Replace the old message with the new oneif isinstance(message["content"], list):new_content = []diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex c2a708663b7..6ed3954f833 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -6,7 +6,7 @@ from typing import Any, Dict, List, Literal, Optional, Tuple, Unionfrom openai._models import BaseModel as OpenAIObjectfrom openai.types.audio.transcription_create_params import FileTypes-from openai.types.completion_usage import CompletionUsage+from openai.types.completion_usage import CompletionTokensDetails, CompletionUsagefrom pydantic import ConfigDict, Field, PrivateAttrfrom typing_extensions import Callable, Dict, Required, TypedDict, override