MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / extractTextCountFromMessage

Function extractTextCountFromMessage

src/api/transform/vscode-lm-format.ts:178–209  ·  view source on GitHub ↗
(message: vscode.LanguageModelChatMessage)

Source from the content-addressed store, hash-verified

176 * @returns The extracted text content.
177 */
178export 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}

Callers 2

internalCountTokensMethod · 0.90

Calls 2

keysMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected