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

Function extractLastUserMessageContent

web/src/lib/ad-providers/gravity.ts:54–62  ·  view source on GitHub ↗

* Extract the content from the last tag in a string. * The CLI wraps raw user text in that tag; if no tag is found, returns the * original content.

(content: string)

Source from the content-addressed store, hash-verified

52 * original content.
53 */
54function extractLastUserMessageContent(content: string): string {
55 const regex = /<user_message>([\s\S]*?)<\/user_message>/gi
56 const matches = [...content.matchAll(regex)]
57 if (matches.length > 0) {
58 const lastMatch = matches[matches.length - 1]
59 return lastMatch[1].trim()
60 }
61 return content
62}
63
64/**
65 * Gravity only wants the last user turn plus the last preceding assistant

Callers 1

prepareGravityMessagesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected