콘텐츠로 이동

Architecture

Flow

Folder path
  -> file scanner
  -> parser
  -> chunker
  -> local embedding provider
  -> Chroma vector store + SQLite metadata store
  -> retriever
  -> prompt builder
  -> optional DB tool calls
  -> LLM provider
  -> grounded answer with citations

Agentic DB Tool Calling

enable_tools=true인 질문은 provider별 tool 선택 경로를 사용합니다. OpenAI는 Responses API function calling을 사용하고, Codex는 tool 선택 JSON을 출력하게 한 뒤 앱이 DB tool을 실행합니다.

question + RAG evidence
  -> OpenAI or Codex provider
  -> tool call request or tool-selection JSON
  -> RAG4U read-only tool execution
  -> tool output
  -> final answer + citations + tool trace

DB tool은 PostgreSQL을 조회하지만 LLM이 SQL을 직접 실행하지 않습니다. 앱이 정의한 get_alarm_history, get_sensor_trend, get_maintenance_history 함수만 고정 SQL과 바인딩 파라미터로 실행됩니다.

Storage

  • SQLite stores document, chunk, query, answer, and profile metadata.
  • Chroma stores chunk vectors and lookup metadata.
  • PostgreSQL demo DB stores sample alarm, sensor, and maintenance records for DB tools.
  • Runtime paths default to data/app.sqlite and data/indexes/chroma.

Boundaries

  • Parsers return normalized text sections with source location metadata.
  • Chunking preserves source metadata and adds chunk ids.
  • Embedding providers implement embed(texts) -> vectors.
  • LLM providers implement generate(question, contexts, profile, options) -> Answer.
  • DB tools are read-only application functions, not model-generated SQL.
  • API and UI never read provider secrets directly beyond settings loading.

Privacy

The index and source documents remain local. External providers receive only retrieved chunks and, when enable_tools=true, selected DB tool outputs. Requests are rejected unless the caller explicitly sets allow_external_context=true.