|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MODEL = "gemini-1.5-flash" |
|
|
MAX_TOKENS = 8192 |
|
|
|
|
|
|
|
|
SEARXNG_ENDPOINT = "https://searx.stream/search" |
|
|
BAIDU_ENDPOINT = "https://www.baidu.com/s" |
|
|
READER_ENDPOINT = "https://r.jina.ai/" |
|
|
REQUEST_TIMEOUT = 300 |
|
|
|
|
|
|
|
|
INSTRUCTIONS_START = """ |
|
|
You are ChatGPT (Gemini backend) with mandatory real-time web search, |
|
|
URL content extraction, cross-validation (≥3 credible sources), and professional summarization. |
|
|
|
|
|
Rules: |
|
|
- Always call tools (`web_search`, `read_url`) for every user request. |
|
|
- Do not rely on cached/internal knowledge; verify with tools. |
|
|
- Present clear structure, neutral tone, inline citations/links. |
|
|
- Prefer recent, authoritative sources; highlight disagreements. |
|
|
""" |
|
|
|
|
|
CONTENT_EXTRACTION = """ |
|
|
<system> |
|
|
- Extract critical facts, data, and arguments from retrieved content. |
|
|
- Normalize terminology and emphasize clarity and logic. |
|
|
</system> |
|
|
""" |
|
|
|
|
|
SEARCH_SELECTION = """ |
|
|
<system> |
|
|
- Fetch full content using `read_url` for each top result. |
|
|
- Summarize professionally and list sources with Markdown links. |
|
|
</system> |
|
|
""" |
|
|
|
|
|
INSTRUCTIONS_END = """ |
|
|
Now provide a comprehensive answer based ONLY on tool results. |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
QUICK_COMMANDS = { |
|
|
"#news": "Find the latest news on: {topic}. Summarize key updates, timelines, stakeholders, and implications. Provide 6–10 bullet points with citations.", |
|
|
"#papers": "Survey recent academic papers about: {topic}. Extract methods, datasets, results, limitations. Provide 5–8 items with links.", |
|
|
"#compare": "Compare {a} vs {b} across capability, latency, cost, ecosystem, constraints. Give a pros/cons table and final recommendation.", |
|
|
"#howto": "Create a practical step-by-step guide for: {topic}, including pitfalls, checks, and quick-start commands.", |
|
|
"#brief": "Give a 5-bullet executive brief on: {topic}, with links for each bullet.", |
|
|
"#timeline": "Build a concise timeline for: {topic}, with dated milestones and sources.", |
|
|
"#faq": "Make a 10-question FAQ for: {topic}, each answer ≤3 sentences with a source.", |
|
|
"#earthquakes": "List earthquakes (Mw >= {mw}) from {start} to {end}, provide a table: time (UTC), region, Mw, depth, link." |
|
|
} |
|
|
|
|
|
|
|
|
STYLE_TAGS = { |
|
|
"講義": "Output as a course handout: sections, definitions, examples, and a quick quiz (5 items).", |
|
|
"簡報": "Output as slide bullets: 6–10 concise slides with titles and 3 bullets each.", |
|
|
"條列": "Prefer bullet points over paragraphs; 7–12 bullets.", |
|
|
"表格": "Provide a comparative table first, then analysis.", |
|
|
"中英對照": "Provide bilingual output: Traditional Chinese first, then English line-by-line.", |
|
|
"行動清單": "End with an actionable checklist (5–8 items) prioritized by impact/effort.", |
|
|
"落地實作": "Include a ready-to-run snippet or command block with validation steps." |
|
|
} |
|
|
|
|
|
|
|
|
DESCRIPTION = r""" |
|
|
<style> |
|
|
.sbx { font-family: ui-sans-serif, system-ui, "Noto Sans TC", "Segoe UI", Roboto, Helvetica, Arial; } |
|
|
.bx { background: #0f172a; color: #e2e8f0; border-radius: 14px; padding: 16px; box-shadow: 0 6px 18px rgba(2,6,23,.35); } |
|
|
.k { display:inline-block; padding:2px 8px; border-radius:8px; background:#1e293b; color:#a5b4fc; font-weight:600; } |
|
|
.tag{ display:inline-block; padding:2px 8px; border-radius:8px; background:#0ea5e9; color:#0b1020; margin-right:4px; font-weight:700; } |
|
|
.pill{ display:inline-block; padding:6px 10px; border-radius:999px; background:#1f2937; color:#d1d5db; margin:4px 6px 0 0; font-size:12px; font-weight:600; } |
|
|
.grid { display:grid; grid-template-columns: 1fr 1fr; gap:10px; } |
|
|
.ok { color:#34d399; font-weight:700; } |
|
|
.muted{ color:#94a3b8; } |
|
|
</style> |
|
|
|
|
|
<div class="sbx"> |
|
|
<div class="bx"> |
|
|
<h2>🔎 SearchGPT · <span class="ok">Gemini</span> 研究助理</h2> |
|
|
<p class="muted">即時搜尋、URL 擷取、≥3 來源交叉驗證,輸出結構化、可引用的專業摘要。</p> |
|
|
|
|
|
<div class="grid" style="margin-top:10px;"> |
|
|
<div> |
|
|
<h4>🚀 快速指令 <span class="k">#commands</span></h4> |
|
|
<div class="pill">#news</div> |
|
|
<div class="pill">#papers</div> |
|
|
<div class="pill">#compare</div> |
|
|
<div class="pill">#howto</div> |
|
|
<div class="pill">#timeline</div> |
|
|
<div class="pill">#faq</div> |
|
|
<div class="pill">#earthquakes</div> |
|
|
<p class="muted" style="margin-top:8px;">例:<code>#news P-wave picking with AI</code></p> |
|
|
</div> |
|
|
<div> |
|
|
<h4>🎨 風格標籤 <span class="k">[tags]</span></h4> |
|
|
<div class="pill">[簡報]</div> |
|
|
<div class="pill">[講義]</div> |
|
|
<div class="pill">[條列]</div> |
|
|
<div class="pill">[表格]</div> |
|
|
<div class="pill">[中英對照]</div> |
|
|
<div class="pill">[落地實作]</div> |
|
|
<p class="muted" style="margin-top:8px;">可混搭:<code>#papers … [表格][中英對照]</code></p> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div style="margin-top:10px;"> |
|
|
<span class="tag">depth:N</span> 控制研究深度(1–5) |
|
|
<span class="tag">creative!</span> 提升創意度 |
|
|
</div> |
|
|
|
|
|
<hr style="border-color:#1f2937; margin:16px 0;"> |
|
|
|
|
|
<h4>🧭 使用建議</h4> |
|
|
<ul> |
|
|
<li>加入關鍵詞、時間範圍與地區,例如:<code>#news Taiwan EEW 2024–2025</code></li> |
|
|
<li>需要課堂產出?加上 <code>[簡報]</code> 或 <code>[講義]</code>。</li> |
|
|
<li>要中文/英文雙語,使用 <code>[中英對照]</code>。</li> |
|
|
</ul> |
|
|
|
|
|
<p class="muted">點選側欄下方的「示例」按鈕,會把文字自動填到輸入框;檢查後按 <b>Enter</b> 送出。</p> |
|
|
</div> |
|
|
</div> |
|
|
""" |