Skip to content

Conversation

@batanus
Copy link
Contributor

@batanus batanus commented Dec 12, 2025

What

Add Annotations property to ChatStreamResult object

Why

When OpenAI uses web tool call in stream mode - it returns annotation object for ChatStreamResult as well

Affected Areas

ChatStreamResult, Annotation structs

Copilot AI review requested due to automatic review settings December 12, 2025 09:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for annotations in chat stream results, enabling the handling of web search tool citations in streaming mode. The Annotation struct is extracted into a shared model and added to ChatStreamResult.

Key Changes:

  • Extracted Annotation struct from ChatResult.Choice into a standalone public model
  • Added annotations property to ChatStreamResult.Choice.Delta

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Sources/OpenAI/Public/Models/ChatStreamResult.swift Added annotations field to Delta struct with documentation referencing web search tool
Sources/OpenAI/Public/Models/ChatResult.swift Removed nested Annotation struct from Choice
Sources/OpenAI/Public/Models/Annotation.swift Created new file with extracted Annotation struct, updated access modifiers to public

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +29
/// Annotations for the message, when applicable, as when using the web search tool.
/// Web search tool: https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation comment spans multiple lines unnecessarily. Consider consolidating into a single-line comment or using a more concise format that doesn't require a URL on a separate line.

Suggested change
/// Annotations for the message, when applicable, as when using the web search tool.
/// Web search tool: https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat
/// Annotations for the message, when applicable, as when using the web search tool: https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant