(message: vscode.LanguageModelChatMessage)
| 176 | * @returns The extracted text content. |
| 177 | */ |
| 178 | export function extractTextCountFromMessage(message: vscode.LanguageModelChatMessage): string { |
| 179 | let text = "" |
| 180 | if (Array.isArray(message.content)) { |
| 181 | for (const item of message.content) { |
| 182 | if (item instanceof vscode.LanguageModelTextPart) { |
| 183 | text += item.value |
| 184 | } |
| 185 | if (item instanceof vscode.LanguageModelToolResultPart) { |
| 186 | text += item.callId |
| 187 | for (const part of item.content) { |
| 188 | if (part instanceof vscode.LanguageModelTextPart) { |
| 189 | text += part.value |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | if (item instanceof vscode.LanguageModelToolCallPart) { |
| 194 | text += item.name |
| 195 | text += item.callId |
| 196 | if (item.input && Object.keys(item.input).length > 0) { |
| 197 | try { |
| 198 | text += JSON.stringify(item.input) |
| 199 | } catch (error) { |
| 200 | console.error("Roo Code <Language Model API>: Failed to stringify tool call input:", error) |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | } else if (typeof message.content === "string") { |
| 206 | text += message.content |
| 207 | } |
| 208 | return text |
| 209 | } |
no test coverage detected