File tree Expand file tree Collapse file tree 3 files changed +1064
-8
lines changed
Sources/OpenAI/Public/ResponseModels/Response Expand file tree Collapse file tree 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 {
14321432
14331433 /// A unique identifier representing your end-user.
14341434 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 ?
14351439}
14361440```
14371441
Original file line number Diff line number Diff line change @@ -93,6 +93,26 @@ public struct ResponseModel: Decodable {
9393 /// A unique identifier representing your end-user.
9494 public let user : String ?
9595
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+
96116 public struct ErrorObject : Decodable {
97117
98118 /// The error code for the response.
You can’t perform that action at this time.
0 commit comments