From af67c3576ff4249cf14c03a0151ae319de9f3fbe Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Mon, 4 Aug 2025 23:10:46 -0700 Subject: [PATCH] fix OCI linting errors (#13279) * fix(types/llms/oci.py): fix linting errors * fix(oci.py): fix linting error * fix(oci.py): fix linting errors * fix: fix linting error * fix: fix linting error --- litellm/llms/oci/chat/transformation.py | 8 ++-- litellm/types/llms/oci.py | 58 ++++++++++++------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/litellm/llms/oci/chat/transformation.py b/litellm/llms/oci/chat/transformation.py index 5175979e7b8..3524817da63 100644 --- a/litellm/llms/oci/chat/transformation.py +++ b/litellm/llms/oci/chat/transformation.py @@ -609,9 +609,9 @@ open_ai_to_generic_oci_role_map: Dict[str, OCIRoles] = { def adapt_messages_to_generic_oci_standard_content_message( - role: str, content: str | list + role: str, content: Union[str, list] ) -> OCIMessage: - new_content: list[OCIContentPartUnion] = [] + new_content: List[OCIContentPartUnion] = [] if isinstance(content, str): return OCIMessage( role=open_ai_to_generic_oci_role_map[role], @@ -787,8 +787,8 @@ def adapt_tool_definition_to_oci_standard(tools: List[Dict], vendor: OCIVendors) def adapt_tools_to_openai_standard( - tools: list[OCIToolCall], -) -> list[ChatCompletionMessageToolCall]: + tools: List[OCIToolCall], +) -> List[ChatCompletionMessageToolCall]: new_tools = [] for tool in tools: new_tool = ChatCompletionMessageToolCall( diff --git a/litellm/types/llms/oci.py b/litellm/types/llms/oci.py index cb76bf87473..52c1b2943f7 100644 --- a/litellm/types/llms/oci.py +++ b/litellm/types/llms/oci.py @@ -1,9 +1,9 @@ from __future__ import annotations -from typing import Any, Literal, Union +from enum import Enum +from typing import Any, Dict, List, Literal, Optional, Union from pydantic import BaseModel -from enum import Enum OCIRoles = Literal["SYSTEM", "USER", "ASSISTANT", "TOOL"] @@ -24,7 +24,7 @@ class OCIVendors(Enum): class OCIContentPart(BaseModel): """Base model for content parts in an OCI message.""" - type: str + pass class OCITextContentPart(OCIContentPart): @@ -59,9 +59,9 @@ class OCIToolDefinition(BaseModel): """Defines a tool that can be used by the model.""" type: Literal["FUNCTION"] = "FUNCTION" - name: str | None = None - description: str | None = None - parameters: dict | None = None + name: Optional[str] = None + description: Optional[str] = None + parameters: Optional[dict] = None # --- Message Models (Request and Response) --- @@ -71,9 +71,9 @@ class OCIMessage(BaseModel): """Model for a single message in the request/response payload.""" role: OCIRoles - content: list[OCIContentPartUnion] | None = None - toolCalls: list[OCIToolCall] | None = None - toolCallId: str | None = None + content: Optional[List[OCIContentPartUnion]] = None + toolCalls: Optional[List[OCIToolCall]] = None + toolCallId: Optional[str] = None # --- Request Payload Models --- @@ -83,17 +83,17 @@ class OCIChatRequestPayload(BaseModel): """Internal 'chatRequest' payload for the OCI API.""" apiFormat: str - messages: list[OCIMessage] - tools: list[OCIToolDefinition] | None = None + messages: List[OCIMessage] + tools: Optional[List[OCIToolDefinition]] = None isStream: bool = False - numGenerations: int | None = None - maxTokens: int | None = None - temperature: float | None = None - topP: float | None = None - stop: list[str] | None = None - seed: int | None = None - frequencyPenalty: float | None = None - presencePenalty: float | None = None + numGenerations: Optional[int] = None + maxTokens: Optional[int] = None + temperature: Optional[float] = None + topP: Optional[float] = None + stop: Optional[List[str]] = None + seed: Optional[int] = None + frequencyPenalty: Optional[float] = None + presencePenalty: Optional[float] = None class OCIServingMode(BaseModel): @@ -142,8 +142,8 @@ class OCIResponseChoice(BaseModel): index: int message: OCIMessage - finishReason: str | None - logprobs: dict[str, Any] | None = None + finishReason: Optional[str] = None + logprobs: Optional[Dict[str, Any]] = None class OCIChatResponse(BaseModel): @@ -151,7 +151,7 @@ class OCIChatResponse(BaseModel): apiFormat: str timeCreated: str - choices: list[OCIResponseChoice] + choices: List[OCIResponseChoice] usage: OCIResponseUsage @@ -169,15 +169,15 @@ class OCICompletionResponse(BaseModel): class OCIStreamDelta(BaseModel): """The content delta in a streaming chunk.""" - content: list[OCIContentPartUnion] | None = None - role: str | None = None - toolCalls: list[OCIToolCall] | None = None + content: Optional[List[OCIContentPartUnion]] = None + role: Optional[str] = None + toolCalls: Optional[List[OCIToolCall]] = None class OCIStreamChunk(BaseModel): """Model for a single SSE event chunk from OCI.""" - finishReason: str | None = None - message: OCIStreamDelta | None = None - pad: str | None = None - index: int | None = None + finishReason: Optional[str] = None + message: Optional[OCIStreamDelta] = None + pad: Optional[str] = None + index: Optional[int] = None