From 4ae0a1f3f8661f685620dbab24bdb640a7d3df6e Mon Sep 17 00:00:00 2001 From: Jun Siang Cheah Date: Sun, 7 Jul 2024 12:06:42 +0100 Subject: [PATCH 01/12] fix: delete docker build cache in integration test --- .github/workflows/integration-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 4ef3d2771..639ea789f 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -35,6 +35,10 @@ jobs: done echo "Service is up!" + - name: Delete Docker build cache + run: | + docker builder prune --all --force + - name: Preload Ollama model run: | docker exec ollama ollama pull qwen:0.5b-chat-v1.5-q2_K From f971ba0c0b8b6b4a476e657c25f30b3775594461 Mon Sep 17 00:00:00 2001 From: Peter De-Ath Date: Sun, 7 Jul 2024 22:07:12 +0100 Subject: [PATCH 02/12] fix email update in AuthsTable model --- backend/apps/webui/models/auths.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/apps/webui/models/auths.py b/backend/apps/webui/models/auths.py index 9f6bd59e8..353dc854d 100644 --- a/backend/apps/webui/models/auths.py +++ b/backend/apps/webui/models/auths.py @@ -182,6 +182,7 @@ class AuthsTable: with get_db() as db: result = db.query(Auth).filter_by(id=id).update({"email": email}) + db.commit() return True if result == 1 else False except: return False From 1bb2724282b69ed9f03e7182f3e1a8a79ee20c18 Mon Sep 17 00:00:00 2001 From: Peter De-Ath Date: Sun, 7 Jul 2024 22:27:26 +0100 Subject: [PATCH 03/12] fix password update in AuthsTable model --- backend/apps/webui/models/auths.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/apps/webui/models/auths.py b/backend/apps/webui/models/auths.py index 353dc854d..616eb70f4 100644 --- a/backend/apps/webui/models/auths.py +++ b/backend/apps/webui/models/auths.py @@ -173,6 +173,7 @@ class AuthsTable: result = ( db.query(Auth).filter_by(id=id).update({"password": new_password}) ) + db.commit() return True if result == 1 else False except: return False From 8eb03c02da6b34046678b44061e4146a7080691e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 03:11:04 +0000 Subject: [PATCH 04/12] chore(deps): update pytest requirement in /backend Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.2.1...8.2.2) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 77585a2f2..49016c2e6 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -73,5 +73,5 @@ duckduckgo-search~=6.1.7 ## Tests docker~=7.1.0 -pytest~=8.2.1 +pytest~=8.2.2 pytest-docker~=3.1.1 From 842a6a6ee05c9544c7eb814e55603ae015d4cad3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 03:11:10 +0000 Subject: [PATCH 05/12] chore(deps): bump alembic from 1.13.1 to 1.13.2 in /backend Bumps [alembic](https://github.com/sqlalchemy/alembic) from 1.13.1 to 1.13.2. - [Release notes](https://github.com/sqlalchemy/alembic/releases) - [Changelog](https://github.com/sqlalchemy/alembic/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/alembic/commits) --- updated-dependencies: - dependency-name: alembic dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 77585a2f2..105859921 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -13,7 +13,7 @@ passlib[bcrypt]==1.7.4 requests==2.32.3 aiohttp==3.9.5 sqlalchemy==2.0.30 -alembic==1.13.1 +alembic==1.13.2 peewee==3.17.5 peewee-migrate==1.12.2 psycopg2-binary==2.9.9 From d9a393eae14ef59656cc1ac13c1136f3a870fd68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 03:11:12 +0000 Subject: [PATCH 06/12] chore(deps): bump opencv-python-headless in /backend Bumps [opencv-python-headless](https://github.com/opencv/opencv-python) from 4.9.0.80 to 4.10.0.84. - [Release notes](https://github.com/opencv/opencv-python/releases) - [Commits](https://github.com/opencv/opencv-python/commits) --- updated-dependencies: - dependency-name: opencv-python-headless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- backend/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/requirements.txt b/backend/requirements.txt index 77585a2f2..9059f6340 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -51,7 +51,7 @@ pyxlsb==1.0.10 xlrd==2.0.1 validators==0.28.1 -opencv-python-headless==4.9.0.80 +opencv-python-headless==4.10.0.84 rapidocr-onnxruntime==1.3.22 fpdf2==2.7.9 From c1d706dc5a47c64a3d7ea77c6a6817f12f5e6528 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jul 2024 23:01:15 -0700 Subject: [PATCH 07/12] fix: db issues --- backend/apps/webui/models/auths.py | 2 -- backend/apps/webui/models/chats.py | 5 +++-- backend/apps/webui/models/users.py | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/apps/webui/models/auths.py b/backend/apps/webui/models/auths.py index 616eb70f4..a17d92ff1 100644 --- a/backend/apps/webui/models/auths.py +++ b/backend/apps/webui/models/auths.py @@ -169,7 +169,6 @@ class AuthsTable: def update_user_password_by_id(self, id: str, new_password: str) -> bool: try: with get_db() as db: - result = ( db.query(Auth).filter_by(id=id).update({"password": new_password}) ) @@ -181,7 +180,6 @@ class AuthsTable: def update_email_by_id(self, id: str, email: str) -> bool: try: with get_db() as db: - result = db.query(Auth).filter_by(id=id).update({"email": email}) db.commit() return True if result == 1 else False diff --git a/backend/apps/webui/models/chats.py b/backend/apps/webui/models/chats.py index ae63999a2..207bfab69 100644 --- a/backend/apps/webui/models/chats.py +++ b/backend/apps/webui/models/chats.py @@ -141,13 +141,14 @@ class ChatTable: db.add(shared_result) db.commit() db.refresh(shared_result) + # Update the original chat with the share_id result = ( db.query(Chat) .filter_by(id=chat_id) .update({"share_id": shared_chat.id}) ) - + db.commit() return shared_chat if (shared_result and result) else None def update_shared_chat_by_chat_id(self, chat_id: str) -> Optional[ChatModel]: @@ -206,8 +207,8 @@ class ChatTable: def archive_all_chats_by_user_id(self, user_id: str) -> bool: try: with get_db() as db: - db.query(Chat).filter_by(user_id=user_id).update({"archived": True}) + db.commit() return True except: return False diff --git a/backend/apps/webui/models/users.py b/backend/apps/webui/models/users.py index 8e3b57bba..2f30cda02 100644 --- a/backend/apps/webui/models/users.py +++ b/backend/apps/webui/models/users.py @@ -212,6 +212,7 @@ class UsersTable: try: with get_db() as db: db.query(User).filter_by(id=id).update({"oauth_sub": oauth_sub}) + db.commit() user = db.query(User).filter_by(id=id).first() return UserModel.model_validate(user) From d157af2fc735c5105147f0ee115e4d6c1e07a124 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 7 Jul 2024 23:04:50 -0700 Subject: [PATCH 08/12] chore: format --- src/lib/i18n/locales/vi-VN/translation.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/i18n/locales/vi-VN/translation.json b/src/lib/i18n/locales/vi-VN/translation.json index b3def6335..aaea87bdc 100644 --- a/src/lib/i18n/locales/vi-VN/translation.json +++ b/src/lib/i18n/locales/vi-VN/translation.json @@ -182,7 +182,7 @@ "Discover, download, and explore custom functions": "Tìm kiếm, tải về và khám phá thêm các function tùy chỉnh", "Discover, download, and explore custom prompts": "Tìm kiếm, tải về và khám phá thêm các prompt tùy chỉnh", "Discover, download, and explore custom tools": "Tìm kiếm, tải về và khám phá thêm các tool tùy chỉnh", - "Discover, download, and explore model preseKhts": "Tìm kiếm, tải về và khám phá thêm các thiết lập mô hình sẵn", + "Discover, download, and explore model presets": "", "Dismissible": "Có thể loại bỏ", "Display Emoji in Call": "Hiển thị Emoji trong cuộc gọi", "Display the username instead of You in the Chat": "Hiển thị tên người sử dụng thay vì 'Bạn' trong nội dung chat", From 3b112375eefe263ab726a5bc51d7884562f4013c Mon Sep 17 00:00:00 2001 From: Jonathan Rohde Date: Mon, 8 Jul 2024 09:14:45 +0200 Subject: [PATCH 09/12] feat(documents): commit document delete --- backend/apps/webui/models/documents.py | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/apps/webui/models/documents.py b/backend/apps/webui/models/documents.py index 16145c4ac..ac8655da9 100644 --- a/backend/apps/webui/models/documents.py +++ b/backend/apps/webui/models/documents.py @@ -158,6 +158,7 @@ class DocumentsTable: with get_db() as db: db.query(Document).filter_by(name=name).delete() + db.commit() return True except: return False From 39d3dcd032e332313e3d0ffc5fb9d3baa474bdcb Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 8 Jul 2024 10:46:35 -0700 Subject: [PATCH 10/12] fix: db --- backend/migrations/env.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/migrations/env.py b/backend/migrations/env.py index 836893bbe..40f0700de 100644 --- a/backend/migrations/env.py +++ b/backend/migrations/env.py @@ -18,6 +18,8 @@ from apps.webui.models.users import User from apps.webui.models.files import File from apps.webui.models.functions import Function +from config import DATABASE_URL + # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config @@ -38,9 +40,13 @@ target_metadata = Auth.metadata # my_important_option = config.get_main_option("my_important_option") # ... etc. -database_url = os.getenv("DATABASE_URL", None) -if database_url: - config.set_main_option("sqlalchemy.url", database_url) +DB_URL = DATABASE_URL +# Replace the postgres:// with postgresql:// +if "postgres://" in DB_URL: + DB_URL = DB_URL.replace("postgres://", "postgresql://") + +if DB_URL: + config.set_main_option("sqlalchemy.url", DB_URL) def run_migrations_offline() -> None: From 95426fc6c9ec5ffafc675e4f4d3f5fe3bc727842 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 8 Jul 2024 11:27:10 -0700 Subject: [PATCH 11/12] refac: do not use subprocess --- backend/main.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/main.py b/backend/main.py index 2da19c5c7..c37124f1e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -173,13 +173,11 @@ https://github.com/open-webui/open-webui def run_migrations(): - env = os.environ.copy() - env["DATABASE_URL"] = DATABASE_URL - migration_task = subprocess.run( - ["alembic", f"-c{BACKEND_DIR}/alembic.ini", "upgrade", "head"], env=env - ) - if migration_task.returncode > 0: - raise ValueError("Error running migrations") + from alembic.config import Config + from alembic import command + + alembic_cfg = Config("alembic.ini") + command.upgrade(alembic_cfg, "head") @asynccontextmanager From 3b27acc77eaf112d8521ae22282c619ef9ccf394 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 8 Jul 2024 11:34:24 -0700 Subject: [PATCH 12/12] fix --- backend/apps/webui/internal/db.py | 6 ------ backend/config.py | 4 ++++ backend/migrations/env.py | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/apps/webui/internal/db.py b/backend/apps/webui/internal/db.py index aed110254..61025489f 100644 --- a/backend/apps/webui/internal/db.py +++ b/backend/apps/webui/internal/db.py @@ -81,12 +81,6 @@ handle_peewee_migration() SQLALCHEMY_DATABASE_URL = DATABASE_URL -# Replace the postgres:// with postgresql:// -if "postgres://" in SQLALCHEMY_DATABASE_URL: - SQLALCHEMY_DATABASE_URL = SQLALCHEMY_DATABASE_URL.replace( - "postgres://", "postgresql://" - ) - if "sqlite" in SQLALCHEMY_DATABASE_URL: engine = create_engine( SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False} diff --git a/backend/config.py b/backend/config.py index fcf44b3ef..4db04ea65 100644 --- a/backend/config.py +++ b/backend/config.py @@ -1331,3 +1331,7 @@ AUDIO_TTS_VOICE = PersistentConfig( #################################### DATABASE_URL = os.environ.get("DATABASE_URL", f"sqlite:///{DATA_DIR}/webui.db") + +# Replace the postgres:// with postgresql:// +if "postgres://" in DATABASE_URL: + DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://") diff --git a/backend/migrations/env.py b/backend/migrations/env.py index 40f0700de..efd37445f 100644 --- a/backend/migrations/env.py +++ b/backend/migrations/env.py @@ -49,6 +49,9 @@ if DB_URL: config.set_main_option("sqlalchemy.url", DB_URL) +print("DB_URL", DB_URL) + + def run_migrations_offline() -> None: """Run migrations in 'offline' mode.