MCPcopy Index your code
hub / github.com/simstudioai/sim / userInputChars

Function userInputChars

apps/docs/app/api/chat/route.ts:106–115  ·  view source on GitHub ↗

Total length of user-authored text across the conversation.

(messages: UIMessage[])

Source from the content-addressed store, hash-verified

104
105/** Total length of user-authored text across the conversation. */
106function userInputChars(messages: UIMessage[]): number {
107 let total = 0
108 for (const message of messages) {
109 if (message.role !== 'user') continue
110 for (const part of message.parts) {
111 if (part.type === 'text' && typeof part.text === 'string') total += part.text.length
112 }
113 }
114 return total
115}
116
117/**
118 * Strip everything the model shouldn't trust from client-supplied history:

Callers 1

POSTFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected