| 228 | * which is what makes a temperature-zero run with a fixed seed reproducible. |
| 229 | */ |
| 230 | export function buildPrompt(input: PromptInput): PromptPlan { |
| 231 | const cards = input.cards.cards; |
| 232 | const cardIds = cards.map((card) => card.id); |
| 233 | const parts: string[] = [CARDS_HEADING, renderCards(cards)]; |
| 234 | if (input.cards.gaps.length > 0) { |
| 235 | parts.push('', GAPS_HEADING, ...input.cards.gaps.map((gap) => `- ${gap}`)); |
| 236 | } |
| 237 | parts.push('', QUESTION_HEADING, input.question, '', CLASS_HINTS[input.klass]); |
| 238 | const user = parts.join('\n'); |
| 239 | const system = SYSTEM_PROMPT; |
| 240 | return { |
| 241 | system, |
| 242 | user, |
| 243 | cards, |
| 244 | cardIds, |
| 245 | estimatedTokens: Math.ceil((system.length + user.length) / 4), |
| 246 | nonThinking: nonThinkingFor(input.modelName), |
| 247 | }; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * The refine prompt: rewrite a deterministic block, keep every number. |