From 5f26029cfe5414a68a103fb9232eff4d7aa2b106 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Sun, 5 Apr 2026 00:37:51 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Vorschl=C3=A4ge=20f=C3=BCr=20Folgesuche?= =?UTF-8?q?n=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CSS-Stile für vorgeschlagene Suchschaltflächen hinzugefügt - HTML-Container für die Anzeige vorgeschlagener Suchen hinzugefügt - Logik zur Darstellung und Interaktion mit vorgeschlagenen Suchen implementiert - OpenRouter-Prompt um Hinweis auf Folgesuchen erweitert - JSON-Schema um Feld 'suggestedSearches' ergänzt --- public/index.html | 46 +++++++++++++++++++++++++++++++ src/services/openRouterService.js | 10 +++---- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/public/index.html b/public/index.html index 08420fa..adab8b8 100644 --- a/public/index.html +++ b/public/index.html @@ -289,6 +289,29 @@ text-decoration: underline; } + .suggested-searches { + display: flex; + flex-wrap: wrap; + gap: 8px; + } + + .suggested-search-btn { + padding: 8px 16px; + background: #f0f0f0; + border: 1px solid #ddd; + border-radius: 20px; + cursor: pointer; + font-size: 0.9rem; + transition: all 0.2s; + color: #333; + } + + .suggested-search-btn:hover { + background: #667eea; + color: white; + border-color: #667eea; + } + /* Cost Breakdown Styles */ .cost-breakdown-details { margin-top: 10px; @@ -556,6 +579,11 @@ +
+

💡 Suggested Follow-up Searches

+
+
+
@@ -607,6 +635,7 @@ const results = document.getElementById('results'); const answerEl = document.getElementById('answer'); const sourcesEl = document.getElementById('sources'); + const suggestedSearchesEl = document.getElementById('suggestedSearches'); const errorEl = document.getElementById('error'); const logContainer = document.getElementById('logContainer'); const statusDot = document.getElementById('statusDot'); @@ -893,6 +922,23 @@ sourcesEl.appendChild(li); } + // Display suggested searches + suggestedSearchesEl.innerHTML = ''; + if (data.suggestedSearches && data.suggestedSearches.length > 0) { + data.suggestedSearches.forEach(search => { + const btn = document.createElement('button'); + btn.className = 'suggested-search-btn'; + btn.textContent = search; + btn.addEventListener('click', () => { + questionInput.value = search; + performSearch(); + }); + suggestedSearchesEl.appendChild(btn); + }); + } else { + suggestedSearchesEl.innerHTML = '

No suggested searches available

'; + } + // Display cost breakdown const costTableBody = document.getElementById('costTableBody'); costTableBody.innerHTML = ''; diff --git a/src/services/openRouterService.js b/src/services/openRouterService.js index d8b22a9..98f0353 100644 --- a/src/services/openRouterService.js +++ b/src/services/openRouterService.js @@ -162,7 +162,7 @@ export async function summarizeFinalAnswer({ openrouter, text, question }) { You are a search result analyst. Today is the date of ${new Date().toLocaleDateString()}. Based on the following search results for the query "${question}", Summarize the search results to answer the original query. Use Emoji and HTML. Tags allowed: , , ,
, 
    ,
  • , ,


    - Also provide the most relevant sources. Answer in the language of the question. + Also provide the most relevant sources. Answer in the language of the question. You may suggest followup searched to the user. `; const params = { @@ -179,13 +179,11 @@ export async function summarizeFinalAnswer({ openrouter, text, question }) { strict: true, schema: { type: 'object', - required: ['fullAnswerHTMLSnippet', 'mostRelevantSources'], + required: ['fullAnswerHTMLSnippet', 'mostRelevantSources', 'suggestedSearches'], properties: { fullAnswerHTMLSnippet: { type: 'string' }, - mostRelevantSources: { - type: 'array', - items: { type: 'string' }, - }, + mostRelevantSources: { type: 'array', items: { type: 'string' } }, + suggestedSearches: { type: 'array', items: { type: 'string' } }, }, }, },