mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: init organizationconfig
This commit is contained in:
parent
982ba037f5
commit
de93d56945
6 changed files with 178 additions and 37 deletions
68
apps/api/src/db/organization_config.py
Normal file
68
apps/api/src/db/organization_config.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
from json import JSONEncoder
|
||||
import json
|
||||
from typing import Literal, Optional
|
||||
from click import Option
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy import JSON, BigInteger, Column, ForeignKey
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
# AI
|
||||
class AILimitsSettings(BaseModel):
|
||||
limits_enabled: bool = False
|
||||
max_asks: int = 0
|
||||
|
||||
|
||||
class AIEnabledFeatures(BaseModel):
|
||||
editor: bool = False
|
||||
activity_ask: bool = False
|
||||
course_ask: bool = False
|
||||
global_ai_ask: bool = False
|
||||
|
||||
|
||||
class AIConfig(BaseModel):
|
||||
limits: AILimitsSettings = AILimitsSettings()
|
||||
embeddings: Literal[
|
||||
"text-embedding-ada-002", "all-MiniLM-L6-v2"
|
||||
] = "all-MiniLM-L6-v2"
|
||||
ai_model: Literal["gpt-3.5-turbo", "gpt-4-1106-preview"] = "gpt-3.5-turbo"
|
||||
features: AIEnabledFeatures = AIEnabledFeatures()
|
||||
|
||||
|
||||
class OrgUserConfig(BaseModel):
|
||||
signup_mechanism: Literal["open", "inviteOnly"] = "open"
|
||||
|
||||
|
||||
# Limits
|
||||
class LimitSettings(BaseModel):
|
||||
limits_enabled: bool = False
|
||||
max_users: int = 0
|
||||
max_storage: int = 0
|
||||
max_staff: int = 0
|
||||
|
||||
|
||||
# General
|
||||
class GeneralConfig(BaseModel):
|
||||
color: str = ""
|
||||
limits: LimitSettings = LimitSettings()
|
||||
users: OrgUserConfig = OrgUserConfig()
|
||||
active: bool = True
|
||||
|
||||
|
||||
class OrganizationConfigBase(SQLModel):
|
||||
GeneralConfig: GeneralConfig
|
||||
AIConfig: AIConfig
|
||||
|
||||
class OrganizationConfig(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
org_id: int = Field(
|
||||
sa_column=Column(BigInteger, ForeignKey("organization.id", ondelete="CASCADE"))
|
||||
)
|
||||
# TODO: fix this to use the correct type GeneralConfig
|
||||
config: dict = Field(default={}, sa_column=Column(JSON))
|
||||
creation_date: Optional[str]
|
||||
update_date: Optional[str]
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue