AI module

Configurable AI agents, chat workflows, provider settings, and knowledge ingestion for AI-enabled products.

What this module does

Multi-modal assistant, prompts, and knowledge base (provider-agnostic).

Key capabilities

  • AI agent configuration, prompts, and access controls
  • Chat sessions, streaming, uploads, and transcription
  • Knowledge ingestion, vector references, and provider management

Core flows

  1. Open/public chat flow

    • Trigger: /open/ai/agents/{uuid}/chat or /chat/stream.
    • Steps: optional password check, resolve agent strategy, process attachments, run provider client, optionally log user/agent messages.
    • Output: agent response payload or SSE stream.
    • Failure/edge cases: wrong password, missing agent/provider config, unsupported attachment type.
  2. Authenticated user/admin chat flow

    • Trigger: user /ai/agents/{uuid}/chat or admin /admin/ai/agents/{uuid}/chat.
    • Steps: resolve user id, execute strategy via AiChatService, persist session/messages when strategy requests logging.
    • Output: chat response and persisted chat history.
    • Failure/edge cases: strategy missing, invalid session context.
  3. Agent configuration flow

    • Trigger: admin endpoints on /admin/ai/agents.
    • Steps: create/update/delete agents, update prompts/settings/password flags, enable/disable upload/recording features.
    • Output: persisted agent config state.
    • Failure/edge cases: unknown agent UUID, invalid provider/model values.
  4. Knowledge document ingestion/removal (RAG)

    • Trigger: admin knowledge endpoints.
    • Steps: validate file type, extract text/chunks, store metadata refs, write/delete vector entries by document metadata filter.
    • Output: updated document references and vector store state.
    • Failure/edge cases: unsupported document, extraction error, provider/vector config issues.
  5. Provider configuration flow

    • Trigger: /admin/ai/providers.
    • Steps: read provider rows, initialize missing providers on startup, update API keys, cache provider config.
    • Output: stable provider configuration records.
    • Failure/edge cases: missing provider row, invalid provider enum.
  6. ChatKit session secret flow

    • Trigger: POST /chatkit/session.
    • Steps: resolve OpenAI provider key, choose workflow id, mint/refresh ChatKit client secret via OpenAI API.
    • Output: client secret for frontend ChatKit session.
    • Failure/edge cases: missing key/workflow, upstream API failure.
  7. Admin dashboard SQL assistant flow

    • Trigger: agent strategy AdminDashboardNavbarChatAgentStrategy invocation.
    • Steps: generate safe SELECT query from prompt using schema context, execute query, optionally generate concise reasoning response.
    • Output: dataset or concise answer.
    • Failure/edge cases: invalid SQL generation, non-select request, query execution errors.

Module is included in

  • AI assistant: AI assistant, vector store, ingestion, and admin tooling.

Source paths

  • backend/modules/ai
  • frontend/modules/ai