Skip to content

Initial o1 support for playground with agent #1

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 3 additions & 2 deletions pydantic_ai_slim/pydantic_ai/models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ async def _completions_create(
openai_messages = list(chain(*(self._map_message(m) for m in messages)))

model_settings = model_settings or {}
is_model_o1 = "o1" in self.model_name

return await self.client.chat.completions.create(
model=self.model_name,
messages=openai_messages,
n=1,
parallel_tool_calls=True if self.tools else NOT_GIVEN,
parallel_tool_calls=True if self.tools and not is_model_o1 else NOT_GIVEN,
tools=self.tools or NOT_GIVEN,
tool_choice=tool_choice or NOT_GIVEN,
stream=stream,
Expand Down Expand Up @@ -250,7 +251,7 @@ def _map_message(cls, message: ModelMessage) -> Iterable[chat.ChatCompletionMess
def _map_user_message(cls, message: ModelRequest) -> Iterable[chat.ChatCompletionMessageParam]:
for part in message.parts:
if isinstance(part, SystemPromptPart):
yield chat.ChatCompletionSystemMessageParam(role='system', content=part.content)
yield chat.ChatCompletionSystemMessageParam(role='developer', content=part.content)
elif isinstance(part, UserPromptPart):
yield chat.ChatCompletionUserMessageParam(role='user', content=part.content)
elif isinstance(part, ToolReturnPart):
Expand Down