forked from danswer-ai/danswer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from mindvalley/chore/merge-upstream-2024050601
chore/merge upstream 2024050601
- Loading branch information
Showing
200 changed files
with
4,484 additions
and
3,174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
backend/alembic/versions/a3bfd0d64902_add_chosen_assistants_to_user_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"""Add chosen_assistants to User table | ||
Revision ID: a3bfd0d64902 | ||
Revises: ec85f2b3c544 | ||
Create Date: 2024-05-26 17:22:24.834741 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a3bfd0d64902" | ||
down_revision = "ec85f2b3c544" | ||
branch_labels: None = None | ||
depends_on: None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"user", | ||
sa.Column("chosen_assistants", postgresql.ARRAY(sa.Integer()), nullable=True), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("user", "chosen_assistants") |
28 changes: 28 additions & 0 deletions
28
backend/alembic/versions/b85f02ec1308_fix_file_type_migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""fix-file-type-migration | ||
Revision ID: b85f02ec1308 | ||
Revises: a3bfd0d64902 | ||
Create Date: 2024-05-31 18:09:26.658164 | ||
""" | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "b85f02ec1308" | ||
down_revision = "a3bfd0d64902" | ||
branch_labels: None = None | ||
depends_on: None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute( | ||
""" | ||
UPDATE file_store | ||
SET file_origin = UPPER(file_origin) | ||
""" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
# Let's not break anything on purpose :) | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from collections.abc import Mapping | ||
from typing import Any | ||
from typing import cast | ||
|
||
from danswer.auth.schemas import UserRole | ||
from danswer.dynamic_configs.store import ConfigNotFoundError | ||
from danswer.dynamic_configs.store import DynamicConfigStore | ||
from danswer.server.manage.models import UserInfo | ||
from danswer.server.manage.models import UserPreferences | ||
|
||
|
||
NO_AUTH_USER_PREFERENCES_KEY = "no_auth_user_preferences" | ||
|
||
|
||
def set_no_auth_user_preferences( | ||
store: DynamicConfigStore, preferences: UserPreferences | ||
) -> None: | ||
store.store(NO_AUTH_USER_PREFERENCES_KEY, preferences.dict()) | ||
|
||
|
||
def load_no_auth_user_preferences(store: DynamicConfigStore) -> UserPreferences: | ||
try: | ||
preferences_data = cast( | ||
Mapping[str, Any], store.load(NO_AUTH_USER_PREFERENCES_KEY) | ||
) | ||
return UserPreferences(**preferences_data) | ||
except ConfigNotFoundError: | ||
return UserPreferences(chosen_assistants=None) | ||
|
||
|
||
def fetch_no_auth_user(store: DynamicConfigStore) -> UserInfo: | ||
return UserInfo( | ||
id="__no_auth_user__", | ||
email="anonymous@danswer.ai", | ||
is_active=True, | ||
is_superuser=False, | ||
is_verified=True, | ||
role=UserRole.ADMIN, | ||
preferences=load_no_auth_user_preferences(store), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.