feat(chat-frasa): acceso total a datos (13 herramientas con escopo por rol), streaming SSE, caché de embeddings, markdown y mantenimiento en Configuraciones

This commit is contained in:
2026-09-17 08:41:21 +00:00
parent 278a79c984
commit 9643f866cc
17 changed files with 3133 additions and 177 deletions

View File

@@ -131,6 +131,40 @@ export async function crearUsuarioConfig(data: {
return (await resp.json()) as UsuarioConfig
}
// ─── Asistente IA (Chat Frasa) ─────────────────────────────────
export interface EstadoAsistente {
conversaciones: number
mensajes: number
documentos: number
chunks: number
ultimasPreguntas: { pregunta: string; fecha: string }[]
}
/** GET /ai/estado — métricas de uso del asistente (admin) */
export async function getEstadoAsistente(): Promise<EstadoAsistente> {
const resp = await fetch(`${API_URL}/ai/estado`, conAuth())
manejar401(resp)
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
return (await resp.json()) as EstadoAsistente
}
/** POST /ai/reindexar — re-indexa la base de conocimiento del asistente (admin) */
export async function reindexarConocimiento(): Promise<{
documentos: number
creados: number
actualizados: number
sinCambios: number
}> {
const resp = await fetch(`${API_URL}/ai/reindexar`, conAuth({ method: 'POST' }))
manejar401(resp)
if (!resp.ok) {
const cuerpo = (await resp.json().catch(() => null)) as { error?: string } | null
throw new Error(cuerpo?.error ?? `HTTP ${resp.status}`)
}
return (await resp.json()) as { documentos: number; creados: number; actualizados: number; sinCambios: number }
}
// ─── Auditoría ─────────────────────────────────────────────────
export interface AuditoriaItem {