File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,15 +161,7 @@ export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHa
161161 * @param message - The message from watsonx response
162162 */
163163 private * processResponseMessage ( message : any ) : Generator < any > {
164- // Handle text content
165- if ( message . content ) {
166- yield {
167- type : "text" ,
168- text : message . content ,
169- }
170- }
171-
172- // Handle tool calls
164+ // Handle tool calls first
173165 if ( message . tool_calls && message . tool_calls . length > 0 ) {
174166 for ( const toolCall of message . tool_calls ) {
175167 if ( toolCall . type === "function" ) {
@@ -199,6 +191,13 @@ export class WatsonxAIHandler extends BaseProvider implements SingleCompletionHa
199191 }
200192 }
201193 }
194+ // Handle text content only if there are no tool_calls, or if content is non-empty
195+ else if ( message . content ) {
196+ yield {
197+ type : "text" ,
198+ text : message . content ,
199+ }
200+ }
202201 }
203202
204203 /**
You can’t perform that action at this time.
0 commit comments