mirror of
https://github.com/open-webui/open-webui
synced 2024-11-22 08:07:55 +00:00
refac: access_control field
This commit is contained in:
parent
dae764fa5a
commit
150d0adea2
@ -34,6 +34,12 @@ class Knowledge(Base):
|
|||||||
data = Column(JSON, nullable=True)
|
data = Column(JSON, nullable=True)
|
||||||
meta = Column(JSON, nullable=True)
|
meta = Column(JSON, nullable=True)
|
||||||
|
|
||||||
|
access_control = Column(JSON, nullable=True) # Controls data access levels.
|
||||||
|
# NULL for public access (open to all users with "user" role).
|
||||||
|
# {} for individual access (private to the owner).
|
||||||
|
# {"group_ids": ["group_id1", "group_id2"]} for access restricted to specific groups.
|
||||||
|
# {"user_ids": ["user_id1", "user_id2"]} for access restricted to specific users.
|
||||||
|
|
||||||
created_at = Column(BigInteger)
|
created_at = Column(BigInteger)
|
||||||
updated_at = Column(BigInteger)
|
updated_at = Column(BigInteger)
|
||||||
|
|
||||||
@ -50,6 +56,8 @@ class KnowledgeModel(BaseModel):
|
|||||||
data: Optional[dict] = None
|
data: Optional[dict] = None
|
||||||
meta: Optional[dict] = None
|
meta: Optional[dict] = None
|
||||||
|
|
||||||
|
access_control = Optional[dict] = None
|
||||||
|
|
||||||
created_at: int # timestamp in epoch
|
created_at: int # timestamp in epoch
|
||||||
updated_at: int # timestamp in epoch
|
updated_at: int # timestamp in epoch
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from typing import Optional
|
|||||||
from open_webui.apps.webui.internal.db import Base, JSONField, get_db
|
from open_webui.apps.webui.internal.db import Base, JSONField, get_db
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import BigInteger, Column, Text
|
from sqlalchemy import BigInteger, Column, Text, JSON
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
@ -67,6 +67,12 @@ class Model(Base):
|
|||||||
Holds a JSON encoded blob of metadata, see `ModelMeta`.
|
Holds a JSON encoded blob of metadata, see `ModelMeta`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
access_control = Column(JSON, nullable=True) # Controls data access levels.
|
||||||
|
# NULL for public access (open to all users with "user" role).
|
||||||
|
# {} for individual access (private to the owner).
|
||||||
|
# {"group_ids": ["group_id1", "group_id2"]} for access restricted to specific groups.
|
||||||
|
# {"user_ids": ["user_id1", "user_id2"]} for access restricted to specific users.
|
||||||
|
|
||||||
updated_at = Column(BigInteger)
|
updated_at = Column(BigInteger)
|
||||||
created_at = Column(BigInteger)
|
created_at = Column(BigInteger)
|
||||||
|
|
||||||
@ -80,6 +86,8 @@ class ModelModel(BaseModel):
|
|||||||
params: ModelParams
|
params: ModelParams
|
||||||
meta: ModelMeta
|
meta: ModelMeta
|
||||||
|
|
||||||
|
access_control = Optional[dict] = None
|
||||||
|
|
||||||
updated_at: int # timestamp in epoch
|
updated_at: int # timestamp in epoch
|
||||||
created_at: int # timestamp in epoch
|
created_at: int # timestamp in epoch
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from typing import Optional
|
|||||||
|
|
||||||
from open_webui.apps.webui.internal.db import Base, get_db
|
from open_webui.apps.webui.internal.db import Base, get_db
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import BigInteger, Column, String, Text
|
from sqlalchemy import BigInteger, Column, String, Text, JSON
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Prompts DB Schema
|
# Prompts DB Schema
|
||||||
@ -19,6 +19,12 @@ class Prompt(Base):
|
|||||||
content = Column(Text)
|
content = Column(Text)
|
||||||
timestamp = Column(BigInteger)
|
timestamp = Column(BigInteger)
|
||||||
|
|
||||||
|
access_control = Column(JSON, nullable=True) # Controls data access levels.
|
||||||
|
# NULL for public access (open to all users with "user" role).
|
||||||
|
# {} for individual access (private to the owner).
|
||||||
|
# {"group_ids": ["group_id1", "group_id2"]} for access restricted to specific groups.
|
||||||
|
# {"user_ids": ["user_id1", "user_id2"]} for access restricted to specific users.
|
||||||
|
|
||||||
|
|
||||||
class PromptModel(BaseModel):
|
class PromptModel(BaseModel):
|
||||||
command: str
|
command: str
|
||||||
@ -27,6 +33,7 @@ class PromptModel(BaseModel):
|
|||||||
content: str
|
content: str
|
||||||
timestamp: int # timestamp in epoch
|
timestamp: int # timestamp in epoch
|
||||||
|
|
||||||
|
access_control = Optional[dict] = None
|
||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from open_webui.apps.webui.internal.db import Base, JSONField, get_db
|
|||||||
from open_webui.apps.webui.models.users import Users
|
from open_webui.apps.webui.models.users import Users
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from pydantic import BaseModel, ConfigDict
|
from pydantic import BaseModel, ConfigDict
|
||||||
from sqlalchemy import BigInteger, Column, String, Text
|
from sqlalchemy import BigInteger, Column, String, Text, JSON
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
log.setLevel(SRC_LOG_LEVELS["MODELS"])
|
||||||
@ -26,6 +26,13 @@ class Tool(Base):
|
|||||||
specs = Column(JSONField)
|
specs = Column(JSONField)
|
||||||
meta = Column(JSONField)
|
meta = Column(JSONField)
|
||||||
valves = Column(JSONField)
|
valves = Column(JSONField)
|
||||||
|
|
||||||
|
access_control = Column(JSON, nullable=True) # Controls data access levels.
|
||||||
|
# NULL for public access (open to all users with "user" role).
|
||||||
|
# {} for individual access (private to the owner).
|
||||||
|
# {"group_ids": ["group_id1", "group_id2"]} for access restricted to specific groups.
|
||||||
|
# {"user_ids": ["user_id1", "user_id2"]} for access restricted to specific users.
|
||||||
|
|
||||||
updated_at = Column(BigInteger)
|
updated_at = Column(BigInteger)
|
||||||
created_at = Column(BigInteger)
|
created_at = Column(BigInteger)
|
||||||
|
|
||||||
@ -42,6 +49,8 @@ class ToolModel(BaseModel):
|
|||||||
content: str
|
content: str
|
||||||
specs: list[dict]
|
specs: list[dict]
|
||||||
meta: ToolMeta
|
meta: ToolMeta
|
||||||
|
access_control = Optional[dict] = None
|
||||||
|
|
||||||
updated_at: int # timestamp in epoch
|
updated_at: int # timestamp in epoch
|
||||||
created_at: int # timestamp in epoch
|
created_at: int # timestamp in epoch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user