Skip to content

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]

Add vertex ai meta llama 4 support + handle tool call result in content for vertex ai (#10492)

Krish Dholakia9cc39af1316b
diff --git a/.github/workflows/test-linting.yml b/.github/workflows/test-linting.yml
index bb0e7adcc03..0e1c895c3a4 100644
--- a/.github/workflows/test-linting.yml
+++ b/.github/workflows/test-linting.yml
@@ -24,6 +24,8 @@ jobs:
run: |
pip install openai==1.68.2
poetry install --with dev
+ pip install openai==1.68.2
+
- name: Run Black formatting
diff --git a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
index e412e3f35f1..ca355fe0ed3 100644
--- a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
+++ b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
@@ -273,12 +273,14 @@ def _extract_reasoning_content(message: dict) -> Tuple[Optional[str], Optional[s
Returns:
tuple[Optional[str], Optional[str]]: A tuple of (reasoning_content, content)
"""
+ message_content = message.get("content")
if "reasoning_content" in message:
return message["reasoning_content"], message["content"]
elif "reasoning" in message:
return message["reasoning"], message["content"]
- else:
- return _parse_content_for_reasoning(message.get("content"))
+ elif isinstance(message_content, str):
+ return _parse_content_for_reasoning(message_content)
+ return None, message_content
class LiteLLMResponseObjectHandler:
@@ -509,9 +511,9 @@ def convert_to_model_response_object( # noqa: PLR0915
provider_specific_fields["thinking_blocks"] = thinking_blocks
if reasoning_content:
- provider_specific_fields["reasoning_content"] = (
- reasoning_content
- )
+ provider_specific_fields[
+ "reasoning_content"
+ ] = reasoning_content
message = Message(
content=content,
diff --git a/litellm/litellm_core_utils/prompt_templates/common_utils.py b/litellm/litellm_core_utils/prompt_templates/common_utils.py
index 963ab33f522..b6af4a710ad 100644
--- a/litellm/litellm_core_utils/prompt_templates/common_utils.py
+++ b/litellm/litellm_core_utils/prompt_templates/common_utils.py
@@ -12,6 +12,8 @@ from litellm.types.llms.openai import (
AllMessageValues,
ChatCompletionAssistantMessage,
ChatCompletionFileObject,
+ ChatCompletionResponseMessage,
+ ChatCompletionToolParam,
ChatCompletionUserMessage,
)
from litellm.types.utils import (
@@ -97,7 +99,9 @@ def strip_none_values_from_message(message: AllMessageValues) -> AllMessageValue
return cast(AllMessageValues, {k: v for k, v in message.items() if v is not None})
-def convert_content_list_to_str(message: AllMessageValues) -> str:
+def convert_content_list_to_str(
+ message: Union[AllMessageValues, ChatCompletionResponseMessage]
+) -> str:
"""
- handles scenario where content is list and not string
- content list is just text, and no images
@@ -556,3 +560,16 @@ def _get_image_mime_type_from_url(url: str) -> Optional[str]:
return mime_type
return None
+
+
+def get_tool_call_names(tools: List[ChatCompletionToolParam]) -> List[str]:
+ """
+ Get tool call names from tools
+ """
+ tool_call_names: List[str] = []
+ for tool in tools:
+ if tool.get("type") == "function":
+ tool_call_name = tool.get("function", {}).get("name")
+ if tool_call_name:
+ tool_call_names.append(tool_call_name)
+ return tool_call_names
diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py
index 7eb3d829631..06f525719cf 100644
--- a/litellm/llms/databricks/chat/transformation.py
+++ b/litellm/llms/databricks/chat/transformation.py
@@ -351,7 +351,7 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig):
thinking_blocks.append(thinking_block)
return reasoning_content, thinking_blocks
- def _transform_choices(
+ def _transform_dbrx_choices(
self, choices: List[DatabricksChoice], json_mode: Optional[bool] = None
) -> List[Choices]:
transformed_choices = []
@@ -462,7 +462,7 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig):
model_response.created = completion_response["created"]
setattr(model_response, "usage", Usage(**completion_response["usage"]))
- model_response.choices = self._transform_choices( # type: ignore
+ model_response.choices = self._transform_dbrx_choices( # type: ignore
choices=completion_response["choices"],
json_mode=json_mode,
)
diff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.py
index f7462d11f0c..9e3d9e5fc91 100644
--- a/litellm/llms/openai/chat/gpt_transformation.py
+++ b/litellm/llms/openai/chat/gpt_transformation.py
@@ -16,6 +16,12 @@ from typing import (
import httpx
import litellm
+from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response import (
+ _extract_reasoning_content,
+ _handle_invalid_parallel_tool_calls,
+ _should_convert_tool_call_to_json_mode,
+)
+from litellm.litellm_core_utils.prompt_templates.common_utils import get_tool_call_names
from litellm.llms.base_llm.base_model_iterator import BaseModelResponseIterator
from litellm.llms.base_llm.base_utils import BaseLLMModelInfo
from litellm.llms.base_llm.chat.transformation import BaseConfig, BaseLLMException
@@ -26,8 +32,16 @@ from litellm.types.llms.openai import (
ChatCompletionFileObjectFile,
ChatCompletionImageObject,
ChatCompletionImageUrlObject,
+ OpenAIChatCompletionChoices,
+)
+from litellm.types.utils import (
+ ChatCompletionMessageToolCall,
+ Choices,
+ Function,
+ Message,
+ ModelResponse,
+ ModelResponseStream,
)
-from litellm.types.utils import ModelResponse, ModelResponseStream
from litellm.utils import convert_to_model_response_object
from ..common_utils import OpenAIError
@@ -240,6 +254,126 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig):
**optional_params,
}
+ def _passed_in_tools(self, optional_params: dict) -> bool:
+ return optional_params.get("tools", None) is not None
+
+ def _check_and_fix_if_content_is_tool_call(
+ self, content: str, optional_params: dict
+ ) -> Optional[ChatCompletionMessageToolCall]:
+ """
+ Check if the content is a tool call
+ """
+ import json
+
+ if not self._passed_in_tools(optional_params):
+ return None
+ tool_call_names = get_tool_call_names(optional_params.get("tools", []))
+ try:
+ json_content = json.loads(content)
+ if (
+ json_content.get("type") == "function"
+ and json_content.get("name") in tool_call_names
+ ):
+ return ChatCompletionMessageToolCall(
+ function=Function(
+ name=json_content.get("name"),
+ arguments=json_content.get("arguments"),
+ )
+ )
+ except Exception:
+ return None
+
+ return None
+
+ def _get_finish_reason(self, message: Message, received_finish_reason: str) -> str:
+ if message.tool_calls is not None:
+ return "tool_calls"
+ else:
+ return received_finish_reason
+
+ def _transform_choices(
+ self,
+ choices: List[OpenAIChatCompletionChoices],
+ json_mode: Optional[bool] = None,
+ optional_params: Optional[dict] = None,
+ ) -> List[Choices]:
+ transformed_choices = []
+
+ for choice in choices:
+ ## HANDLE JSON MODE - anthropic returns single function call]
+ tool_calls = choice["message"].get("tool_calls", None)
+ new_tool_calls: Optional[List[ChatCompletionMessageToolCall]] = None
+ message_content = choice["message"].get("content", None)
+ if tool_calls is not None:
+ _openai_tool_calls = []
+ for _tc in tool_calls:
+ _openai_tc = ChatCompletionMessageToolCall(**_tc) # type: ignore
+ _openai_tool_calls.append(_openai_tc)
+ fixed_tool_calls = _handle_invalid_parallel_tool_calls(
+ _openai_tool_calls
+ )
+
+ if fixed_tool_calls is not None:
+ new_tool_calls = fixed_tool_calls
+ elif (
+ optional_params is not None
+ and message_content
+ and isinstance(message_content, str)
+ ):
+ new_tool_call = self._check_and_fix_if_content_is_tool_call(
+ message_content, optional_params
+ )
+ if new_tool_call is not None:
+ choice["message"]["content"] = None # remove the content
+ new_tool_calls = [new_tool_call]
+
+ translated_message: Optional[Message] = None
+ finish_reason: Optional[str] = None
+ if new_tool_calls and _should_convert_tool_call_to_json_mode(
+ tool_calls=new_tool_calls,
+ convert_tool_call_to_json_mode=json_mode,
+ ):
+ # to support response_format on claude models
+ json_mode_content_str: Optional[str] = (
+ str(new_tool_calls[0]["function"].get("arguments", "")) or None
+ )
+ if json_mode_content_str is not None:
+ translated_message = Message(content=json_mode_content_str)
+ finish_reason = "stop"
+
+ if translated_message is None:
+ ## get the reasoning content
+ (
+ reasoning_content,
+ content_str,
+ ) = _extract_reasoning_content(cast(dict, choice["message"]))
+
+ translated_message = Message(
+ role="assistant",
+ content=content_str,
+ reasoning_content=reasoning_content,
+ thinking_blocks=None,
+ tool_calls=new_tool_calls,
+ )
+
+ if finish_reason is None:
+ finish_reason = choice["finish_reason"]
+
+ translated_choice = Choices(
+ finish_reason=finish_reason,
+ index=choice["index"],
+ message=translated_message,
+ logprobs=None,
+ enhancements=None,
+ )
+
+ translated_choice.finish_reason = self._get_finish_reason(
+ translated_message, choice["finish_reason"]
+ )
+ transformed_choices.append(translated_choice)
+
+ return transformed_choices
+
def transform_response(
self,
model: str,
diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py
index cf46f4a7429..7e965313a0b 100644
--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py
+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/transformation.py
@@ -1,7 +1,14 @@
import types
-from typing import Optional
+from typing import Any, List, Optional
+import httpx
+
+from litellm.litellm_core_utils.litellm_logging import Logging as LiteLLMLoggingObj
from litellm.llms.openai.chat.gpt_transformation import OpenAIGPTConfig
+from litellm.types.llms.openai import AllMessageValues, OpenAIChatCompletionResponse
+from litellm.types.utils import ModelResponse, Usage
+
+from ...common_utils import VertexAIError
class VertexAILlama3Config(OpenAIGPTConfig):
@@ -71,3 +78,49 @@ class VertexAILlama3Config(OpenAIGPTConfig):
model=model,
drop_params=drop_params,
)
+
+ def transform_response(
+ self,
+ model: str,
+ raw_response: httpx.Response,
+ model_response: ModelResponse,
+ logging_obj: LiteLLMLoggingObj,
+ request_data: dict,
+ messages: List[AllMessageValues],
+ optional_params: dict,
+ litellm_params: dict,
+ encoding: Any,
+ api_key: Optional[str] = None,
+ json_mode: Optional[bool] = None,
+ ) -> ModelResponse:
+ ## LOGGING
+ logging_obj.post_call(
+ input=messages,
+ api_key=api_key,
+ original_response=raw_response.text,
+ additional_args={"complete_input_dict": request_data},
+ )
+
+ ## RESPONSE OBJECT
+ try:
+ completion_response = OpenAIChatCompletionResponse(**raw_response.json()) # type: ignore
+ except Exception as e:
+ response_headers = getattr(raw_response, "headers", None)
+ raise VertexAIError(
+ message="Unable to get json response - {}, Original Response: {}".format(
+ str(e), raw_response.text
+ ),
+ status_code=raw_response.status_code,
+ headers=response_headers,
+ )
+ model_response.model = completion_response["model"]
+ model_response.id = completion_response["id"]
+ model_response.created = completion_response["created"]
+ setattr(model_response, "usage", Usage(**completion_response["usage"]))
+
+ model_response.choices = self._transform_choices( # type: ignore
+ choices=completion_response["choices"],
+ json_mode=json_mode,
+ )
+
+ return model_response
diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
index b8d2658f807..9d67b4e8f9a 100644
--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/main.py
@@ -9,8 +9,11 @@ import litellm
from litellm import LlmProviders
from litellm.utils import ModelResponse
+from ...custom_httpx.llm_http_handler import BaseLLMHTTPHandler
from ..vertex_llm_base import VertexBase
+base_llm_http_handler = BaseLLMHTTPHandler()
+
class VertexPartnerProvider(str, Enum):
mistralai = "mistralai"
@@ -214,7 +217,24 @@ class VertexAIPartnerModels(VertexBase):
client=client,
custom_llm_provider=LlmProviders.VERTEX_AI.value,
)
-
+ elif "llama" in model:
+ return base_llm_http_handler.completion(
+ model=model,
+ stream=stream,
+ messages=messages,
+ acompletion=acompletion,
+ api_base=api_base,
+ model_response=model_response,
+ optional_params=optional_params,
+ litellm_params=litellm_params,
+ custom_llm_provider="vertex_ai",
+ timeout=timeout,
+ headers=headers,
+ encoding=encoding,
+ api_key=access_token,
+ logging_obj=logging_obj, # model call logging done inside the class as we make need to modify I/O to fit aleph alpha's requirements
+ client=client,
+ )
return openai_like_chat_completions.completion(
model=model,
messages=messages,
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index bf958815b93..f771296c74b 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -6309,6 +6309,62 @@
"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
"supports_tool_choice": true
},
+ "vertex_ai/meta/llama-4-scout-17b-16e-instruct-maas": {
+ "max_tokens": 10e6,
+ "max_input_tokens": 10e6,
+ "max_output_tokens": 10e6,
+ "input_cost_per_token": 0.25e-6,
+ "output_cost_per_token": 0.70e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-scout-128b-16e-instruct-maas": {
+ "max_tokens": 10e6,
+ "max_input_tokens": 10e6,
+ "max_output_tokens": 10e6,
+ "input_cost_per_token": 0.25e-6,
+ "output_cost_per_token": 0.70e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-maverick-17b-128e-instruct-maas": {
+ "max_tokens": 1e6,
+ "max_input_tokens": 1e6,
+ "max_output_tokens": 1e6,
+ "input_cost_per_token": 0.35e-6,
+ "output_cost_per_token": 1.15e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-maverick-17b-16e-instruct-maas": {
+ "max_tokens": 1e6,
+ "max_input_tokens": 1e6,
+ "max_output_tokens": 1e6,
+ "input_cost_per_token": 0.35e-6,
+ "output_cost_per_token": 1.15e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
"vertex_ai/meta/llama3-70b-instruct-maas": {
"max_tokens": 32000,
"max_input_tokens": 32000,
diff --git a/litellm/types/llms/openai.py b/litellm/types/llms/openai.py
index 3d45ac2d999..bf21bc1ed78 100644
--- a/litellm/types/llms/openai.py
+++ b/litellm/types/llms/openai.py
@@ -809,10 +809,12 @@ class ChatCompletionResponseMessage(TypedDict, total=False):
]
-class ChatCompletionUsageBlock(TypedDict):
- prompt_tokens: int
- completion_tokens: int
- total_tokens: int
+class ChatCompletionUsageBlock(TypedDict, total=False):
+ prompt_tokens: Required[int]
+ completion_tokens: Required[int]
+ total_tokens: Required[int]
+ prompt_tokens_details: Optional[dict]
+ completion_tokens_details: Optional[dict]
class OpenAIChatCompletionChunk(ChatCompletionChunk):
@@ -1295,6 +1297,42 @@ class OpenAIModerationResponse(BaseLiteLLMOpenAIResponseObject):
_hidden_params: dict = PrivateAttr(default_factory=dict)
+class OpenAIChatCompletionLogprobsContentTopLogprobs(TypedDict, total=False):
+ bytes: List
+ logprob: Required[float]
+ token: Required[str]
+
+
+class OpenAIChatCompletionLogprobsContent(TypedDict, total=False):
+ bytes: List
+ logprob: Required[float]
+ token: Required[str]
+ top_logprobs: List[OpenAIChatCompletionLogprobsContentTopLogprobs]
+
+
+class OpenAIChatCompletionLogprobs(TypedDict, total=False):
+ content: List[OpenAIChatCompletionLogprobsContent]
+ refusal: List[OpenAIChatCompletionLogprobsContent]
+
+
+class OpenAIChatCompletionChoices(TypedDict, total=False):
+ finish_reason: Required[str]
+ index: Required[int]
+ logprobs: Optional[OpenAIChatCompletionLogprobs]
+ message: Required[ChatCompletionResponseMessage]
+
+
+class OpenAIChatCompletionResponse(TypedDict, total=False):
+ id: Required[str]
+ object: Required[str]
+ created: Required[int]
+ model: Required[str]
+ choices: Required[List[OpenAIChatCompletionChoices]]
+ usage: Required[ChatCompletionUsageBlock]
+ system_fingerprint: str
+ service_tier: str
+
OpenAIChatCompletionFinishReason = Literal[
"stop", "content_filter", "function_call", "tool_calls", "length"
]
+
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index bf958815b93..f771296c74b 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -6309,6 +6309,62 @@
"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
"supports_tool_choice": true
},
+ "vertex_ai/meta/llama-4-scout-17b-16e-instruct-maas": {
+ "max_tokens": 10e6,
+ "max_input_tokens": 10e6,
+ "max_output_tokens": 10e6,
+ "input_cost_per_token": 0.25e-6,
+ "output_cost_per_token": 0.70e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-scout-128b-16e-instruct-maas": {
+ "max_tokens": 10e6,
+ "max_input_tokens": 10e6,
+ "max_output_tokens": 10e6,
+ "input_cost_per_token": 0.25e-6,
+ "output_cost_per_token": 0.70e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-maverick-17b-128e-instruct-maas": {
+ "max_tokens": 1e6,
+ "max_input_tokens": 1e6,
+ "max_output_tokens": 1e6,
+ "input_cost_per_token": 0.35e-6,
+ "output_cost_per_token": 1.15e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
+ "vertex_ai/meta/llama-4-maverick-17b-16e-instruct-maas": {
+ "max_tokens": 1e6,
+ "max_input_tokens": 1e6,
+ "max_output_tokens": 1e6,
+ "input_cost_per_token": 0.35e-6,
+ "output_cost_per_token": 1.15e-6,
+ "litellm_provider": "vertex_ai-llama_models",
+ "mode": "chat",
+ "source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#partner-models",
+ "supports_tool_choice": true,
+ "supports_function_calling": true,
+ "supported_modalities": ["text", "image"],
+ "supported_output_modalities": ["text", "code"]
+ },
"vertex_ai/meta/llama3-70b-instruct-maas": {
"max_tokens": 32000,
"max_input_tokens": 32000,
diff --git a/poetry.lock b/poetry.lock
index 658f99e1afc..4af921d00aa 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -2116,13 +2116,13 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
[[package]]
name = "openai"
-version = "1.76.2"
+version = "1.75.0"
description = "The official Python library for the openai API"
optional = false
python-versions = ">=3.8"
files = [
- {file = "openai-1.76.2-py3-none-any.whl", hash = "sha256:9c1d9ad59e6e3bea7205eedc9ca66eeebae18d47b527e505a2b0d2fb1538e26e"},
- {file = "openai-1.76.2.tar.gz", hash = "sha256:f430c8b848775907405c6eff54621254c96f6444c593c097e0cc3a9f8fdda96f"},
+ {file = "openai-1.75.0-py3-none-any.whl", hash = "sha256:fe6f932d2ded3b429ff67cc9ad118c71327db32eb9d32dd723de3acfca337125"},
+ {file = "openai-1.75.0.tar.gz", hash = "sha256:fb3ea907efbdb1bcfd0c44507ad9c961afd7dce3147292b54505ecfd17be8fd1"},
]
[package.dependencies]
@@ -4357,4 +4357,4 @@ proxy = ["PyJWT", "apscheduler", "backoff", "boto3", "cryptography", "fastapi",
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<4.0, !=3.9.7"
-content-hash = "ecd8910b3cdafcf87df7af2907738c883404ab49903b33001640f1dbf98f371c"
+content-hash = "23a660966fb8924895b28d805c85911a74678c4c10668662d36e54212c3ec00e"
diff --git a/pyproject.toml b/pyproject.toml
index 2598f933e0a..e9e25b99f76 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,7 +21,7 @@ Documentation = "https://docs.litellm.ai"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0, !=3.9.7"
httpx = ">=0.23.0"
-openai = ">=1.68.2"
+openai = ">=1.68.2, <1.76.0"
python-dotenv = ">=0.2.0"
tiktoken = ">=0.7.0"
importlib-metadata = ">=6.8.0"
diff --git a/tests/litellm/llms/databricks/chat/test_databricks_chat_transformation.py b/tests/litellm/llms/databricks/chat/test_databricks_chat_transformation.py
index f3935212f44..1026a210098 100644
--- a/tests/litellm/llms/databricks/chat/test_databricks_chat_transformation.py
+++ b/tests/litellm/llms/databricks/chat/test_databricks_chat_transformation.py
@@ -38,7 +38,7 @@ def test_transform_choices():
}
]
- choices = config._transform_choices(choices=databricks_choices)
+ choices = config._transform_dbrx_choices(choices=databricks_choices)
assert len(choices) == 1
assert choices[0].message.content == "# 5 Question and Answer Pairs"
diff --git a/tests/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/test_vertex_ai_partner_models_llama3_transformation.py b/tests/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/test_vertex_ai_partner_models_llama3_transformation.py
new file mode 100644
index 00000000000..b6228bc2e10
--- /dev/null
+++ b/tests/litellm/llms/vertex_ai/vertex_ai_partner_models/llama3/test_vertex_ai_partner_models_llama3_transformation.py
@@ -0,0 +1,62 @@
+import json
+import os
+import sys
+from unittest.mock import AsyncMock, MagicMock, patch
+
+import httpx
+import pytest
+
+sys.path.insert(
+ 0, os.path.abspath("../../../../../..")
+) # Adds the parent directory to the system path
+
+from litellm.llms.vertex_ai.vertex_ai_partner_models.llama3.transformation import (
+ VertexAILlama3Config,
+)
+
+
+class TestVertexAILlama3Config:
+ def test_transform_choices(self):
+ """
+ Relevant Issue: https://github.com/BerriAI/litellm/issues/10441#issuecomment-2844975599
+ """
+ config = VertexAILlama3Config()
+
+ choices = [
+ {
+ "finish_reason": "stop",
+ "index": 0,
+ "logprobs": None,
+ "message": {
+ "content": '{"type": "function", "name": "get_weather", "parameters": {"location": "Boston, MA"}}',
+ "role": "assistant",
+ },
+ }
+ ]
+ tools = [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get current temperature for a given location.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "location": {
+ "type": "string",
+ "description": "City and country e.g. Bogotá, Colombia",
+ }
+ },
+ "required": ["location"],
+ "additionalProperties": False,
+ },
+ },
+ }
+ ]
+ optional_params = {"tools": tools}
+ response = config._transform_choices(
+ choices=choices, json_mode=False, optional_params=optional_params
+ )
+ assert response[0].message.tool_calls is not None
+ assert response[0].finish_reason == "tool_calls"
+ # response = config.transform_response(
diff --git a/tests/llm_translation/test_vertex.py b/tests/llm_translation/test_vertex.py
index 0c8c1cffea6..1ef8c1513cd 100644
--- a/tests/llm_translation/test_vertex.py
+++ b/tests/llm_translation/test_vertex.py
@@ -1407,3 +1407,5 @@ def test_aaavertex_embeddings_distances(
)
print("text_response: ", text_response)
text_embedding = text_response.data[0].embedding
+
+
diff --git a/tests/local_testing/test_amazing_vertex_completion.py b/tests/local_testing/test_amazing_vertex_completion.py
index 275e9c046aa..db0526b6ca9 100644
--- a/tests/local_testing/test_amazing_vertex_completion.py
+++ b/tests/local_testing/test_amazing_vertex_completion.py
@@ -3706,3 +3706,50 @@ def test_gemini_tool_calling_not_working():
}
response = completion(model="vertex_ai/gemini-2.0-flash", **args)
print(response)
+
+def test_vertex_ai_llama_tool_calling():
+ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
+ litellm.model_cost = litellm.get_model_cost_map(url="")
+ load_vertex_ai_credentials()
+ litellm._turn_on_debug()
+ args = {
+ "model": "vertex_ai/meta/llama-4-maverick-17b-128e-instruct-maas",
+ "messages": [
+ {
+ "role": "user",
+ "content": "What is the weather in Boston, MA today?"
+ }
+ ],
+ "tools": [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get current temperature for a given location.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "location": {
+ "type": "string",
+ "description": "City and country e.g. Bogotá, Colombia"
+ }
+ },
+ "required": [
+ "location"
+ ],
+ "additionalProperties": False
+ }
+ }
+ }
+ ],
+ "vertex_location": "us-east5"
+ }
+ try:
+ response = completion(**args)
+ except litellm.RateLimitError:
+ pytest.skip("Rate limit error")
+ print(response)
+
+ assert response.choices[0].message.tool_calls is not None
+ assert response.choices[0].finish_reason == "tool_calls"
+ assert response._hidden_params["response_cost"] > 0
\ No newline at end of file
diff --git a/tests/local_testing/test_get_model_info.py b/tests/local_testing/test_get_model_info.py
index 41af51dee7a..6ae8c6331be 100644
--- a/tests/local_testing/test_get_model_info.py
+++ b/tests/local_testing/test_get_model_info.py
@@ -552,7 +552,7 @@ def test_aaamodel_prices_and_context_window_json_is_valid():
"type": "array",
"items": {
"type": "string",
- "enum": ["text", "image", "audio"],
+ "enum": ["text", "image", "audio", "code"],
},
},
"supports_native_streaming": {"type": "boolean"},