2024-04-29 11:27:50 +03:00
|
|
|
from datetime import datetime
|
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
|
|
|
|
|
2023-12-18 16:23:45 +03:00
|
|
|
from modules.brain.entity.api_brain_definition_entity import ApiBrainDefinitionEntity
|
2024-02-20 08:44:06 +03:00
|
|
|
from modules.brain.entity.integration_brain import (
|
|
|
|
IntegrationDescriptionEntity,
|
|
|
|
IntegrationEntity,
|
|
|
|
)
|
2024-01-22 04:03:25 +03:00
|
|
|
from pydantic import BaseModel
|
2023-12-18 16:23:45 +03:00
|
|
|
|
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"
|
2024-02-06 08:02:46 +03:00
|
|
|
INTEGRATION = "integration"
|
2023-11-07 18:23:52 +03:00
|
|
|
|
|
|
|
|
2023-08-03 11:37:13 +03:00
|
|
|
class BrainEntity(BaseModel):
|
|
|
|
brain_id: UUID
|
|
|
|
name: str
|
2024-02-15 01:01:35 +03:00
|
|
|
description: Optional[str] = None
|
|
|
|
temperature: Optional[float] = None
|
|
|
|
model: Optional[str] = None
|
|
|
|
max_tokens: Optional[int] = None
|
|
|
|
status: Optional[str] = None
|
|
|
|
prompt_id: Optional[UUID] = None
|
2024-04-29 11:27:50 +03:00
|
|
|
last_update: datetime
|
2023-11-07 18:23:52 +03:00
|
|
|
brain_type: BrainType
|
2024-02-15 01:01:35 +03:00
|
|
|
brain_definition: Optional[ApiBrainDefinitionEntity] = None
|
|
|
|
connected_brains_ids: Optional[List[UUID]] = None
|
|
|
|
raw: Optional[bool] = None
|
|
|
|
jq_instructions: Optional[str] = None
|
2024-02-20 08:44:06 +03:00
|
|
|
integration: Optional[IntegrationEntity] = None
|
|
|
|
integration_description: Optional[IntegrationDescriptionEntity] = None
|
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
|
2024-02-15 01:01:35 +03:00
|
|
|
description: Optional[str] = None
|
2023-09-21 10:35:53 +03:00
|
|
|
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
|
2024-02-15 01:01:35 +03:00
|
|
|
brain_definition: Optional[ApiBrainDefinitionEntity] = None
|
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
|
2024-02-20 09:33:18 +03:00
|
|
|
integration_logo_url: str
|
2024-02-21 01:31:25 +03:00
|
|
|
max_files: int
|