accounts/dashboard-fresh/lib/knowledgeBase.ts
Haitao Pan 9c877ceb3c feat(dashboard-fresh): migrate and integrate dashboard source
- Add fresh app structure (auth, tenant, mail, insight, docs, panel)
- Include CMS content, API routes, scripts, and config
- Migrate UI components, themes, and extensions to fresh runtime
2025-11-04 18:06:21 +08:00

19 lines
594 B
TypeScript

import { getServerServiceBaseUrl } from './serviceConfig'
export async function fetchRelatedDocs(query: string): Promise<string[]> {
const apiBase = getServerServiceBaseUrl()
try {
const res = await fetch(`${apiBase}/api/rag/query`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ question: query })
})
if (!res.ok) return []
const data = await res.json()
return (data.chunks || []).map((c: any) => `${c.repo}:${c.path}`)
} catch (err) {
console.warn('fetchRelatedDocs failed', err)
return []
}
}