Skip to content

Commit

Permalink
Updated chat flow (#3244)
Browse files Browse the repository at this point in the history
* proper no assistant typing + no assistant modal

* updated chat flow

* k

* updates

* update

* k

* clean up

* fix mystery reorg

* cleanup

* update scroll

* default

* update logs

* push fade

* scroll nit

* finalize tags

* updates

* k

* various updates

* viewport height update

* source types update

* clean up unused components

* minor cleanup

* cleanup complete

* finalize changes

* badge up

* update filters

* small nit

* k

* k

* address comments

* quick unification of icons

* minor date range clarity

* minor nit

* k

* update sidebar line

* update for all screen sizes

* k

* k

* k

* k

* rm shs

* fix memoization

* fix memoization

* slack chat

* k

* k

* build org
  • Loading branch information
pablonyx authored Dec 2, 2024
1 parent 3432d93 commit de66f7a
Show file tree
Hide file tree
Showing 80 changed files with 3,458 additions and 3,475 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""add auto scroll to user model
Revision ID: a8c2065484e6
Revises: abe7378b8217
Create Date: 2024-11-22 17:34:09.690295
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "a8c2065484e6"
down_revision = "abe7378b8217"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column(
"user",
sa.Column("auto_scroll", sa.Boolean(), nullable=True, server_default=None),
)


def downgrade() -> None:
op.drop_column("user", "auto_scroll")
4 changes: 3 additions & 1 deletion backend/danswer/auth/noauth_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def load_no_auth_user_preferences(store: KeyValueStore) -> UserPreferences:
)
return UserPreferences(**preferences_data)
except KvKeyNotFoundError:
return UserPreferences(chosen_assistants=None, default_model=None)
return UserPreferences(
chosen_assistants=None, default_model=None, auto_scroll=True
)


def fetch_no_auth_user(store: KeyValueStore) -> UserInfo:
Expand Down
1 change: 1 addition & 0 deletions backend/danswer/chat/process_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ def stream_chat_message_objects(
additional_headers=custom_tool_additional_headers,
),
)

tools: list[Tool] = []
for tool_list in tool_dict.values():
tools.extend(tool_list)
Expand Down
1 change: 1 addition & 0 deletions backend/danswer/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class User(SQLAlchemyBaseUserTableUUID, Base):

# if specified, controls the assistants that are shown to the user + their order
# if not specified, all assistants are shown
auto_scroll: Mapped[bool] = mapped_column(Boolean, default=True)
chosen_assistants: Mapped[list[int] | None] = mapped_column(
postgresql.JSONB(), nullable=True, default=None
)
Expand Down
2 changes: 1 addition & 1 deletion backend/danswer/seeding/personas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ personas:
# this is for DanswerBot to use when tagged in a non-configured channel
# Careful setting specific IDs, this won't autoincrement the next ID value for postgres
- id: 0
name: "Knowledge"
name: "Search"
description: >
Assistant with access to documents from your Connected Sources.
# Default Prompt objects attached to the persona, see prompts.yaml
Expand Down
6 changes: 6 additions & 0 deletions backend/danswer/server/manage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class UserPreferences(BaseModel):
visible_assistants: list[int] = []
recent_assistants: list[int] | None = None
default_model: str | None = None
auto_scroll: bool | None = None


class UserInfo(BaseModel):
Expand Down Expand Up @@ -79,6 +80,7 @@ def from_model(
role=user.role,
preferences=(
UserPreferences(
auto_scroll=user.auto_scroll,
chosen_assistants=user.chosen_assistants,
default_model=user.default_model,
hidden_assistants=user.hidden_assistants,
Expand Down Expand Up @@ -128,6 +130,10 @@ class HiddenUpdateRequest(BaseModel):
hidden: bool


class AutoScrollRequest(BaseModel):
auto_scroll: bool | None


class SlackBotCreationRequest(BaseModel):
name: str
enabled: bool
Expand Down
26 changes: 25 additions & 1 deletion backend/danswer/server/manage/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from danswer.db.users import validate_user_role_update
from danswer.key_value_store.factory import get_kv_store
from danswer.server.manage.models import AllUsersResponse
from danswer.server.manage.models import AutoScrollRequest
from danswer.server.manage.models import UserByEmail
from danswer.server.manage.models import UserInfo
from danswer.server.manage.models import UserPreferences
Expand Down Expand Up @@ -497,7 +498,6 @@ def verify_user_logged_in(
return fetch_no_auth_user(store)

raise BasicAuthenticationError(detail="User Not Authenticated")

if user.oidc_expiry and user.oidc_expiry < datetime.now(timezone.utc):
raise BasicAuthenticationError(
detail="Access denied. User's OIDC token has expired.",
Expand Down Expand Up @@ -581,6 +581,30 @@ def update_user_recent_assistants(
db_session.commit()


@router.patch("/auto-scroll")
def update_user_auto_scroll(
request: AutoScrollRequest,
user: User | None = Depends(current_user),
db_session: Session = Depends(get_session),
) -> None:
if user is None:
if AUTH_TYPE == AuthType.DISABLED:
store = get_kv_store()
no_auth_user = fetch_no_auth_user(store)
no_auth_user.preferences.auto_scroll = request.auto_scroll
set_no_auth_user_preferences(store, no_auth_user.preferences)
return
else:
raise RuntimeError("This should never happen")

db_session.execute(
update(User)
.where(User.id == user.id) # type: ignore
.values(auto_scroll=request.auto_scroll)
)
db_session.commit()


@router.patch("/user/default-model")
def update_user_default_model(
request: ChosenDefaultModelRequest,
Expand Down
1 change: 1 addition & 0 deletions backend/danswer/server/query_and_chat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CreateChatMessageRequest(ChunkContext):
message: str
# Files that we should attach to this message
file_descriptors: list[FileDescriptor]

# If no prompt provided, uses the largest prompt of the chat session
# but really this should be explicitly specified, only in the simplified APIs is this inferred
# Use prompt_id 0 to use the system default prompt which is Answer-Question
Expand Down
5 changes: 0 additions & 5 deletions backend/danswer/server/settings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from fastapi import APIRouter
from fastapi import Depends
from fastapi import HTTPException
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -38,10 +37,6 @@
def put_settings(
settings: Settings, _: User | None = Depends(current_admin_user)
) -> None:
try:
settings.check_validity()
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
store_settings(settings)


Expand Down
23 changes: 0 additions & 23 deletions backend/danswer/server/settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,10 @@ def from_model(cls, notif: NotificationDBModel) -> "Notification":
class Settings(BaseModel):
"""General settings"""

chat_page_enabled: bool = True
search_page_enabled: bool = True
default_page: PageType = PageType.SEARCH
maximum_chat_retention_days: int | None = None
gpu_enabled: bool | None = None
product_gating: GatingType = GatingType.NONE

def check_validity(self) -> None:
chat_page_enabled = self.chat_page_enabled
search_page_enabled = self.search_page_enabled
default_page = self.default_page

if chat_page_enabled is False and search_page_enabled is False:
raise ValueError(
"One of `search_page_enabled` and `chat_page_enabled` must be True."
)

if default_page == PageType.CHAT and chat_page_enabled is False:
raise ValueError(
"The default page cannot be 'chat' if the chat page is disabled."
)

if default_page == PageType.SEARCH and search_page_enabled is False:
raise ValueError(
"The default page cannot be 'search' if the search page is disabled."
)


class UserSettings(Settings):
notifications: list[Notification]
Expand Down
4 changes: 0 additions & 4 deletions backend/ee/danswer/server/enterprise_settings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ async def refresh_access_token(
def put_settings(
settings: EnterpriseSettings, _: User | None = Depends(current_admin_user)
) -> None:
try:
settings.check_validity()
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
store_settings(settings)


Expand Down
1 change: 0 additions & 1 deletion backend/ee/danswer/server/seeding.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def _seed_personas(db_session: Session, personas: list[CreatePersonaRequest]) ->
def _seed_settings(settings: Settings) -> None:
logger.notice("Seeding Settings")
try:
settings.check_validity()
store_base_settings(settings)
logger.notice("Successfully seeded Settings")
except ValueError as e:
Expand Down
9 changes: 9 additions & 0 deletions web/@types/favicon-fetch.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module "favicon-fetch" {
interface FaviconFetchOptions {
uri: string;
}

function faviconFetch(options: FaviconFetchOptions): string | null;

export default faviconFetch;
}
Loading

0 comments on commit de66f7a

Please sign in to comment.