accounts/dashboard/lib/knowledgeBase.ts
Haitao Pan f3d0a7f931 fix(dashboard): resolve npm run build errors
- Fix module path in prebuild script (../../scripts → ../scripts)
- Update API routes to use Promise-based params for Next.js 16
- Install @types/sanitize-html and @types/js-yaml
- Fix component prop naming (loading → isLoading, saving → isSaving, etc.)
- Update VLESS config type definition with missing 'id' property
- Fix TypeScript type conflicts and export declarations

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2025-11-06 11:07:30 +08:00

19 lines
602 B
TypeScript

import { getServerServiceBaseUrl } from '../server/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 []
}
}