mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-24 10:40:19 +02:00
Remove Slack bot personas from web UI
This commit is contained in:
parent
78d1ae0379
commit
eab4fe83a0
@ -5,6 +5,7 @@ from uuid import UUID
|
|||||||
from sqlalchemy import and_
|
from sqlalchemy import and_
|
||||||
from sqlalchemy import delete
|
from sqlalchemy import delete
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
|
from sqlalchemy import not_
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
from sqlalchemy.exc import NoResultFound
|
from sqlalchemy.exc import NoResultFound
|
||||||
from sqlalchemy.orm import selectinload
|
from sqlalchemy.orm import selectinload
|
||||||
@ -12,6 +13,7 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
from danswer.configs.chat_configs import HARD_DELETE_CHATS
|
from danswer.configs.chat_configs import HARD_DELETE_CHATS
|
||||||
from danswer.configs.constants import MessageType
|
from danswer.configs.constants import MessageType
|
||||||
|
from danswer.db.constants import SLACK_BOT_PERSONA_PREFIX
|
||||||
from danswer.db.models import ChatMessage
|
from danswer.db.models import ChatMessage
|
||||||
from danswer.db.models import ChatSession
|
from danswer.db.models import ChatSession
|
||||||
from danswer.db.models import DocumentSet as DocumentSetDBModel
|
from danswer.db.models import DocumentSet as DocumentSetDBModel
|
||||||
@ -381,11 +383,16 @@ def upsert_persona(
|
|||||||
|
|
||||||
|
|
||||||
def fetch_personas(
|
def fetch_personas(
|
||||||
db_session: Session, include_default: bool = False
|
db_session: Session,
|
||||||
|
include_default: bool = False,
|
||||||
|
include_slack_bot_personas: bool = False,
|
||||||
) -> Sequence[Persona]:
|
) -> Sequence[Persona]:
|
||||||
stmt = select(Persona).where(Persona.deleted == False) # noqa: E712
|
stmt = select(Persona).where(Persona.deleted == False) # noqa: E712
|
||||||
if not include_default:
|
if not include_default:
|
||||||
stmt = stmt.where(Persona.default_persona == False) # noqa: E712
|
stmt = stmt.where(Persona.default_persona == False) # noqa: E712
|
||||||
|
if not include_slack_bot_personas:
|
||||||
|
stmt = stmt.where(not_(Persona.name.startswith(SLACK_BOT_PERSONA_PREFIX)))
|
||||||
|
|
||||||
return db_session.scalars(stmt).all()
|
return db_session.scalars(stmt).all()
|
||||||
|
|
||||||
|
|
||||||
|
1
backend/danswer/db/constants.py
Normal file
1
backend/danswer/db/constants.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
SLACK_BOT_PERSONA_PREFIX = "__slack_bot_persona__"
|
@ -4,6 +4,7 @@ from sqlalchemy import select
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from danswer.db.chat import upsert_persona
|
from danswer.db.chat import upsert_persona
|
||||||
|
from danswer.db.constants import SLACK_BOT_PERSONA_PREFIX
|
||||||
from danswer.db.models import ChannelConfig
|
from danswer.db.models import ChannelConfig
|
||||||
from danswer.db.models import Persona
|
from danswer.db.models import Persona
|
||||||
from danswer.db.models import Persona__DocumentSet
|
from danswer.db.models import Persona__DocumentSet
|
||||||
@ -11,7 +12,7 @@ from danswer.db.models import SlackBotConfig
|
|||||||
|
|
||||||
|
|
||||||
def _build_persona_name(channel_names: list[str]) -> str:
|
def _build_persona_name(channel_names: list[str]) -> str:
|
||||||
return f"__slack_bot_persona__{'-'.join(channel_names)}"
|
return f"{SLACK_BOT_PERSONA_PREFIX}{'-'.join(channel_names)}"
|
||||||
|
|
||||||
|
|
||||||
def _cleanup_relationships(db_session: Session, persona_id: int) -> None:
|
def _cleanup_relationships(db_session: Session, persona_id: int) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user