Skip to content

Commit 1fa4f85

Browse files
committed
refactor(continue-watsonx-ai-provider): prioritize tool calls over text content in response processing
1 parent 5f9bcc8 commit 1fa4f85

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/api/providers/ibm-watsonx.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff 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
/**

0 commit comments

Comments
 (0)