Major changes: - Add Go backend (backend/) with microservices architecture - Enhanced master-agents-svc: reranker, content-classifier, stealth-crawler, proxy-manager, media-search, fastClassifier, language detection - New web-svc widgets: KnowledgeCard, ProductCard, ProfileCard, VideoCard, UnifiedCard, CardGallery, InlineImageGallery, SourcesPanel, RelatedQuestions - Improved discover-svc with discover-db integration - Docker deployment improvements (Caddyfile, vendor.sh, BUILD.md) - Library-svc: project_id schema migration - Remove deprecated finance-svc and travel-svc - Localization improvements across services Made-with: Cursor
116 lines
6.2 KiB
TypeScript
116 lines
6.2 KiB
TypeScript
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,
|
|
detectedLanguage?: string,
|
|
isArticleSummary?: 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`
|
|
: '';
|
|
|
|
const articleSummaryBlock = isArticleSummary
|
|
? `\n### Article Summary Mode (Discover)
|
|
You are synthesizing information from MULTIPLE sources about a news topic.
|
|
This is a Perplexity-style multi-source digest. Follow these rules strictly:
|
|
|
|
- **EVERY sentence** MUST have at least one citation [N] referring to a search_results source.
|
|
- Use **ALL** available sources, not just the first one. Distribute citations across all sources.
|
|
- Structure the summary as:
|
|
1. **Introduction** (2-3 sentences, overview of the topic)
|
|
2. **Key Details** (main facts, events, numbers from multiple sources)
|
|
3. **Analysis** (expert opinions, implications, different viewpoints)
|
|
4. **Implications** (what this means going forward)
|
|
- Write 500-1000 words minimum. Be comprehensive.
|
|
- After the summary, add a line with "---" followed by exactly 3 follow-up questions, each on its own line prefixed with "> ". These questions should help the user explore the topic deeper.
|
|
- Write in Russian (unless the user's locale indicates otherwise).
|
|
- Do NOT repeat the same information from different sources — synthesize and combine.
|
|
- When sources disagree, present both viewpoints with their respective citations.
|
|
`
|
|
: '';
|
|
|
|
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.
|
|
- Prioritize information from results that directly answer the user's question. Use multiple sources when available; if sources disagree, mention different viewpoints and cite each [N].
|
|
- 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. Use as many of the provided results as relevant." : ''}
|
|
|
|
${articleSummaryBlock}${verticalBlock}${prefsBlock}${learningBlock}
|
|
### User instructions
|
|
${systemInstructions}
|
|
${memoryBlock}
|
|
|
|
<context>
|
|
${context}
|
|
</context>
|
|
|
|
Current date & time (UTC): ${new Date().toISOString()}.
|
|
${getLocaleInstruction(locale, detectedLanguage)}
|
|
`;
|
|
}
|