buildUserContextString function presentation

Last updated: 2026-03-04T23:21:38.398Z

Metrics

LOC: 17 Complexity: 7 Params: 2

Signature

buildUserContextString( context?: AIContextPayload, ): : string | undefined

Summary

Aggregates all parts of an AIContextPayload into a single plaintext string to be forwarded to the AI prompt.

Source Code

function buildUserContextString(
  context?: AIContextPayload,
): string | undefined {
  if (!context) return undefined;

  const parts: string[] = [];
  if (context.text?.trim()) parts.push(context.text.trim());
  if (context.audioTranscript?.trim())
    parts.push(`Audio transcript: ${context.audioTranscript.trim()}`);
  if (context.csvText?.trim())
    parts.push(`CSV data:\n${context.csvText.trim()}`);
  if (context.pdfText?.trim())
    parts.push(`PDF document content:\n${context.pdfText.trim()}`);
  // imageDataUrl is passed separately as multimodal input — not included in text

  return parts.length > 0 ? parts.join("\n\n") : undefined;
}

No outgoing dependencies.

Impact (Incoming)

graph LR buildUserContextString["buildUserContextString"] fillContextualAI["fillContextualAI"] fillContextualAI -->|calls| buildUserContextString style buildUserContextString fill:#dbeafe,stroke:#2563eb,stroke-width:2px click buildUserContextString "c7237ee5672c23a4.html" click fillContextualAI "854e1a4562eb49e4.html"
SourceType
fillContextualAI calls