2023-11-07 18:23:52 +03:00
|
|
|
from enum import Enum
|
2023-12-06 10:40:18 +03:00
|
|
|
from typing import List, Optional
|
2023-08-03 11:37:13 +03:00
|
|
|
from uuid import UUID
|
|
|
|
|
|
|
|
from pydantic import BaseModel
|
2023-11-16 13:02:58 +03:00
|
|
|
|
2023-12-18 16:23:45 +03:00
|
|
|
from modules.brain.entity.api_brain_definition_entity import ApiBrainDefinitionEntity
|
|
|
|
|
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-12-06 10:40:18 +03:00
|
|
|
COMPOSITE = "composite"
|
2023-11-07 18:23:52 +03:00
|
|
|
|
|
|
|
|
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-12-06 10:40:18 +03:00
|
|
|
brain_definition: Optional[ApiBrainDefinitionEntity]
|
|
|
|
connected_brains_ids: Optional[List[UUID]]
|
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
|
|
|
|
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
|
2023-12-06 10:40:18 +03:00
|
|
|
brain_definition: Optional[ApiBrainDefinitionEntity]
|
2023-11-13 21:08:47 +03:00
|
|
|
|
|
|
|
|
2023-12-01 00:29:28 +03:00
|
|
|
class RoleEnum(str, Enum):
|
|
|
|
Viewer = "Viewer"
|
|
|
|
Editor = "Editor"
|
|
|
|
Owner = "Owner"
|
|
|
|
|
|
|
|
|
2023-11-13 21:08:47 +03:00
|
|
|
class BrainUser(BaseModel):
|
|
|
|
id: UUID
|
|
|
|
user_id: UUID
|
|
|
|
rights: RoleEnum
|
|
|
|
default_brain: bool = False
|
2023-12-01 00:29:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
class MinimalUserBrainEntity(BaseModel):
|
|
|
|
id: UUID
|
|
|
|
name: str
|
|
|
|
rights: RoleEnum
|
|
|
|
status: str
|
|
|
|
brain_type: BrainType
|
2023-12-18 16:23:45 +03:00
|
|
|
description: str
|