mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-28 15:27:03 +02:00
16 lines
575 B
TypeScript
16 lines
575 B
TypeScript
import type { TranscriptTurn } from '../types';
|
|
|
|
/**
|
|
* User-side turns from a captured transcript, flattened as a text block for
|
|
* prompt-aware checks. Single-turn → plain text; multi-turn → numbered prefix.
|
|
*/
|
|
export function userTurnsAsText(transcript: TranscriptTurn[]): string {
|
|
const turns = transcript
|
|
.map((t) => t.userMessage)
|
|
.filter((m): m is string => typeof m === 'string' && m.length > 0);
|
|
|
|
if (turns.length === 0) return '';
|
|
if (turns.length === 1) return turns[0];
|
|
return turns.map((text, i) => `Turn ${String(i + 1)}: ${text}`).join('\n\n');
|
|
}
|