@@ -100,6 +100,8 @@ actor OpenAIChatCompletionsService: ChatCompletionsStreamAPI, ChatCompletionsAPI
100100 struct Delta : Codable {
101101 var role : MessageRole ?
102102 var content : String ?
103+ var reasoning_content : String ?
104+ var reasoning : String ?
103105 var function_call : RequestBody . MessageFunctionCall ?
104106 var tool_calls : [ RequestBody . MessageToolCall ] ?
105107 }
@@ -112,6 +114,8 @@ actor OpenAIChatCompletionsService: ChatCompletionsStreamAPI, ChatCompletionsAPI
112114 var role : MessageRole
113115 /// The content of the message.
114116 var content : String ?
117+ var reasoning_content : String ?
118+ var reasoning : String ?
115119 /// When we want to reply to a function call with the result, we have to provide the
116120 /// name of the function call, and include the result in `content`.
117121 ///
@@ -482,6 +486,7 @@ extension OpenAIChatCompletionsService.ResponseBody {
482486 . init(
483487 role: message. role. formalized,
484488 content: message. content ?? " " ,
489+ reasoningContent: message. reasoning_content ?? message. reasoning ?? " " ,
485490 toolCalls: {
486491 if let toolCalls = message. tool_calls {
487492 return toolCalls. map { toolCall in
@@ -553,6 +558,8 @@ extension OpenAIChatCompletionsService.StreamDataChunk {
553558 return . init(
554559 role: choice. delta? . role? . formalized,
555560 content: choice. delta? . content,
561+ reasoningContent: choice. delta? . reasoning_content
562+ ?? choice. delta? . reasoning,
556563 toolCalls: {
557564 if let toolCalls = choice. delta? . tool_calls {
558565 return toolCalls. map {
0 commit comments