Skip to content
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