kotaemon/libs/ktem/ktem/index/models.py
Duc Nguyen (john) 8a90fcfc99 Restructure index to allow it to be dynamically created by end-user (#151)
1. Introduce the concept of "collection_name" to docstore and vector store. Each collection can be viewed similarly to a table in a SQL database. It allows better organizing information within this data source.
2. Move the `Index` and `Source` tables from the application scope into the index scope. For each new index created by user, these tables should increase accordingly. So it depends on the index, rather than the app.
3. Make each index responsible for the UI components in the app.
4. Construct the File UI page.
2024-03-07 01:50:47 +07:00

20 lines
543 B
Python

from typing import Optional
from ktem.db.engine import engine
from sqlalchemy import JSON, Column
from sqlmodel import Field, SQLModel
# TODO: simplify with using SQLAlchemy directly
class Index(SQLModel, table=True):
__table_args__ = {"extend_existing": True}
__tablename__ = "ktem__index" # type: ignore
id: Optional[int] = Field(default=None, primary_key=True)
name: str = Field(unique=True)
index_type: str = Field()
config: dict = Field(default={}, sa_column=Column(JSON))
Index.metadata.create_all(engine)