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 #42 from mindvalley/chore/merge-upstream-2024061901
chore/merge upstream 2024061901
- Loading branch information
Showing
88 changed files
with
3,761 additions
and
1,026 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
.idea | ||
/deployment/data/nginx/app.conf | ||
.vscode/launch.json | ||
*.sw? |
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
61 changes: 61 additions & 0 deletions
61
backend/alembic/versions/48d14957fe80_add_support_for_custom_tools.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,61 @@ | ||
"""Add support for custom tools | ||
Revision ID: 48d14957fe80 | ||
Revises: b85f02ec1308 | ||
Create Date: 2024-06-09 14:58:19.946509 | ||
""" | ||
from alembic import op | ||
import fastapi_users_db_sqlalchemy | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "48d14957fe80" | ||
down_revision = "b85f02ec1308" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"tool", | ||
sa.Column( | ||
"openapi_schema", | ||
postgresql.JSONB(astext_type=sa.Text()), | ||
nullable=True, | ||
), | ||
) | ||
op.add_column( | ||
"tool", | ||
sa.Column( | ||
"user_id", | ||
fastapi_users_db_sqlalchemy.generics.GUID(), | ||
nullable=True, | ||
), | ||
) | ||
op.create_foreign_key("tool_user_fk", "tool", "user", ["user_id"], ["id"]) | ||
|
||
op.create_table( | ||
"tool_call", | ||
sa.Column("id", sa.Integer(), primary_key=True), | ||
sa.Column("tool_id", sa.Integer(), nullable=False), | ||
sa.Column("tool_name", sa.String(), nullable=False), | ||
sa.Column( | ||
"tool_arguments", postgresql.JSONB(astext_type=sa.Text()), nullable=False | ||
), | ||
sa.Column( | ||
"tool_result", postgresql.JSONB(astext_type=sa.Text()), nullable=False | ||
), | ||
sa.Column( | ||
"message_id", sa.Integer(), sa.ForeignKey("chat_message.id"), nullable=False | ||
), | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_table("tool_call") | ||
|
||
op.drop_constraint("tool_user_fk", "tool", type_="foreignkey") | ||
op.drop_column("tool", "user_id") | ||
op.drop_column("tool", "openapi_schema") |
22 changes: 22 additions & 0 deletions
22
backend/alembic/versions/e209dc5a8156_added_prune_frequency.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,22 @@ | ||
"""added-prune-frequency | ||
Revision ID: e209dc5a8156 | ||
Revises: 48d14957fe80 | ||
Create Date: 2024-06-16 16:02:35.273231 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
revision = "e209dc5a8156" | ||
down_revision = "48d14957fe80" | ||
branch_labels = None # type: ignore | ||
depends_on = None # type: ignore | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column("connector", sa.Column("prune_freq", sa.Integer(), nullable=True)) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("connector", "prune_freq") |
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,21 @@ | ||
from typing import cast | ||
|
||
from danswer.dynamic_configs.factory import get_dynamic_config_store | ||
from danswer.dynamic_configs.interface import ConfigNotFoundError | ||
from danswer.dynamic_configs.interface import JSON_ro | ||
|
||
USER_STORE_KEY = "INVITED_USERS" | ||
|
||
|
||
def get_invited_users() -> list[str]: | ||
try: | ||
store = get_dynamic_config_store() | ||
return cast(list, store.load(USER_STORE_KEY)) | ||
except ConfigNotFoundError: | ||
return list() | ||
|
||
|
||
def write_invited_users(emails: list[str]) -> int: | ||
store = get_dynamic_config_store() | ||
store.store(USER_STORE_KEY, cast(JSON_ro, emails)) | ||
return len(emails) |
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
Oops, something went wrong.