Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a17060a
Provide Additional Context for Chunk Options in APIs (#1330)
yuhongsun96 Apr 15, 2024
1b41ec2
Remove Search Only Model (#1331)
yuhongsun96 Apr 15, 2024
599db71
Permission Sync Models (#1334)
yuhongsun96 Apr 15, 2024
654c103
test
avhagedorn Apr 15, 2024
26f8d88
Allow NLTK Failures (#1340)
yuhongsun96 Apr 17, 2024
be12e4f
Double Check Files/URLs (#1344)
yuhongsun96 Apr 18, 2024
89ff07a
Slack improvement
yuhongsun96 Apr 18, 2024
e361e92
Healthcheck for model server (#1350)
yuhongsun96 Apr 18, 2024
82b9cb4
Add check to ensure auth is enabled for every endpoint unless explici…
Weves Apr 19, 2024
87f304d
Swap Index Early (#1353)
yuhongsun96 Apr 19, 2024
58545cc
Pre download models (#1354)
yuhongsun96 Apr 20, 2024
4e9605e
Only Log Index Attempt CC Pair Miscount (#1355)
yuhongsun96 Apr 20, 2024
7d51549
Remove Unused Volumes (#1356)
yuhongsun96 Apr 20, 2024
f616b7e
Web Connector to only allow Global IPs (#1357)
yuhongsun96 Apr 20, 2024
b407edb
Personal assistants
Weves Apr 20, 2024
df216ea
Assistant rework fixes
Weves Apr 22, 2024
832d40e
Allow separate vespa config server host
Weves Apr 23, 2024
7044cae
Remove Nested DB Sessions (#1367)
yuhongsun96 Apr 23, 2024
8b4e55c
Vespa Batch Size (#1368)
yuhongsun96 Apr 23, 2024
0b1695f
fix error: NextRouter was not mounted
jigneshsolanki Apr 23, 2024
d2774f8
k
yuhongsun96 Apr 24, 2024
66d9569
Disabled Connectors List (#1376)
yuhongsun96 Apr 25, 2024
648f2d0
Add env variable to disable streaming for the DefaultMultiLLM class
Weves Apr 25, 2024
ee6b8b7
properly yield non-streaming responses
mbektas Apr 25, 2024
b4842e3
Rework Disabled Connector options to Whitelist instead (#1386)
yuhongsun96 Apr 25, 2024
d756ad3
Connectors Whitelist Fix (#1387)
yuhongsun96 Apr 25, 2024
ead7a80
Fix Tag Integer Enums (#1388)
yuhongsun96 Apr 26, 2024
fe03747
Support to loop through all nested subcategories (#1382)
VikasNeha Apr 26, 2024
85a8f99
Fix credential form refresh
Weves Apr 26, 2024
60d5aba
Add token rate limit tables to MIT
Weves Apr 26, 2024
9211334
Fix document360 mypy issue
Weves Apr 26, 2024
73d9408
Fix compose file dependencies
Weves Apr 26, 2024
6f2d6fc
Set message logging to debug (#1396)
yuhongsun96 Apr 27, 2024
4c74006
Fix Citation Sort Tiebreak (#1397)
yuhongsun96 Apr 27, 2024
f5b3333
Add UI-based LLM selection
Weves Apr 14, 2024
a19290c
Address 'PGRES_TUPLES_OK and no message from the libpq' issues
Weves Apr 27, 2024
a2156dd
Cancel scheduled indexing attempts on deletion request
Weves Apr 27, 2024
350e548
fix(gitignore): properly ignore celery-generated file
dheavy Apr 26, 2024
5b93e78
Add image upload capabilities
Weves Apr 29, 2024
3fb68af
Address rate limiting for Notion
Weves Apr 30, 2024
b89e912
Fix double message send
Weves Apr 30, 2024
96762cf
Misc UI improvments
Weves May 1, 2024
7b94159
Api key email display for manage/me endpoint (#1409)
yuhongsun96 May 1, 2024
577c870
Manage me endpoint key rename (#1410)
yuhongsun96 May 1, 2024
143b50c
Save correct document url from document360 (#1413)
VikasNeha May 2, 2024
39ff243
Merge branch 'main' into ginetta-frontend
brunnolou May 6, 2024
c80d9cf
feat: use theme colors fix dark mode
brunnolou Apr 22, 2024
fa971b4
feat: adjust colors
brunnolou May 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ api_keys.py
.env
vespa-app.zip
dynamic_config_storage/
celerybeat-schedule
celerybeat-schedule*
9 changes: 9 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ RUN apt-get remove -y --allow-remove-essential perl-base xserver-common xvfb cma
rm -rf /var/lib/apt/lists/* && \
rm /usr/local/lib/python3.11/site-packages/tornado/test/test.key

# Pre-downloading models for setups with limited egress
RUN python -c "from transformers import AutoTokenizer; AutoTokenizer.from_pretrained('intfloat/e5-base-v2')"

# Pre-downloading NLTK for setups with limited egress
RUN python -c "import nltk; \
nltk.download('stopwords', quiet=True); \
nltk.download('wordnet', quiet=True); \
nltk.download('punkt', quiet=True);"

# Set up application files
WORKDIR /app
COPY ./danswer /app/danswer
Expand Down
10 changes: 10 additions & 0 deletions backend/Dockerfile.model_server
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt
RUN apt-get remove -y --allow-remove-essential perl-base && \
apt-get autoremove -y

# Pre-downloading models for setups with limited egress
RUN python -c "from transformers import AutoModel, AutoTokenizer, TFDistilBertForSequenceClassification; \
from huggingface_hub import snapshot_download; \
AutoTokenizer.from_pretrained('danswer/intent-model'); \
AutoTokenizer.from_pretrained('intfloat/e5-base-v2'); \
AutoTokenizer.from_pretrained('mixedbread-ai/mxbai-rerank-xsmall-v1'); \
snapshot_download('danswer/intent-model'); \
snapshot_download('intfloat/e5-base-v2'); \
snapshot_download('mixedbread-ai/mxbai-rerank-xsmall-v1')"

WORKDIR /app

# Utils used by model server
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Add tables for UI-based LLM configuration

Revision ID: 401c1ac29467
Revises: 703313b75876
Create Date: 2024-04-13 18:07:29.153817

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "401c1ac29467"
down_revision = "703313b75876"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
"llm_provider",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(), nullable=False),
sa.Column("api_key", sa.String(), nullable=True),
sa.Column("api_base", sa.String(), nullable=True),
sa.Column("api_version", sa.String(), nullable=True),
sa.Column(
"custom_config",
postgresql.JSONB(astext_type=sa.Text()),
nullable=True,
),
sa.Column("default_model_name", sa.String(), nullable=False),
sa.Column("fast_default_model_name", sa.String(), nullable=True),
sa.Column("is_default_provider", sa.Boolean(), unique=True, nullable=True),
sa.Column("model_names", postgresql.ARRAY(sa.String()), nullable=True),
sa.PrimaryKeyConstraint("id"),
sa.UniqueConstraint("name"),
)

op.add_column(
"persona",
sa.Column("llm_model_provider_override", sa.String(), nullable=True),
)


def downgrade() -> None:
op.drop_column("persona", "llm_model_provider_override")

op.drop_table("llm_provider")
83 changes: 83 additions & 0 deletions backend/alembic/versions/703313b75876_add_tokenratelimit_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Add TokenRateLimit Tables

Revision ID: 703313b75876
Revises: fad14119fb92
Create Date: 2024-04-15 01:36:02.952809

"""
import json
from typing import cast
from alembic import op
import sqlalchemy as sa
from danswer.dynamic_configs.factory import get_dynamic_config_store

# revision identifiers, used by Alembic.
revision = "703313b75876"
down_revision = "fad14119fb92"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
"token_rate_limit",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("enabled", sa.Boolean(), nullable=False),
sa.Column("token_budget", sa.Integer(), nullable=False),
sa.Column("period_hours", sa.Integer(), nullable=False),
sa.Column(
"scope",
sa.String(length=10),
nullable=False,
),
sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"token_rate_limit__user_group",
sa.Column("rate_limit_id", sa.Integer(), nullable=False),
sa.Column("user_group_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["rate_limit_id"],
["token_rate_limit.id"],
),
sa.ForeignKeyConstraint(
["user_group_id"],
["user_group.id"],
),
sa.PrimaryKeyConstraint("rate_limit_id", "user_group_id"),
)

try:
settings_json = cast(
str, get_dynamic_config_store().load("token_budget_settings")
)
settings = json.loads(settings_json)

is_enabled = settings.get("enable_token_budget", False)
token_budget = settings.get("token_budget", -1)
period_hours = settings.get("period_hours", -1)

if is_enabled and token_budget > 0 and period_hours > 0:
op.execute(
f"INSERT INTO token_rate_limit \
(enabled, token_budget, period_hours, scope) VALUES \
({is_enabled}, {token_budget}, {period_hours}, 'GLOBAL')"
)

# Delete the dynamic config
get_dynamic_config_store().delete("token_budget_settings")

except Exception:
# Ignore if the dynamic config is not found
pass


def downgrade() -> None:
op.drop_table("token_rate_limit__user_group")
op.drop_table("token_rate_limit")
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Permission Auto Sync Framework

Revision ID: 72bdc9929a46
Revises: 475fcefe8826
Create Date: 2024-04-14 21:15:28.659634

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "72bdc9929a46"
down_revision = "475fcefe8826"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.create_table(
"email_to_external_user_cache",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("external_user_id", sa.String(), nullable=False),
sa.Column("user_id", sa.UUID(), nullable=True),
sa.Column("user_email", sa.String(), nullable=False),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"external_permission",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("user_id", sa.UUID(), nullable=True),
sa.Column("user_email", sa.String(), nullable=False),
sa.Column(
"source_type",
sa.String(),
nullable=False,
),
sa.Column("external_permission_group", sa.String(), nullable=False),
sa.ForeignKeyConstraint(
["user_id"],
["user.id"],
),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"permission_sync_run",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column(
"source_type",
sa.String(),
nullable=False,
),
sa.Column("update_type", sa.String(), nullable=False),
sa.Column("cc_pair_id", sa.Integer(), nullable=True),
sa.Column(
"status",
sa.String(),
nullable=False,
),
sa.Column("error_msg", sa.Text(), nullable=True),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.ForeignKeyConstraint(
["cc_pair_id"],
["connector_credential_pair.id"],
),
sa.PrimaryKeyConstraint("id"),
)


def downgrade() -> None:
op.drop_table("permission_sync_run")
op.drop_table("external_permission")
op.drop_table("email_to_external_user_cache")
27 changes: 27 additions & 0 deletions backend/alembic/versions/ef7da92f7213_add_files_to_chatmessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add files to ChatMessage

Revision ID: ef7da92f7213
Revises: 401c1ac29467
Create Date: 2024-04-28 16:59:33.199153

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "ef7da92f7213"
down_revision = "401c1ac29467"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column(
"chat_message",
sa.Column("files", postgresql.JSONB(astext_type=sa.Text()), nullable=True),
)


def downgrade() -> None:
op.drop_column("chat_message", "files")
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Delete Tags with wrong Enum

Revision ID: fad14119fb92
Revises: 72bdc9929a46
Create Date: 2024-04-25 17:05:09.695703

"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "fad14119fb92"
down_revision = "72bdc9929a46"
branch_labels = None
depends_on = None


def upgrade() -> None:
# Some documents may lose their tags but this is the only way as the enum
# mapping may have changed since tag switched to string (it will be reindexed anyway)
op.execute(
"""
DELETE FROM document__tag
WHERE tag_id IN (
SELECT id FROM tag
WHERE source ~ '^[0-9]+$'
)
"""
)

op.execute(
"""
DELETE FROM tag
WHERE source ~ '^[0-9]+$'
"""
)


def downgrade() -> None:
pass
17 changes: 17 additions & 0 deletions backend/danswer/auth/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
from danswer.configs.app_configs import VALID_EMAIL_DOMAINS
from danswer.configs.app_configs import WEB_DOMAIN
from danswer.configs.constants import AuthType
from danswer.configs.constants import DANSWER_API_KEY_DUMMY_EMAIL_DOMAIN
from danswer.configs.constants import DANSWER_API_KEY_PREFIX
from danswer.configs.constants import UNNAMED_KEY_PLACEHOLDER
from danswer.db.auth import get_access_token_db
from danswer.db.auth import get_user_count
from danswer.db.auth import get_user_db
Expand Down Expand Up @@ -69,6 +72,20 @@ def verify_auth_setting() -> None:
logger.info(f"Using Auth Type: {AUTH_TYPE.value}")


def get_display_email(email: str | None, space_less: bool = False) -> str:
if email and email.endswith(DANSWER_API_KEY_DUMMY_EMAIL_DOMAIN):
name = email.split("@")[0]
if name == DANSWER_API_KEY_PREFIX + UNNAMED_KEY_PLACEHOLDER:
return "Unnamed API Key"

if space_less:
return name

return name.replace("API_KEY__", "API Key: ")

return email or ""


def user_needs_to_be_verified() -> bool:
# all other auth types besides basic should require users to be
# verified
Expand Down
Loading