From b0245a7eff6ca96e097449d99ce37f07ebdeb8bc Mon Sep 17 00:00:00 2001 From: Yanyutin753 <132346501+Yanyutin753@users.noreply.github.com> Date: Sun, 28 Apr 2024 06:54:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8feat=20added=20environment=20variables?= =?UTF-8?q?=20and=20sync.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync.yml | 47 +++++++++++++++++++++++++++++++++++++ backend/apps/images/main.py | 12 ++++++---- backend/apps/rag/main.py | 3 ++- backend/config.py | 11 ++++++++- 4 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 000000000..b22e77265 --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,47 @@ +name: Upstream Sync + +permissions: + contents: write + issues: write + actions: write + +on: + schedule: + - cron: '0 * * * *' # every hour + workflow_dispatch: + +jobs: + sync_latest_from_upstream: + name: Sync latest commits from upstream repo + runs-on: ubuntu-latest + if: ${{ github.event.repository.fork }} + + steps: + - uses: actions/checkout@v4 + + - name: Clean issue notice + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issues' + labels: '🚨 Sync Fail' + + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 + with: + upstream_sync_repo: open-webui/open-webui + upstream_sync_branch: main + target_sync_branch: main + target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set + test_mode: false + + - name: Sync check + if: failure() + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-issue' + title: '🚨 Sync Fail' + labels: '🚨 Sync Fail' + body: | + Due to a change in the workflow file of the [open-webui] upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed [Tutorial][tutorial-en-US] for instructions. + [open-webui]: https://github.com/open-webui/open-webui \ No newline at end of file diff --git a/backend/apps/images/main.py b/backend/apps/images/main.py index 2059ac3c0..3b80a41b3 100644 --- a/backend/apps/images/main.py +++ b/backend/apps/images/main.py @@ -32,11 +32,15 @@ import logging from config import ( SRC_LOG_LEVELS, CACHE_DIR, + IMAGES_GENERATION_ENGINE, ENABLE_IMAGE_GENERATION, AUTOMATIC1111_BASE_URL, COMFYUI_BASE_URL, IMAGES_OPENAI_API_BASE_URL, IMAGES_OPENAI_API_KEY, + IMAGES_MODEL, + IMAGE_SIZE, + IMAGE_STEPS, ) @@ -55,21 +59,21 @@ app.add_middleware( allow_headers=["*"], ) -app.state.ENGINE = "" +app.state.ENGINE = IMAGES_GENERATION_ENGINE app.state.ENABLED = ENABLE_IMAGE_GENERATION app.state.OPENAI_API_BASE_URL = IMAGES_OPENAI_API_BASE_URL app.state.OPENAI_API_KEY = IMAGES_OPENAI_API_KEY -app.state.MODEL = "" +app.state.MODEL = IMAGES_MODEL app.state.AUTOMATIC1111_BASE_URL = AUTOMATIC1111_BASE_URL app.state.COMFYUI_BASE_URL = COMFYUI_BASE_URL -app.state.IMAGE_SIZE = "512x512" -app.state.IMAGE_STEPS = 50 +app.state.IMAGE_SIZE = IMAGE_SIZE +app.state.IMAGE_STEPS = IMAGE_STEPS @app.get("/config") diff --git a/backend/apps/rag/main.py b/backend/apps/rag/main.py index 715d70b1b..a33a29659 100644 --- a/backend/apps/rag/main.py +++ b/backend/apps/rag/main.py @@ -74,6 +74,7 @@ from config import ( RAG_EMBEDDING_MODEL_TRUST_REMOTE_CODE, ENABLE_RAG_HYBRID_SEARCH, RAG_RERANKING_MODEL, + PDF_EXTRACT_IMAGES, RAG_RERANKING_MODEL_AUTO_UPDATE, RAG_RERANKING_MODEL_TRUST_REMOTE_CODE, RAG_OPENAI_API_BASE_URL, @@ -108,7 +109,7 @@ app.state.RAG_TEMPLATE = RAG_TEMPLATE app.state.OPENAI_API_BASE_URL = RAG_OPENAI_API_BASE_URL app.state.OPENAI_API_KEY = RAG_OPENAI_API_KEY -app.state.PDF_EXTRACT_IMAGES = False +app.state.PDF_EXTRACT_IMAGES = PDF_EXTRACT_IMAGES def update_embedding_model( diff --git a/backend/config.py b/backend/config.py index f5eda8366..b05f5cee9 100644 --- a/backend/config.py +++ b/backend/config.py @@ -441,6 +441,8 @@ ENABLE_RAG_HYBRID_SEARCH = ( RAG_EMBEDDING_ENGINE = os.environ.get("RAG_EMBEDDING_ENGINE", "") +PDF_EXTRACT_IMAGES = os.environ.get("PDF_EXTRACT_IMAGES", "False").lower() == "true" + RAG_EMBEDDING_MODEL = os.environ.get( "RAG_EMBEDDING_MODEL", "sentence-transformers/all-MiniLM-L6-v2" ) @@ -529,18 +531,25 @@ WHISPER_MODEL_AUTO_UPDATE = ( # Images #################################### +IMAGES_GENERATION_ENGINE = os.getenv("IMAGES_GENERATION_ENGINE", "") + ENABLE_IMAGE_GENERATION = ( os.environ.get("ENABLE_IMAGE_GENERATION", "").lower() == "true" ) AUTOMATIC1111_BASE_URL = os.getenv("AUTOMATIC1111_BASE_URL", "") -COMFYUI_BASE_URL = os.getenv("COMFYUI_BASE_URL", "") +COMFYUI_BASE_URL = os.getenv("COMFYUI_BASE_URL", "") IMAGES_OPENAI_API_BASE_URL = os.getenv( "IMAGES_OPENAI_API_BASE_URL", OPENAI_API_BASE_URL ) IMAGES_OPENAI_API_KEY = os.getenv("IMAGES_OPENAI_API_KEY", OPENAI_API_KEY) +IMAGE_SIZE = os.getenv("IMAGE_SIZE", "512x512") + +IMAGE_STEPS = int(os.getenv("IMAGE_STEPS", 50)) + +IMAGES_MODEL = os.getenv("IMAGES_MODEL", "") #################################### # Audio