Skip to main content

AI & Knowledge Base

Column-level detail for ai_config, knowledge_base, document, chunk

Overview

This domain has 4 tables in the public schema (managed by Prisma). ai_config holds the LLM provider settings per LINE OA; the other three form a RAG knowledge store that nests downward: knowledge_base (the store) → knowledge_document (uploaded documents / FAQ entries) → knowledge_chunk (split text pieces with their embedding reference).

Table ai_config

ColumnTypeNullableDefaultDescription
idSERIALNOauto incrementPrimary key
line_oa_idINTEGERNO-LINE OA this config belongs to
organization_idINTEGERNO-Owning organization (tenant separation)
providerVARCHAR(50)NO'gemini'LLM provider
modelVARCHAR(100)NO'gemini-2.0-flash'Model name to call
api_keyTEXTNO-Provider API key
settingsJSONBNO'{}'Extra tuning options such as temperature, max tokens
statusVARCHAR(20)NO'active'Record status
created_byINTEGERYES-Creator user id
updated_byINTEGERYES-Last updater user id
created_dateTIMESTAMP(3)YESnow()Creation timestamp
updated_dateTIMESTAMP(3)YESnow()Last update timestamp
deleted_dateTIMESTAMP(3)YES-Soft-delete timestamp

Table knowledge_base

ColumnTypeNullableDefaultDescription
idSERIALNOauto incrementPrimary key
line_oa_idINTEGERNO-LINE OA this knowledge base belongs to
organization_idINTEGERNO-Owning organization
nameVARCHAR(255)NO-Knowledge base name
descriptionTEXTNO''Knowledge base description
system_instructionTEXTNO''System prompt sent to the model when answering from this base
statusVARCHAR(20)NO'active'Record status
statsJSONBNO'{}'Summary statistics such as document / chunk counts
created_byINTEGERYES-Creator user id
updated_byINTEGERYES-Last updater user id
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp
updated_dateTIMESTAMPTZ(3)NOnow()Last update timestamp
deleted_dateTIMESTAMPTZ(3)YES-Soft-delete timestamp

Table knowledge_document

ColumnTypeNullableDefaultDescription
idSERIALNOauto incrementPrimary key
knowledge_base_idINTEGERNO-FK to knowledge_base.id
typeVARCHAR(20)NO-Document kind: file / plain text / question-answer pair
titleVARCHAR(500)NO''Document title
contentTEXTNO''Plain-text body
questionTEXTNO''Question (FAQ-type documents)
answerTEXTNO''Answer (FAQ-type documents)
file_urlTEXTNO''Uploaded file URL
file_nameVARCHAR(255)NO''Original file name
file_typeVARCHAR(50)NO''File type / MIME type
file_sizeINTEGERNO0File size in bytes
index_statusVARCHAR(20)NO'pending'Indexing / embedding status
index_errorTEXTNO''Error message from the last indexing run
statusVARCHAR(20)NO'active'Record status
created_byINTEGERYES-Creator user id
updated_byINTEGERYES-Last updater user id
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp
updated_dateTIMESTAMPTZ(3)NOnow()Last update timestamp
deleted_dateTIMESTAMPTZ(3)YES-Soft-delete timestamp

Table knowledge_chunk

ColumnTypeNullableDefaultDescription
idSERIALNOauto incrementPrimary key
knowledge_document_idINTEGERNO-FK to knowledge_document.id
knowledge_base_idINTEGERNO-FK to knowledge_base.id (denormalized for base-level queries)
contentTEXTNO-Chunk text
chunk_indexINTEGERNO0Chunk position within its document
embedding_idVARCHAR(100)NO''Reference to the vector in the external vector store
metadataJSONBNO'{}'Auxiliary chunk metadata
created_dateTIMESTAMPTZ(3)NOnow()Creation timestamp

Notes

  • Foreign keys: knowledge_document.knowledge_base_idknowledge_base.id, knowledge_chunk.knowledge_document_idknowledge_document.id, knowledge_chunk.knowledge_base_idknowledge_base.id
  • Unique: ai_config has unique constraint uq_ai_config_org_lineoa_provider on (organization_id, line_oa_id, provider) — one config per provider per OA
  • Indexes: idx_ai_config_org_lineoa on (organization_id, line_oa_id); knowledge_base on (line_oa_id, organization_id); knowledge_document on knowledge_base_id; knowledge_chunk on knowledge_base_id and on knowledge_document_id
  • knowledge_chunk has no soft-delete column and no updated_date — when a document changes, its chunks are regenerated as a set rather than edited row by row
  • Vector embeddings are not stored in PostgreSQL; they live in an external vector store and are referenced through knowledge_chunk.embedding_id