Overview
Formats an array of segments for an LLM prompt by combining the system/instruction prompt with formatted segment text. Each segment is formatted as “ID - Text” and separated by double newlines.Function Signature
Parameters
Array of segments to format. Each segment must have an
id and text property.The instruction or system prompt to prepend to the formatted segments.
Returns
Combined string with the prompt prepended, followed by double newline, then all segments formatted as “ID - Text” and separated by double newlines.
Usage
Basic Example
Output
When to Use
UseformatExcerptsForPrompt when:
- Preparing text segments for LLM translation requests
- Building prompts that need to maintain segment ID tracking
- Creating structured input for batch translation operations
- Combining system instructions with source material