contract-query/backend/app/models/index.py
2025-08-14 15:03:33 -05:00

52 lines
No EOL
1.6 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional, List, Dict, Any
from datetime import datetime
from bson import ObjectId
from .user import PyObjectId
class IndexBase(BaseModel):
name: str
description: Optional[str] = None
created_by: PyObjectId
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None
class IndexCreate(IndexBase):
pass
class IndexUpdate(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
updated_at: Optional[datetime] = None
class IndexInDB(IndexBase):
id: PyObjectId = Field(default_factory=PyObjectId, alias="_id")
index_id: str # Unique string identifier for the index
status: str = "active" # active, inactive, deleted
document_count: int = 0
settings: Dict[str, Any] = Field(default_factory=dict)
vector_store_path: Optional[str] = None
embedding_model: str = "text-embedding-ada-002"
chunk_size: int = 1000
chunk_overlap: int = 200
class Config:
populate_by_name = True
arbitrary_types_allowed = True
json_encoders = {ObjectId: str}
class Index(IndexBase):
id: PyObjectId = Field(default_factory=PyObjectId, alias="_id")
index_id: str
status: str = "active"
document_count: int = 0
settings: Dict[str, Any] = Field(default_factory=dict)
vector_store_path: Optional[str] = None
embedding_model: str = "text-embedding-ada-002"
chunk_size: int = 1000
chunk_overlap: int = 200
class Config:
populate_by_name = True
arbitrary_types_allowed = True
json_encoders = {ObjectId: str}