fix(transformation.py): allows passing native responses api tools like web_search_preview, and mcp via .completion() (#12627)

Closes https://github.com/BerriAI/litellm/issues/12105
This commit is contained in:
Krish Dholakia
2025-07-15 22:45:42 -07:00
committed by GitHub
parent 955b504f7b
commit 1ce3558f96
2 changed files with 20 additions and 12 deletions
@@ -454,17 +454,7 @@ class LiteLLMResponsesTransformationHandler(CompletionTransformationBridge):
"""Convert chat completion tools to responses API tools format"""
responses_tools = []
for tool in tools:
if tool.get("type") == "function":
function = tool.get("function", {})
responses_tools.append(
{
"type": "function",
"name": function.get("name", ""),
"description": function.get("description", ""),
"parameters": function.get("parameters", {}),
"strict": function.get("strict", False),
}
)
responses_tools.append(tool)
return cast(List["ALL_RESPONSES_API_TOOL_PARAMS"], responses_tools)
def _map_reasoning_effort(self, reasoning_effort: str) -> Optional[Reasoning]:
@@ -647,7 +637,8 @@ class OpenAiResponsesToChatCompletionStreamIterator(BaseModelResponseIterator):
return ModelResponseStream(
choices=[
StreamingChoices(
index=parsed_chunk.get("summary_index"), delta=Delta(reasoning_content=content_part)
index=cast(int, parsed_chunk.get("summary_index")),
delta=Delta(reasoning_content=content_part),
)
]
)
+17
View File
@@ -543,3 +543,20 @@ async def test_openai_codex(sync_mode):
print("response: ", response)
assert response.choices[0].message.content is not None
def test_openai_deepresearch_model_bridge():
"""
Test that the deepresearch model bridge works correctly
"""
litellm._turn_on_debug()
response = litellm.completion(
model="o3-deep-research-2025-06-26",
messages=[{"role": "user", "content": "What is the capital of France?"}],
tools=[
{"type": "web_search_preview"},
{"type": "code_interpreter", "container": {"type": "auto"}},
],
)
print("response: ", response)