feat(briefing): add article Discuss endpoint with synthetic tool exchange
POST /api/briefing/articles/<id>/discuss injects stored article content as a persisted read_article tool exchange before triggering generation. The LLM sees the article as already read; follow-ups retain context via the fixed history builder. Frontend Discuss button now calls the new endpoint instead of inlining article text in the user message. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import WeatherCard from '@/components/WeatherCard.vue'
|
||||
import BriefingSetupWizard from '@/components/BriefingSetupWizard.vue'
|
||||
import {
|
||||
apiGet,
|
||||
apiPost,
|
||||
getBriefingConfig,
|
||||
getBriefingConversations,
|
||||
getBriefingToday,
|
||||
@@ -113,26 +114,19 @@ watch(selectedConvId, async (id) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Keep send() as a helper for discussArticle
|
||||
async function send(text: string) {
|
||||
if (!text || !todayConvId.value || chatStore.streaming) return
|
||||
if (chatStore.currentConversation?.id !== todayConvId.value) {
|
||||
await chatStore.fetchConversation(todayConvId.value)
|
||||
}
|
||||
await chatStore.sendMessage(text, undefined, undefined, true)
|
||||
}
|
||||
|
||||
async function discussArticle(item: NewsItem) {
|
||||
if (!todayConvId.value) return
|
||||
if (!todayConvId.value || chatStore.streaming) return
|
||||
if (!isToday.value) selectedConvId.value = todayConvId.value
|
||||
const body = (item.content || item.snippet || '').trim()
|
||||
const bodyBlock = body ? `\n\n---\n${body}\n---` : ''
|
||||
const text = `Please summarize and share your thoughts on this article. Do not use any research or search tools — respond conversationally based only on the content below.\n\n**${item.title}**\nSource: ${item.source}${bodyBlock}`
|
||||
// Scroll to chat column
|
||||
await nextTick(() => {
|
||||
document.querySelector('.briefing-center')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
||||
})
|
||||
await send(text)
|
||||
try {
|
||||
await apiPost<{ assistant_message_id: number }>(`/api/briefing/articles/${item.id}/discuss`, { conv_id: todayConvId.value })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
await chatStore.fetchConversation(todayConvId.value)
|
||||
await chatStore.reconnectIfGenerating(todayConvId.value)
|
||||
}
|
||||
|
||||
// RSS reactions: map of rss_item_id -> 'up' | 'down' | null
|
||||
|
||||
Reference in New Issue
Block a user