diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 57b7f6982f..0000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -ko_fi: oobabooga diff --git a/.github/ISSUE_TEMPLATE/bug_report_template.yml b/.github/ISSUE_TEMPLATE/bug_report_template.yml index bd30a0c9c1..ad22b6565a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_template.yml +++ b/.github/ISSUE_TEMPLATE/bug_report_template.yml @@ -46,7 +46,7 @@ body: id: system-info attributes: label: System Info - description: "Please share your system info with us: operating system, GPU brand, and GPU model. If you are using a Google Colab notebook, mention that instead." + description: "Please share your operating system and GPU type (NVIDIA/AMD/Intel/Apple). If you are using a Google Colab notebook, mention that instead." render: shell placeholder: validations: diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 91abb11fdf..9f7c99a63b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,10 @@ version: 2 updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests + - package-ecosystem: "pip" + directories: + - "/requirements/full/" + - "/requirements/portable/" + target-branch: "dev" schedule: interval: "weekly" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 51e26b13a3..a9d0250534 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,3 @@ ## Checklist: -- [ ] I have read the [Contributing guidelines](https://github.com/oobabooga/text-generation-webui/wiki/Contributing-guidelines). +- [ ] I have read the [Contributing guidelines](https://github.com/oobabooga/textgen/wiki/Contributing-guidelines). diff --git a/.github/workflows/build-everything-tgw.yml b/.github/workflows/build-everything-tgw.yml new file mode 100644 index 0000000000..7d7baa6d77 --- /dev/null +++ b/.github/workflows/build-everything-tgw.yml @@ -0,0 +1,105 @@ +name: Build Everything TGW + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + +permissions: + contents: write + +jobs: + build_release_cuda_windows: + name: CUDA Windows + uses: ./.github/workflows/build-portable-release-cuda.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_cuda_linux: + name: CUDA Linux + uses: ./.github/workflows/build-portable-release-cuda.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' + + build_release_vulkan_windows: + name: Vulkan Windows + uses: ./.github/workflows/build-portable-release-vulkan.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_vulkan_linux: + name: Vulkan Linux + uses: ./.github/workflows/build-portable-release-vulkan.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' + + build_release_rocm_windows: + name: ROCm Windows + uses: ./.github/workflows/build-portable-release-rocm.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_rocm_linux: + name: ROCm Linux + uses: ./.github/workflows/build-portable-release-rocm.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' + + build_release_cpu_windows: + name: CPU Windows + uses: ./.github/workflows/build-portable-release.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_cpu_linux: + name: CPU Linux + uses: ./.github/workflows/build-portable-release.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' + + build_release_macos: + name: macOS + uses: ./.github/workflows/build-portable-release.yml + with: + version: ${{ inputs.version }} + config: 'os:macos-15-intel,macos-14' + + build_release_ik_cuda_windows: + name: ik CUDA Windows + uses: ./.github/workflows/build-portable-release-ik-cuda.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_ik_cuda_linux: + name: ik CUDA Linux + uses: ./.github/workflows/build-portable-release-ik-cuda.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' + + build_release_ik_cpu_windows: + name: ik CPU Windows + uses: ./.github/workflows/build-portable-release-ik.yml + with: + version: ${{ inputs.version }} + config: 'os:windows-2022' + + build_release_ik_cpu_linux: + name: ik CPU Linux + uses: ./.github/workflows/build-portable-release-ik.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-22.04' diff --git a/.github/workflows/build-portable-release-cuda.yml b/.github/workflows/build-portable-release-cuda.yml new file mode 100644 index 0000000000..7c4d95e2b1 --- /dev/null +++ b/.github/workflows/build-portable-release-cuda.yml @@ -0,0 +1,225 @@ +name: Build CUDA + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022') + 'pyver' = @("3.13") + 'cuda' = @("12.4", "13.1") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} CUDA ${{ matrix.cuda }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-${VERSION_CLEAN}" + cd "textgen-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + CUDA_VERSION="${{ matrix.cuda }}" + VERSION="${{ inputs.version }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + else + PLATFORM="linux" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + cd .. + echo "Downloading Python for $PLATFORM..." + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file based on CUDA version + cd "textgen-${VERSION_CLEAN}" + if [[ "$CUDA_VERSION" == "13.1" ]]; then + REQ_FILE="requirements/portable/requirements_cuda131.txt" + else + REQ_FILE="requirements/portable/requirements.txt" + fi + + # 4. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 5. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 6. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-cuda${CUDA_VERSION}.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-cuda${CUDA_VERSION}.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/build-portable-release-ik-cuda.yml b/.github/workflows/build-portable-release-ik-cuda.yml new file mode 100644 index 0000000000..2613a5c234 --- /dev/null +++ b/.github/workflows/build-portable-release-ik-cuda.yml @@ -0,0 +1,230 @@ +name: Build ik CUDA + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022') + 'pyver' = @("3.13") + 'cuda' = @("12.4", "13.1") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} CUDA ${{ matrix.cuda }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-ik-${VERSION_CLEAN}" + cd "textgen-ik-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + CUDA_VERSION="${{ matrix.cuda }}" + VERSION="${{ inputs.version }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + else + PLATFORM="linux" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + cd .. + echo "Downloading Python for $PLATFORM..." + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-ik-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file based on CUDA version + cd "textgen-ik-${VERSION_CLEAN}" + if [[ "$CUDA_VERSION" == "13.1" ]]; then + REQ_FILE="requirements/portable/requirements_ik_cuda131.txt" + else + REQ_FILE="requirements/portable/requirements_ik.txt" + fi + + # 5. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 6. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 5d. Inject --ik into spawn args + sed -i 's/"--portable", "--api"/"--portable", "--ik", "--api"/' "${APP_DIR}/main.js" + sed -i 's|--portable --api|--portable --ik --api|g' textgen 2>/dev/null || true + sed -i 's|--portable --api|--portable --ik --api|g' textgen.bat 2>/dev/null || true + + # 7. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-ik-${VERSION_CLEAN}-${PLATFORM}-cuda${CUDA_VERSION}.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-ik-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-ik-${VERSION_CLEAN}-${PLATFORM}-cuda${CUDA_VERSION}.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-ik-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-ik-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/build-portable-release-ik.yml b/.github/workflows/build-portable-release-ik.yml new file mode 100644 index 0000000000..66f79711f1 --- /dev/null +++ b/.github/workflows/build-portable-release-ik.yml @@ -0,0 +1,225 @@ +name: Build ik CPU + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022') + 'pyver' = @("3.13") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-ik-${VERSION_CLEAN}" + cd "textgen-ik-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + VERSION="${{ inputs.version }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows-cpu" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + else + PLATFORM="linux-cpu" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + echo "Downloading Python for $PLATFORM..." + cd .. + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-ik-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file + cd "textgen-ik-${VERSION_CLEAN}" + REQ_FILE="requirements/portable/requirements_ik_cpu_only.txt" + echo "Using requirements file: $REQ_FILE" + + # 5. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 6. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 5d. Inject --ik into spawn args + sed -i 's/"--portable", "--api"/"--portable", "--ik", "--api"/' "${APP_DIR}/main.js" + sed -i 's|--portable --api|--portable --ik --api|g' textgen 2>/dev/null || true + sed -i 's|--portable --api|--portable --ik --api|g' textgen.bat 2>/dev/null || true + + # 7. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-ik-${VERSION_CLEAN}-${PLATFORM}.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-ik-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-ik-${VERSION_CLEAN}-${PLATFORM}.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-ik-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-ik-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/build-portable-release-rocm.yml b/.github/workflows/build-portable-release-rocm.yml new file mode 100644 index 0000000000..6a6a5a0218 --- /dev/null +++ b/.github/workflows/build-portable-release-rocm.yml @@ -0,0 +1,220 @@ +name: Build ROCm + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022') + 'pyver' = @("3.13") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-${VERSION_CLEAN}" + cd "textgen-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + VERSION="${{ inputs.version }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + else + PLATFORM="linux" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + cd .. + echo "Downloading Python for $PLATFORM..." + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file + REQ_FILE="requirements/portable/requirements_amd.txt" + + cd "textgen-${VERSION_CLEAN}" + + # 4. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 5. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 6. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-rocm7.2.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-rocm7.2.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/build-portable-release-vulkan.yml b/.github/workflows/build-portable-release-vulkan.yml new file mode 100644 index 0000000000..092aeb5700 --- /dev/null +++ b/.github/workflows/build-portable-release-vulkan.yml @@ -0,0 +1,220 @@ +name: Build Vulkan + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022') + 'pyver' = @("3.13") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-${VERSION_CLEAN}" + cd "textgen-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + VERSION="${{ inputs.version }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + else + PLATFORM="linux" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + cd .. + echo "Downloading Python for $PLATFORM..." + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file + REQ_FILE="requirements/portable/requirements_vulkan.txt" + + cd "textgen-${VERSION_CLEAN}" + + # 4. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 5. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 6. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-vulkan.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}-vulkan.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/build-portable-release.yml b/.github/workflows/build-portable-release.yml new file mode 100644 index 0000000000..dcd61ae3ce --- /dev/null +++ b/.github/workflows/build-portable-release.yml @@ -0,0 +1,246 @@ +name: Build CPU and macOS + +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Override configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + workflow_call: + inputs: + version: + description: 'Version tag of textgen to build: v3.0' + default: 'v3.0' + required: true + type: string + config: + description: 'Configurations to build: key1:item1-1,item1-2;key2:item2-1,item2-2' + default: 'Default' + required: false + type: string + exclude: + description: 'Exclude build configurations: key1-1:item1-1,key1-2:item1-2;key2-1:item2-1,key2-2:item2-2' + default: 'None' + required: false + type: string + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + env: + CONFIGIN: ${{ inputs.config }} + EXCLUDEIN: ${{ inputs.exclude }} + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('ubuntu-22.04', 'windows-2022', 'macos-14') + 'pyver' = @("3.13") + } + + if ($env:CONFIGIN -ne 'Default') {$env:CONFIGIN.split(';').foreach({$matrix[$_.split(':')[0]] = $_.split(':')[1].split(',')})} + + if ($env:EXCLUDEIN -ne 'None') { + $exclusions = @() + $exclusions += $env:EXCLUDEIN.split(';').replace(':','=').replace(',',"`n") | ConvertFrom-StringData + $matrix['exclude'] = $exclusions + } + + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT + + build_wheels: + name: ${{ matrix.os }} ${{ matrix.pyver }} + needs: define_matrix + runs-on: ${{ matrix.os }} + strategy: + matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} + defaults: + run: + shell: pwsh + env: + PCKGVER: ${{ inputs.version }} + + steps: + - uses: actions/checkout@v6 + with: + repository: 'oobabooga/textgen' + ref: ${{ inputs.version }} + submodules: 'recursive' + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.pyver }} + + - name: Build Package + shell: bash + run: | + VERSION_CLEAN="${{ inputs.version }}" + VERSION_CLEAN="${VERSION_CLEAN#v}" + cd .. + cp -r textgen "textgen-${VERSION_CLEAN}" + cd "textgen-${VERSION_CLEAN}" + + # Remove extensions that need additional requirements + allowed=("character_bias" "gallery" "sd_api_pictures") + find extensions/ -mindepth 1 -maxdepth 1 -type d | grep -v -E "$(printf '%s|' "${allowed[@]}" | sed 's/|$//')" | xargs rm -rf + + # Define common variables + VERSION="${{ inputs.version }}" + OS_TYPE="${{ matrix.os }}" + + # 1. Set platform-specific variables + if [[ "$RUNNER_OS" == "Windows" ]]; then + PLATFORM="windows-cpu" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-pc-windows-msvc-install_only_stripped.tar.gz" + PIP_PATH="portable_env/python.exe -m pip" + PACKAGES_PATH="portable_env/Lib/site-packages" + rm start_linux.sh start_macos.sh + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + PLATFORM="macos-x86_64" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-apple-darwin-install_only_stripped.tar.gz" + REQ_TYPE="apple_intel" + else + PLATFORM="macos-arm64" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-aarch64-apple-darwin-install_only_stripped.tar.gz" + REQ_TYPE="apple_silicon" + fi + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_linux.sh start_windows.bat + else + # Linux case + PLATFORM="linux-cpu" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz" + PIP_PATH="portable_env/bin/python -m pip" + PACKAGES_PATH="portable_env/lib/python3.13/site-packages" + rm start_macos.sh start_windows.bat + fi + + # 2. Download and extract Python + echo "Downloading Python for $PLATFORM..." + cd .. + curl -L -o python-build.tar.gz "$PYTHON_URL" + tar -xzf python-build.tar.gz + mv python "textgen-${VERSION_CLEAN}/portable_env" + + # 3. Prepare requirements file based on platform + cd "textgen-${VERSION_CLEAN}" + + # Select requirements file based on platform + if [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + REQ_FILE="requirements/portable/requirements_apple_intel.txt" + else + REQ_FILE="requirements/portable/requirements_apple_silicon.txt" + fi + else + REQ_FILE="requirements/portable/requirements_cpu_only.txt" + fi + + echo "Using requirements file: $REQ_FILE" + + # 4. Install packages + echo "Installing Python packages from $REQ_FILE..." + $PIP_PATH install --target="./$PACKAGES_PATH" -r "$REQ_FILE" + + # 5. Clean up + rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker setup.cfg .github .gitignore requirements/ one_click.py + + # 5b. Bundle Electron desktop launcher + ELECTRON_VERSION="41.5.0" + APP_DIR="app" + if [[ "$RUNNER_OS" == "Windows" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-win32-x64.zip" + ELECTRON_BIN="electron/electron.exe" + rm -f start_windows.bat + elif [[ "$RUNNER_OS" == "macOS" ]]; then + if [[ "$OS_TYPE" == "macos-15-intel" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-x64.zip" + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-darwin-arm64.zip" + fi + ELECTRON_BIN="electron/Electron.app/Contents/MacOS/Electron" + rm -f start_macos.sh + else + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-x64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.sh + fi + + echo "Downloading Electron ${ELECTRON_VERSION} (${ELECTRON_ZIP})..." + curl -L -o /tmp/electron.zip \ + "https://github.com/electron/electron/releases/download/v${ELECTRON_VERSION}/${ELECTRON_ZIP}" + mkdir electron + unzip -q /tmp/electron.zip -d electron + rm /tmp/electron.zip + + if [[ "$RUNNER_OS" == "Windows" ]]; then + sed "s|__APP__|${APP_DIR}|g" desktop/textgen.bat > textgen.bat + sed -i 's/$/\r/' textgen.bat + else + sed "s|__APP__|${APP_DIR}|g; s|__ELECTRON__|${ELECTRON_BIN}|g" desktop/textgen.sh > textgen + chmod +x textgen + fi + + mv desktop/main.js desktop/package.json . + rm -rf desktop + + # 5c. Restructure: textgen-VERSION/{textgen, user_data/, app/} + mkdir "${APP_DIR}" + shopt -s dotglob + for item in *; do + case "$item" in + "${APP_DIR}"|user_data|textgen|textgen.bat) ;; + *) mv "$item" "${APP_DIR}/" ;; + esac + done + shopt -u dotglob + + # 6. Create archive + cd .. + if [[ "$RUNNER_OS" == "Windows" ]]; then + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}.zip" + echo "Creating archive: $ARCHIVE_NAME" + powershell -Command "Compress-Archive -Path textgen-${VERSION_CLEAN} -DestinationPath $ARCHIVE_NAME" + else + ARCHIVE_NAME="textgen-portable-${VERSION_CLEAN}-${PLATFORM}.tar.gz" + echo "Creating archive: $ARCHIVE_NAME" + tar czf "$ARCHIVE_NAME" "textgen-${VERSION_CLEAN}" + fi + + - name: Upload files to a GitHub release + id: upload-release + uses: svenstaro/upload-release-action@2.7.0 + continue-on-error: true + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ../textgen-portable-* + tag: ${{ inputs.version }} + file_glob: true + make_latest: false + overwrite: true diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 2de6d955a3..0000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Close inactive issues -on: - schedule: - - cron: "10 23 * * *" - -jobs: - close-issues: - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - steps: - - uses: actions/stale@v5 - with: - stale-issue-message: "" - close-issue-message: "This issue has been closed due to inactivity for 6 weeks. If you believe it is still relevant, please leave a comment below. You can tag a developer in your comment." - days-before-issue-stale: 42 - days-before-issue-close: 0 - stale-issue-label: "stale" - days-before-pr-stale: -1 - days-before-pr-close: -1 - repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 61006cec18..b869ffe46a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,34 @@ -cache -characters -training/datasets -extensions/silero_tts/outputs -extensions/elevenlabs_tts/outputs -extensions/sd_api_pictures/outputs -extensions/multimodal/pipelines -logs -loras -models -presets -repositories -softprompts -torch-dumps -*pycache* -*/*pycache* -*/*/pycache* -venv/ -.venv/ +/css +/extensions +/installer_files +/repositories +/user_data + +.chroma +.DS_Store +.eslintrc.js +.idea +.installer_state.json +.venv +venv +.envrc +.direnv +.vs .vscode -.idea/ *.bak *.ipynb *.log - -settings.json -settings.yaml -notification.mp3 -img_bot* -img_me* -prompts/[0-9]* -models/config-user.yaml - -.DS_Store +*pycache* +cert.pem +key.pem +package.json +!desktop/package.json +package-lock.json Thumbs.db +wandb + +# ignore user docker config and top level links to docker files +/docker-compose.yaml +/docker-compose.yml +/Dockerfile +.env diff --git a/Colab-TextGen-GPU.ipynb b/Colab-TextGen-GPU.ipynb new file mode 100644 index 0000000000..734fe4fc7f --- /dev/null +++ b/Colab-TextGen-GPU.ipynb @@ -0,0 +1,119 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "private_outputs": true, + "provenance": [], + "gpuType": "T4" + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "source": [ + "# oobabooga/textgen\n", + "\n", + "After running both cells, a public gradio URL will appear at the bottom in around 10 minutes. You can optionally generate an API link.\n", + "\n", + "* Project page: https://github.com/oobabooga/textgen\n", + "* Gradio server status: https://status.gradio.app/" + ], + "metadata": { + "id": "MFQl6-FjSYtY" + } + }, + { + "cell_type": "code", + "source": [ + "#@title 1. Keep this tab alive to prevent Colab from disconnecting you { display-mode: \"form\" }\n", + "\n", + "#@markdown Press play on the music player that will appear below:\n", + "%%html\n", + "