Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -332,21 +332,26 @@ T = TypeVar('T', bound=BaseModel)

@override
async def structured_output(
self, output_model: Type[T], prompt: Messages, **kwargs: Any
self,
output_model: Type[T],
prompt: Messages,
system_prompt: Optional[str] = None,
**kwargs: Any
) -> Generator[dict[str, Union[T, Any]], None, None]:
"""Get structured output using tool calling.

Args:
output_model: The output model to use for the agent.
prompt: The prompt messages to use for the agent.
system_prompt: The system prompt to use for the agent.
**kwargs: Additional keyword arguments for future extensibility.
"""

# Convert Pydantic model to tool specification
tool_spec = convert_pydantic_to_tool_spec(output_model)

# Use the stream method with tool specification
response = await self.stream(messages=prompt, tool_specs=[tool_spec], **kwargs)
response = await self.stream(messages=prompt, tool_specs=[tool_spec], system_prompt=system_prompt, **kwargs)

# Process streaming response
async for event in process_stream(response, prompt):
Expand Down
Loading