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]
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
from typing import Optional
|
||||
from sqlalchemy import BigInteger, Column, ForeignKey
|
||||
from sqlmodel import Field, SQLModel
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class HeaderTypeEnum(str, Enum):
|
||||
LOGO_MENU_SETTINGS = "LOGO_MENU_SETTINGS"
|
||||
MENU_LOGO_SETTINGS = "MENU_LOGO_SETTINGS"
|
||||
|
||||
|
||||
class OrganizationSettings(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"))
|
||||
)
|
||||
logo_image: Optional[str] = ""
|
||||
header_type: HeaderTypeEnum = HeaderTypeEnum.LOGO_MENU_SETTINGS
|
||||
color: str = ""
|
||||
creation_date: str
|
||||
update_date: str
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
from typing import Optional
|
||||
from sqlmodel import Field, SQLModel
|
||||
from src.db.organization_config import OrganizationConfig
|
||||
|
||||
|
||||
class OrganizationBase(SQLModel):
|
||||
name: str
|
||||
description: Optional[str]
|
||||
description: Optional[str]
|
||||
slug: str
|
||||
email: str
|
||||
logo_image: Optional[str]
|
||||
logo_image: Optional[str]
|
||||
|
||||
|
||||
class Organization(OrganizationBase, table=True):
|
||||
|
|
@ -16,9 +17,11 @@ class Organization(OrganizationBase, table=True):
|
|||
creation_date: str = ""
|
||||
update_date: str = ""
|
||||
|
||||
|
||||
class OrganizationUpdate(OrganizationBase):
|
||||
pass
|
||||
|
||||
|
||||
class OrganizationCreate(OrganizationBase):
|
||||
pass
|
||||
|
||||
|
|
@ -26,5 +29,6 @@ class OrganizationCreate(OrganizationBase):
|
|||
class OrganizationRead(OrganizationBase):
|
||||
id: int
|
||||
org_uuid: str
|
||||
creation_date: str
|
||||
update_date: str
|
||||
config: OrganizationConfig | dict
|
||||
creation_date: str
|
||||
update_date: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue