tweak: swap 🌚/🌝 UI states for link summary; adjust link summarizer prompt

This commit is contained in:
Thomas Cravey 2025-08-17 20:17:29 -05:00
parent 01ff3a0579
commit 43f1235482
2 changed files with 4 additions and 4 deletions

View file

@ -74,11 +74,11 @@ function processLinks(scope){ const links = scope.querySelectorAll('a[href]:not(
const toggle = ()=>{ const hidden = c.style.display==='none'; c.style.display = hidden? '' : 'none'; chevron.textContent = hidden? '▾':'▸'; pinBottomMulti(); }; const toggle = ()=>{ const hidden = c.style.display==='none'; c.style.display = hidden? '' : 'none'; chevron.textContent = hidden? '▾':'▸'; pinBottomMulti(); };
chevron.onclick = (ev)=>{ ev.stopPropagation(); toggle(); }; chevron.onclick = (ev)=>{ ev.stopPropagation(); toggle(); };
sumBtn.onclick = async ()=>{ sumBtn.onclick = async ()=>{
if(sum.style.display!== 'none' && sum.textContent){ sum.style.display='none'; sumBtn.textContent='🌝'; pinBottomMulti(); return; } if(sum.style.display!== 'none' && sum.textContent){ sum.style.display='none'; sumBtn.textContent='🌚'; pinBottomMulti(); return; }
// Ensure card is visible when showing summary // Ensure card is visible when showing summary
if(c.style.display==='none'){ toggle(); } if(c.style.display==='none'){ toggle(); }
sumBtn.disabled=true; spinner.textContent='…'; sum.textContent=''; sum.style.display=''; sumBtn.disabled=true; spinner.textContent='…'; sum.textContent=''; sum.style.display='';
try{ const data = await api('/api/linksummary',{query:{url:a.href}}); sum.textContent = (data && data.summary) ? data.summary : '(no summary)'; sumBtn.textContent='🌚'; } try{ const data = await api('/api/linksummary',{query:{url:a.href}}); sum.textContent = (data && data.summary) ? data.summary : '(no summary)'; sumBtn.textContent='🌝'; }
catch(e){ sum.textContent = 'error: '+e; } catch(e){ sum.textContent = 'error: '+e; }
spinner.textContent=''; sumBtn.disabled=false; pinBottomMulti(); spinner.textContent=''; sumBtn.disabled=false; pinBottomMulti();
}; };

View file

@ -249,7 +249,7 @@ func (o *OpenAI) SummarizeLink(ctx context.Context, rawURL string) (string, erro
} }
// Build link-specific prompt // Build link-specific prompt
sys := "You summarize the content at a single URL. Ignore surrounding chat context. Be concise and natural." sys := "You summarize web content."
var userParts []openai.ChatMessagePart var userParts []openai.ChatMessagePart
b := strings.Builder{} b := strings.Builder{}
b.WriteString("URL: ") b.WriteString("URL: ")
@ -266,7 +266,7 @@ func (o *OpenAI) SummarizeLink(ctx context.Context, rawURL string) (string, erro
b.WriteString(content) b.WriteString(content)
b.WriteString("\n\n") b.WriteString("\n\n")
} }
b.WriteString("Write a short, skimmable summary of the page/video/image above. If relevant, include key takeaways and any notable cautions. Keep it under a few short paragraphs.") b.WriteString("Write a summary of the page/video/image above.")
userParts = append(userParts, openai.ChatMessagePart{Type: openai.ChatMessagePartTypeText, Text: b.String()}) userParts = append(userParts, openai.ChatMessagePart{Type: openai.ChatMessagePartTypeText, Text: b.String()})
if img != "" { if img != "" {
userParts = append(userParts, openai.ChatMessagePart{Type: openai.ChatMessagePartTypeImageURL, ImageURL: &openai.ChatMessageImageURL{URL: img}}) userParts = append(userParts, openai.ChatMessagePart{Type: openai.ChatMessagePartTypeImageURL, ImageURL: &openai.ChatMessageImageURL{URL: img}})