Skip to content
Open
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions Sources/OpenAI/Public/Models/Annotation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

public struct Annotation: Codable, Equatable, Sendable {
/// The type of the URL citation. Always `url_citation`.
public let type: String
/// A URL citation when using web search.
public let urlCitation: URLCitation

public enum CodingKeys: String, CodingKey {
case type, urlCitation = "url_citation"
}

public struct URLCitation: Codable, Equatable, Sendable {
/// The index of the last character of the URL citation in the message.
public let endIndex: Int
/// The index of the first character of the URL citation in the message.
public let startIndex: Int
/// The title of the web resource.
public let title: String
/// The URL of the web resource.
public let url: String

public enum CodingKeys: String, CodingKey {
case endIndex = "end_index"
case startIndex = "start_index"
case title, url
}
}
}
28 changes: 0 additions & 28 deletions Sources/OpenAI/Public/Models/ChatResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,34 +156,6 @@ public struct ChatResult: Codable, Equatable, Sendable {
case _reasoningContent = "reasoning_content"
}

public struct Annotation: Codable, Equatable, Sendable {
/// The type of the URL citation. Always `url_citation`.
let type: String
/// A URL citation when using web search.
let urlCitation: URLCitation

public enum CodingKeys: String, CodingKey {
case type, urlCitation = "url_citation"
}

public struct URLCitation: Codable, Equatable, Sendable {
/// The index of the last character of the URL citation in the message.
let endIndex: Int
/// The index of the first character of the URL citation in the message.
let startIndex: Int
/// The title of the web resource.
let title: String
/// The URL of the web resource.
let url: String

public enum CodingKeys: String, CodingKey {
case endIndex = "end_index"
case startIndex = "start_index"
case title, url
}
}
}

public struct Audio: Codable, Equatable, Sendable {
/// Base64 encoded audio bytes generated by the model, in the format specified in the request.
public let data: String
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenAI/Public/Models/ChatStreamResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public struct ChatStreamResult: Codable, Equatable, Sendable {
/// The role of the author of this message.
public let role: Self.Role?
public let toolCalls: [Self.ChoiceDeltaToolCall]?
/// 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
Comment on lines +28 to +29
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.
public let annotations: [Annotation]?

/// Value for `reasoning` field in response.
///
Expand Down Expand Up @@ -111,6 +114,7 @@ public struct ChatStreamResult: Codable, Equatable, Sendable {
case content
case audio
case role
case annotations
case toolCalls = "tool_calls"
case _reasoning = "reasoning"
case _reasoningContent = "reasoning_content"
Expand Down
Loading