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

Function extractTextContent

apps/sim/lib/tokenization/utils.ts:82–100  ·  view source on GitHub ↗
(input: unknown)

Source from the content-addressed store, hash-verified

80 * Safely extracts text content from various input formats
81 */
82export function extractTextContent(input: unknown): string {
83 if (typeof input === 'string') {
84 return input.trim()
85 }
86
87 if (input && typeof input === 'object') {
88 try {
89 return JSON.stringify(input)
90 } catch (error) {
91 logger.warn('Failed to stringify input object', {
92 inputType: typeof input,
93 error: toError(error).message,
94 })
95 return ''
96 }
97 }
98
99 return String(input || '')
100}
101
102/**
103 * Creates a preview of text for logging (truncated)

Callers 1

processStreamingBlockLogFunction · 0.90

Calls 2

toErrorFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected