- Updated ChatMessage and ChatWindow components to support inline web search results and articles. - Integrated new web search and RSS plugins into the chat system for real-time information retrieval. - Enhanced useContentPanel to manage web search results alongside existing media types. - Added ArticleOverlay component for displaying selected articles from search results. - Improved UI elements and styles for better user interaction with web search features. Made-with: Cursor
27 lines
957 B
TypeScript
27 lines
957 B
TypeScript
import type { WebSearchResult } from '@aiui/core/types/message'
|
|
|
|
export async function fetchRssFromUrls(urls: string[]): Promise<WebSearchResult[]> {
|
|
const safe = urls.filter((u) => typeof u === 'string' && /^https?:\/\//i.test(u.trim())).slice(0, 8)
|
|
if (safe.length === 0) return []
|
|
|
|
try {
|
|
const params = new URLSearchParams()
|
|
safe.forEach((u) => params.append('url', u))
|
|
const res = await fetch(`/api/rss-articles?${params}`, { signal: AbortSignal.timeout(15000) })
|
|
if (!res.ok) return []
|
|
const data = (await res.json()) as { articles?: Array<{ title?: string; url?: string; content?: string; imgSrc?: string }> }
|
|
const articles = data.articles ?? []
|
|
return articles
|
|
.filter((a) => a.title && a.url)
|
|
.map((a) => ({
|
|
title: a.title ?? '',
|
|
url: a.url ?? '',
|
|
content: a.content,
|
|
imgSrc: a.imgSrc,
|
|
}))
|
|
} catch (err) {
|
|
console.warn('[AIUI rss]', err)
|
|
return []
|
|
}
|
|
}
|