Skip to content

wip litellm thinking #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/agents/extensions/models/litellm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
ChatCompletionMessage,
)
from openai.types.chat.chat_completion_message_tool_call import Function
from openai.types.responses import Response
from openai.types.responses import Response, ResponseReasoningItem
from openai.types.responses.response_reasoning_item import Summary

from ... import _debug
from ...agent_output import AgentOutputSchemaBase
from ...handoffs import Handoff
from ...items import ModelResponse, TResponseInputItem, TResponseStreamEvent
from ...items import ModelResponse, ReasoningItem, TResponseInputItem, TResponseStreamEvent
from ...logger import logger
from ...model_settings import ModelSettings
from ...models.chatcmpl_converter import Converter
Expand Down Expand Up @@ -123,10 +124,21 @@ async def get_response(
"output_tokens": usage.output_tokens,
}

message = response.choices[0].message

items = Converter.message_to_output_items(
LitellmConverter.convert_message_to_openai(response.choices[0].message)
LitellmConverter.convert_message_to_openai(message)
)

if hasattr(message, "reasoning_content") and message.reasoning_content:
items.append(
ResponseReasoningItem(
id=FAKE_RESPONSES_ID,
summary=[Summary(text=message.reasoning_content, type="summary_text")],
type="reasoning",
)
)

return ModelResponse(
output=items,
usage=usage,
Expand Down
Loading