import { taskModelCompletion } from './task-model.js'; const SYSTEM_PROMPT = 'You rewrite user messages into concise web search queries. Reply with ONLY the search query. 3 to 6 words. No quotes, no explanation.'; const MAX_INPUT_CHARS = 500; const FALLBACK_CHARS = 60; export async function rewriteSearchQuery(userMessage: string): Promise { const input = userMessage.slice(0, MAX_INPUT_CHARS); const result = await taskModelCompletion({ system: SYSTEM_PROMPT, user: input, maxTokens: 20, temperature: 0.2, }); if (result.length > 0) return result; return userMessage.slice(0, FALLBACK_CHARS).trim(); }