Deploy: migrate k3s → Docker; search logic → master-agents-svc
- deploy/k3s удалён, deploy/docker добавлен (Caddyfile, docker-compose, searxng) - chat-svc: agents/models/prompts удалены, использует llm-svc (LLMClient, EmbeddingClient) - master-agents-svc: SearchOrchestrator, classifier, researcher, actions, widgets - web-svc: ChatModelSelector, Optimization, Sources удалены; InputBarPlus; UnregisterSW - geo-device-svc, localization-svc: Dockerfiles - docs: 02-k3s-services-spec.md, RUNBOOK/TELEMETRY/WORKING удалены Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
92
services/master-agents-svc/src/lib/prompts/writer.ts
Normal file
92
services/master-agents-svc/src/lib/prompts/writer.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { getLocaleInstruction } from './locale.js';
|
||||
|
||||
export type AnswerMode =
|
||||
| 'standard' | 'focus' | 'academic' | 'writing' | 'travel' | 'finance'
|
||||
| 'health' | 'education' | 'medicine' | 'realEstate' | 'psychology' | 'sports'
|
||||
| 'children' | 'goods' | 'shopping' | 'games' | 'taxes' | 'legislation';
|
||||
|
||||
export type ResponsePrefs = { format?: string; length?: string; tone?: string };
|
||||
|
||||
const VERTICAL_BLOCKS: Partial<Record<AnswerMode, string>> = {
|
||||
travel: `### Answer Mode: Travel\nPrioritize: destinations, itineraries, hotels, transport, practical tips. Format: clear sections (Where to stay, What to see, Getting there).\n`,
|
||||
finance: `### Answer Mode: Finance\nPrioritize: market data, company analysis, financial metrics. Cite sources for numbers.\n`,
|
||||
health: `### Answer Mode: Health\nPrioritize: wellness, medicine, nutrition, fitness, mental health. Cite medical sources.\n`,
|
||||
education: `### Answer Mode: Education\nPrioritize: learning, courses, pedagogy, academic resources.\n`,
|
||||
medicine: `### Answer Mode: Medicine\nPrioritize: clinical info, treatments, diagnostics. Cite medical sources.\n`,
|
||||
academic: `### Answer Mode: Academic\nPrioritize: scholarly sources, citations, research-based answers.\n`,
|
||||
writing: `### Answer Mode: Writing\nPrioritize: clear structure, engaging prose, well-cited content.\n`,
|
||||
};
|
||||
|
||||
export function getWriterPrompt(
|
||||
context: string,
|
||||
systemInstructions: string,
|
||||
mode: 'speed' | 'balanced' | 'quality',
|
||||
locale?: string,
|
||||
memoryContext?: string,
|
||||
answerMode?: AnswerMode,
|
||||
responsePrefs?: ResponsePrefs,
|
||||
learningMode?: boolean,
|
||||
): string {
|
||||
const memoryBlock = memoryContext?.trim()
|
||||
? `\n### User memory (personalization)\nUse these stored facts/preferences to personalize when relevant. Do NOT cite as source.\n${memoryContext}\n`
|
||||
: '';
|
||||
const verticalBlock = answerMode ? (VERTICAL_BLOCKS[answerMode] ?? '') : '';
|
||||
|
||||
const prefs: string[] = [];
|
||||
if (responsePrefs?.format) {
|
||||
const f = responsePrefs.format;
|
||||
if (f === 'bullets') prefs.push('Format: use bullet points where appropriate.');
|
||||
else if (f === 'outline') prefs.push('Format: use clear headings and outline structure.');
|
||||
else prefs.push('Format: use paragraphs and flowing prose.');
|
||||
}
|
||||
if (responsePrefs?.length) {
|
||||
const l = responsePrefs.length;
|
||||
if (l === 'short') prefs.push('Length: keep response concise and brief.');
|
||||
else if (l === 'long') prefs.push('Length: provide comprehensive, detailed coverage.');
|
||||
else prefs.push('Length: medium depth, balanced.');
|
||||
}
|
||||
if (responsePrefs?.tone) {
|
||||
const t = responsePrefs.tone;
|
||||
if (t === 'professional') prefs.push('Tone: formal, professional.');
|
||||
else if (t === 'casual') prefs.push('Tone: friendly, conversational.');
|
||||
else if (t === 'concise') prefs.push('Tone: direct, to the point.');
|
||||
else prefs.push('Tone: neutral.');
|
||||
}
|
||||
const prefsBlock = prefs.length ? `\n### Response preferences\n${prefs.join(' ')}\n` : '';
|
||||
|
||||
const learningBlock = learningMode
|
||||
? `\n### Step-by-step Learning mode\nExplain your reasoning step-by-step. Break down complex concepts. Show the logical flow. Use numbered steps or "First... Then... Finally" structure.\n`
|
||||
: '';
|
||||
|
||||
return `
|
||||
You are GooSeek, an AI model skilled in web search and crafting detailed, engaging, and well-structured answers.
|
||||
|
||||
Your task is to provide answers that are:
|
||||
- **Informative and relevant**: Thoroughly address the user's query using the given context.
|
||||
- **Well-structured**: Include clear headings and subheadings, professional tone.
|
||||
- **Cited and credible**: Use inline citations with [number] notation to refer to the context source(s) for each fact.
|
||||
- **Explanatory and Comprehensive**: Explain the topic in depth, offer detailed analysis and insights.
|
||||
|
||||
### Citation Requirements
|
||||
- Cite every fact from **search_results** using [number] notation. Citations [1], [2], etc. refer ONLY to sources in search_results.
|
||||
- **widgets_result** (calculations, weather, stock data) — use this to answer directly, do NOT cite it.
|
||||
- Integrate citations naturally at the end of sentences.
|
||||
|
||||
### Special Instructions
|
||||
- The context contains two sections: \`search_results\` (web search) and \`widgets_result\` (calculations, weather, stocks). If widgets_result has the answer, USE IT.
|
||||
- If BOTH search_results AND widgets_result lack relevant information, say: "Hmm, sorry I could not find any relevant information on this topic."
|
||||
${mode === 'quality' ? "- QUALITY MODE: Generate very deep, detailed responses. At least 2000 words, cover everything like a research report." : ''}
|
||||
|
||||
${verticalBlock}${prefsBlock}${learningBlock}
|
||||
### User instructions
|
||||
${systemInstructions}
|
||||
${memoryBlock}
|
||||
|
||||
<context>
|
||||
${context}
|
||||
</context>
|
||||
|
||||
Current date & time (UTC): ${new Date().toISOString()}.
|
||||
${getLocaleInstruction(locale)}
|
||||
`;
|
||||
}
|
||||
Reference in New Issue
Block a user