2023-11-07 18:23:52 +03:00
|
|
|
from enum import Enum
|
2023-08-03 11:37:13 +03:00
|
|
|
from typing import Optional
|
|
|
|
from uuid import UUID
|
|
|
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from routes.authorizations.types import RoleEnum
|
|
|
|
|
2023-11-16 13:02:58 +03:00
|
|
|
from models.ApiBrainDefinition import ApiBrainDefinition
|
|
|
|
|
2023-08-03 11:37:13 +03:00
|
|
|
|
2023-11-07 18:23:52 +03:00
|
|
|
class BrainType(str, Enum):
|
|
|
|
DOC = "doc"
|
|
|
|
API = "api"
|
|
|
|
|
|
|
|
|
2023-08-03 11:37:13 +03:00
|
|
|
class BrainEntity(BaseModel):
|
|
|
|
brain_id: UUID
|
|
|
|
name: str
|
|
|
|
description: Optional[str]
|
|
|
|
temperature: Optional[float]
|
|
|
|
model: Optional[str]
|
|
|
|
max_tokens: Optional[int]
|
|
|
|
status: Optional[str]
|
|
|
|
prompt_id: Optional[UUID]
|
2023-09-22 12:44:09 +03:00
|
|
|
last_update: str
|
2023-11-07 18:23:52 +03:00
|
|
|
brain_type: BrainType
|
2023-11-16 13:02:58 +03:00
|
|
|
brain_definition: Optional[ApiBrainDefinition]
|
2023-08-03 11:37:13 +03:00
|
|
|
|
2023-08-04 21:25:09 +03:00
|
|
|
@property
|
|
|
|
def id(self) -> UUID:
|
|
|
|
return self.brain_id
|
|
|
|
|
|
|
|
def dict(self, **kwargs):
|
|
|
|
data = super().dict(
|
|
|
|
**kwargs,
|
|
|
|
)
|
|
|
|
data["id"] = self.id
|
|
|
|
return data
|
|
|
|
|
2023-08-03 11:37:13 +03:00
|
|
|
|
|
|
|
class MinimalBrainEntity(BaseModel):
|
|
|
|
id: UUID
|
|
|
|
name: str
|
|
|
|
rights: RoleEnum
|
2023-09-20 17:24:56 +03:00
|
|
|
status: str
|
2023-11-20 20:22:06 +03:00
|
|
|
brain_type: BrainType
|
2023-09-21 10:35:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
class PublicBrain(BaseModel):
|
|
|
|
id: UUID
|
|
|
|
name: str
|
|
|
|
description: Optional[str]
|
|
|
|
number_of_subscribers: int = 0
|
2023-09-22 12:44:09 +03:00
|
|
|
last_update: str
|
2023-11-16 13:04:12 +03:00
|
|
|
brain_type: BrainType
|
|
|
|
brain_definition: Optional[ApiBrainDefinition]
|
2023-11-13 21:08:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
class BrainUser(BaseModel):
|
|
|
|
id: UUID
|
|
|
|
user_id: UUID
|
|
|
|
rights: RoleEnum
|
|
|
|
default_brain: bool = False
|