MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / extractTextParts

Function extractTextParts

web/src/app/api/v1/token-count/_post.ts:281–291  ·  view source on GitHub ↗
(content: Array<Record<string, unknown>>)

Source from the content-addressed store, hash-verified

279}
280
281function extractTextParts(content: Array<Record<string, unknown>>): string {
282 const parts: string[] = []
283 for (const part of content) {
284 if (part.type === 'text' && typeof part.text === 'string') {
285 parts.push(part.text)
286 } else if (part.type === 'json') {
287 parts.push(typeof part.value === 'string' ? part.value : JSON.stringify(part.value))
288 }
289 }
290 return parts.join('\n')
291}
292
293async function countTokensViaAnthropic(params: {
294 messages: TokenCountRequest['messages']

Callers 1

buildMessageContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected