Skip to content

Commit 4aba092

Browse files
authored
Response API Updates (#19)
1 parent 110b63e commit 4aba092

File tree

10 files changed

+1721
-106
lines changed

10 files changed

+1721
-106
lines changed

src/Conversation.swift

Lines changed: 248 additions & 64 deletions
Large diffs are not rendered by default.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
3+
extension Collection {
4+
subscript(safe index: Index) -> Element? {
5+
guard indices.contains(index) else { return nil }
6+
return self[index]
7+
}
8+
}

src/Models/Config.swift

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import MetaCodable
1717
///
1818
/// This can be useful for debugging and understanding the model's reasoning process.
1919
public enum SummaryConfig: String, CaseIterable, Equatable, Hashable, Codable, Sendable {
20+
case auto
2021
case concise
2122
case detailed
2223
}
@@ -26,18 +27,18 @@ import MetaCodable
2627
/// Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
2728
public var effort: Effort?
2829

29-
/// A summary of the reasoning performed by the model. `computer_use_preview` only.
30+
/// A summary of the reasoning performed by the model.
3031
///
3132
/// This can be useful for debugging and understanding the model's reasoning process.
32-
public var generateSummary: SummaryConfig?
33+
public var summary: SummaryConfig?
3334

3435
/// Creates a new `ReasoningConfig` instance.
3536
///
3637
/// - Parameter effort: Constrains effort on reasoning for reasoning models.
37-
/// - Parameter generateSummary: A summary of the reasoning performed by the model.
38-
public init(effort: Effort? = nil, generateSummary: SummaryConfig? = nil) {
38+
/// - Parameter summary: A summary of the reasoning performed by the model.
39+
public init(effort: Effort? = nil, summary: SummaryConfig? = nil) {
3940
self.effort = effort
40-
self.generateSummary = generateSummary
41+
self.summary = summary
4142
}
4243
}
4344

@@ -94,10 +95,40 @@ public enum Truncation: String, CaseIterable, Equatable, Hashable, Codable, Send
9495

9596
/// The latency to use when processing the request
9697
public enum ServiceTier: String, CaseIterable, Equatable, Hashable, Codable, Sendable {
97-
/// If the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. Otherwise, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
98+
/// The request will be processed with the service tier configured in the Project settings.
99+
///
100+
/// Unless otherwise configured, the Project will use 'default'.
98101
case auto
99-
/// The request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.
102+
103+
/// The requset will be processed with the standard pricing and performance for the selected model.
100104
case `default`
105+
101106
/// The request will be processed with the Flex Processing service tier.
102107
case flex
108+
109+
/// The request will be processed with the Priority Processing service tier.
110+
case priority
111+
}
112+
113+
public struct Prompt: Equatable, Hashable, Codable, Sendable {
114+
/// The unique identifier of the prompt template to use.
115+
public var id: String
116+
117+
/// Optional version of the prompt template.
118+
public var version: String?
119+
120+
/// Optional map of values to substitute in for variables in your prompt.
121+
///
122+
/// The substitution values can either be strings, or other Response input types like images or files.
123+
public var variables: [String: String]?
124+
125+
/// Creates a new `Prompt` instance.
126+
/// - Parameter id: The unique identifier of the prompt template to use.
127+
/// - Parameter version: Optional version of the prompt template.
128+
/// - Parameter variables: Optional map of values to substitute in for variables in your prompt.
129+
public init(id: String, version: String? = nil, variables: [String: String]? = nil) {
130+
self.id = id
131+
self.version = version
132+
self.variables = variables
133+
}
103134
}

0 commit comments

Comments
 (0)