diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 7fd111381d..0000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -github: oobabooga -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/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index b94974f865..7a0534a77d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,6 +1,6 @@ --- name: Feature request -about: Suggest an improvement or new feature for the web UI +about: Suggest an improvement or new feature for TextGen title: '' labels: 'enhancement' assignees: '' diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 93aaf445f0..8f0d2814e2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,8 +5,9 @@ version: 2 updates: - - package-ecosystem: "pip" # See documentation for possible values - directory: "/" # Location of package manifests - target-branch: "dev" + - package-ecosystem: "pip" + directories: + - "/requirements/full/" + - "/requirements/portable/" 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..904269a7df --- /dev/null +++ b/.github/workflows/build-everything-tgw.yml @@ -0,0 +1,112 @@ +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_cuda_linux_arm: + name: CUDA Linux ARM + uses: ./.github/workflows/build-portable-release-cuda.yml + with: + version: ${{ inputs.version }} + config: 'os:ubuntu-24.04-arm;cuda:13.1' + + 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..e6594f4369 --- /dev/null +++ b/.github/workflows/build-portable-release-cuda.yml @@ -0,0 +1,235 @@ +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 + elif [[ "$RUNNER_ARCH" == "ARM64" ]]; then + PLATFORM="linux-arm64" + PYTHON_URL="https://github.com/astral-sh/python-build-standalone/releases/download/20260303/cpython-3.13.12+20260303-aarch64-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 + 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 + elif [[ "$RUNNER_ARCH" == "ARM64" ]]; then + ELECTRON_ZIP="electron-v${ELECTRON_VERSION}-linux-arm64.zip" + ELECTRON_BIN="electron/electron" + rm -f start_linux.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/preload.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..cce1fc61c4 --- /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/preload.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..75e905c0ce --- /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/preload.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..189d0415d8 --- /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/preload.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..2ba49f228d --- /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/preload.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..a1c5808922 --- /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/preload.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 8eb03299eb..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 months. If you believe it is still relevant, please leave a comment below. You can tag a developer in your comment." - days-before-issue-stale: 180 - 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 ca307c4a95..b869ffe46a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,14 @@ -/cache -/characters /css /extensions -/grammars /installer_files -/logs -/loras -/models -/presets -/prompts /repositories -/softprompts -/torch-dumps -/training/datasets - -/CMD_FLAGS.txt -/img_bot* -/img_me* -/models/config-user.yaml -/notification.mp3 -/settings*.json -/settings*.yaml +/user_data .chroma .DS_Store .eslintrc.js .idea +.installer_state.json .venv venv .envrc @@ -39,6 +22,7 @@ venv cert.pem key.pem package.json +!desktop/package.json package-lock.json Thumbs.db wandb diff --git a/CMD_FLAGS.txt b/CMD_FLAGS.txt deleted file mode 100644 index c2d63d9e8f..0000000000 --- a/CMD_FLAGS.txt +++ /dev/null @@ -1,3 +0,0 @@ -# Only used by the one-click installer. -# Example: -# --listen --api diff --git a/Colab-TextGen-GPU.ipynb b/Colab-TextGen-GPU.ipynb index 8e305e1dc3..734fe4fc7f 100644 --- a/Colab-TextGen-GPU.ipynb +++ b/Colab-TextGen-GPU.ipynb @@ -20,11 +20,11 @@ { "cell_type": "markdown", "source": [ - "# oobabooga/text-generation-webui\n", + "# 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/text-generation-webui\n", + "* Project page: https://github.com/oobabooga/textgen\n", "* Gradio server status: https://status.gradio.app/" ], "metadata": { @@ -51,30 +51,30 @@ "source": [ "#@title 2. Launch the web UI\n", "\n", - "#@markdown If unsure about the branch, write \"main\" or leave it blank.\n", + "#@markdown You can provide a direct GGUF link or a Hugging Face model URL.\n", "\n", "import os\n", "from pathlib import Path\n", "\n", "os.environ.pop('PYTHONPATH', None)\n", + "os.environ.pop('MPLBACKEND', None)\n", "\n", - "if Path.cwd().name != 'text-generation-webui':\n", + "if Path.cwd().name != 'textgen':\n", " print(\"\\033[1;32;1m\\n --> Installing the web UI. This will take a while, but after the initial setup, you can download and test as many models as you like.\\033[0;37;0m\\n\")\n", "\n", - " !git clone https://github.com/oobabooga/text-generation-webui\n", - " %cd text-generation-webui\n", + " !git clone https://github.com/oobabooga/textgen\n", + " %cd textgen\n", "\n", " # Install the project in an isolated environment\n", " !GPU_CHOICE=A \\\n", - " USE_CUDA118=FALSE \\\n", " LAUNCH_AFTER_INSTALL=FALSE \\\n", " INSTALL_EXTENSIONS=FALSE \\\n", " ./start_linux.sh\n", "\n", "# Parameters\n", - "model_url = \"https://huggingface.co/turboderp/gemma-2-9b-it-exl2\" #@param {type:\"string\"}\n", - "branch = \"8.0bpw\" #@param {type:\"string\"}\n", - "command_line_flags = \"--n-gpu-layers 128 --load-in-4bit --use_double_quant --no_flash_attn\" #@param {type:\"string\"}\n", + "model_url = \"https://huggingface.co/unsloth/Qwen3.5-9B-GGUF/resolve/main/Qwen3.5-9B-Q4_K_M.gguf\" #@param {type:\"string\"}\n", + "branch = \"\" #@param {type:\"string\"}\n", + "command_line_flags = \"--load-in-4bit --use_double_quant\" #@param {type:\"string\"}\n", "api = False #@param {type:\"boolean\"}\n", "\n", "if api:\n", @@ -83,26 +83,28 @@ " command_line_flags += f\" {param}\"\n", "\n", "model_url = model_url.strip()\n", + "model_name = \"\"\n", "if model_url != \"\":\n", " if not model_url.startswith('http'):\n", " model_url = 'https://huggingface.co/' + model_url\n", "\n", - " # Download the model\n", - " url_parts = model_url.strip('/').strip().split('/')\n", - " output_folder = f\"{url_parts[-2]}_{url_parts[-1]}\"\n", - " branch = branch.strip('\"\\' ')\n", - " if branch.strip() not in ['', 'main']:\n", - " output_folder += f\"_{branch}\"\n", - " !python download-model.py {model_url} --branch {branch}\n", - " else:\n", + " branch = branch.strip()\n", + " if '/resolve/' in model_url:\n", + " model_name = model_url.split('?')[0].split('/')[-1]\n", " !python download-model.py {model_url}\n", - "else:\n", - " output_folder = \"\"\n", + " else:\n", + " url_parts = model_url.strip('/').split('/')\n", + " model_name = f\"{url_parts[-2]}_{url_parts[-1]}\"\n", + " if branch not in ['', 'main']:\n", + " model_name += f\"_{branch}\"\n", + " !python download-model.py {model_url} --branch {branch}\n", + " else:\n", + " !python download-model.py {model_url}\n", "\n", "# Start the web UI\n", "cmd = f\"./start_linux.sh {command_line_flags} --share\"\n", - "if output_folder != \"\":\n", - " cmd += f\" --model {output_folder}\"\n", + "if model_name != \"\":\n", + " cmd += f\" --model {model_name}\"\n", "\n", "!$cmd" ], diff --git a/README.md b/README.md index 40ae94d538..8ede35269f 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,170 @@ -# Text generation web UI +
+ Special thanks to: +
+
+ + Warp sponsorship + -A Gradio web UI for Large Language Models. +### [Warp, built for coding with multiple AI agents](https://go.warp.dev/text-generation-webui) +[Available for macOS, Linux, & Windows](https://go.warp.dev/text-generation-webui)
+
+
-Its goal is to become the [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) of text generation. +# TextGen -|![Image1](https://github.com/oobabooga/screenshots/raw/main/print_instruct.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_chat.png) | -|:---:|:---:| -|![Image1](https://github.com/oobabooga/screenshots/raw/main/print_default.png) | ![Image2](https://github.com/oobabooga/screenshots/raw/main/print_parameters.png) | +**A desktop app for local LLMs. Open source, no telemetry.** Text, vision, tool-calling, web search. UI + API. + +[![GitHub stars](https://img.shields.io/github/stars/oobabooga/textgen?style=for-the-badge&logo=github&logoColor=white&labelColor=black)](https://github.com/oobabooga/textgen) + +[![Chat mode](https://raw.githubusercontent.com/oobabooga/screenshots/refs/heads/main/CHAT-4.8.png)](https://raw.githubusercontent.com/oobabooga/screenshots/refs/heads/main/CHAT-4.8.png) + +## Get started in 1 minute + +Download, unzip, double-click `textgen`. A window opens. + +**https://github.com/oobabooga/textgen/releases** + +Portable builds for Linux, Windows, and macOS with CUDA, Vulkan, ROCm, and CPU-only options. All dependencies included. Compatible with GGUF (llama.cpp) models. + +For additional backends (ExLlamaV3, Transformers), training, image generation, and extensions, see [Installation](#installation). ## Features -* 3 interface modes: default (two columns), notebook, and chat. -* Multiple model backends: [Transformers](https://github.com/huggingface/transformers), [llama.cpp](https://github.com/ggerganov/llama.cpp) (through [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)), [ExLlamaV2](https://github.com/turboderp/exllamav2), [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ), [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM). -* Dropdown menu for quickly switching between different models. -* Large number of extensions (built-in and user-contributed), including Coqui TTS for realistic voice outputs, Whisper STT for voice inputs, translation, [multimodal pipelines](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/multimodal), vector databases, Stable Diffusion integration, and a lot more. See [the wiki](https://github.com/oobabooga/text-generation-webui/wiki/07-%E2%80%90-Extensions) and [the extensions directory](https://github.com/oobabooga/text-generation-webui-extensions) for details. -* [Chat with custom characters](https://github.com/oobabooga/text-generation-webui/wiki/03-%E2%80%90-Parameters-Tab#character). -* Precise chat templates for instruction-following models, including Llama-2-chat, Alpaca, Vicuna, Mistral. -* LoRA: train new LoRAs with your own data, load/unload LoRAs on the fly for generation. -* Transformers library integration: load models in 4-bit or 8-bit precision through bitsandbytes, use llama.cpp with transformers samplers (`llamacpp_HF` loader), CPU inference in 32-bit precision using PyTorch. -* OpenAI-compatible API server with Chat and Completions endpoints -- see the [examples](https://github.com/oobabooga/text-generation-webui/wiki/12-%E2%80%90-OpenAI-API#examples). +### Chat & generation + +- `instruct` mode for instruction-following (like ChatGPT), and `chat-instruct`/`chat` modes for talking to custom characters. Prompts are automatically formatted with Jinja2 templates. +- **Vision (multimodal)**: Attach images to messages for visual understanding ([tutorial](https://github.com/oobabooga/textgen/wiki/Multimodal-Tutorial)). +- **File attachments**: Upload text files, PDF documents, and .docx documents to talk about their contents. +- Edit messages, navigate between message versions, and branch conversations at any point. +- Notebook tab for free-form text generation outside of chat turns. + +### Backends & API -## How to install +- **Multiple backends**: [llama.cpp](https://github.com/ggerganov/llama.cpp), [ik_llama.cpp](https://github.com/ikawrakow/ik_llama.cpp), [Transformers](https://github.com/huggingface/transformers), [ExLlamaV3](https://github.com/turboderp-org/exllamav3), and [TensorRT-LLM](https://github.com/NVIDIA/TensorRT-LLM). Switch between backends and models without restarting. +- **OpenAI/Anthropic-compatible API**: Chat, Completions, and Messages endpoints with tool-calling support. Use as a local drop-in replacement for the OpenAI/Anthropic APIs ([examples](https://github.com/oobabooga/textgen/wiki/12-%E2%80%90-OpenAI-API#examples)). +- **Tool-calling**: Models can call custom functions during chat, including web search, page fetching, and math. Each tool is a single `.py` file. MCP servers are also supported ([tutorial](https://github.com/oobabooga/textgen/wiki/Tool-Calling-Tutorial)). -1) Clone or [download](https://github.com/oobabooga/text-generation-webui/archive/refs/heads/main.zip) the repository. -2) Run the `start_linux.sh`, `start_windows.bat`, `start_macos.sh`, or `start_wsl.bat` script depending on your OS. -3) Select your GPU vendor when asked. -4) Once the installation ends, browse to `http://localhost:7860/?__theme=dark`. -5) Have fun! +### Training & image generation -To restart the web UI in the future, just run the `start_` script again. This script creates an `installer_files` folder where it sets up the project's requirements. In case you need to reinstall the requirements, you can simply delete that folder and start the web UI again. +- **Training**: Fine-tune LoRAs on multi-turn chat or raw text datasets. Supports resuming interrupted runs ([tutorial](https://github.com/oobabooga/textgen/wiki/05-%E2%80%90-Training-Tab)). +- **Image generation**: A dedicated tab for `diffusers` models like **Z-Image-Turbo**. Features 4-bit/8-bit quantization and a persistent gallery with image metadata ([tutorial](https://github.com/oobabooga/textgen/wiki/Image-Generation-Tutorial)). + +### Privacy & interface + +- 100% offline and private, with zero telemetry, external resources, or remote update requests. +- Dark/light themes, syntax highlighting for code blocks, and LaTeX rendering for mathematical expressions. +- Built-in and community [extensions](https://github.com/oobabooga/textgen/wiki/07-%E2%80%90-Extensions) including TTS, voice input, and translation. See the [extensions directory](https://github.com/oobabooga/textgen-extensions) for the full list. + +## Downloading models + +1. Download a GGUF model file from [Hugging Face](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads&search=gguf). +2. Place it in the `user_data/models` folder. + +That's it. The UI will detect it automatically. + +For recommended GGUF quants, check out [LocalBench](https://localbench.substack.com). To estimate how much memory a model will use, try the [GGUF Memory Calculator](https://huggingface.co/spaces/oobabooga/accurate-gguf-vram-calculator). + +
+Other model types (Transformers, EXL3) + +Models that consist of multiple files (like 16-bit Transformers models and EXL3 models) should be placed in a subfolder inside `user_data/models`: + +``` +textgen +└── user_data + └── models + └── Qwen_Qwen3-8B + ├── config.json + ├── generation_config.json + ├── model-00001-of-00004.safetensors + ├── ... + ├── tokenizer_config.json + └── tokenizer.json +``` + +These formats require the full installation (not the portable build). +
+ +## Installation + +For the desktop app, see the [portable builds](https://github.com/oobabooga/textgen/releases). The options below run the web UI in your browser instead. + +### Manual portable install with venv + +Fast setup on any Python 3.9+: + +```bash +# Clone repository +git clone https://github.com/oobabooga/textgen +cd textgen + +# Create virtual environment +python -m venv venv + +# Activate virtual environment +# On Windows: +venv\Scripts\activate +# On macOS/Linux: +source venv/bin/activate + +# Install dependencies (choose appropriate file under requirements/portable for your hardware) +pip install -r requirements/portable/requirements.txt --upgrade + +# Launch server (basic command) +python server.py --portable --api --auto-launch + +# When done working, deactivate +deactivate +``` -The script accepts command-line flags. Alternatively, you can edit the `CMD_FLAGS.txt` file with a text editor and add your flags there. +### Full installation -To get updates in the future, run `update_wizard_linux.sh`, `update_wizard_windows.bat`, `update_wizard_macos.sh`, or `update_wizard_wsl.bat`. +For users who need additional backends (ExLlamaV3, Transformers), training, image generation, or extensions like TTS, voice input, and translation. Requires ~10GB disk space and downloads PyTorch.
- -Setup details and information about installing manually - +Installation details -### One-click-installer +### One-click installer -The script uses Miniconda to set up a Conda environment in the `installer_files` folder. +1. Clone the repository, or [download its source code](https://github.com/oobabooga/textgen/archive/refs/heads/main.zip) and extract it. +2. Run the startup script for your OS: `start_windows.bat`, `start_linux.sh`, or `start_macos.sh`. +3. When prompted, select your GPU vendor. +4. After installation, open `http://127.0.0.1:7860` in your browser. -If you ever need to install something manually in the `installer_files` environment, you can launch an interactive shell using the cmd script: `cmd_linux.sh`, `cmd_windows.bat`, `cmd_macos.sh`, or `cmd_wsl.bat`. +After installation: -* There is no need to run any of those scripts (`start_`, `update_wizard_`, or `cmd_`) as admin/root. -* To install the requirements for extensions, you can use the `extensions_reqs` script for your OS. At the end, this script will install the main requirements for the project to make sure that they take precedence in case of version conflicts. -* For additional instructions about AMD and WSL setup, consult [the documentation](https://github.com/oobabooga/text-generation-webui/wiki). -* For automated installation, you can use the `GPU_CHOICE`, `USE_CUDA118`, `LAUNCH_AFTER_INSTALL`, and `INSTALL_EXTENSIONS` environment variables. For instance: `GPU_CHOICE=A USE_CUDA118=FALSE LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh`. +* **Restart**: run the same `start_` script. +* **Pass command-line flags**: directly (e.g., `./start_linux.sh --help`), or persist them in `user_data/CMD_FLAGS.txt` (e.g., `--api` to enable the API). +* **Update**: run the update script for your OS (`update_wizard_windows.bat`, `update_wizard_linux.sh`, or `update_wizard_macos.sh`). +* **Reinstall from scratch**: delete the `installer_files` folder and run the `start_` script again. +* **Install extension requirements**: use the update wizard's "Install/update extensions requirements" option. It reinstalls the main project requirements at the end to ensure they take precedence over conflicting extension dependencies. -### Manual installation using Conda +Notes: -Recommended if you have some experience with the command-line. +* These scripts (`start_`, `update_wizard_`, `cmd_`) don't need to run as admin/root. +* For automated installation, set the `GPU_CHOICE`, `LAUNCH_AFTER_INSTALL`, and `INSTALL_EXTENSIONS` environment variables. Example: `GPU_CHOICE=A LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh`. +* Under the hood, the script uses Miniforge to set up a Conda environment in `installer_files/`. To run anything manually in this environment, launch an interactive shell using `cmd_linux.sh`, `cmd_windows.bat`, or `cmd_macos.sh`. + +### Full installation with Conda #### 0. Install Conda -https://docs.conda.io/en/latest/miniconda.html +https://github.com/conda-forge/miniforge -On Linux or WSL, it can be automatically installed with these two commands ([source](https://educe-ubc.github.io/conda.html)): +On Linux or WSL, Miniforge can be automatically installed with these two commands: ``` -curl -sL "https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh" > "Miniconda3.sh" -bash Miniconda3.sh +curl -sL "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" > "Miniforge3.sh" +bash Miniforge3.sh ``` +For other platforms, download from: https://github.com/conda-forge/miniforge/releases/latest + #### 1. Create a new conda environment ``` -conda create -n textgen python=3.11 +conda create -n textgen python=3.13 conda activate textgen ``` @@ -76,334 +172,314 @@ conda activate textgen | System | GPU | Command | |--------|---------|---------| -| Linux/WSL | NVIDIA | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121` | -| Linux/WSL | CPU only | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cpu` | -| Linux | AMD | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/rocm5.6` | -| MacOS + MPS | Any | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2` | -| Windows | NVIDIA | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121` | -| Windows | CPU only | `pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2` | +| Linux/WSL | NVIDIA | `pip3 install torch==2.9.1 --index-url https://download.pytorch.org/whl/cu128` | +| Linux/WSL | CPU only | `pip3 install torch==2.9.1 --index-url https://download.pytorch.org/whl/cpu` | +| Linux | AMD | `pip3 install https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp313-cp313-linux_x86_64.whl` | +| MacOS + MPS | Any | `pip3 install torch==2.9.1` | +| Windows | NVIDIA | `pip3 install torch==2.9.1 --index-url https://download.pytorch.org/whl/cu128` | +| Windows | CPU only | `pip3 install torch==2.9.1` | The up-to-date commands can be found here: https://pytorch.org/get-started/locally/. -For NVIDIA, you also need to install the CUDA runtime libraries: +If you need `nvcc` to compile some library manually, you will additionally need to install this: ``` -conda install -y -c "nvidia/label/cuda-12.1.1" cuda-runtime -``` - -If you need `nvcc` to compile some library manually, replace the command above with - -``` -conda install -y -c "nvidia/label/cuda-12.1.1" cuda +conda install -y -c "nvidia/label/cuda-12.8.1" cuda ``` #### 3. Install the web UI ``` -git clone https://github.com/oobabooga/text-generation-webui -cd text-generation-webui -pip install -r +git clone https://github.com/oobabooga/textgen +cd textgen +pip install -r requirements/full/ ``` Requirements file to use: -| GPU | CPU | requirements file to use | -|--------|---------|---------| -| NVIDIA | has AVX2 | `requirements.txt` | -| NVIDIA | no AVX2 | `requirements_noavx2.txt` | -| AMD | has AVX2 | `requirements_amd.txt` | -| AMD | no AVX2 | `requirements_amd_noavx2.txt` | -| CPU only | has AVX2 | `requirements_cpu_only.txt` | -| CPU only | no AVX2 | `requirements_cpu_only_noavx2.txt` | -| Apple | Intel | `requirements_apple_intel.txt` | -| Apple | Apple Silicon | `requirements_apple_silicon.txt` | +| GPU | requirements file to use | +|--------|---------| +| NVIDIA | `requirements.txt` | +| AMD | `requirements_amd.txt` | +| CPU only | `requirements_cpu_only.txt` | +| Apple Intel | `requirements_apple_intel.txt` | +| Apple Silicon | `requirements_apple_silicon.txt` | -### Start the web UI +#### 4. Start the web UI ``` conda activate textgen -cd text-generation-webui +cd textgen python server.py ``` -Then browse to - -`http://localhost:7860/?__theme=dark` - -##### AMD GPU on Windows +Then browse to `http://127.0.0.1:7860`. -1) Use `requirements_cpu_only.txt` or `requirements_cpu_only_noavx2.txt` in the command above. +#### Manual compilation -2) Manually install llama-cpp-python using the appropriate command for your hardware: [Installation from PyPI](https://github.com/abetlen/llama-cpp-python#installation-with-hardware-acceleration). - * Use the `LLAMA_HIPBLAS=on` toggle. - * Note the [Windows remarks](https://github.com/abetlen/llama-cpp-python#windows-remarks). +The `requirements*.txt` files above contain wheels precompiled through GitHub Actions. To compile manually (e.g., if no wheels are available for your hardware), use `requirements_nowheels.txt` and install your desired loaders manually. -3) Manually install AutoGPTQ: [Installation](https://github.com/PanQiWei/AutoGPTQ#install-from-source). - * Perform the from-source installation - there are no prebuilt ROCm packages for Windows. +#### Updating the requirements -##### Older NVIDIA GPUs - -1) For Kepler GPUs and older, you will need to install CUDA 11.8 instead of 12: +From time to time, the `requirements*.txt` files change. To update: ``` -pip3 install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu118 -conda install -y -c "nvidia/label/cuda-11.8.0" cuda-runtime +conda activate textgen +cd textgen +pip install -r --upgrade ``` -2) bitsandbytes >= 0.39 may not work. In that case, to use `--load-in-8bit`, you may have to downgrade like this: - * Linux: `pip install bitsandbytes==0.38.1` - * Windows: `pip install https://github.com/jllllll/bitsandbytes-windows-webui/raw/main/bitsandbytes-0.38.1-py3-none-any.whl` - -##### Manual install - -The `requirements*.txt` above contain various wheels precompiled through GitHub Actions. If you wish to compile things manually, or if you need to because no suitable wheels are available for your hardware, you can use `requirements_nowheels.txt` and then install your desired loaders manually. - -### Alternative: Docker +### Docker ``` For NVIDIA GPU: ln -s docker/{nvidia/Dockerfile,nvidia/docker-compose.yml,.dockerignore} . -For AMD GPU: -ln -s docker/{amd/Dockerfile,intel/docker-compose.yml,.dockerignore} . +For AMD GPU: +ln -s docker/{amd/Dockerfile,amd/docker-compose.yml,.dockerignore} . For Intel GPU: -ln -s docker/{intel/Dockerfile,amd/docker-compose.yml,.dockerignore} . +ln -s docker/{intel/Dockerfile,intel/docker-compose.yml,.dockerignore} . For CPU only ln -s docker/{cpu/Dockerfile,cpu/docker-compose.yml,.dockerignore} . cp docker/.env.example .env -#Create logs/cache dir : -mkdir -p logs cache -# Edit .env and set: +#Create logs/cache dir : +mkdir -p user_data/logs user_data/cache +# Edit .env and set: # TORCH_CUDA_ARCH_LIST based on your GPU model # APP_RUNTIME_GID your host user's group id (run `id -g` in a terminal) # BUILD_EXTENIONS optionally add comma separated list of extensions to build -# Edit CMD_FLAGS.txt and add in it the options you want to execute (like --listen --cpu) -# +# Edit user_data/CMD_FLAGS.txt and add in it the options you want to execute (like --listen --cpu) +# docker compose up --build ``` -* You need to have Docker Compose v2.17 or higher installed. See [this guide](https://github.com/oobabooga/text-generation-webui/wiki/09-%E2%80%90-Docker) for instructions. +* You need to have Docker Compose v2.17 or higher installed. See [this guide](https://github.com/oobabooga/textgen/wiki/09-%E2%80%90-Docker) for instructions. * For additional docker files, check out [this repository](https://github.com/Atinoda/text-generation-webui-docker). -### Updating the requirements - -From time to time, the `requirements*.txt` change. To update, use these commands: - -``` -conda activate textgen -cd text-generation-webui -pip install -r --upgrade -```
+## Command-line flags +
- -List of command-line flags - +Show full list ```txt -usage: server.py [-h] [--multi-user] [--character CHARACTER] [--model MODEL] [--lora LORA [LORA ...]] [--model-dir MODEL_DIR] [--lora-dir LORA_DIR] [--model-menu] [--settings SETTINGS] - [--extensions EXTENSIONS [EXTENSIONS ...]] [--verbose] [--chat-buttons] [--idle-timeout IDLE_TIMEOUT] [--loader LOADER] [--cpu] [--auto-devices] - [--gpu-memory GPU_MEMORY [GPU_MEMORY ...]] [--cpu-memory CPU_MEMORY] [--disk] [--disk-cache-dir DISK_CACHE_DIR] [--load-in-8bit] [--bf16] [--no-cache] [--trust-remote-code] - [--force-safetensors] [--no_use_fast] [--use_flash_attention_2] [--use_eager_attention] [--load-in-4bit] [--use_double_quant] [--compute_dtype COMPUTE_DTYPE] [--quant_type QUANT_TYPE] - [--flash-attn] [--tensorcores] [--n_ctx N_CTX] [--threads THREADS] [--threads-batch THREADS_BATCH] [--no_mul_mat_q] [--n_batch N_BATCH] [--no-mmap] [--mlock] - [--n-gpu-layers N_GPU_LAYERS] [--tensor_split TENSOR_SPLIT] [--numa] [--logits_all] [--no_offload_kqv] [--cache-capacity CACHE_CAPACITY] [--row_split] [--streaming-llm] - [--attention-sink-size ATTENTION_SINK_SIZE] [--gpu-split GPU_SPLIT] [--autosplit] [--max_seq_len MAX_SEQ_LEN] [--cfg-cache] [--no_flash_attn] [--no_xformers] [--no_sdpa] - [--cache_8bit] [--cache_4bit] [--num_experts_per_token NUM_EXPERTS_PER_TOKEN] [--triton] [--no_inject_fused_mlp] [--no_use_cuda_fp16] [--desc_act] [--disable_exllama] - [--disable_exllamav2] [--wbits WBITS] [--groupsize GROUPSIZE] [--no_inject_fused_attention] [--hqq-backend HQQ_BACKEND] [--cpp-runner] [--deepspeed] - [--nvme-offload-dir NVME_OFFLOAD_DIR] [--local_rank LOCAL_RANK] [--alpha_value ALPHA_VALUE] [--rope_freq_base ROPE_FREQ_BASE] [--compress_pos_emb COMPRESS_POS_EMB] [--listen] - [--listen-port LISTEN_PORT] [--listen-host LISTEN_HOST] [--share] [--auto-launch] [--gradio-auth GRADIO_AUTH] [--gradio-auth-path GRADIO_AUTH_PATH] [--ssl-keyfile SSL_KEYFILE] - [--ssl-certfile SSL_CERTFILE] [--subpath SUBPATH] [--api] [--public-api] [--public-api-id PUBLIC_API_ID] [--api-port API_PORT] [--api-key API_KEY] [--admin-key ADMIN_KEY] [--nowebui] - [--multimodal-pipeline MULTIMODAL_PIPELINE] [--model_type MODEL_TYPE] [--pre_layer PRE_LAYER [PRE_LAYER ...]] [--checkpoint CHECKPOINT] [--monkey-patch] - -Text generation web UI +usage: server.py [-h] [--user-data-dir USER_DATA_DIR] [--multi-user] [--model MODEL] [--lora LORA [LORA ...]] [--model-dir MODEL_DIR] [--lora-dir LORA_DIR] [--model-menu] [--settings SETTINGS] + [--extensions EXTENSIONS [EXTENSIONS ...]] [--verbose] [--idle-timeout IDLE_TIMEOUT] [--image-model IMAGE_MODEL] [--image-model-dir IMAGE_MODEL_DIR] [--image-dtype {bfloat16,float16}] + [--image-attn-backend {flash_attention_2,sdpa}] [--image-cpu-offload] [--image-compile] [--image-quant {none,bnb-8bit,bnb-4bit,torchao-int8wo,torchao-fp4,torchao-float8wo}] + [--loader LOADER] [--ctx-size N] [--cache-type N] [--model-draft MODEL_DRAFT] [--draft-max DRAFT_MAX] [--gpu-layers-draft GPU_LAYERS_DRAFT] [--device-draft DEVICE_DRAFT] + [--ctx-size-draft CTX_SIZE_DRAFT] [--spec-type {none,ngram-mod,ngram-simple,ngram-map-k,ngram-map-k4v,ngram-cache}] [--spec-ngram-size-n SPEC_NGRAM_SIZE_N] + [--spec-ngram-size-m SPEC_NGRAM_SIZE_M] [--spec-ngram-min-hits SPEC_NGRAM_MIN_HITS] [--gpu-layers N] [--cpu-moe] [--mmproj MMPROJ] [--streaming-llm] [--tensor-split TENSOR_SPLIT] + [--split-mode {layer,row,tensor,none}] [--no-mmap] [--mlock] [--no-kv-offload] [--batch-size BATCH_SIZE] [--ubatch-size UBATCH_SIZE] [--threads THREADS] + [--threads-batch THREADS_BATCH] [--numa] [--parallel PARALLEL] [--fit-target FIT_TARGET] [--extra-flags EXTRA_FLAGS] [--ik] [--cpu] [--cpu-memory CPU_MEMORY] [--disk] + [--disk-cache-dir DISK_CACHE_DIR] [--load-in-8bit] [--bf16] [--no-cache] [--trust-remote-code] [--force-safetensors] [--no_use_fast] [--attn-implementation IMPLEMENTATION] + [--load-in-4bit] [--use_double_quant] [--compute_dtype COMPUTE_DTYPE] [--quant_type QUANT_TYPE] [--gpu-split GPU_SPLIT] [--enable-tp] [--tp-backend TP_BACKEND] [--cfg-cache] + [--listen] [--listen-port LISTEN_PORT] [--listen-host LISTEN_HOST] [--share] [--auto-launch] [--gradio-auth GRADIO_AUTH] [--gradio-auth-path GRADIO_AUTH_PATH] + [--ssl-keyfile SSL_KEYFILE] [--ssl-certfile SSL_CERTFILE] [--subpath SUBPATH] [--old-colors] [--portable] [--api] [--public-api] [--public-api-id PUBLIC_API_ID] [--api-port API_PORT] + [--api-key API_KEY] [--admin-key ADMIN_KEY] [--api-enable-ipv6] [--api-disable-ipv4] [--nowebui] [--temperature N] [--dynatemp-low N] [--dynatemp-high N] [--dynatemp-exponent N] + [--smoothing-factor N] [--smoothing-curve N] [--top-p N] [--top-k N] [--min-p N] [--top-n-sigma N] [--typical-p N] [--xtc-threshold N] [--xtc-probability N] [--epsilon-cutoff N] + [--eta-cutoff N] [--tfs N] [--top-a N] [--adaptive-target N] [--adaptive-decay N] [--dry-multiplier N] [--dry-allowed-length N] [--dry-base N] [--repetition-penalty N] + [--frequency-penalty N] [--presence-penalty N] [--encoder-repetition-penalty N] [--no-repeat-ngram-size N] [--repetition-penalty-range N] [--penalty-alpha N] [--guidance-scale N] + [--mirostat-mode N] [--mirostat-tau N] [--mirostat-eta N] [--do-sample | --no-do-sample] [--dynamic-temperature | --no-dynamic-temperature] + [--temperature-last | --no-temperature-last] [--sampler-priority N] [--dry-sequence-breakers N] [--enable-thinking | --no-enable-thinking] [--reasoning-effort N] + [--preserve-thinking | --no-preserve-thinking] [--chat-template-file CHAT_TEMPLATE_FILE] [--no-electron] + +TextGen options: - -h, --help show this help message and exit + -h, --help show this help message and exit Basic settings: - --multi-user Multi-user mode. Chat histories are not saved or automatically loaded. Warning: this is likely not safe for sharing publicly. - --character CHARACTER The name of the character to load in chat mode by default. - --model MODEL Name of the model to load by default. - --lora LORA [LORA ...] The list of LoRAs to load. If you want to load more than one LoRA, write the names separated by spaces. - --model-dir MODEL_DIR Path to directory with all the models. - --lora-dir LORA_DIR Path to directory with all the loras. - --model-menu Show a model menu in the terminal when the web UI is first launched. - --settings SETTINGS Load the default interface settings from this yaml file. See settings-template.yaml for an example. If you create a file called settings.yaml, this - file will be loaded by default without the need to use the --settings flag. - --extensions EXTENSIONS [EXTENSIONS ...] The list of extensions to load. If you want to load more than one extension, write the names separated by spaces. - --verbose Print the prompts to the terminal. - --chat-buttons Show buttons on the chat tab instead of a hover menu. - --idle-timeout IDLE_TIMEOUT Unload model after this many minutes of inactivity. It will be automatically reloaded when you try to use it again. + --user-data-dir USER_DATA_DIR Path to the user data directory. Default: auto-detected. + --multi-user Multi-user mode. Chat histories are not saved or automatically loaded. Best suited for small trusted teams. + --model MODEL Name of the model to load by default. + --lora LORA [LORA ...] The list of LoRAs to load. If you want to load more than one LoRA, write the names separated by spaces. + --model-dir MODEL_DIR Path to directory with all the models. + --lora-dir LORA_DIR Path to directory with all the loras. + --model-menu Show a model menu in the terminal when the web UI is first launched. + --settings SETTINGS Load the default interface settings from this yaml file. See user_data/settings-template.yaml for an example. If you create a file called + user_data/settings.yaml, this file will be loaded by default without the need to use the --settings flag. + --extensions EXTENSIONS [EXTENSIONS ...] The list of extensions to load. If you want to load more than one extension, write the names separated by spaces. + --verbose Print the prompts to the terminal. + --idle-timeout IDLE_TIMEOUT Unload model after this many minutes of inactivity. It will be automatically reloaded when you try to use it again. + +Image model: + --image-model IMAGE_MODEL Name of the image model to select on startup (overrides saved setting). + --image-model-dir IMAGE_MODEL_DIR Path to directory with all the image models. + --image-dtype {bfloat16,float16} Data type for image model. + --image-attn-backend {flash_attention_2,sdpa} Attention backend for image model. + --image-cpu-offload Enable CPU offloading for image model. + --image-compile Compile the image model for faster inference. + --image-quant {none,bnb-8bit,bnb-4bit,torchao-int8wo,torchao-fp4,torchao-float8wo} + Quantization method for image model. Model loader: - --loader LOADER Choose the model loader manually, otherwise, it will get autodetected. Valid options: Transformers, llama.cpp, llamacpp_HF, ExLlamav2_HF, ExLlamav2, - AutoGPTQ, AutoAWQ. + --loader LOADER Choose the model loader manually, otherwise, it will get autodetected. Valid options: Transformers, llama.cpp, ExLlamav3_HF, ExLlamav3, TensorRT- + LLM. + +Context and cache: + --ctx-size, --n_ctx, --max_seq_len N Context size in tokens. 0 = auto for llama.cpp (requires gpu-layers=-1), 8192 for other loaders. + --cache-type, --cache_type N KV cache type; valid options: llama.cpp - fp16, q8_0, q4_0; ExLlamaV3 - fp16, q2 to q8 (can specify k_bits and v_bits separately, e.g. q4_q8). + +Speculative decoding: + --model-draft MODEL_DRAFT Path to the draft model for speculative decoding. + --draft-max DRAFT_MAX Number of tokens to draft for speculative decoding. + --gpu-layers-draft GPU_LAYERS_DRAFT Number of layers to offload to the GPU for the draft model. + --device-draft DEVICE_DRAFT Comma-separated list of devices to use for offloading the draft model. Example: CUDA0,CUDA1 + --ctx-size-draft CTX_SIZE_DRAFT Size of the prompt context for the draft model. If 0, uses the same as the main model. + --spec-type {none,ngram-mod,ngram-simple,ngram-map-k,ngram-map-k4v,ngram-cache} + Draftless speculative decoding type. Recommended: ngram-mod. + --spec-ngram-size-n SPEC_NGRAM_SIZE_N N-gram lookup size for ngram speculative decoding. + --spec-ngram-size-m SPEC_NGRAM_SIZE_M Draft n-gram size for ngram speculative decoding. + --spec-ngram-min-hits SPEC_NGRAM_MIN_HITS Minimum n-gram hits for ngram-map speculative decoding. + +llama.cpp: + --gpu-layers, --n-gpu-layers N Number of layers to offload to the GPU. -1 = auto. + --cpu-moe Move the experts to the CPU (for MoE models). + --mmproj MMPROJ Path to the mmproj file for vision models. + --streaming-llm Activate StreamingLLM to avoid re-evaluating the entire prompt when old messages are removed. + --tensor-split TENSOR_SPLIT Split the model across multiple GPUs. Comma-separated list of proportions. Example: 60,40. + --split-mode {layer,row,tensor,none} How to split the model across multiple GPUs. "tensor" can make multi-GPU significantly faster. + --no-mmap Prevent mmap from being used. + --mlock Force the system to keep the model in RAM. + --no-kv-offload Do not offload the K, Q, V to the GPU. This saves VRAM but reduces performance. + --batch-size BATCH_SIZE Maximum number of prompt tokens to batch together when calling llama-server. This is the application level batch size. + --ubatch-size UBATCH_SIZE Maximum number of prompt tokens to batch together when calling llama-server. This is the max physical batch size for computation (device level). + --threads THREADS Number of threads to use. + --threads-batch THREADS_BATCH Number of threads to use for batches/prompt processing. + --numa Activate NUMA task allocation for llama.cpp. + --parallel PARALLEL Number of parallel request slots. The context size is divided equally among slots. For example, to have 4 slots with 8192 context each, set + ctx_size to 32768. + --fit-target FIT_TARGET Target VRAM margin per device for auto GPU layers, comma-separated list of values in MiB. A single value is broadcast across all devices. + --extra-flags EXTRA_FLAGS Extra flags to pass to llama-server. Example: "--jinja --rpc 192.168.1.100:50052" + --ik Use ik_llama.cpp instead of upstream llama.cpp. Requires the ik_llama_cpp_binaries package to be installed. Transformers/Accelerate: - --cpu Use the CPU to generate text. Warning: Training on CPU is extremely slow. - --auto-devices Automatically split the model across the available GPU(s) and CPU. - --gpu-memory GPU_MEMORY [GPU_MEMORY ...] Maximum GPU memory in GiB to be allocated per GPU. Example: --gpu-memory 10 for a single GPU, --gpu-memory 10 5 for two GPUs. You can also set values - in MiB like --gpu-memory 3500MiB. - --cpu-memory CPU_MEMORY Maximum CPU memory in GiB to allocate for offloaded weights. Same as above. - --disk If the model is too large for your GPU(s) and CPU combined, send the remaining layers to the disk. - --disk-cache-dir DISK_CACHE_DIR Directory to save the disk cache to. Defaults to "cache". - --load-in-8bit Load the model with 8-bit precision (using bitsandbytes). - --bf16 Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU. - --no-cache Set use_cache to False while generating text. This reduces VRAM usage slightly, but it comes at a performance cost. - --trust-remote-code Set trust_remote_code=True while loading the model. Necessary for some models. - --force-safetensors Set use_safetensors=True while loading the model. This prevents arbitrary code execution. - --no_use_fast Set use_fast=False while loading the tokenizer (it's True by default). Use this if you have any problems related to use_fast. - --use_flash_attention_2 Set use_flash_attention_2=True while loading the model. - --use_eager_attention Set attn_implementation= eager while loading the model. + --cpu Use the CPU to generate text. Warning: Training on CPU is extremely slow. + --cpu-memory CPU_MEMORY Maximum CPU memory in GiB. Use this for CPU offloading. + --disk If the model is too large for your GPU(s) and CPU combined, send the remaining layers to the disk. + --disk-cache-dir DISK_CACHE_DIR Directory to save the disk cache to. + --load-in-8bit Load the model with 8-bit precision (using bitsandbytes). + --bf16 Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU. + --no-cache Set use_cache to False while generating text. This reduces VRAM usage slightly, but it comes at a performance cost. + --trust-remote-code Set trust_remote_code=True while loading the model. Necessary for some models. + --force-safetensors Set use_safetensors=True while loading the model. This prevents arbitrary code execution. + --no_use_fast Set use_fast=False while loading the tokenizer (it's True by default). Use this if you have any problems related to use_fast. + --attn-implementation IMPLEMENTATION Attention implementation. Valid options: sdpa, eager, flash_attention_2. bitsandbytes 4-bit: - --load-in-4bit Load the model with 4-bit precision (using bitsandbytes). - --use_double_quant use_double_quant for 4-bit. - --compute_dtype COMPUTE_DTYPE compute dtype for 4-bit. Valid options: bfloat16, float16, float32. - --quant_type QUANT_TYPE quant_type for 4-bit. Valid options: nf4, fp4. + --load-in-4bit Load the model with 4-bit precision (using bitsandbytes). + --use_double_quant use_double_quant for 4-bit. + --compute_dtype COMPUTE_DTYPE compute dtype for 4-bit. Valid options: bfloat16, float16, float32. + --quant_type QUANT_TYPE quant_type for 4-bit. Valid options: nf4, fp4. -llama.cpp: - --flash-attn Use flash-attention. - --tensorcores NVIDIA only: use llama-cpp-python compiled with tensor cores support. This may increase performance on newer cards. - --n_ctx N_CTX Size of the prompt context. - --threads THREADS Number of threads to use. - --threads-batch THREADS_BATCH Number of threads to use for batches/prompt processing. - --no_mul_mat_q Disable the mulmat kernels. - --n_batch N_BATCH Maximum number of prompt tokens to batch together when calling llama_eval. - --no-mmap Prevent mmap from being used. - --mlock Force the system to keep the model in RAM. - --n-gpu-layers N_GPU_LAYERS Number of layers to offload to the GPU. - --tensor_split TENSOR_SPLIT Split the model across multiple GPUs. Comma-separated list of proportions. Example: 60,40. - --numa Activate NUMA task allocation for llama.cpp. - --logits_all Needs to be set for perplexity evaluation to work. Otherwise, ignore it, as it makes prompt processing slower. - --no_offload_kqv Do not offload the K, Q, V to the GPU. This saves VRAM but reduces the performance. - --cache-capacity CACHE_CAPACITY Maximum cache capacity (llama-cpp-python). Examples: 2000MiB, 2GiB. When provided without units, bytes will be assumed. - --row_split Split the model by rows across GPUs. This may improve multi-gpu performance. - --streaming-llm Activate StreamingLLM to avoid re-evaluating the entire prompt when old messages are removed. - --attention-sink-size ATTENTION_SINK_SIZE StreamingLLM: number of sink tokens. Only used if the trimmed prompt does not share a prefix with the old prompt. - -ExLlamaV2: - --gpu-split GPU_SPLIT Comma-separated list of VRAM (in GB) to use per GPU device for model layers. Example: 20,7,7. - --autosplit Autosplit the model tensors across the available GPUs. This causes --gpu-split to be ignored. - --max_seq_len MAX_SEQ_LEN Maximum sequence length. - --cfg-cache ExLlamav2_HF: Create an additional cache for CFG negative prompts. Necessary to use CFG with that loader. - --no_flash_attn Force flash-attention to not be used. - --no_xformers Force xformers to not be used. - --no_sdpa Force Torch SDPA to not be used. - --cache_8bit Use 8-bit cache to save VRAM. - --cache_4bit Use Q4 cache to save VRAM. - --num_experts_per_token NUM_EXPERTS_PER_TOKEN Number of experts to use for generation. Applies to MoE models like Mixtral. - -AutoGPTQ: - --triton Use triton. - --no_inject_fused_mlp Triton mode only: disable the use of fused MLP, which will use less VRAM at the cost of slower inference. - --no_use_cuda_fp16 This can make models faster on some systems. - --desc_act For models that do not have a quantize_config.json, this parameter is used to define whether to set desc_act or not in BaseQuantizeConfig. - --disable_exllama Disable ExLlama kernel, which can improve inference speed on some systems. - --disable_exllamav2 Disable ExLlamav2 kernel. - --wbits WBITS Load a pre-quantized model with specified precision in bits. 2, 3, 4 and 8 are supported. - --groupsize GROUPSIZE Group size. - -AutoAWQ: - --no_inject_fused_attention Disable the use of fused attention, which will use less VRAM at the cost of slower inference. - -HQQ: - --hqq-backend HQQ_BACKEND Backend for the HQQ loader. Valid options: PYTORCH, PYTORCH_COMPILE, ATEN. - -TensorRT-LLM: - --cpp-runner Use the ModelRunnerCpp runner, which is faster than the default ModelRunner but doesn't support streaming yet. - -DeepSpeed: - --deepspeed Enable the use of DeepSpeed ZeRO-3 for inference via the Transformers integration. - --nvme-offload-dir NVME_OFFLOAD_DIR DeepSpeed: Directory to use for ZeRO-3 NVME offloading. - --local_rank LOCAL_RANK DeepSpeed: Optional argument for distributed setups. - -RoPE: - --alpha_value ALPHA_VALUE Positional embeddings alpha factor for NTK RoPE scaling. Use either this or compress_pos_emb, not both. - --rope_freq_base ROPE_FREQ_BASE If greater than 0, will be used instead of alpha_value. Those two are related by rope_freq_base = 10000 * alpha_value ^ (64 / 63). - --compress_pos_emb COMPRESS_POS_EMB Positional embeddings compression factor. Should be set to (context length) / (model's original context length). Equal to 1/rope_freq_scale. +ExLlamaV3: + --gpu-split GPU_SPLIT Comma-separated list of VRAM (in GB) to use per GPU device for model layers. Example: 20,7,7. + --enable-tp, --enable_tp Enable Tensor Parallelism (TP) to split the model across GPUs. + --tp-backend TP_BACKEND The backend for tensor parallelism. Valid options: native, nccl. Default: native. + --cfg-cache Create an additional cache for CFG negative prompts. Necessary to use CFG with that loader. Gradio: - --listen Make the web UI reachable from your local network. - --listen-port LISTEN_PORT The listening port that the server will use. - --listen-host LISTEN_HOST The hostname that the server will use. - --share Create a public URL. This is useful for running the web UI on Google Colab or similar. - --auto-launch Open the web UI in the default browser upon launch. - --gradio-auth GRADIO_AUTH Set Gradio authentication password in the format "username:password". Multiple credentials can also be supplied with "u1:p1,u2:p2,u3:p3". - --gradio-auth-path GRADIO_AUTH_PATH Set the Gradio authentication file path. The file should contain one or more user:password pairs in the same format as above. - --ssl-keyfile SSL_KEYFILE The path to the SSL certificate key file. - --ssl-certfile SSL_CERTFILE The path to the SSL certificate cert file. - --subpath SUBPATH Customize the subpath for gradio, use with reverse proxy + --listen Make the web UI reachable from your local network. + --listen-port LISTEN_PORT The listening port that the server will use. + --listen-host LISTEN_HOST The hostname that the server will use. + --share Create a public URL. This is useful for running the web UI on Google Colab or similar. + --auto-launch Open the web UI in the default browser upon launch. + --gradio-auth GRADIO_AUTH Set Gradio authentication password in the format "username:password". Multiple credentials can also be supplied with "u1:p1,u2:p2,u3:p3". + --gradio-auth-path GRADIO_AUTH_PATH Set the Gradio authentication file path. The file should contain one or more user:password pairs in the same format as above. + --ssl-keyfile SSL_KEYFILE The path to the SSL certificate key file. + --ssl-certfile SSL_CERTFILE The path to the SSL certificate cert file. + --subpath SUBPATH Customize the subpath for gradio, use with reverse proxy + --old-colors Use the legacy Gradio colors, before the December/2024 update. + --portable Hide features not available in portable mode like training. API: - --api Enable the API extension. - --public-api Create a public URL for the API using Cloudfare. - --public-api-id PUBLIC_API_ID Tunnel ID for named Cloudflare Tunnel. Use together with public-api option. - --api-port API_PORT The listening port for the API. - --api-key API_KEY API authentication key. - --admin-key ADMIN_KEY API authentication key for admin tasks like loading and unloading models. If not set, will be the same as --api-key. - --nowebui Do not launch the Gradio UI. Useful for launching the API in standalone mode. - -Multimodal: - --multimodal-pipeline MULTIMODAL_PIPELINE The multimodal pipeline to use. Examples: llava-7b, llava-13b. + --api Enable the API server. + --public-api Create a public URL for the API using Cloudflare. + --public-api-id PUBLIC_API_ID Tunnel ID for named Cloudflare Tunnel. Use together with public-api option. + --api-port API_PORT The listening port for the API. + --api-key API_KEY API authentication key. + --admin-key ADMIN_KEY API authentication key for admin tasks like loading and unloading models. If not set, will be the same as --api-key. + --api-enable-ipv6 Enable IPv6 for the API + --api-disable-ipv4 Disable IPv4 for the API + --nowebui Do not launch the Gradio UI. Useful for launching the API in standalone mode. + +API generation defaults: + --temperature N Temperature + --dynatemp-low N Dynamic temperature low + --dynatemp-high N Dynamic temperature high + --dynatemp-exponent N Dynamic temperature exponent + --smoothing-factor N Smoothing factor + --smoothing-curve N Smoothing curve + --top-p N Top P + --top-k N Top K + --min-p N Min P + --top-n-sigma N Top N Sigma + --typical-p N Typical P + --xtc-threshold N XTC threshold + --xtc-probability N XTC probability + --epsilon-cutoff N Epsilon cutoff + --eta-cutoff N Eta cutoff + --tfs N TFS + --top-a N Top A + --adaptive-target N Adaptive target + --adaptive-decay N Adaptive decay + --dry-multiplier N DRY multiplier + --dry-allowed-length N DRY allowed length + --dry-base N DRY base + --repetition-penalty N Repetition penalty + --frequency-penalty N Frequency penalty + --presence-penalty N Presence penalty + --encoder-repetition-penalty N Encoder repetition penalty + --no-repeat-ngram-size N No repeat ngram size + --repetition-penalty-range N Repetition penalty range + --penalty-alpha N Penalty alpha + --guidance-scale N Guidance scale + --mirostat-mode N Mirostat mode + --mirostat-tau N Mirostat tau + --mirostat-eta N Mirostat eta + --do-sample, --no-do-sample Do sample + --dynamic-temperature, --no-dynamic-temperature Dynamic temperature + --temperature-last, --no-temperature-last Temperature last + --sampler-priority N Sampler priority + --dry-sequence-breakers N DRY sequence breakers + --enable-thinking, --no-enable-thinking Enable thinking + --reasoning-effort N Reasoning effort + --preserve-thinking, --no-preserve-thinking Preserve thinking blocks from prior turns in the chat template + --chat-template-file CHAT_TEMPLATE_FILE Path to a chat template file (.jinja, .jinja2, or .yaml) to use as the default instruction template for API requests. Overrides the model's + built-in template. + +Electron: + --no-electron In portable builds, skip the Electron desktop window. Useful if you prefer to use the web UI in the browser. ```
-## Documentation +## Loading a model automatically -https://github.com/oobabooga/text-generation-webui/wiki - -## Downloading models - -Models should be placed in the folder `text-generation-webui/models`. They are usually downloaded from [Hugging Face](https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads). - -* GGUF models are a single file and should be placed directly into `models`. Example: +To skip the Model tab on every launch, add this to `user_data/CMD_FLAGS.txt`: ``` -text-generation-webui -└── models - └── llama-2-13b-chat.Q4_K_M.gguf +--model my-model.gguf ``` -* The remaining model types (like 16-bit transformers models and GPTQ models) are made of several files and must be placed in a subfolder. Example: - -``` -text-generation-webui -├── models -│   ├── lmsys_vicuna-33b-v1.3 -│   │   ├── config.json -│   │   ├── generation_config.json -│   │   ├── pytorch_model-00001-of-00007.bin -│   │   ├── pytorch_model-00002-of-00007.bin -│   │   ├── pytorch_model-00003-of-00007.bin -│   │   ├── pytorch_model-00004-of-00007.bin -│   │   ├── pytorch_model-00005-of-00007.bin -│   │   ├── pytorch_model-00006-of-00007.bin -│   │   ├── pytorch_model-00007-of-00007.bin -│   │   ├── pytorch_model.bin.index.json -│   │   ├── special_tokens_map.json -│   │   ├── tokenizer_config.json -│   │   └── tokenizer.model -``` +Replace `my-model.gguf` with the name of a file in `user_data/models`. The model will load on startup. -In both cases, you can use the "Model" tab of the UI to download the model from Hugging Face automatically. It is also possible to download it via the command-line with +To pass extra flags, put each on its own line: ``` -python download-model.py organization/model +--model my-model.gguf +--cache-type q8_0 ``` -Run `python download-model.py --help` to see all the options. - -## Google Colab notebook +## Documentation -https://colab.research.google.com/github/oobabooga/text-generation-webui/blob/main/Colab-TextGen-GPU.ipynb +https://github.com/oobabooga/textgen/wiki ## Community -* Subreddit: https://www.reddit.com/r/oobabooga/ -* Discord: https://discord.gg/jwZCF2dPQN +[![Reddit](https://img.shields.io/reddit/subreddit-subscribers/Oobabooga?style=for-the-badge&logo=reddit&logoColor=white&label=r%2FOobabooga&labelColor=black&color=FF4500)](https://www.reddit.com/r/Oobabooga/) -## Acknowledgment +## Acknowledgments -In August 2023, [Andreessen Horowitz](https://a16z.com/) (a16z) provided a generous grant to encourage and support my independent work on this project. I am **extremely** grateful for their trust and recognition. +- In August 2023, [Andreessen Horowitz](https://a16z.com/) (a16z) provided a generous grant to encourage and support my independent work on this project. I am **extremely** grateful for their trust and recognition. +- This project was inspired by [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui) and wouldn't exist without it. diff --git a/cmd_linux.sh b/cmd_linux.sh index 576dbf0223..e124aab9d6 100755 --- a/cmd_linux.sh +++ b/cmd_linux.sh @@ -2,7 +2,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")" -if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniforge which can not be silently installed under a path with spaces. && exit; fi # deactivate existing conda envs as needed to avoid conflicts { conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null diff --git a/cmd_macos.sh b/cmd_macos.sh index 1b052e5c34..7e1a379fd6 100755 --- a/cmd_macos.sh +++ b/cmd_macos.sh @@ -2,7 +2,7 @@ cd "$(dirname "${BASH_SOURCE[0]}")" -if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi +if [[ "$(pwd)" =~ " " ]]; then echo This script relies on Miniforge which can not be silently installed under a path with spaces. && exit; fi # deactivate existing conda envs as needed to avoid conflicts { conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null diff --git a/cmd_windows.bat b/cmd_windows.bat index 531a326158..b0540bd817 100755 --- a/cmd_windows.bat +++ b/cmd_windows.bat @@ -4,7 +4,7 @@ cd /D "%~dp0" set PATH=%PATH%;%SystemRoot%\system32 -echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end +echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniforge which can not be silently installed under a path with spaces. && goto end @rem fix failed install when installing to a separate drive set TMP=%cd%\installer_files @@ -21,11 +21,12 @@ set INSTALL_ENV_DIR=%cd%\installer_files\env set PYTHONNOUSERSITE=1 set PYTHONPATH= set PYTHONHOME= +set PYTHONUTF8=1 set "CUDA_PATH=%INSTALL_ENV_DIR%" set "CUDA_HOME=%CUDA_PATH%" @rem activate installer env -call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end ) +call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniforge hook not found. && goto end ) @rem enter commands cmd /k "%*" diff --git a/cmd_wsl.bat b/cmd_wsl.bat deleted file mode 100755 index f9f4348a46..0000000000 --- a/cmd_wsl.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off - -cd /D "%~dp0" - -set PATH=%PATH%;%SystemRoot%\system32 - -@rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script -call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh cmd" - -:end -pause diff --git a/convert-to-safetensors.py b/convert-to-safetensors.py deleted file mode 100644 index 3b721e7cd4..0000000000 --- a/convert-to-safetensors.py +++ /dev/null @@ -1,38 +0,0 @@ -''' - -Converts a transformers model to safetensors format and shards it. - -This makes it faster to load (because of safetensors) and lowers its RAM usage -while loading (because of sharding). - -Based on the original script by 81300: - -https://gist.github.com/81300/fe5b08bff1cba45296a829b9d6b0f303 - -''' - -import argparse -from pathlib import Path - -import torch -from transformers import AutoModelForCausalLM, AutoTokenizer - -parser = argparse.ArgumentParser(formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=54)) -parser.add_argument('MODEL', type=str, default=None, nargs='?', help="Path to the input model.") -parser.add_argument('--output', type=str, default=None, help='Path to the output folder (default: models/{model_name}_safetensors).') -parser.add_argument("--max-shard-size", type=str, default="2GB", help="Maximum size of a shard in GB or MB (default: %(default)s).") -parser.add_argument('--bf16', action='store_true', help='Load the model with bfloat16 precision. Requires NVIDIA Ampere GPU.') -args = parser.parse_args() - -if __name__ == '__main__': - path = Path(args.MODEL) - model_name = path.name - - print(f"Loading {model_name}...") - model = AutoModelForCausalLM.from_pretrained(path, low_cpu_mem_usage=True, torch_dtype=torch.bfloat16 if args.bf16 else torch.float16) - tokenizer = AutoTokenizer.from_pretrained(path) - - out_folder = args.output or Path(f"models/{model_name}_safetensors") - print(f"Saving the converted model to {out_folder} with a maximum shard size of {args.max_shard_size}...") - model.save_pretrained(out_folder, max_shard_size=args.max_shard_size, safe_serialization=True) - tokenizer.save_pretrained(out_folder) diff --git a/css/Inter/Inter-Italic-VariableFont_opsz,wght.ttf b/css/Inter/Inter-Italic-VariableFont_opsz,wght.ttf new file mode 100644 index 0000000000..43ed4f5ee6 Binary files /dev/null and b/css/Inter/Inter-Italic-VariableFont_opsz,wght.ttf differ diff --git a/css/Inter/Inter-VariableFont_opsz,wght.ttf b/css/Inter/Inter-VariableFont_opsz,wght.ttf new file mode 100644 index 0000000000..e31b51e3e9 Binary files /dev/null and b/css/Inter/Inter-VariableFont_opsz,wght.ttf differ diff --git a/css/chat_style-Dark.css b/css/chat_style-Dark.css new file mode 100644 index 0000000000..01a168abe9 --- /dev/null +++ b/css/chat_style-Dark.css @@ -0,0 +1,129 @@ +.message { + display: grid; + align-items: start; + grid-template-columns: 60px minmax(0, 1fr); + width: min(100%, calc(724px + 60px)); + padding-bottom: 22px; + padding-top: 6px; + font-size: 18px; + font-family: Roboto, Arial, sans-serif; /* Modern font */ + line-height: 1.5; +} + +.circle-you, +.circle-bot { + background-color: #2b2b2b; /* Darker background for circles */ + border-radius: 50%; /* Perfect circle */ + border: 1px solid #4a90e2; /* Soft blue border */ + box-shadow: 0 4px 8px rgb(0 0 0 / 50%); /* Soft shadow for depth */ +} + +.circle-bot img, +.circle-you img { + border-radius: 50%; /* Make images circular */ + width: 100%; + height: 100%; + object-fit: cover; +} + +.circle-you, .circle-bot { + width: 64px; /* Smaller size for modern look */ + height: 64px; +} + +.text { + padding-left: 12px; /* Reduced padding for a cleaner layout */ + color: #f0f0f0; /* Light text color for readability */ +} + +.text p { + margin-top: 2px; +} + +.username { + padding-left: 10px; + font-size: 20px; + font-weight: bold; + color: #e0e0e0; /* Light gray text */ + transition: color 0.3s ease; /* Smooth color transition */ +} + +.username:hover { + color: #4a90e2; /* Blue color on hover */ +} + +.message-body { + position: relative; + border: 1px solid rgb(255 255 255 / 10%); /* Soft white border */ + border-radius: 8px; /* Slightly rounded corners */ + padding: 15px; + background: #1e1e1e; /* Dark background */ + box-shadow: 0 4px 10px rgb(0 0 0 / 30%); /* Subtle shadow for depth */ + transition: background 0.3s ease; /* Smooth transition for background */ +} + +.message-body:hover { + background: #252525; /* Slightly lighter on hover */ +} + +/* Adds 2 extra lines at the top and bottom of the message */ +.message-body::before, +.message-body::after { + content: ""; + position: absolute; + left: 10px; + right: 10px; + height: 1px; + background-color: rgb(255 255 255 / 5%); /* Faded lines for subtle separation */ +} + +.message-body::before { + top: 4px; +} + +.message-body::after { + bottom: 4px; +} + +.message-body img { + max-width: 300px; + max-height: 300px; + border-radius: 10px; /* Rounded corners for images */ +} + +.message-body p { + color: #e0e0e0 !important; /* Light color for text */ +} + +.message-body p em { + color: #a6a6a6 !important; /* Softer gray for emphasized text */ +} + +@media screen and (width <= 688px) { + .message { + display: grid; + align-items: start; + grid-template-columns: 60px minmax(0, 1fr); + padding-bottom: 25px; + font-size: 15px; + font-family: Roboto, Arial, sans-serif; /* Modern font */ + line-height: 1.5; + } + + .circle-you, .circle-bot { + width: 40px; /* Smaller size for mobile */ + height: 40px; + } + + .text { + padding-left: 10px; /* Reduced padding for mobile */ + } + + .message-body p { + font-size: 14px !important; + } + + .username { + font-size: 18px; /* Smaller username for mobile */ + } +} diff --git a/css/chat_style-TheEncrypted777.css b/css/chat_style-TheEncrypted777.css index 6404f41d7a..9543a3dfd8 100644 --- a/css/chat_style-TheEncrypted777.css +++ b/css/chat_style-TheEncrypted777.css @@ -2,8 +2,11 @@ .message { display: grid; + align-items: start; grid-template-columns: 60px minmax(0, 1fr); - padding-bottom: 28px; + width: min(100%, calc(724px + 60px + 90px)); + padding-bottom: 21px; + padding-top: 7px; font-size: 18px; font-family: 'Noto Sans', Arial, sans-serif; line-height: 1.428571429; @@ -84,10 +87,8 @@ border-radius: 20px; } -.message-body p { - margin-bottom: 0 !important; +.message-body p, .message-body li { font-size: 18px !important; - line-height: 1.428571429 !important; color: rgb(243 244 246) !important; text-shadow: 2px 2px 2px rgb(0 0 0); font-weight: 500; @@ -100,6 +101,7 @@ @media screen and (width <= 688px) { .message { display: grid; + align-items: start; grid-template-columns: 60px minmax(0, 1fr); padding-bottom: 25px; font-size: 15px; @@ -124,7 +126,7 @@ padding-left: 0; } - .message-body p { + .message-body p, .message-body li { font-size: 16px !important; } diff --git a/css/chat_style-cai-chat-square.css b/css/chat_style-cai-chat-square.css index d626dbb1c8..8254a4ecfd 100644 --- a/css/chat_style-cai-chat-square.css +++ b/css/chat_style-cai-chat-square.css @@ -16,6 +16,8 @@ } .message { - padding-bottom: 30px; + padding-bottom: 1.5em; + padding-top: 0.5em; grid-template-columns: 70px minmax(0, 1fr); + width: min(100%, calc(724px + 70px)); } diff --git a/css/chat_style-cai-chat.css b/css/chat_style-cai-chat.css index 618184cfab..66d2816d9f 100644 --- a/css/chat_style-cai-chat.css +++ b/css/chat_style-cai-chat.css @@ -1,7 +1,10 @@ .message { display: grid; + align-items: start; grid-template-columns: 60px minmax(0, 1fr); - padding-bottom: 15px; + width: min(100%, calc(724px + 60px)); + padding-bottom: 1.5em; + padding-top: 0.5em; font-size: 15px; font-family: 'Noto Sans', Helvetica, Arial, sans-serif; line-height: 22.5px !important; @@ -9,6 +12,7 @@ .message-body { margin-top: 3px; + font-size: 15px !important; } .circle-you { @@ -43,16 +47,10 @@ border-radius: 20px; } -.message-body p { - font-size: 15px !important; - line-height: 22.5px !important; +.message-body p, .message-body li { font-weight: 500; } -.message-body p, .chat .message-body ul, .chat .message-body ol { - margin-bottom: 10px !important; -} - .dark .message-body p em { color: rgb(138 138 138) !important; } diff --git a/css/chat_style-messenger.css b/css/chat_style-messenger.css index f0fd15788b..fd9b5b7000 100644 --- a/css/chat_style-messenger.css +++ b/css/chat_style-messenger.css @@ -1,5 +1,7 @@ .message { - padding-bottom: 25px; + width: min(100%, calc(724px + 60px)); + padding-bottom: 22px; + padding-top: 3px; font-size: 15px; font-family: 'Noto Sans', Helvetica, Arial, sans-serif; line-height: 1.428571429; @@ -59,8 +61,10 @@ text-align: right; } -.dark .circle-bot + .text div, .dark .circle-bot + .text * { - color: #000; +.dark .circle-bot + .text div, .dark .circle-bot + .text *, +.dark .chat .message .circle-bot + .text .message-body :is(h1, h2, h3, h4, h5, h6), +.dark .chat .message .circle-bot + .text .message-body a { + color: #000 !important; } .text { @@ -75,19 +79,14 @@ font-weight: bold; } -.message-body { -} - .message-body img { max-width: 300px; max-height: 300px; border-radius: 20px; } -.message-body p { - margin-bottom: 0 !important; +.message-body p, .message-body li { font-size: 15px !important; - line-height: 1.428571429 !important; font-weight: 500; } @@ -98,3 +97,11 @@ .message-body p em { color: rgb(110 110 110) !important; } + +.editing-textarea { + width: max(30rem) !important; +} + +.circle-you + .text .edit-control-button, .circle-you + .text .editing-textarea { + color: #000 !important; +} diff --git a/css/chat_style-wpp.css b/css/chat_style-wpp.css index 30ca61f335..65e253d9c3 100644 --- a/css/chat_style-wpp.css +++ b/css/chat_style-wpp.css @@ -1,56 +1,97 @@ .message { - padding-bottom: 25px; + display: block; + width: min(100%, 724px); + padding-top: 0; + padding-bottom: 21px; font-size: 15px; font-family: 'Noto Sans', Helvetica, Arial, sans-serif; line-height: 1.428571429; + grid-template-columns: none; } -.text-you { +.circle-you, .circle-bot { + display: none; +} + +.text { + max-width: 65%; + border-radius: 18px; + padding: 12px 16px; + margin-bottom: 8px; + clear: both; + box-shadow: 0 1px 2px rgb(0 0 0 / 10%); +} + +.username { + font-weight: 600; + margin-bottom: 8px; + opacity: 0.65; + padding-left: 0; +} + +/* User messages - right aligned, WhatsApp green */ +.circle-you + .text { background-color: #d9fdd3; - border-radius: 15px; - padding: 10px; - padding-top: 5px; float: right; + margin-left: auto; + margin-right: 8px; } -.text-bot { - background-color: #f2f2f2; - border-radius: 15px; - padding: 10px; - padding-top: 5px; +.circle-you + .text .username { + display: none; } -.dark .text-you { - background-color: #005c4b; - color: #111b21; +/* Bot messages - left aligned, white */ +.circle-bot + .text { + background-color: #fff; + float: left; + margin-right: auto; + margin-left: 8px; + border: 1px solid #e5e5e5; } -.dark .text-bot { - background-color: #1f2937; - color: #111b21; +.circle-bot + .text .message-actions { + bottom: -25px !important; } -.text-bot p, .text-you p { - margin-top: 5px; +/* Dark theme colors */ +.dark .circle-you + .text { + background-color: #144d37; + color: #e4e6ea; + box-shadow: 0 1px 2px rgb(0 0 0 / 30%); +} + +.dark .circle-bot + .text { + background-color: #202c33; + color: #e4e6ea; + border: 1px solid #3c4043; + box-shadow: 0 1px 2px rgb(0 0 0 / 30%); +} + +.dark .username { + opacity: 0.7; } .message-body img { max-width: 300px; max-height: 300px; - border-radius: 20px; + border-radius: 12px; } -.message-body p { - margin-bottom: 0 !important; +.message-body p, .message-body li { font-size: 15px !important; - line-height: 1.428571429 !important; - font-weight: 500; } .dark .message-body p em { - color: rgb(138 138 138) !important; + color: rgb(170 170 170) !important; } .message-body p em { - color: rgb(110 110 110) !important; + color: rgb(100 100 100) !important; } + +/* Message actions positioning */ +.message-actions { + margin-top: 8px; +} + diff --git a/css/highlightjs/highlightjs-copy.min.css b/css/highlightjs/highlightjs-copy.min.css index 5a94fece08..473ba4e51b 100644 --- a/css/highlightjs/highlightjs-copy.min.css +++ b/css/highlightjs/highlightjs-copy.min.css @@ -1 +1,73 @@ -.hljs-copy-wrapper{position:relative;overflow:hidden}.hljs-copy-wrapper:hover .hljs-copy-button,.hljs-copy-button:focus{transform:translateX(0)}.hljs-copy-button{position:absolute;transform:translateX(calc(100% + 1.125em));top:1em;right:1em;width:2rem;height:2rem;text-indent:-9999px;color:#fff;border-radius:.25rem;border:1px solid #ffffff22;background-color:#2d2b57;background-color:var(--hljs-theme-background);background-image:url('data:image/svg+xml;utf-8,');background-repeat:no-repeat;background-position:center;transition:background-color 200ms ease,transform 200ms ease-out}.hljs-copy-button:hover{border-color:#ffffff44}.hljs-copy-button:active{border-color:#ffffff66}.hljs-copy-button[data-copied="true"]{text-indent:0;width:auto;background-image:none}@media(prefers-reduced-motion){.hljs-copy-button{transition:none}}.hljs-copy-alert{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px} +.hljs-copy-wrapper { + position: relative; + overflow: hidden; + min-height: 3em; +} + +.hljs-copy-wrapper:hover .hljs-copy-button, +.hljs-copy-button:focus { + transform: translateX(0); +} + +.hljs-copy-button { + position: absolute; + transform: translateX(calc(100% + 1.125em)); + top: min(1em, calc(50% - 1rem)); + right: 1em; + width: 2rem; + height: 2rem; + text-indent: -9999px; + color: #1f2328; + border-radius: .25rem; + border: 1px solid #1f232822; + background-color: #2d2b57; + background-color: var(--hljs-theme-background); + background-image: url('data:image/svg+xml;utf-8,'); + background-repeat: no-repeat; + background-position: center; + transition: background-color 200ms ease, transform 200ms ease-out; +} + +.hljs-copy-button:hover { + border-color: #1f232844; +} + +.hljs-copy-button:active { + border-color: #1f232866; +} + +.dark .hljs-copy-button { + color: #fff; + border-color: #ffffff22; + background-image: url('data:image/svg+xml;utf-8,'); +} + +.dark .hljs-copy-button:hover { + border-color: #ffffff44; +} + +.dark .hljs-copy-button:active { + border-color: #ffffff66; +} + +.hljs-copy-button[data-copied="true"] { + text-indent: 0; + width: auto; + background-image: none; +} + +@media(prefers-reduced-motion) { + .hljs-copy-button { + transition: none; + } +} + +.hljs-copy-alert { + clip: rect(0 0 0 0); + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; +} diff --git a/css/html_instruct_style.css b/css/html_instruct_style.css index 50b9402f4d..fcd4731983 100644 --- a/css/html_instruct_style.css +++ b/css/html_instruct_style.css @@ -1,21 +1,39 @@ .chat { background: transparent; - padding: 24px 19px; - padding-right: 19px !important; + padding: 0; padding-top: 0; } -.chat > .messages { - padding-top: 18px !important; +.chat > .messages:first-child { + padding-top: 0 !important; } -.message { - display: grid; - grid-template-columns: 60px 1fr; - padding-bottom: 25px; - font-size: 15px; - font-family: 'Noto Sans', Helvetica, Arial, sans-serif; - line-height: 24px; +.chat .message-body p, .chat .message-body li { + font-size: 1rem !important; + line-height: 28px !important; +} + +.dark .chat .message-body :is(p,li), +.dark .chat .message-body em:not(:is(h1,h2,h3,h4,h5,h6,b,strong) em), +.dark .chat .message-body q:not(:is(h1,h2,h3,h4,h5,h6,b,strong) q) { + color: #d1d5db !important; +} + + +.chat .message-body :is(p, ul, ol) { + margin: 1.25em 0 !important; +} + +.chat .message-body :is(p, ul, ol):first-child { + margin-top: 0 !important; +} + +.chat .message-body :is(p, ul, ol):last-child { + margin-bottom: 0 !important; +} + +.user-message, .assistant-message { + font-family: Inter, Helvetica, Arial, sans-serif; } .message:first-child { @@ -26,49 +44,45 @@ display: none; } -.message-body p, .message-body li { - font-size: 15px !important; - line-height: 24px !important; +.chat .user-message { + background: var(--bg-rail); + padding: 1.5rem 1rem; + padding-bottom: 2rem; + border-radius: 0; + border-bottom-right-radius: 0; } -.message-body p, .chat .message-body ul, .chat .message-body ol { - margin-bottom: 16px !important; +.chat .assistant-message { + padding: 1.5rem 1rem; + padding-bottom: 2rem; + border-radius: 0; + border: 0; } -.message-body p:last-child, .chat .message-body ul:last-child, .chat .message-body ol:last-child { - margin-bottom: 0 !important; -} - -.gradio-container .chat .assistant-message { - padding: 20px; - background: #f4f4f4; - margin-top: 9px !important; - margin-bottom: 12px !important; - border-radius: 7px; - border: 1px solid var(--border-color-primary); +.dark .chat .user-message { + background: var(--light-gray); } .dark .chat .assistant-message { - background: var(--color-grey-800); + background: transparent; } -.gradio-container .chat .user-message { - padding: 20px; - padding-left: 0; - padding-right: 0; - background-color: transparent; - border-radius: 8px; - border-bottom-right-radius: 0; +.chat .user-message .text, +.chat .assistant-message .text { + max-width: 724px; + margin-left: auto; + margin-right: auto; } -.gradio-container .chat .assistant-message:last-child, .gradio-container .chat .user-message:last-child { - margin-bottom: 0 !important; +/* Create space between two assistant messages in a row */ +.assistant-message + .assistant-message { + margin-top: 1.5rem; } -code { +pre > code { background-color: #f3f4f6 !important; } -.dark code { +.dark pre > code { background-color: #1f2937 !important; } diff --git a/css/icon.png b/css/icon.png new file mode 100644 index 0000000000..65b51ab385 Binary files /dev/null and b/css/icon.png differ diff --git a/css/main.css b/css/main.css index cf3babdba6..419bc8d0d7 100644 --- a/css/main.css +++ b/css/main.css @@ -1,5 +1,104 @@ -.tabs.svelte-710i53 { - margin-top: 0 +:root { + /* Legacy hue-named tokens (still referenced elsewhere). */ + --darker-gray: #1C1C1D; + --dark-gray: #212125; + --light-gray: #2C2E34; + --light-theme-gray: #f0f3fb; + --border-color-dark: rgba(255, 255, 255, 0.10); + --header-width: 112px; + --selected-item-color-dark: #282930; + + /* Role-based design tokens (light mode defaults). + Blue-leaning grays. The rail is one step darker than + the sidebar so the two read as distinct elevations. */ + --bg-body: #ffffff; + --bg-rail: #e4e8f0; + --bg-sidebar: #f0f3fb; + --bg-input: #f3f4f6; + --bg-elevated: #ffffff; + --bg-hover: #dbeafe; + --bg-active: #c8d8f5; + --text: #1a1a1a; + --text-muted: #6b6b73; + --border: rgba(0, 0, 0, 0.10); + --border-soft: rgba(0, 0, 0, 0.06); + --accent: #4a72ff; + + --radius-sm: 6px; + --radius-md: 8px; + --radius-lg: 12px; + --radius-xl: 16px; + + --space-1: 4px; + --space-2: 8px; + --space-3: 12px; + --space-4: 16px; + --space-5: 24px; + + --motion: 0.15s ease; + --motion-slow: 0.2s ease; +} + +.dark { + --bg-body: #212125; + --bg-rail: #161617; + --bg-sidebar: #1a1a1c; + --bg-input: #2c2e34; + --bg-elevated: #1d1d1f; + --bg-hover: #2a2a2c; + --bg-active: #303033; + --text: #ececec; + --text-muted: #a3a3a8; + --border: rgba(255, 255, 255, 0.10); + --border-soft: rgba(255, 255, 255, 0.06); + --accent: #4a72ff; +} + +@font-face { + font-family: Inter; + src: url('file/css/Inter/Inter-VariableFont_opsz,wght.ttf') format('truetype'); + font-weight: 100 900; + font-style: normal; +} + +@font-face { + font-family: Inter; + src: url('file/css/Inter/Inter-Italic-VariableFont_opsz,wght.ttf') format('truetype'); + font-weight: 100 900; + font-style: italic; +} + +body, +.gradio-container, +gradio-app { + font-family: 'Inter', 'Noto Sans', ui-sans-serif, system-ui, -apple-system, + 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; +} + +/* Hide spin buttons on number inputs (look bad on Windows) */ +input[type="number"]::-webkit-outer-spin-button, +input[type="number"]::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} + +input[type="number"] { + -moz-appearance: textfield; +} + +.padded.svelte-12cmxck { + padding: 3px 0; +} + +div.svelte-sfqy0y, +div.svelte-iyf88w { + background: transparent; + border: 0; +} + +/* "info" messages without a title above */ +.block > .svelte-e8n7p6:not(:only-of-type, #chat-mode *) { + margin-bottom: 0; } .py-6 { @@ -14,19 +113,34 @@ } .refresh-button { - max-width: 4.4em; + max-width: none; min-width: 2.2em !important; height: 39.594px; align-self: end; line-height: 1em; - border-radius: 0.5em; + border-radius: 0.75rem; flex: none; } +.gradio-container .stretch:has(> .refresh-button):has([role="listbox"]) { + gap: 8px; +} + +.refresh-button-medium { + max-width: 4.4em; +} + .refresh-button-small { max-width: 2.2em; } +.settings-button { + width: fit-content !important; + min-width: 0 !important; + max-width: 100% !important; + align-self: flex-start; +} + .button_nowrap { white-space: nowrap; } @@ -42,12 +156,12 @@ padding: 0 !important; } -#download-label, #upload-label { - min-height: 0 +.slim-textbox { + padding: 0 !important; } -.dark svg { - fill: white; +#download-label, #upload-label { + min-height: 0 } .dark a { @@ -58,18 +172,24 @@ ol li p, ul li p { display: inline-block; } -#chat-tab, #default-tab, #notebook-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab { +#notebook-parent-tab, #chat-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab, #image-ai-tab { border: 0; } +#notebook-parent-tab, #parameters, #chat-settings, #lora, #training-tab, #model-tab, #session-tab, #character-tab, #image-ai-tab { + padding: 1rem; +} + .gradio-container { max-width: 100% !important; padding-top: 0 !important; } #extensions { - margin-top: 5px; - margin-bottom: 35px; + margin: 5px auto 35px; + max-width: 880px; + padding: 1em; + padding-left: calc(var(--header-width) + 1em); } .extension-tab { @@ -81,55 +201,63 @@ span.math.inline { vertical-align: baseline !important; } -div.svelte-15lo0d8 > *, div.svelte-15lo0d8 > .form > * { - flex-wrap: nowrap; -} - gradio-app > :first-child { - padding-left: var(--size-4) !important; - padding-right: var(--size-4) !important; + padding: 0 !important; } .header_bar { - background-color: #f4f4f4; - box-shadow: 0 0 3px rgba(22 22 22 / 35%); + border-right: none; margin-bottom: 0; overflow-x: scroll; - margin-left: calc(-1 * var(--size-4)); - margin-right: calc(-1 * var(--size-4)); - display: block !important; text-wrap: nowrap; z-index: 90; + position: fixed; + display: flex !important; + flex-direction: column; + height: 100dvh; + width: var(--header-width); } -.dark .header_bar { - border: none !important; - box-shadow: 0 3px 4px rgba(20 20 20 / 60%); - background-color: #8080802b; +.header_bar button { + margin: 0; + padding: 0.75rem; + border-radius: 0 !important; + transition: background-color var(--motion), color var(--motion); +} + +.header_bar button:hover { + background-color: var(--bg-hover); } .header_bar button.selected { + border: 0; border-radius: 0; } +.dark .header_bar { + border: none !important; + box-shadow: none; + background-color: var(--bg-rail); +} + .textbox_default textarea { - height: calc(100dvh - 271px); + height: calc(100dvh - 202px); } .textbox_default_output textarea { - height: calc(100dvh - 185px); + height: calc(100dvh - 126px); } .textbox textarea { - height: calc(100dvh - 241px); + height: calc(100dvh - 153px) } .textbox_logits textarea { - height: calc(100dvh - 236px); + height: calc(100dvh - 213px); } .textbox_logits_notebook textarea { - height: calc(100dvh - 292px); + height: calc(100dvh - 229px); } .monospace textarea { @@ -149,24 +277,6 @@ gradio-app > :first-child { color: #efefef !important; } -@media screen and (width <= 711px) { - .textbox_default textarea { - height: calc(100dvh - 259px); - } - - div .default-token-counter { - top: calc( 0.5 * (100dvh - 236px) ) !important; - } - - .transparent-substring { - display: none; - } - - .hover-menu { - min-width: 250px !important; - } -} - /* Hide the gradio footer */ footer { display: none !important; @@ -194,6 +304,7 @@ button { max-width: 500px; background-color: var(--input-background-fill); border: var(--input-border-width) solid var(--input-border-color) !important; + padding: 10px; } .file-saver > :first-child > :last-child { @@ -215,34 +326,45 @@ button { font-size: 100% !important; } -.pretty_scrollbar::-webkit-scrollbar { +.pretty_scrollbar::-webkit-scrollbar, +#image-history-gallery > :nth-child(2)::-webkit-scrollbar { width: 7px; height: 7px; } -.pretty_scrollbar::-webkit-scrollbar-track { +.pretty_scrollbar::-webkit-scrollbar-track, +#image-history-gallery > :nth-child(2)::-webkit-scrollbar-track { background: transparent; } .pretty_scrollbar::-webkit-scrollbar-thumb, -.pretty_scrollbar::-webkit-scrollbar-thumb:hover { +.pretty_scrollbar::-webkit-scrollbar-thumb:hover, +#image-history-gallery > :nth-child(2)::-webkit-scrollbar-thumb, +#image-history-gallery > :nth-child(2)::-webkit-scrollbar-thumb:hover { background: var(--neutral-300); + border-radius: 9999px; } .dark .pretty_scrollbar::-webkit-scrollbar-thumb, -.dark .pretty_scrollbar::-webkit-scrollbar-thumb:hover { - background: var(--neutral-700); +.dark .pretty_scrollbar::-webkit-scrollbar-thumb:hover, +.dark #image-history-gallery > :nth-child(2)::-webkit-scrollbar-thumb, +.dark #image-history-gallery > :nth-child(2)::-webkit-scrollbar-thumb:hover { + background: rgb(255 255 255 / 6.25%); + border-radius: 9999px; } -.pretty_scrollbar::-webkit-resizer { - background: #c5c5d2; +.pretty_scrollbar::-webkit-resizer, +#image-history-gallery > :nth-child(2)::-webkit-resizer { + background: transparent; } -.dark .pretty_scrollbar::-webkit-resizer { - background: #374151; +.dark .pretty_scrollbar::-webkit-resizer, +.dark #image-history-gallery > :nth-child(2)::-webkit-resizer { + background: transparent; } -.pretty_scrollbar::-webkit-scrollbar-corner { +.pretty_scrollbar::-webkit-scrollbar-corner, +#image-history-gallery > :nth-child(2)::-webkit-scrollbar-corner { background: transparent; } @@ -251,20 +373,26 @@ audio { } /* Copied from https://github.com/AUTOMATIC1111/stable-diffusion-webui */ -.token-counter { +#default-token-counter, #notebook-token-counter { position: absolute !important; - top: calc( 0.5 * (100dvh - 218px) ) !important; - right: 2px; z-index: 100; background: var(--input-background-fill) !important; min-height: 0 !important; + width: 0; + text-align: left; + direction: rtl; + right: 13px; +} + +#default-token-counter { + top: calc(100dvh - 200px) !important; } -.default-token-counter { - top: calc( 0.5 * (100dvh - 248px) ) !important; +#notebook-token-counter { + top: calc(100dvh - 180px) !important; } -.token-counter span { +#default-token-counter span, #notebook-token-counter span { padding: 1px; box-shadow: 0 0 0 0.3em rgb(192 192 192 / 15%), inset 0 0 0.6em rgb(192 192 192 / 7.5%); border: 2px solid rgb(192 192 192 / 40%) !important; @@ -272,15 +400,15 @@ audio { } .no-background { - background: var(--background-fill-primary) !important; + background: transparent; padding: 0 !important; } /* ---------------------------------------------- Chat tab ---------------------------------------------- */ -.h-\[40vh\], .wrap.svelte-byatnx.svelte-byatnx.svelte-byatnx { - height: 66.67vh +.h-\[40dvh\] { + height: 66.67dvh } .gradio-container { @@ -292,29 +420,18 @@ audio { width: unset } -div.svelte-362y77>*, div.svelte-362y77>.form>* { - flex-wrap: nowrap -} - .pending.svelte-1ed2p3z { opacity: 1; } -.wrap.svelte-6roggh.svelte-6roggh { - max-height: 92.5%; -} - -/* This is for the microphone button in the whisper extension */ -.sm.svelte-1ipelgc { - width: 100%; -} - #chat-tab { - padding-top: 0; + padding: 0; } -#chat-tab button#Generate, #chat-tab button#stop { - width: 89.3438px !important; +#chat-tab > :nth-child(1) { + display: flex; + flex-direction: row; + gap: 0; } #chat-tab button, #notebook-tab button, #default-tab button { @@ -322,7 +439,6 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { } #chat-tab > :first-child, #extensions { - max-width: 880px; margin-left: auto; margin-right: auto; } @@ -342,104 +458,173 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { .chat { margin-left: auto; margin-right: auto; - max-width: 880px; - min-height: var(--chat-height); - overflow-y: auto; - padding-right: 15px; + flex: 1; + overflow-y: hidden; display: flex; flex-direction: column; word-break: break-word; overflow-wrap: anywhere; border-top: none; - border-radius: 0 0 0 8px; + border-radius: 0; visibility: visible; } .chat-parent { - height: calc(100dvh - 98px - var(--header-height) - var(--input-delta)); + flex: 1; overflow: auto !important; border-radius: 0 !important; - margin-bottom: var(--input-delta) !important; -} - -/* On desktop, automatically hide the chat scroll bar - * when not hovered. */ -@media (hover: hover) and (pointer: fine) { - .chat-parent { - visibility: hidden; - } - - .chat-parent:focus, .chat-parent:hover { - visibility: visible; - } + margin-bottom: 8px; } .chat-parent .prose { visibility: visible; } -.old-ui .chat-parent { - height: calc(100dvh - 192px - var(--header-height) - var(--input-delta)); - margin-bottom: var(--input-delta) !important; +.chat .message { + margin-left: auto; + margin-right: auto; + text-align: start; + padding-left: 1rem; + padding-right: 1rem; + contain: layout paint; +} + +.message, +.user-message, +.assistant-message { + contain: layout paint; + animation: fadeIn 0.2s ease-out; } -.chat-parent.bigchat { - height: calc(100dvh - 98px - var(--header-height) - var(--input-delta)) !important; - margin-bottom: var(--input-delta) !important; +.chat .message .timestamp { + font-size: 0.7em; + display: inline-block; + font-weight: normal; + opacity: 0.7; + margin-left: 5px; } .chat > .messages { display: flex; flex-direction: column; - padding-top: 25px; + min-height: calc(100dvh - 225px); } -.chat .message:last-child { - margin-bottom: 0 !important; - padding-bottom: 15px !important; +.chat > .messages > :first-child { + padding-top: 20px; +} + +.chat > .messages > .message:last-child { + padding-bottom: 2rem; +} + +.message-body { + font-size: 16px; +} + +.dark .message-body h1, +.dark .message-body h2, +.dark .message-body h3, +.dark .message-body h4, +.dark .message-body h5, +.dark .message-body h6 { + color: #e8e8e8 !important; +} + +.message-body blockquote { + border-left-width: 4px; + border-left-color: var(--border-color-primary); } .message-body h1, .message-body h2, .message-body h3, +.message-body h4, +.message-body h5, +.message-body h6 { + color: #1a1a1a; +} + +.message-body h1 { + font-weight: 700; + font-size: 2.25em; + margin-top: 0; + margin-bottom: 0.8888889em; + line-height: 1.1111111; +} + +.message-body h2 { + font-weight: 700; + font-size: 1.5em; + margin-top: 2em; + margin-bottom: 1em; + line-height: 1.3333333; +} + +.message-body h3 { + font-weight: 600; + font-size: 1.25em; + margin-top: 1.6em; + margin-bottom: 0.6em; + line-height: 1.6; +} + .message-body h4 { - color: var(--body-text-color); - margin: 20px 0 10px 0; + font-weight: 600; + font-size: 1em; + margin-top: 1.5em; + margin-bottom: 0.5em; + line-height: 1.5; +} + +.message-body h5 { + font-weight: 600; + font-size: 1em; + margin: 0; +} + +.message-body h6 { + font-weight: 600; + font-size: 1em; + margin: 0; } .dark .message q { color: #f5b031; } +.message q { + color: #3480be; +} + .message-body q::before, .message-body q::after { content: ""; } .message-body li { list-style-position: outside; + margin-top: 0.5em !important; + margin-bottom: 0.5em !important; } -.chat .message-body ul, .chat .message-body ol { - padding-inline-start: 2em; +.message-body ul.long-list > li, +.message-body ol.long-list > li { + margin-top: 1.25em !important; + margin-bottom: 1.25em !important; } -.message-body li:not(:last-child) { - margin-top: 0 !important; - margin-bottom: 2px !important; +.message-body a { + font-weight: 500; } -.message-body li:last-child { - margin-bottom: 0 !important; +.chat .message-body ul, .chat .message-body ol { + padding-inline-start: 2em; } .message-body li > p { display: inline !important; } -.message-body ul, .message-body ol { - font-size: 15px !important; -} - .message-body ul { list-style-type: disc !important; } @@ -456,20 +641,28 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { overflow: scroll; } -.message-body code { - white-space: pre-wrap !important; - word-wrap: break-word !important; +.prose ul ul { + margin: 0; +} + +.message-body pre > code { + white-space: pre !important; + overflow-x: auto !important; + max-width: calc(100dvw - 39px); border: 1px solid #666; border-radius: 5px; font-size: 82%; padding: 1px 3px; - background: white !important; + background: #f3f4f6 !important; color: #1f2328; + scrollbar-width: thin; + scrollbar-color: var(--neutral-300) transparent; } -.dark .message-body code { +.dark .message-body pre > code { background: #0d1117 !important; color: rgb(201 209 217); + scrollbar-color: rgb(255 255 255 / 6.25%) transparent; } .message-body pre > code { @@ -479,15 +672,56 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { .message-body :not(pre) > code { white-space: normal !important; + font-weight: bold; + font-size: 0.95em; + font-family: Menlo,"Roboto Mono","Courier New",Courier,monospace,Inter,sans-serif; + padding: .15rem .3rem; + background-color: #ececec; +} + +.dark .message-body :not(pre) > code { + background-color: rgb(255 255 255 / 10%); } #chat-input { padding: 0; - padding-top: 18px; background: transparent; border: none; } +#chat-input textarea { + background: var(--bg-input); + padding: 0.675rem 2.5rem 0.6rem; + margin-top: 0.15rem; + border: 1px solid var(--border); + border-radius: 1.5rem; + overflow-y: auto !important; +} + +#chat-input textarea::-webkit-scrollbar { + width: 7px; +} + +#chat-input textarea::-webkit-scrollbar-track { + background: transparent; +} + +#chat-input textarea::-webkit-scrollbar-thumb { + background: var(--neutral-300); + border-radius: 9999px; +} + +.dark #chat-input textarea::-webkit-scrollbar-thumb { + background: rgb(255 255 255 / 6.25%); +} + +#chat-input textarea::placeholder { + white-space: nowrap; + overflow: hidden; + color: #9ca3af !important; + opacity: 1 !important; +} + #chat-input textarea:focus { box-shadow: none !important; } @@ -500,6 +734,16 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { display: none; } +#chat-input .submit-button { + display: none; +} + +#chat-input .upload-button { + margin-right: 16px; + margin-bottom: 7px; + background: transparent; +} + @media print { body { visibility: hidden; @@ -515,151 +759,149 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { width: 100%; overflow-y: visible; } - + .message { break-inside: avoid; } - + .gradio-container { overflow: visible; } - + .tab-nav { display: none !important; } - + #chat-tab > :first-child { max-width: unset; } } -#show-controls { - position: absolute; - height: 100%; - background-color: transparent; - border: 0 !important; - border-radius: 0; +#chat-tab .generating { + display: none !important; } -#show-controls label { - z-index: 1000; - position: absolute; - right: 0; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; +.hover-element { + position: relative; + padding-top: 4px; } -.dark #show-controls span { - color: var(--neutral-400); +#hover-element-button { + display: flex; + align-items: center; + justify-content: center; + width: 32px; + height: 32px; + border-radius: 0.5rem; + cursor: pointer; + color: gray; } -#show-controls span { - color: var(--neutral-600); +#hover-element-button:hover { + background-color: var(--background-fill-secondary); } -#typing-container { - display: none; - position: absolute; - background-color: transparent; - left: -2px; - top: 4px; - padding: var(--block-padding); +#hover-element-button svg { + color: inherit; } -.typing { - position: relative; +.dark #hover-element-button:hover { + background-color: var(--selected-item-color-dark); } -.visible-dots #typing-container { - display: block; +.hover-menu { + display: none; + position: absolute; + bottom: 100%; + left: 0; + background: white; + border: 1px solid rgba(0, 0, 0, 0.1); + box-shadow: 0 4px 16px rgb(0 0 0 / 12%), 0 1px 3px rgb(0 0 0 / 8%); + border-radius: 0.75rem; + z-index: 10000; + min-width: 330px; + flex-direction: column; + padding: 4px; } -.typing span { +.hover-menu::before { content: ''; - animation: blink 1.5s infinite; - animation-fill-mode: both; - height: 10px; - width: 10px; - background: #3b5998;; position: absolute; - left:0; - top:0; - border-radius: 50%; + top: 100%; + left: 0; + width: 100%; + height: 8px; } -.typing .dot1 { - animation-delay: .2s; - margin-left: calc(10px * 1.5); +.hover-menu > * { + border: none !important; + box-shadow: none !important; } -.typing .dot2 { - animation-delay: .4s; - margin-left: calc(10px * 3); +.hover-menu button { + width: 100%; + background: transparent !important; + border: none !important; + border-radius: 0.5rem !important; + justify-content: space-between; + margin: 0 !important; + height: 36px; + font-weight: 500; + box-shadow: none !important; } -@keyframes blink { - 0% { - opacity: .1; - } - - 20% { - opacity: 1; - } - - 100% { - opacity: .1; - } +.hover-menu button:hover { + background: #dbeafe !important; } -#chat-tab .generating { - display: none !important; +.dark .hover-menu button:hover { + background: var(--selected-item-color-dark) !important; } -.hover-element { - position: relative; - font-size: 24px; +#show-controls { + background-color: transparent; + border: none !important; + height: 36px; + border-radius: 0.5rem; + padding-top: 3px; + padding-left: 4px; + display: flex; + font-weight: normal; } -.hover-menu { - display: none; - position: absolute; - bottom: 80%; - left: 0; - background-color: var(--background-fill-primary); - box-shadow: 0 0 5px rgb(0 0 0 / 25%); - z-index: 10000; - min-width: 330px; - flex-direction: column; +#show-controls:hover { + background-color: #dbeafe; } -.hover-menu button { - width: 100%; - background: transparent !important; - border-radius: 0 !important; - border-color: var(--border-color-primary); - justify-content: space-between; - margin: 0 !important; - height: 36px; +.dark #show-controls { + background-color: transparent; } -.hover-menu button:not(#clear-history-confirm) { - border-bottom: 0 !important; +#show-controls label { + display: flex; + flex-direction: row-reverse; + justify-content: start; + width: 100%; + padding-right: 12px; + gap: 10px; + font-weight: 500; + font-size: 14px; + color: var(--button-secondary-text-color); } -.hover-menu button:not(#clear-history-confirm):last-child { - border-bottom: var(--button-border-width) solid var(--border-color-primary) !important; +#show-controls label span { + color: inherit; } -.hover-menu button:hover { - background: var(--button-secondary-background-fill-hover) !important; +#show-controls label input { + margin-top: 5px; } .transparent-substring { opacity: 0.333; } -#chat-tab:not(.old-ui) #chat-buttons { +#chat-tab #chat-buttons { display: none !important; } @@ -681,6 +923,8 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { } #chat-input-container { + display: flex; + flex-direction: column; min-width: 0 !important; } @@ -690,64 +934,100 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { } #chat-input-row { - padding-bottom: 20px; + padding: 0.5rem 1rem 1rem; } -.old-ui #chat-input-row, #chat-input-row.bigchat { - padding-bottom: 0 !important; +#chat-col { + height: 100dvh; + display: flex; + flex-direction: column; + padding-bottom: 0; + gap: 0; } -#chat-col { - padding-bottom: 100px; +@media screen and (width <= 924px) { + #chat-col { + margin-top: 32px; + height: calc(100dvh - 32px); + } +} + +.message-body p, .message-body li { + line-height: 1.75 !important; } -.old-ui #chat-col, #chat-col.bigchat { - padding-bottom: 80px !important; +.message-body p, .message-body ul, .message-body ol { + margin: 1.25em 0 !important; } -.old-ui #chat-buttons #clear-history-confirm { - order: -1; +.message-body :is(p, ul, ol):first-child { + margin-top: 0 !important; } -.chat ol, .chat ul { - margin-top: 6px !important; +.message-body :is(p, ul, ol):last-child { + margin-bottom: 0 !important; } /* ---------------------------------------------- Past chats menus ---------------------------------------------- */ #rename-row label { - margin-top: var(--layout-gap); + margin-top: 0; +} + +#rename-row > :nth-child(2) { + justify-content: center; } /* ---------------------------------------------- - Past chat histories in a side bar on desktop + Create the sidebars ---------------------------------------------- */ -@media screen and (width >= 1327px) { - #past-chats-row { - position: absolute; - top: 36px; - left: 0; - width: calc(0.5*(var(--document-width) - 880px - 120px - 16px*2)); - max-width: 300px; - margin-left: calc(-0.5*(var(--document-width) - 880px - 14px - 16px * 2)); - } +#chat-controls, +#past-chats-row { + width: 260px; + max-width: 80vw; + padding: 0.5rem; + height: 100dvh; + flex-shrink: 0; + box-sizing: content-box; + z-index: 10; +} - #chat-controls { - position: absolute; - top: 16px; - right: 0; - width: calc(0.5*(var(--document-width) - 880px - 120px - 16px*2)); - max-width: 400px; - margin-right: calc(-0.5*(var(--document-width) - 880px - 14px - 16px * 2)); - } +#past-chats-row:not(.negative-header) { + max-width: calc(85vw - var(--header-width)); } -/* ---------------------------------------------- - Keep dropdown menus above errored components ----------------------------------------------- */ -.options { - z-index: 100 !important; +#chat-controls { + padding: 1rem; + padding-bottom: 0; + overflow-y: scroll; +} + +#chat-controls > :nth-child(1) { + padding: 0.5rem; +} + +#past-chats-row + * { + width: unset; + flex-grow: 1; + flex-shrink: 1; +} + +#search_chat { + padding-right: 0.5rem; +} + +#search_chat > :nth-child(2) > :first-child { + display: none; +} + +/* ---------------------------------------------- + Keep dropdown menus above errored components +---------------------------------------------- */ +.options { + z-index: 100 !important; + border: 1px solid var(--input-border-color); + border-radius: 0.5rem; } /* ---------------------------------------------- @@ -757,12 +1037,12 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { position: fixed; bottom: 0; left: 0; - width: calc((100vw - 880px - 120px) /2); + width: calc(0.5 * (100vw - min(100vw, 48rem) - (120px - var(--header-width)))); + z-index: 10000; } .pfp_character { position: relative; - z-index: 100; } .pfp_character:hover { @@ -776,10 +1056,14 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { } #past-chats { - max-height: calc(100vh - 195px); + max-height: calc(100dvh - 135px); overflow-y: scroll !important; border-radius: 0; - scrollbar-width: none; /* Hide scrollbar in Firefox by default */ + scrollbar-width: auto; +} + +#past-chats::-webkit-scrollbar { + display: block; } #past-chats label { @@ -790,6 +1074,24 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { border-radius: 0; padding-top: 8px; padding-bottom: 8px; + position: relative; + min-height: 42px !important; +} + +#past-chats label::before { + content: url('data:image/svg+xml;utf8,'); + position: absolute; + top: 12px; + left: 12px; + margin-right: 8px; +} + +.dark #past-chats label::before { + content: url('data:image/svg+xml;utf8,'); +} + +#past-chats label span { + margin-left: 29px; } #past-chats > :nth-child(2) { @@ -797,23 +1099,1694 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* { } #past-chats > :nth-child(3) { - gap: 0; + gap: 0.25rem; } -#past-chats::-webkit-scrollbar { +#past-chats input { display: none; } -#past-chats:hover { - scrollbar-width: auto; +#past-chats label { + padding: 0.75rem; + font-size: 12.5px; + font-weight: 400; + margin-right: 8px; +} + +#past-chats .selected, +#past-chats label:hover { + border-radius: 0.5rem; +} + +#past-chats label:hover { + cursor: pointer; +} + +#past-chats label { + transition: background-color 0.15s ease; +} + +#past-chats .selected, +#past-chats label:hover { + background-color: #c8d8f5 !important; +} + +#past-chats-buttons, +#delete-chat-row, +#rename-row { + width: 100%; + justify-content: center; + gap: 9px; + padding-right: 0.5rem; } -#past-chats:hover::-webkit-scrollbar { +#new-chat-wrapper { + display: contents; +} + +.new-chat-arrow { + cursor: pointer; + position: relative; + padding: 0; + margin-right: -15px; + height: 39.594px; + display: flex; + align-items: center; +} + +.new-chat-menu { + display: none; + position: absolute; + top: 0; + left: 0; + padding-top: 1.2em; + z-index: var(--layer-top); + white-space: nowrap; +} + +.new-chat-arrow:hover .new-chat-menu { display: block; } -@media screen and (width < 1327px) { - #past-chats { - max-height: 300px; +.new-chat-menu-item { + cursor: pointer; + padding: var(--size-2); + background: var(--background-fill-primary); + box-shadow: var(--shadow-drop-lg); + border-radius: var(--container-radius); + color: var(--body-text-color); + font-size: var(--text-md); + font-weight: var(--button-large-text-weight); +} + +.new-chat-menu-item:hover { + background: var(--background-fill-secondary); +} + +#past-chats-row, +#chat-controls { + width: 260px; + padding: 0.5rem; + padding-right: 0; + height: calc(100dvh - 16px); + flex-shrink: 0; + box-sizing: content-box; +} + +.sidebar-hidden { + width: 0 !important; + padding: 0 !important; + overflow: hidden; +} + +#past-chats-toggle, +#chat-controls-toggle, +#navigation-toggle { + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + user-select: none; + border-radius: 3px; + z-index: 1000; + position: fixed; + width: 2rem; + height: 2rem; + top: 0; +} + +#past-chats-toggle svg, +#chat-controls-toggle svg, +#navigation-toggle svg { + pointer-events: none; +} + +@media screen and (width <= 408px) { + #past-chats-toggle.past-chats-open { + top: 28px; + } + + #chat-controls-toggle.chat-controls-open { + top: 28px; + right: calc(16px + min(260px, 80vw)) !important; + } +} + +#past-chats-toggle.past-chats-open.negative-header { + left: calc(min(260px, 85vw) + 16px); +} + +#past-chats-toggle.past-chats-open:not(.negative-header) { + left: calc(112px + min(260px, calc(85vw - var(--header-width))) + 16px); +} + +#past-chats-toggle.past-chats-closed:not(.negative-header) { + left: 112px; +} + +#past-chats-toggle.past-chats-closed.negative-header { + left: 0; + top: 28px; +} + +@media screen and (width <= 924px) { + #past-chats-toggle.past-chats-closed.negative-header { + left: 28px; + top: 0; + } +} + +.header_bar ~ * { + margin-left: var(--header-width); +} + +/* Positions for chat-controls-toggle */ +#chat-controls-toggle.chat-controls-open { + right: calc(min(260px, 80vw) + 23px); +} + +#chat-controls-toggle.chat-controls-closed { + right: 7px; +} + +@media screen and (width <= 924px) { + #chat-controls.sidebar-shown { + position: fixed; + right: 0; + } + + #past-chats-row.sidebar-shown { + position: fixed; + } +} + + +/* ---------------------------------------------- + Dark theme +---------------------------------------------- */ +.dark .header_bar { + background-color: var(--bg-rail) !important; +} + +.dark .header_bar button.selected { + background: var(--bg-active); +} + +.dark #chat-input textarea { + background: var(--bg-input); + color: var(--text) !important; + border-color: var(--border); +} + +.dark #chat-input textarea::placeholder { + color: var(--text-muted) !important; + opacity: 1 !important; +} + +.dark .hover-menu { + background: var(--darker-gray); + border-color: transparent; + box-shadow: 0 4px 16px rgb(0 0 0 / 40%); +} + +.dark .hover-menu button { + background-color: transparent !important; +} + +.dark #chat-controls, +.dark #past-chats-row { + border: 0 !important; + box-shadow: none; +} + +.dark gradio-app .gradio-container.gradio-container-4-37-2 .contain #past-chats label:hover { + background-color: var(--bg-hover) !important; +} + +.dark gradio-app .gradio-container.gradio-container-4-37-2 .contain #past-chats .selected { + background-color: var(--bg-active) !important; +} + +.dark #past-chats-toggle, +.dark #chat-controls-toggle, +.dark #navigation-toggle { + color: white; +} + +.dark svg { + color: white; +} + +@media screen and (width <= 408px) { + .dark #past-chats-toggle.past-chats-open { + background: var(--darker-gray); + } + + .dark #chat-controls-toggle.chat-controls-open { + background: var(--darker-gray); + } +} + +/* ---------------------------------------------- + Light theme +---------------------------------------------- */ +.header_bar { + background-color: var(--bg-rail) !important; +} + +.header_bar button.selected { + background: var(--bg-active); +} + +#chat-controls, +#past-chats-row { + background-color: var(--bg-sidebar); +} + + +#past-chats-toggle, +#chat-controls-toggle, +#navigation-toggle { + color: gray !important; +} + +.mobile-top-bar { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 32px; + z-index: 2; + opacity: 0; + pointer-events: none; +} + +@media screen and (width <= 924px) { + .mobile-top-bar { + opacity: 1; + pointer-events: auto; + } + + .dark .mobile-top-bar { + background-color: var(--darker-gray); } + + .mobile-top-bar { + background-color: var(--light-theme-gray); + } +} + +@media screen and (width <= 408px) { + #past-chats-toggle.past-chats-open { + background: var(--light-theme-gray); + } + + #chat-controls-toggle.chat-controls-open { + background: var(--light-theme-gray); + } +} + +/* ---------------------------------------------- + Copy button for chat messages +---------------------------------------------- */ +.message .text, +.message .text-you, +.message .text-bot, +.user-message .text, +.assistant-message .text { + position: relative; +} + +.message, .user-message, .assistant-message { + position: relative; +} + +/* New container for the buttons */ +.message-actions { + position: absolute; + bottom: -23px; + left: 0; + display: flex; + gap: 5px; + opacity: 0; + transition: opacity 0.2s; +} + +.footer-button { + padding: 0; + margin: 0; + border: none; + border-radius: 3px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; +} + +.message:hover .message-actions, +.user-message:hover .message-actions, +.assistant-message:hover .message-actions { + opacity: 1; +} + +/* Disable message actions and version navigation hover effects during generation */ +._generating :is(.message, .user-message, .assistant-message):hover :is(.message-actions, .version-navigation) { + opacity: 0 !important; + pointer-events: none; +} + +/* Disable message actions and version navigation hover effects during scrolling */ +.scrolling :is(.message, .user-message, .assistant-message):hover :is(.message-actions, .version-navigation) { + opacity: 0 !important; + pointer-events: none; +} + +.footer-button svg { + stroke: rgb(140 140 148); +} + +.footer-button:hover svg { + stroke: rgb(107 114 128); +} + +.dark .footer-button svg { + stroke: rgb(156 163 175); +} + +.dark .footer-button:hover svg { + stroke: rgb(209 213 219); +} + +.block:has(> .label-wrap) { + padding: 10px 12px !important; + border: 1px solid var(--border-color-primary); +} + +.dark .block:has(> .label-wrap) { + border: 1px solid var(--border-color-dark); +} + +.welcome-greeting { + text-align: center; + margin-top: 40vh; + font-size: 24px; + opacity: 0.7; + padding-left: 1rem; + padding-right: 1rem; +} + +/* Thinking blocks styling */ +.thinking-block { + margin-bottom: 12px; + border-radius: 8px; + border: 1px solid rgb(0 0 0 / 10%); + background-color: var(--light-theme-gray); + overflow: hidden; +} + +.thinking-content:focus, .thinking-header:focus { + outline: 0 !important; +} + +.dark .thinking-block { + background-color: transparent; + border: 1px solid var(--input-border-color); +} + +.thinking-header { + display: flex; + align-items: center; + padding: 10px 16px; + cursor: pointer; + user-select: none; + font-size: 14px; + line-height: var(--line-sm); + color: rgb(0 0 0 / 70%); + transition: background-color 0.2s; +} + +.thinking-header:hover { + background-color: rgb(0 0 0 / 3%); +} + +.thinking-header::-webkit-details-marker { + display: none; +} + +.thinking-icon { + margin-right: 8px; + color: rgb(0 0 0 / 50%); + + /* Prevents the SVG from shrinking + * when tool call arguments are long */ + flex-shrink: 0; +} + +.thinking-title { + font-weight: 500; +} + +.tool-call-spinner { + display: inline-block; + width: 12px; + height: 12px; + margin-left: 8px; + border: 2px solid rgb(0 0 0 / 15%); + border-top-color: rgb(0 0 0 / 55%); + border-radius: 50%; + animation: tool-call-spin 0.8s linear infinite; + flex-shrink: 0; +} + +@keyframes tool-call-spin { + to { transform: rotate(360deg); } +} + +.dark .tool-call-spinner { + border-color: rgb(255 255 255 / 15%); + border-top-color: rgb(255 255 255 / 65%); +} + +.web-search-results { + display: flex; + flex-direction: column; + gap: var(--space-2); +} + +.web-search-result { + padding: var(--space-3) var(--space-4); + background: var(--border-soft); + border-radius: var(--radius-sm); +} + +.web-search-title { + display: block; + font-weight: 500; + margin-bottom: var(--space-1); + text-decoration: none; +} + +.web-search-title:hover { + text-decoration: underline; +} + +.web-search-snippet { + font-size: 0.9em; + color: var(--text-muted); + line-height: 1.4; +} + +.thinking-content { + padding: 12px 16px; + border-top: 1px solid rgb(0 0 0 / 7%); + color: rgb(0 0 0 / 70%); + font-size: 14px; + line-height: 1.5; + overflow-wrap: break-word; + max-height: 250px; + overflow-y: scroll; +} + +.chat .message-body .thinking-content p, +.chat .message-body .thinking-content li { + font-size: 15px !important; +} + +/* Animation for opening thinking blocks */ +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +.thinking-block[open] .thinking-content { + animation: fadeIn 0.3s ease-out; +} + +/* Additional style for in-progress thinking */ +.thinking-block[data-streaming="true"] .thinking-title { + animation: pulse 1.5s infinite; +} + +@keyframes pulse { + 0% { opacity: 0.6; } + 50% { opacity: 1; } + 100% { opacity: 0.6; } +} + +.tool-approval-buttons { + display: flex; + gap: 8px; + max-height: none; + overflow-y: visible; +} + +.tool-approval-btn { + padding: 6px 12px; + border: 1px solid var(--border-color-primary); + border-radius: 0.75rem; + background: var(--button-secondary-background-fill); + color: var(--button-secondary-text-color); + cursor: pointer; + font-size: 12px; + margin-bottom: 0 !important; +} + +.tool-approval-btn:hover { + background: var(--button-secondary-background-fill-hover); +} + +strong { + font-weight: bold; +} + +.min.svelte-1ybaih5 { + min-height: 0; +} + +#vram-info .value { + color: #008d00; +} + +.dark #vram-info .value { + color: #07ff07; +} + +.message-attachments { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-top: 8px; + padding-bottom: 6px; +} + +.attachment-box { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 8px; + background: rgb(0 0 0 / 5%); + border-radius: 6px; + border: 1px solid rgb(0 0 0 / 10%); + min-width: 80px; + max-width: 120px; +} + +.attachment-icon { + margin-bottom: 4px; + color: #555; +} + +.attachment-name { + font-size: 0.8em; + text-align: center; + word-break: break-word; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; +} + +.dark .attachment-box { + background: rgb(255 255 255 / 5%); + border: 1px solid rgb(255 255 255 / 10%); +} + +.dark .attachment-icon { + color: #ccc; +} + +/* Message Editing Styles */ +.editing-textarea { + width: 100%; + min-height: 200px; + max-height: 65vh; + padding: 10px; + border-radius: 0.5rem; + border: 1px solid var(--border-color-primary); + background-color: var(--light-theme-gray); + font-family: inherit; + font-size: inherit; + resize: vertical; +} + +.dark .editing-textarea { + border: 1px solid var(--border-color-dark); + background-color: var(--darker-gray); +} + +.editing-textarea:focus { + outline: none; + border-color: var(--selected-item-color-dark); +} + +.edit-controls-container { + margin-top: 0; + display: flex; + gap: 8px; + padding-bottom: 8px; +} + +.edit-control-button { + padding: 6px 12px; + border: 1px solid var(--border-color-primary); + border-radius: 0.75rem; + cursor: pointer; + background: var(--button-secondary-background-fill); + color: var(--button-secondary-text-color); + font-size: 12px; + margin: 0; +} + +/* --- Simple Version Navigation --- */ +.version-navigation { + position: absolute; + bottom: -23px; + right: 0; + display: flex; + align-items: center; + gap: 5px; + opacity: 0; + transition: opacity 0.2s; +} + +.message:hover .version-navigation, +.user-message:hover .version-navigation, +.assistant-message:hover .version-navigation { + opacity: 1; +} + +.version-nav-button { + padding: 2px 6px; + font-size: 12px; + min-width: auto; +} + +.version-nav-button[disabled] { + opacity: 0.3; + cursor: not-allowed; +} + +.version-position { + font-size: 11px; + color: currentcolor; + font-family: monospace; + min-width: 35px; + text-align: center; + opacity: 0.8; + user-select: none; +} + +.token-display { + font-family: monospace; + font-size: 13px; + color: var(--body-text-color-subdued); + margin-top: 4px; +} + +.image-attachment { + flex-direction: column; + max-width: 314px; +} + +.image-preview { + border-radius: 16px; + margin-bottom: 5px; + object-fit: cover; + object-position: center; + border: 2px solid var(--border-color-primary); + aspect-ratio: 1 / 1; +} + +button:focus { + outline: none; +} + +/* Fix extra gaps for hidden elements on the right sidebar */ +.svelte-sa48pu.stretch:has(> .hidden:only-child) { + display: none; +} + +.delete-container { + position: absolute; + right: 8px; + display: flex; + gap: 6px; + opacity: 0; + transition: opacity 0.2s; + margin-left: 0; +} + +.chat-label-with-delete { + position: relative; + padding-right: 60px; +} + +.trash-btn { + border: none; + background: none; + cursor: pointer; + padding: 2px; + opacity: 0.7; +} + +.cancel-btn { + border: none; + background: #ef4444; + color: white; + cursor: pointer; + width: 20px; + height: 20px; + border-radius: 2px; + font-family: monospace; + font-size: 12px; + align-items: center; + justify-content: center; + display: none; +} + +.confirm-btn { + border: none; + background: #22c55e; + color: white; + cursor: pointer; + width: 20px; + height: 20px; + border-radius: 2px; + font-family: monospace; + font-size: 12px; + align-items: center; + justify-content: center; + display: none; +} + +#character-context textarea { + height: calc((100vh - 358px) * 2/3) !important; + min-height: 90px !important; +} + +#character-greeting textarea { + height: calc((100vh - 358px) * 1/3) !important; + min-height: 90px !important; +} + +#user-description textarea { + height: calc(100vh - 342px) !important; + min-height: 90px !important; +} + +#instruction-template-str textarea, +#chat-template-str textarea { + height: calc(100vh - 308px) !important; + min-height: 90px !important; +} + +#textbox-notebook span { + display: none; +} + +.chat-parent { + will-change: scroll-position; + contain: style; + transform: translateZ(0); + overflow-anchor: none; +} + +#chat-input span { + display: none; +} + +.sidebar-vertical-separator { + margin: 0; + border-bottom: var(--input-border-width) solid var(--input-border-color); +} + +.dark .sidebar-vertical-separator { + border-bottom: 1px solid var(--border-soft); +} + +button#swap-height-width { + position: absolute; + top: -50px; + right: 0; + border: 0; +} + +#image-output-gallery, #image-output-gallery > :nth-child(2) { + height: calc(100vh - 91px); + max-height: calc(100vh - 91px); +} + +#image-history-gallery, #image-history-gallery > :nth-child(2) { + height: calc(100vh - 182px); + max-height: calc(100vh - 182px); +} + +/* Additional CSS for the paginated image gallery */ + +/* Page info styling */ +#image-page-info { + display: flex; + align-items: center; + justify-content: center; + min-width: 200px; + font-size: 0.9em; + color: var(--body-text-color-subdued); +} + +/* Settings display panel */ +#image-ai-tab .settings-display-panel { + background: var(--background-fill-secondary); + padding: 12px; + border-radius: 8px; + font-size: 0.9em; + max-height: 300px; + overflow-y: auto; + margin-top: 8px; +} + +/* Gallery status message */ +#image-ai-tab .gallery-status { + color: var(--color-accent); + font-size: 0.85em; + margin-top: 4px; +} + +/* Pagination button row alignment */ +#image-ai-tab .pagination-controls { + display: flex; + align-items: center; + gap: 8px; + flex-wrap: wrap; +} + +/* Selected image preview container */ +#image-ai-tab .selected-preview-container { + border: 1px solid var(--border-color-primary); + border-radius: 8px; + padding: 8px; + background: var(--background-fill-secondary); +} + +/* Fix a gr.Markdown UI glitch when clicking Next in the + * Image AI > Gallery tab */ +.min.svelte-1yrv54 { + min-height: 0; +} + +/* Image Generation Progress Bar */ +#image-progress .image-ai-separator { + height: 24px; + margin: 20px 0; + border-top: 1px solid var(--input-border-color); +} + +#image-progress .image-ai-progress-wrapper { + height: 24px; + margin: 20px 0; +} + +#image-progress .image-ai-progress-track { + background: #e5e7eb; + border-radius: 4px; + overflow: hidden; + height: 8px; +} + +.dark #image-progress .image-ai-progress-track { + background: #333; +} + +#image-progress .image-ai-progress-fill { + background: #4a9eff; + height: 100%; +} + +#image-progress .image-ai-progress-text { + text-align: center; + font-size: 12px; + color: #666; + margin-top: 4px; +} + +.dark #image-progress .image-ai-progress-text { + color: #888; +} + +#llm-prompt-variations { + position: absolute; + top: 0; + left: calc(100% - 174px); +} + +table { + border-collapse: collapse; +} + +.table-wrapper { + overflow-x: auto; +} + +.message-body :is(td, th) { + word-break: normal; + overflow-wrap: normal; +} + +table, tr, td, th, thead { + border: 0; +} + +.prose hr { + border-color: var(--border-color-primary); +} + +td + td, +th + th { + border-left: 1px solid var(--border-color-primary) !important; +} + +tr + tr td, +tr + tr th { + border-top: 1px solid var(--border-color-primary) !important; +} + +thead + tbody tr:first-child td, +thead + tbody tr:first-child th { + border-top: 1px solid var(--border-color-primary) !important; +} + +/* ------------------------------------------------ + Tools CheckboxGroup - vertical DragDrop-like style + ------------------------------------------------ */ + +/* "Refresh list" link in the Tools label */ +.tools-refresh-link { + cursor: pointer; +} + +/* Checkbox list container */ +#tools-group { + padding: 0 !important; + border-width: 0 !important; + background: transparent !important; + min-height: 0 !important; +} + +#tools-group .wrap { + display: flex; + flex-direction: column; + flex-wrap: nowrap; + gap: 4px; + padding: 0; + margin-top: var(--spacing-lg); + max-height: 350px; + overflow-y: auto; +} + +/* Pretty scrollbar for the tools list */ +#tools-group .wrap::-webkit-scrollbar { + width: 7px; + height: 7px; +} + +#tools-group .wrap::-webkit-scrollbar-track { + background: transparent; +} + +#tools-group .wrap::-webkit-scrollbar-thumb, +#tools-group .wrap::-webkit-scrollbar-thumb:hover { + background: var(--neutral-300); + border-radius: 9999px; +} + +.dark #tools-group .wrap::-webkit-scrollbar-thumb, +.dark #tools-group .wrap::-webkit-scrollbar-thumb:hover { + background: rgb(255 255 255 / 6.25%); + border-radius: 9999px; +} + +#tools-group .wrap::-webkit-scrollbar-corner { + background: transparent; +} + +/* Each checkbox item */ +#tools-group label { + display: flex; + align-items: center; + gap: 8px; + padding: 5px 8px; + border-radius: var(--radius-sm, 4px); + background: var(--block-background-fill); + border: 1px solid var(--border-color-primary); + color: var(--body-text-color); + font-size: var(--input-text-size); + font-weight: var(--input-text-weight); + cursor: pointer; + user-select: none; + transition: border-color 0.15s ease, background 0.15s ease; + box-shadow: none; +} + +#tools-group label:hover { + border-color: var(--input-border-color-focus); +} + +#tools-group label span { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* Mode selector: segmented control + Targets the gr.Radio at #chat-mode and replaces the default + stacked / wrap-prone radio appearance with a 3-up segmented + control. The actual is hidden; the parent +