File tree 3 files changed +1064
-8
lines changed
Sources/OpenAI/Public/ResponseModels/Response
3 files changed +1064
-8
lines changed Original file line number Diff line number Diff line change @@ -1432,6 +1432,10 @@ public struct ResponseModel: Decodable {
1432
1432
1433
1433
/// A unique identifier representing your end-user.
1434
1434
public let user: String ?
1435
+
1436
+ /// Convenience property that aggregates all text output from output_text items in the output array.
1437
+ /// Similar to the outputText property in Python and JavaScript SDKs.
1438
+ public var outputText: String ?
1435
1439
}
1436
1440
```
1437
1441
Original file line number Diff line number Diff line change @@ -93,6 +93,26 @@ public struct ResponseModel: Decodable {
93
93
/// A unique identifier representing your end-user.
94
94
public let user : String ?
95
95
96
+ /// Convenience property that aggregates all text output from output_text items in the output array.
97
+ /// Similar to the outputText property in Python and JavaScript SDKs.
98
+ public var outputText : String ? {
99
+ let outputTextItems = output. compactMap { outputItem -> String ? in
100
+ switch outputItem {
101
+ case . message( let message) :
102
+ return message. content. compactMap { contentItem -> String ? in
103
+ switch contentItem {
104
+ case . outputText( let outputText) :
105
+ return outputText. text
106
+ }
107
+ } . joined ( )
108
+ default :
109
+ return nil
110
+ }
111
+ }
112
+
113
+ return outputTextItems. isEmpty ? nil : outputTextItems. joined ( )
114
+ }
115
+
96
116
public struct ErrorObject : Decodable {
97
117
98
118
/// The error code for the response.
You can’t perform that action at this time.
0 commit comments