mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 21:42:58 +00:00
Merge branch 'dev' into dependabot/pip/backend/dev/peewee-3.17.6
This commit is contained in:
commit
642c5e035d
4
.github/workflows/integration-test.yml
vendored
4
.github/workflows/integration-test.yml
vendored
@ -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
|
||||
|
@ -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}
|
||||
|
@ -169,10 +169,10 @@ 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})
|
||||
)
|
||||
db.commit()
|
||||
return True if result == 1 else False
|
||||
except:
|
||||
return False
|
||||
@ -180,8 +180,8 @@ 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
|
||||
except:
|
||||
return False
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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://")
|
||||
|
@ -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
|
||||
|
@ -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,16 @@ 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)
|
||||
|
||||
|
||||
print("DB_URL", DB_URL)
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
|
@ -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.6
|
||||
peewee-migrate==1.12.2
|
||||
psycopg2-binary==2.9.9
|
||||
@ -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
|
||||
@ -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
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user