Full Code of nomic-ai/gpt4all for AI

main b666d16db5ae cached
307 files
3.0 MB
797.1k tokens
647 symbols
2 requests
Download .txt
Showing preview only (3,182K chars total). Download the full file or copy to clipboard to get everything.
Repository: nomic-ai/gpt4all
Branch: main
Commit: b666d16db5ae
Files: 307
Total size: 3.0 MB

Directory structure:
gitextract_o3o4fycr/

├── .circleci/
│   ├── config.yml
│   ├── continue_config.yml
│   └── grab_notary_id.py
├── .codespellrc
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bindings-bug.md
│   │   ├── chat-bug.md
│   │   ├── config.yml
│   │   ├── documentation.md
│   │   ├── feature-request.md
│   │   └── other-bug.md
│   ├── pull_request_template.md
│   └── workflows/
│       ├── close_issues.yml
│       └── codespell.yml
├── .gitignore
├── .gitmodules
├── CONTRIBUTING.md
├── LICENSE.txt
├── MAINTAINERS.md
├── README.md
├── common/
│   └── common.cmake
├── gpt4all-backend/
│   ├── CMakeLists.txt
│   ├── README.md
│   ├── include/
│   │   └── gpt4all-backend/
│   │       ├── llmodel.h
│   │       ├── llmodel_c.h
│   │       └── sysinfo.h
│   ├── llama.cpp.cmake
│   └── src/
│       ├── dlhandle.cpp
│       ├── dlhandle.h
│       ├── llamamodel.cpp
│       ├── llamamodel_impl.h
│       ├── llmodel.cpp
│       ├── llmodel_c.cpp
│       ├── llmodel_shared.cpp
│       └── utils.h
├── gpt4all-bindings/
│   ├── README.md
│   ├── cli/
│   │   ├── README.md
│   │   ├── app.py
│   │   └── developer_notes.md
│   ├── python/
│   │   ├── .gitignore
│   │   ├── .isort.cfg
│   │   ├── CHANGELOG.md
│   │   ├── LICENSE.txt
│   │   ├── MANIFEST.in
│   │   ├── README.md
│   │   ├── docs/
│   │   │   ├── css/
│   │   │   │   └── custom.css
│   │   │   ├── gpt4all_api_server/
│   │   │   │   └── home.md
│   │   │   ├── gpt4all_desktop/
│   │   │   │   ├── chat_templates.md
│   │   │   │   ├── chats.md
│   │   │   │   ├── cookbook/
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-Obsidian.md
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-One-Drive.md
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-google-drive.md
│   │   │   │   │   └── use-local-ai-models-to-privately-chat-with-microsoft-excel.md
│   │   │   │   ├── localdocs.md
│   │   │   │   ├── models.md
│   │   │   │   ├── quickstart.md
│   │   │   │   └── settings.md
│   │   │   ├── gpt4all_help/
│   │   │   │   ├── faq.md
│   │   │   │   └── troubleshooting.md
│   │   │   ├── gpt4all_python/
│   │   │   │   ├── home.md
│   │   │   │   ├── monitoring.md
│   │   │   │   └── ref.md
│   │   │   ├── index.md
│   │   │   └── old/
│   │   │       ├── gpt4all_chat.md
│   │   │       ├── gpt4all_cli.md
│   │   │       ├── gpt4all_faq.md
│   │   │       ├── gpt4all_monitoring.md
│   │   │       ├── gpt4all_nodejs.md
│   │   │       ├── gpt4all_python.md
│   │   │       ├── gpt4all_python_embedding.md
│   │   │       └── index.md
│   │   ├── gpt4all/
│   │   │   ├── __init__.py
│   │   │   ├── _pyllmodel.py
│   │   │   ├── gpt4all.py
│   │   │   └── tests/
│   │   │       ├── __init__.py
│   │   │       ├── test_embed_timings.py
│   │   │       └── test_gpt4all.py
│   │   ├── makefile
│   │   ├── mkdocs.yml
│   │   └── setup.py
│   └── typescript/
│       ├── .clang-format
│       ├── .gitignore
│       ├── .npmignore
│       ├── .yarnrc.yml
│       ├── README.md
│       ├── binding.ci.gyp
│       ├── binding.gyp
│       ├── index.cc
│       ├── index.h
│       ├── package.json
│       ├── prompt.cc
│       ├── prompt.h
│       ├── scripts/
│       │   ├── build.js
│       │   ├── docs.js
│       │   ├── mkclangd.js
│       │   └── prebuild.js
│       ├── spec/
│       │   ├── callbacks.mjs
│       │   ├── chat-memory.mjs
│       │   ├── chat-minimal.mjs
│       │   ├── concurrency.mjs
│       │   ├── embed-jsonl.mjs
│       │   ├── embed.mjs
│       │   ├── llmodel.mjs
│       │   ├── long-context.mjs
│       │   ├── model-switching.mjs
│       │   ├── stateless.mjs
│       │   ├── streaming.mjs
│       │   └── system.mjs
│       ├── src/
│       │   ├── chat-session.js
│       │   ├── config.js
│       │   ├── gpt4all.d.ts
│       │   ├── gpt4all.js
│       │   ├── models.js
│       │   └── util.js
│       └── test/
│           ├── gpt4all.test.js
│           └── models.json
├── gpt4all-chat/
│   ├── .flake8
│   ├── CHANGELOG.md
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── cmake/
│   │   ├── Modules/
│   │   │   ├── SignMacOSBinaries.cmake
│   │   │   └── SignWindowsBinaries.cmake
│   │   ├── cpack-steal-config.cmake.in
│   │   ├── cpack_config.cmake
│   │   ├── deploy-qt-linux.cmake.in
│   │   ├── deploy-qt-mac.cmake.in
│   │   ├── deploy-qt-windows.cmake.in
│   │   ├── download_model.cmake
│   │   ├── installer_control.qs
│   │   ├── installer_gpt4all_component.qs
│   │   ├── installer_maintenancetool_component.qs
│   │   └── sign_dmg.py
│   ├── contributing_translations.md
│   ├── deps/
│   │   └── CMakeLists.txt
│   ├── dev-requirements.txt
│   ├── flatpak-manifest/
│   │   ├── io.gpt4all.gpt4all.appdata.xml
│   │   └── io.gpt4all.gpt4all.desktop
│   ├── main.qml
│   ├── metadata/
│   │   ├── latestnews.md
│   │   ├── models.json
│   │   ├── models2.json
│   │   ├── models3.json
│   │   └── release.json
│   ├── pyproject.toml
│   ├── qa_checklist.md
│   ├── qml/
│   │   ├── AddCollectionView.qml
│   │   ├── AddGPT4AllModelView.qml
│   │   ├── AddHFModelView.qml
│   │   ├── AddModelView.qml
│   │   ├── AddRemoteModelView.qml
│   │   ├── ApplicationSettings.qml
│   │   ├── ChatCollapsibleItem.qml
│   │   ├── ChatDrawer.qml
│   │   ├── ChatItemView.qml
│   │   ├── ChatMessageButton.qml
│   │   ├── ChatTextItem.qml
│   │   ├── ChatView.qml
│   │   ├── CollectionsDrawer.qml
│   │   ├── ConfirmationDialog.qml
│   │   ├── HomeView.qml
│   │   ├── LocalDocsSettings.qml
│   │   ├── LocalDocsView.qml
│   │   ├── ModelSettings.qml
│   │   ├── ModelsView.qml
│   │   ├── MyBusyIndicator.qml
│   │   ├── MyButton.qml
│   │   ├── MyCheckBox.qml
│   │   ├── MyComboBox.qml
│   │   ├── MyDialog.qml
│   │   ├── MyDirectoryField.qml
│   │   ├── MyFancyLink.qml
│   │   ├── MyFileDialog.qml
│   │   ├── MyFileIcon.qml
│   │   ├── MyFolderDialog.qml
│   │   ├── MyMenu.qml
│   │   ├── MyMenuItem.qml
│   │   ├── MyMiniButton.qml
│   │   ├── MySettingsButton.qml
│   │   ├── MySettingsDestructiveButton.qml
│   │   ├── MySettingsLabel.qml
│   │   ├── MySettingsStack.qml
│   │   ├── MySettingsTab.qml
│   │   ├── MySlug.qml
│   │   ├── MyTabButton.qml
│   │   ├── MyTextArea.qml
│   │   ├── MyTextButton.qml
│   │   ├── MyTextField.qml
│   │   ├── MyToolButton.qml
│   │   ├── MyWelcomeButton.qml
│   │   ├── NetworkDialog.qml
│   │   ├── NewVersionDialog.qml
│   │   ├── PopupDialog.qml
│   │   ├── RemoteModelCard.qml
│   │   ├── SettingsView.qml
│   │   ├── StartupDialog.qml
│   │   ├── Theme.qml
│   │   ├── ThumbsDownDialog.qml
│   │   ├── Toast.qml
│   │   └── ToastManager.qml
│   ├── resources/
│   │   ├── gpt4all.icns
│   │   └── gpt4all.rc
│   ├── src/
│   │   ├── chat.cpp
│   │   ├── chat.h
│   │   ├── chatapi.cpp
│   │   ├── chatapi.h
│   │   ├── chatlistmodel.cpp
│   │   ├── chatlistmodel.h
│   │   ├── chatllm.cpp
│   │   ├── chatllm.h
│   │   ├── chatmodel.cpp
│   │   ├── chatmodel.h
│   │   ├── chatviewtextprocessor.cpp
│   │   ├── chatviewtextprocessor.h
│   │   ├── codeinterpreter.cpp
│   │   ├── codeinterpreter.h
│   │   ├── config.h.in
│   │   ├── database.cpp
│   │   ├── database.h
│   │   ├── download.cpp
│   │   ├── download.h
│   │   ├── embllm.cpp
│   │   ├── embllm.h
│   │   ├── jinja_helpers.cpp
│   │   ├── jinja_helpers.h
│   │   ├── jinja_replacements.cpp
│   │   ├── jinja_replacements.h
│   │   ├── llm.cpp
│   │   ├── llm.h
│   │   ├── localdocs.cpp
│   │   ├── localdocs.h
│   │   ├── localdocsmodel.cpp
│   │   ├── localdocsmodel.h
│   │   ├── logger.cpp
│   │   ├── logger.h
│   │   ├── macosdock.h
│   │   ├── macosdock.mm
│   │   ├── main.cpp
│   │   ├── modellist.cpp
│   │   ├── modellist.h
│   │   ├── mysettings.cpp
│   │   ├── mysettings.h
│   │   ├── network.cpp
│   │   ├── network.h
│   │   ├── server.cpp
│   │   ├── server.h
│   │   ├── tool.cpp
│   │   ├── tool.h
│   │   ├── toolcallparser.cpp
│   │   ├── toolcallparser.h
│   │   ├── toolmodel.cpp
│   │   ├── toolmodel.h
│   │   ├── utils.h
│   │   ├── utils.inl
│   │   ├── xlsxtomd.cpp
│   │   └── xlsxtomd.h
│   ├── system_requirements.md
│   ├── test-requirements.txt
│   ├── tests/
│   │   ├── CMakeLists.txt
│   │   ├── cpp/
│   │   │   ├── basic_test.cpp
│   │   │   └── test_main.cpp
│   │   └── python/
│   │       ├── __init__.py
│   │       ├── config.py.in
│   │       └── test_server_api.py
│   └── translations/
│       ├── gpt4all_en_US.ts
│       ├── gpt4all_es_MX.ts
│       ├── gpt4all_it_IT.ts
│       ├── gpt4all_pt_BR.ts
│       ├── gpt4all_ro_RO.ts
│       ├── gpt4all_zh_CN.ts
│       └── gpt4all_zh_TW.ts
├── gpt4all-training/
│   ├── GPT-J_MAP.md
│   ├── README.md
│   ├── TRAINING_LOG.md
│   ├── clean.py
│   ├── configs/
│   │   ├── deepspeed/
│   │   │   ├── ds_config.json
│   │   │   ├── ds_config_gptj.json
│   │   │   ├── ds_config_gptj_lora.json
│   │   │   ├── ds_config_mpt.json
│   │   │   └── ds_config_pythia.json
│   │   ├── eval/
│   │   │   ├── generate_baseline.yaml
│   │   │   ├── generate_gpt4all_gptj.yaml
│   │   │   ├── generate_gpt4all_gptj_lora.yaml
│   │   │   └── generate_gpt4all_llama_lora.yaml
│   │   ├── generate/
│   │   │   ├── generate.yaml
│   │   │   ├── generate_gptj.yaml
│   │   │   ├── generate_gptj_lora.yaml
│   │   │   └── generate_llama.yaml
│   │   ├── inference/
│   │   │   └── gptj.yaml
│   │   └── train/
│   │       ├── finetune.yaml
│   │       ├── finetune_falcon.yaml
│   │       ├── finetune_gptj.yaml
│   │       ├── finetune_gptj_lora.yaml
│   │       ├── finetune_lora.yaml
│   │       ├── finetune_mpt.yaml
│   │       └── finetune_openllama.yaml
│   ├── create_hostname.sh
│   ├── data.py
│   ├── env.yaml
│   ├── eval_figures.py
│   ├── eval_self_instruct.py
│   ├── generate.py
│   ├── inference.py
│   ├── launcher.sh
│   ├── old-README.md
│   ├── read.py
│   ├── requirements.txt
│   └── train.py
└── roadmap.md

================================================
FILE CONTENTS
================================================

================================================
FILE: .circleci/config.yml
================================================
version: 2.1
setup: true
orbs:
  path-filtering: circleci/path-filtering@1.3.0

workflows:
  version: 2.1
  generate-config:
    jobs:
      - path-filtering/filter:
          filters:
            tags:
              only:
                - /.*/
          base-revision: main
          config-path: .circleci/continue_config.yml
          mapping: |
            .circleci/.* run-all-workflows true
            gpt4all-backend/.* run-all-workflows true
            gpt4all-bindings/python/.* run-python-workflow true
            gpt4all-bindings/typescript/.* run-ts-workflow true
            gpt4all-chat/.* run-chat-workflow true


================================================
FILE: .circleci/continue_config.yml
================================================
version: 2.1
orbs:
  win: circleci/windows@5.0
  python: circleci/python@1.2
  node: circleci/node@5.1

parameters:
  run-all-workflows:
    type: boolean
    default: false
  run-python-workflow:
    type: boolean
    default: false
  run-chat-workflow:
    type: boolean
    default: false
  run-ts-workflow:
    type: boolean
    default: false

job-macos-executor: &job-macos-executor
  macos:
    xcode: 16.2.0
  resource_class: macos.m1.medium.gen1
  environment:
    HOMEBREW_NO_AUTO_UPDATE: 1

job-macos-install-deps: &job-macos-install-deps
  name: Install basic macOS build dependencies
  command: brew install ccache llvm wget

job-linux-install-chat-deps: &job-linux-install-chat-deps
  name: Install Linux build dependencies for gpt4all-chat
  command: |
    # Prevent apt-get from interactively prompting for service restart
    echo "\$nrconf{restart} = 'l'" | sudo tee /etc/needrestart/conf.d/90-autorestart.conf >/dev/null
    wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
    sudo add-apt-repository -yn 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main'
    wget -qO- "https://packages.lunarg.com/lunarg-signing-key-pub.asc" \
      | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc >/dev/null
    wget -qO- "https://packages.lunarg.com/vulkan/1.3.290/lunarg-vulkan-1.3.290-jammy.list" \
      | sudo tee /etc/apt/sources.list.d/lunarg-vulkan-1.3.290-jammy.list >/dev/null
    wget "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb"
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    packages=(
      bison build-essential ccache clang-19 clang-tools-19 cuda-compiler-11-8 flex gperf libcublas-dev-11-8
      libfontconfig1 libfreetype6 libgl1-mesa-dev libmysqlclient21 libnvidia-compute-550-server libodbc2 libpq5
      libstdc++-12-dev libwayland-dev libx11-6 libx11-xcb1 libxcb-cursor0 libxcb-glx0 libxcb-icccm4 libxcb-image0
      libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1
      libxcb-xfixes0 libxcb-xinerama0 libxcb-xkb1 libxcb1 libxext6 libxfixes3 libxi6 libxkbcommon-dev libxkbcommon-x11-0
      libxrender1 patchelf python3 vulkan-sdk python3 vulkan-sdk
    )
    sudo apt-get update
    sudo apt-get install -y "${packages[@]}"
    wget "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-linux-x64-4.8.1.run"
    chmod +x qt-online-installer-linux-x64-4.8.1.run
    ./qt-online-installer-linux-x64-4.8.1.run --no-force-installations --no-default-installations \
      --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations \
      --email "$QT_EMAIL" --password "$QT_PASSWORD" install \
      qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.linux_gcc_64 qt.qt6.682.addons.qt5compat \
      qt.qt6.682.debug_info extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver

job-linux-install-backend-deps: &job-linux-install-backend-deps
  name: Install Linux build dependencies for gpt4all-backend
  command: |
    wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null
    sudo add-apt-repository -yn 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main'
    wget -qO- "https://packages.lunarg.com/lunarg-signing-key-pub.asc" \
      | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc >/dev/null
    wget -qO- "https://packages.lunarg.com/vulkan/1.3.290/lunarg-vulkan-1.3.290-jammy.list" \
      | sudo tee /etc/apt/sources.list.d/lunarg-vulkan-1.3.290-jammy.list >/dev/null
    wget "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb"
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    packages=(
      build-essential ccache clang-19 clang-tools-19 cuda-compiler-11-8 libcublas-dev-11-8
      libnvidia-compute-550-server libstdc++-12-dev vulkan-sdk
    )
    sudo apt-get update
    sudo apt-get install -y "${packages[@]}"
    pyenv global 3.13.2
    pip install setuptools wheel cmake ninja

jobs:
  # work around CircleCI-Public/path-filtering-orb#20
  noop:
    docker:
      - image: cimg/base:stable
    steps:
      - run: "true"
  validate-commit-on-main:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - run:
          name: Verify that commit is on the main branch
          command: git merge-base --is-ancestor HEAD main
  build-offline-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-macos-
      - run:
          <<: *job-macos-install-deps
      - run:
          name: Install Rosetta
          command: softwareupdate --install-rosetta --agree-to-license  # needed for QtIFW
      - run:
          name: Installing Qt
          command: |
            wget "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-macOS-x64-4.8.1.dmg"
            hdiutil attach qt-online-installer-macOS-x64-4.8.1.dmg
            /Volumes/qt-online-installer-macOS-x64-4.8.1/qt-online-installer-macOS-x64-4.8.1.app/Contents/MacOS/qt-online-installer-macOS-x64-4.8.1 \
              --no-force-installations --no-default-installations --no-size-checking --default-answer \
              --accept-licenses --confirm-command --accept-obligations --email "$QT_EMAIL" --password "$QT_PASSWORD" \
              install \
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.clang_64 qt.qt6.682.addons.qt5compat \
              extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
            hdiutil detach /Volumes/qt-online-installer-macOS-x64-4.8.1
      - run:
          name: Setup Keychain
          command: |
            echo $MAC_SIGNING_CERT | base64 --decode > cert.p12
            security create-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security default-keychain -s sign.keychain
            security unlock-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security import cert.p12 -k sign.keychain -P "$MAC_SIGNING_CERT_PWD" -T /usr/bin/codesign
            security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MAC_KEYCHAIN_KEY" sign.keychain
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            export PATH=$PATH:$HOME/Qt/Tools/QtInstallerFramework/4.8/bin
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake \
              -S ../gpt4all-chat -B . -G Ninja \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_PREFIX_PATH:PATH=~/Qt/6.8.2/macos/lib/cmake \
              -DCMAKE_MAKE_PROGRAM:FILEPATH=~/Qt/Tools/Ninja/ninja \
              -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
              -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
              -DCMAKE_RANLIB=/usr/bin/ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DBUILD_UNIVERSAL=ON \
              -DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
              -DGGML_METAL_MACOSX_VERSION_MIN=12.6 \
              -DMACDEPLOYQT=~/Qt/6.8.2/macos/bin/macdeployqt \
              -DGPT4ALL_OFFLINE_INSTALLER=ON \
              -DGPT4ALL_SIGN_INSTALL=ON \
              -DGPT4ALL_GEN_CPACK_CONFIG=ON
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target package
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake . -DGPT4ALL_GEN_CPACK_CONFIG=OFF
            # The 'install' step here *should* be completely unnecessary. There is absolutely no reason we should have
            # to copy all of the build artifacts to an output directory that we do not use (because we package GPT4All
            # as an installer instead).
            # However, because of the way signing is implemented in the cmake script, the *source* files are signed at
            # install time instead of the *installed* files. This side effect is the *only* way libraries that are not
            # processed by macdeployqt, such as libllmodel.so, get signed (at least, with -DBUILD_UNIVERSAL=ON).
            # Also, we have to run this as a *separate* step. Telling cmake to run both targets in one command causes it
            # to execute them in parallel, since it is not aware of the dependency of the package target on the install
            # target.
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target install
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target package
            ccache -s
            mkdir upload
            cp gpt4all-installer-* upload
      # persist the unsigned installer
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-macos-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-offline-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      # attach to a workspace containing unsigned dmg
      - attach_workspace:
          at: build
      - run:
          name: "Setup Keychain"
          command: |
            echo $MAC_SIGNING_CERT | base64 --decode > cert.p12
            security create-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security default-keychain -s sign.keychain
            security unlock-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security import cert.p12 -k sign.keychain -P "$MAC_SIGNING_CERT_PWD" -T /usr/bin/codesign
            security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MAC_KEYCHAIN_KEY" sign.keychain
            rm cert.p12
      - run:
          name: "Sign App Bundle"
          command: |
            python3 -m pip install click
            python3 gpt4all-chat/cmake/sign_dmg.py --input-dmg build/upload/gpt4all-installer-darwin.dmg --output-dmg build/upload/gpt4all-installer-darwin-signed.dmg --signing-identity "$MAC_SIGNING_CERT_NAME"
      - run:
          name: "Sign DMG"
          command: |
            codesign --options runtime --timestamp -s "$MAC_SIGNING_CERT_NAME" build/upload/gpt4all-installer-darwin-signed.dmg
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  notarize-offline-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: "Notarize"
          command: |
            xcrun notarytool submit build/upload/gpt4all-installer-darwin-signed.dmg --apple-id "$MAC_NOTARIZATION_ID" --team-id "$MAC_NOTARIZATION_TID" --password "$MAC_NOTARIZATION_KEY" --wait  | tee notarize_log.txt
      - run:
          name: "Report Notarization Failure"
          command: |
            NID=`python3 .circleci/grab_notary_id.py notarize_log.txt` && export NID
            xcrun notarytool log $NID --keychain-profile "notary-profile"
            exit 1
          when: on_fail
      - run:
          name: "Staple"
          command: |
            xcrun stapler staple build/upload/gpt4all-installer-darwin-signed.dmg
      - store_artifacts:
          path: build/upload
      - run:
          name: Install Rosetta
          command: softwareupdate --install-rosetta --agree-to-license  # needed for QtIFW
      - run:
          name: Test installation and verify that it is signed
          command: |
            set -e
            hdiutil attach build/upload/gpt4all-installer-darwin-signed.dmg
            codesign --verify --deep --verbose /Volumes/gpt4all-installer-darwin/gpt4all-installer-darwin.app
            /Volumes/gpt4all-installer-darwin/gpt4all-installer-darwin.app/Contents/MacOS/gpt4all-installer-darwin \
              --no-size-checking --default-answer --accept-licenses --confirm-command \
              install gpt4all
            codesign --verify --deep --verbose /Applications/gpt4all/bin/gpt4all.app
            codesign --verify --deep --verbose /Applications/gpt4all/maintenancetool.app
            hdiutil detach /Volumes/gpt4all-installer-darwin

  build-online-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-macos-
      - run:
          <<: *job-macos-install-deps
      - run:
          name: Install Rosetta
          command: softwareupdate --install-rosetta --agree-to-license  # needed for QtIFW
      - run:
          name: Installing Qt
          command: |
            wget "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-macOS-x64-4.8.1.dmg"
            hdiutil attach qt-online-installer-macOS-x64-4.8.1.dmg
            /Volumes/qt-online-installer-macOS-x64-4.8.1/qt-online-installer-macOS-x64-4.8.1.app/Contents/MacOS/qt-online-installer-macOS-x64-4.8.1 \
              --no-force-installations --no-default-installations --no-size-checking --default-answer \
              --accept-licenses --confirm-command --accept-obligations --email "$QT_EMAIL" --password "$QT_PASSWORD" \
              install \
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.clang_64 qt.qt6.682.addons.qt5compat \
              extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
            hdiutil detach /Volumes/qt-online-installer-macOS-x64-4.8.1
      - run:
          name: Setup Keychain
          command: |
            echo $MAC_SIGNING_CERT | base64 --decode > cert.p12
            security create-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security default-keychain -s sign.keychain
            security unlock-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security import cert.p12 -k sign.keychain -P "$MAC_SIGNING_CERT_PWD" -T /usr/bin/codesign
            security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MAC_KEYCHAIN_KEY" sign.keychain
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            export PATH=$PATH:$HOME/Qt/Tools/QtInstallerFramework/4.8/bin
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake \
              -S ../gpt4all-chat -B . -G Ninja \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_PREFIX_PATH:PATH=~/Qt/6.8.2/macos/lib/cmake \
              -DCMAKE_MAKE_PROGRAM:FILEPATH=~/Qt/Tools/Ninja/ninja \
              -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
              -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
              -DCMAKE_RANLIB=/usr/bin/ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DBUILD_UNIVERSAL=ON \
              -DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
              -DGGML_METAL_MACOSX_VERSION_MIN=12.6 \
              -DMACDEPLOYQT=~/Qt/6.8.2/macos/bin/macdeployqt \
              -DGPT4ALL_OFFLINE_INSTALLER=OFF \
              -DGPT4ALL_SIGN_INSTALL=ON \
              -DGPT4ALL_GEN_CPACK_CONFIG=ON
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target package
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake . -DGPT4ALL_GEN_CPACK_CONFIG=OFF
            # See comment above related to the 'install' target.
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target install
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build . --target package
            ccache -s
            mkdir upload
            cp gpt4all-installer-* upload
            tar -cvzf upload/repository.tar.gz -C _CPack_Packages/Darwin/IFW/gpt4all-installer-darwin repository
      # persist the unsigned installer
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-macos-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-online-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      # attach to a workspace containing unsigned dmg
      - attach_workspace:
          at: build
      - run:
          name: "Setup Keychain"
          command: |
            echo $MAC_SIGNING_CERT | base64 --decode > cert.p12
            security create-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security default-keychain -s sign.keychain
            security unlock-keychain -p "$MAC_KEYCHAIN_KEY" sign.keychain
            security import cert.p12 -k sign.keychain -P "$MAC_SIGNING_CERT_PWD" -T /usr/bin/codesign
            security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MAC_KEYCHAIN_KEY" sign.keychain
            rm cert.p12
      - run:
          name: "Sign App Bundle"
          command: |
            python3 -m pip install click
            python3 gpt4all-chat/cmake/sign_dmg.py --input-dmg build/upload/gpt4all-installer-darwin.dmg --output-dmg build/upload/gpt4all-installer-darwin-signed.dmg --signing-identity "$MAC_SIGNING_CERT_NAME"
      - run:
          name: "Sign DMG"
          command: |
            codesign --options runtime --timestamp -s "$MAC_SIGNING_CERT_NAME" build/upload/gpt4all-installer-darwin-signed.dmg
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  notarize-online-chat-installer-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: "Notarize"
          command: |
            xcrun notarytool submit build/upload/gpt4all-installer-darwin-signed.dmg --apple-id "$MAC_NOTARIZATION_ID" --team-id "$MAC_NOTARIZATION_TID" --password "$MAC_NOTARIZATION_KEY" --wait  | tee notarize_log.txt
      - run:
          name: "Report Notarization Failure"
          command: |
            NID=`python3 .circleci/grab_notary_id.py notarize_log.txt` && export NID
            xcrun notarytool log $NID --keychain-profile "notary-profile"
            exit 1
          when: on_fail
      - run:
          name: "Staple"
          command: |
            xcrun stapler staple build/upload/gpt4all-installer-darwin-signed.dmg
      - store_artifacts:
          path: build/upload
      - run:
          name: Install Rosetta
          command: softwareupdate --install-rosetta --agree-to-license  # needed for QtIFW
      - run:
          name: Test installation and verify that it is signed
          command: |
            set -e
            hdiutil attach build/upload/gpt4all-installer-darwin-signed.dmg
            codesign --verify --deep --verbose /Volumes/gpt4all-installer-darwin/gpt4all-installer-darwin.app
            tar -xf build/upload/repository.tar.gz
            /Volumes/gpt4all-installer-darwin/gpt4all-installer-darwin.app/Contents/MacOS/gpt4all-installer-darwin \
              --no-size-checking --default-answer --accept-licenses --confirm-command --set-temp-repository repository \
              install gpt4all
            codesign --verify --deep --verbose /Applications/gpt4all/bin/gpt4all.app
            codesign --verify --deep --verbose /Applications/gpt4all/maintenancetool.app
            hdiutil detach /Volumes/gpt4all-installer-darwin

  build-offline-chat-installer-linux:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-linux-amd64-
      - run:
          <<: *job-linux-install-chat-deps
      - run:
          name: Build linuxdeployqt
          command: |
            git clone https://github.com/nomic-ai/linuxdeployqt
            cd linuxdeployqt && qmake && sudo make install
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            set -eo pipefail
            export CMAKE_PREFIX_PATH=~/Qt/6.8.2/gcc_64/lib/cmake
            export PATH=$PATH:$HOME/Qt/Tools/QtInstallerFramework/4.8/bin
            export PATH=$PATH:/usr/local/cuda/bin
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            mkdir upload
            ~/Qt/Tools/CMake/bin/cmake \
              -S ../gpt4all-chat -B . \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=clang-19 \
              -DCMAKE_CXX_COMPILER=clang++-19 \
              -DCMAKE_CXX_COMPILER_AR=ar \
              -DCMAKE_CXX_COMPILER_RANLIB=ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON \
              -DGPT4ALL_OFFLINE_INSTALLER=ON
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target all
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target install
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target package
            ccache -s
            cp gpt4all-installer-* upload
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-linux-amd64-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - run:
          name: Test installation
          command: |
            mkdir ~/Desktop
            build/upload/gpt4all-installer-linux.run --no-size-checking --default-answer --accept-licenses \
              --confirm-command \
              install gpt4all

  build-online-chat-installer-linux:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-linux-amd64-
      - run:
          <<: *job-linux-install-chat-deps
      - run:
          name: Build linuxdeployqt
          command: |
            git clone https://github.com/nomic-ai/linuxdeployqt
            cd linuxdeployqt && qmake && sudo make install
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            set -eo pipefail
            export CMAKE_PREFIX_PATH=~/Qt/6.8.2/gcc_64/lib/cmake
            export PATH=$PATH:$HOME/Qt/Tools/QtInstallerFramework/4.8/bin
            export PATH=$PATH:/usr/local/cuda/bin
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            mkdir upload
            ~/Qt/Tools/CMake/bin/cmake \
              -S ../gpt4all-chat -B . \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=clang-19 \
              -DCMAKE_CXX_COMPILER=clang++-19 \
              -DCMAKE_CXX_COMPILER_AR=ar \
              -DCMAKE_CXX_COMPILER_RANLIB=ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON \
              -DGPT4ALL_OFFLINE_INSTALLER=OFF
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target all
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target install
            ~/Qt/Tools/CMake/bin/cmake --build . -j$(nproc) --target package
            ccache -s
            cp gpt4all-installer-* upload
            tar -cvzf upload/repository.tar.gz -C _CPack_Packages/Linux/IFW/gpt4all-installer-linux repository
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-linux-amd64-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - run:
          name: Test installation
          command: |
            mkdir ~/Desktop
            build/upload/gpt4all-installer-linux.run --no-size-checking --default-answer --accept-licenses \
              --confirm-command \
              --set-temp-repository build/_CPack_Packages/Linux/IFW/gpt4all-installer-linux/repository \
              install gpt4all

  build-offline-chat-installer-windows:
    machine:
      # we use 2024.04.01 because nvcc complains about the MSVC ver if we use anything newer
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-amd64-
      - run:
          name: Install dependencies
          command: choco install -y ccache wget
      - run:
          name: Installing Qt
          command: |
            wget.exe "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-windows-x64-4.8.1.exe"
            & .\qt-online-installer-windows-x64-4.8.1.exe --no-force-installations --no-default-installations `
              --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
              --email "${Env:QT_EMAIL}" --password "${Env:QT_PASSWORD}" install `
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.win64_msvc2022_64 qt.qt6.682.addons.qt5compat `
              qt.qt6.682.debug_info extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
      - run:
          name: Install VulkanSDK
          command: |
            wget.exe "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe"
            .\VulkanSDK-1.3.261.1-Installer.exe --accept-licenses --default-answer --confirm-command install
      - run:
          name: Install CUDA Toolkit
          command: |
            wget.exe "https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe"
            .\cuda_11.8.0_windows_network.exe -s cudart_11.8 nvcc_11.8 cublas_11.8 cublas_dev_11.8
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'

            $Env:PATH = "${Env:PATH};C:\VulkanSDK\1.3.261.1\bin"
            $Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            & "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
              -S ..\gpt4all-chat -B . -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              "-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.8.2\msvc2022_64" `
              "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache `
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON `
              -DGPT4ALL_OFFLINE_INSTALLER=ON
            & "C:\Qt\Tools\Ninja\ninja.exe"
            & "C:\Qt\Tools\Ninja\ninja.exe" install
            & "C:\Qt\Tools\Ninja\ninja.exe" package
            ccache -s
            mkdir upload
            copy gpt4all-installer-win64.exe upload
      - store_artifacts:
          path: build/upload
            # add workspace so signing jobs can connect & obtain dmg
      - save_cache:
          key: ccache-gpt4all-win-amd64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-offline-chat-installer-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: Install dependencies
          command: choco install -y wget
      - run:
          name: "Install Dotnet 8 && Azure Sign Tool"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: "Sign Windows Installer With AST"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)\build\upload\gpt4all-installer-win64.exe"
      - store_artifacts:
          path: build/upload
      - run:
          name: Test installation
          command: |
            build\upload\gpt4all-installer-win64.exe --no-size-checking --default-answer --accept-licenses `
              --confirm-command `
              install gpt4all

  build-online-chat-installer-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-amd64-
      - run:
          name: Install dependencies
          command: choco install -y ccache wget
      - run:
          name: Installing Qt
          command: |
            wget.exe "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-windows-x64-4.8.1.exe"
            & .\qt-online-installer-windows-x64-4.8.1.exe --no-force-installations --no-default-installations `
              --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
              --email "${Env:QT_EMAIL}" --password "${Env:QT_PASSWORD}" install `
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.win64_msvc2022_64 qt.qt6.682.addons.qt5compat `
              qt.qt6.682.debug_info extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
      - run:
          name: Install VulkanSDK
          command: |
            wget.exe "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe"
            .\VulkanSDK-1.3.261.1-Installer.exe --accept-licenses --default-answer --confirm-command install
      - run:
          name: Install CUDA Toolkit
          command: |
            wget.exe "https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe"
            .\cuda_11.8.0_windows_network.exe -s cudart_11.8 nvcc_11.8 cublas_11.8 cublas_dev_11.8
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
      - run:
          name: "Setup Azure SignTool"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'

            $Env:PATH = "${Env:PATH};C:\VulkanSDK\1.3.261.1\bin"
            $Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            & "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
              -S ..\gpt4all-chat -B . -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              "-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.8.2\msvc2022_64" `
              "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache `
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON `
              -DGPT4ALL_OFFLINE_INSTALLER=OFF
            & "C:\Qt\Tools\Ninja\ninja.exe"
            & "C:\Qt\Tools\Ninja\ninja.exe" install
            & "C:\Qt\Tools\Ninja\ninja.exe" package
            ccache -s
            mkdir upload
            copy gpt4all-installer-win64.exe upload
            Set-Location -Path "_CPack_Packages/win64/IFW/gpt4all-installer-win64"
            Compress-Archive -Path 'repository' -DestinationPath '..\..\..\..\upload\repository.zip'
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-win-amd64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-online-chat-installer-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: Install dependencies
          command: choco install -y wget
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
      - run:
          name: "Setup Azure SignTool"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: "Sign Windows Installer With AST"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)/build/upload/gpt4all-installer-win64.exe"
      - store_artifacts:
          path: build/upload
      - run:
          name: Test installation
          command: |
            Expand-Archive -LiteralPath build\upload\repository.zip -DestinationPath .
            build\upload\gpt4all-installer-win64.exe --no-size-checking --default-answer --accept-licenses `
              --confirm-command --set-temp-repository repository `
              install gpt4all

  build-offline-chat-installer-windows-arm:
    machine:
      # we use 2024.04.01 because nvcc complains about the MSVC ver if we use anything newer
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-aarch64-
      - run:
          name: Install dependencies
          command: choco install -y ccache wget
      - run:
          name: Installing Qt
          command: |
            wget.exe "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-windows-x64-4.8.1.exe"
            & .\qt-online-installer-windows-x64-4.8.1.exe --no-force-installations --no-default-installations `
              --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
              --email "${Env:QT_EMAIL}" --password "${Env:QT_PASSWORD}" install `
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.win64_msvc2022_64 `
              qt.qt6.682.win64_msvc2022_arm64_cross_compiled qt.qt6.682.addons.qt5compat qt.qt6.682.debug_info `
              qt.qt6.682.addons.qthttpserver
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -Arch arm64 -HostArch amd64 -DevCmdArguments '-no_logo'

            $Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            & "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
              -S ..\gpt4all-chat -B . -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              "-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.8.2\msvc2022_arm64" `
              "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
              "-DCMAKE_TOOLCHAIN_FILE=C:\Qt\6.8.2\msvc2022_arm64\lib\cmake\Qt6\qt.toolchain.cmake" `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DLLMODEL_CUDA=OFF `
              -DLLMODEL_KOMPUTE=OFF `
              "-DWINDEPLOYQT=C:\Qt\6.8.2\msvc2022_64\bin\windeployqt.exe;--qtpaths;C:\Qt\6.8.2\msvc2022_arm64\bin\qtpaths.bat" `
              -DGPT4ALL_TEST=OFF `
              -DGPT4ALL_OFFLINE_INSTALLER=ON
            & "C:\Qt\Tools\Ninja\ninja.exe"
            & "C:\Qt\Tools\Ninja\ninja.exe" install
            & "C:\Qt\Tools\Ninja\ninja.exe" package
            ccache -s
            mkdir upload
            copy gpt4all-installer-win64-arm.exe upload
      - store_artifacts:
          path: build/upload
            # add workspace so signing jobs can connect & obtain dmg
      - save_cache:
          key: ccache-gpt4all-win-aarch64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-offline-chat-installer-windows-arm:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: Install dependencies
          command: choco install -y wget
      - run:
          name: "Install Dotnet 8 && Azure Sign Tool"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: "Sign Windows Installer With AST"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)\build\upload\gpt4all-installer-win64-arm.exe"
      - store_artifacts:
          path: build/upload
      - run:
          name: Test installation
          command: |
            build\upload\gpt4all-installer-win64-arm.exe --no-size-checking --default-answer --accept-licenses `
              --confirm-command `
              install gpt4all

  build-online-chat-installer-windows-arm:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-aarch64-
      - run:
          name: Install dependencies
          command: choco install -y ccache wget
      - run:
          name: Installing Qt
          command: |
            wget.exe "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-windows-x64-4.8.1.exe"
            & .\qt-online-installer-windows-x64-4.8.1.exe --no-force-installations --no-default-installations `
              --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
              --email "${Env:QT_EMAIL}" --password "${Env:QT_PASSWORD}" install `
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.win64_msvc2022_64 `
              qt.qt6.682.win64_msvc2022_arm64_cross_compiled qt.qt6.682.addons.qt5compat qt.qt6.682.debug_info `
              qt.qt6.682.addons.qthttpserver
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
      - run:
          name: "Setup Azure SignTool"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -Arch arm64 -HostArch amd64 -DevCmdArguments '-no_logo'

            $Env:PATH = "${Env:PATH};C:\Qt\Tools\QtInstallerFramework\4.8\bin"
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            mkdir build
            cd build
            & "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
              -S ..\gpt4all-chat -B . -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              "-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.8.2\msvc2022_arm64" `
              "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
              "-DCMAKE_TOOLCHAIN_FILE=C:\Qt\6.8.2\msvc2022_arm64\lib\cmake\Qt6\qt.toolchain.cmake" `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DLLMODEL_CUDA=OFF `
              -DLLMODEL_KOMPUTE=OFF `
              "-DWINDEPLOYQT=C:\Qt\6.8.2\msvc2022_64\bin\windeployqt.exe;--qtpaths;C:\Qt\6.8.2\msvc2022_arm64\bin\qtpaths.bat" `
              -DGPT4ALL_TEST=OFF `
              -DGPT4ALL_OFFLINE_INSTALLER=OFF
            & "C:\Qt\Tools\Ninja\ninja.exe"
            & "C:\Qt\Tools\Ninja\ninja.exe" install
            & "C:\Qt\Tools\Ninja\ninja.exe" package
            ccache -s
            mkdir upload
            copy gpt4all-installer-win64-arm.exe upload
            Set-Location -Path "_CPack_Packages/win64/IFW/gpt4all-installer-win64-arm"
            Compress-Archive -Path 'repository' -DestinationPath '..\..\..\..\upload\repository.zip'
      - store_artifacts:
          path: build/upload
      - save_cache:
          key: ccache-gpt4all-win-aarch64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      # add workspace so signing jobs can connect & obtain dmg
      - persist_to_workspace:
          root: build
          # specify path to only include components we want to persist
          # accross builds
          paths:
            - upload

  sign-online-chat-installer-windows-arm:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - attach_workspace:
          at: build
      - run:
          name: Install dependencies
          command: choco install -y wget
      - run:
          name: "Install Dotnet 8"
          command: |
            mkdir dotnet
            cd dotnet
            $dotnet_url="https://download.visualstudio.microsoft.com/download/pr/5af098e1-e433-4fda-84af-3f54fd27c108/6bd1c6e48e64e64871957289023ca590/dotnet-sdk-8.0.302-win-x64.zip"
            wget.exe "$dotnet_url"
            Expand-Archive -LiteralPath .\dotnet-sdk-8.0.302-win-x64.zip
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
      - run:
          name: "Setup Azure SignTool"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            $Env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=$true
            dotnet tool install --global AzureSignTool
      - run:
          name: "Sign Windows Installer With AST"
          command: |
            $Env:DOTNET_ROOT="$($(Get-Location).Path)\dotnet\dotnet-sdk-8.0.302-win-x64"
            $Env:PATH="$Env:DOTNET_ROOT;$Env:PATH"
            AzureSignTool.exe sign -du "https://gpt4all.io/index.html" -kvu https://gpt4all.vault.azure.net -kvi "$Env:AZSignGUID" -kvs "$Env:AZSignPWD" -kvc "$Env:AZSignCertName" -kvt "$Env:AZSignTID" -tr http://timestamp.digicert.com -v "$($(Get-Location).Path)/build/upload/gpt4all-installer-win64-arm.exe"
      - store_artifacts:
          path: build/upload
      - run:
          name: Test installation
          command: |
            Expand-Archive -LiteralPath build\upload\repository.zip -DestinationPath .
            build\upload\gpt4all-installer-win64-arm.exe --no-size-checking --default-answer --accept-licenses `
              --confirm-command --set-temp-repository repository `
              install gpt4all

  build-gpt4all-chat-linux:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-linux-amd64-
      - run:
          <<: *job-linux-install-chat-deps
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            export CMAKE_PREFIX_PATH=~/Qt/6.8.2/gcc_64/lib/cmake
            export PATH=$PATH:/usr/local/cuda/bin
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            ~/Qt/Tools/CMake/bin/cmake \
              -S gpt4all-chat -B build \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=clang-19 \
              -DCMAKE_CXX_COMPILER=clang++-19 \
              -DCMAKE_CXX_COMPILER_AR=ar \
              -DCMAKE_CXX_COMPILER_RANLIB=ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON
            ~/Qt/Tools/CMake/bin/cmake --build build -j$(nproc) --target all
            ccache -s
      - save_cache:
          key: ccache-gpt4all-linux-amd64-{{ epoch }}
          when: always
          paths:
            - ../.ccache

  build-gpt4all-chat-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-amd64-
      - run:
          name: Install dependencies
          command: choco install -y ccache wget
      - run:
          name: Installing Qt
          command: |
            wget.exe "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-windows-x64-4.8.1.exe"
            & .\qt-online-installer-windows-x64-4.8.1.exe --no-force-installations --no-default-installations `
              --no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations `
              --email "${Env:QT_EMAIL}" --password "${Env:QT_PASSWORD}" install `
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.win64_msvc2022_64 qt.qt6.682.addons.qt5compat `
              qt.qt6.682.debug_info extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
      - run:
          name: Install VulkanSDK
          command: |
            wget.exe "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe"
            .\VulkanSDK-1.3.261.1-Installer.exe --accept-licenses --default-answer --confirm-command install
      - run:
          name: Install CUDA Toolkit
          command: |
            wget.exe "https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe"
            .\cuda_11.8.0_windows_network.exe -s cudart_11.8 nvcc_11.8 cublas_11.8 cublas_dev_11.8
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'

            $Env:PATH = "${Env:PATH};C:\VulkanSDK\1.3.261.1\bin"
            $Env:VULKAN_SDK = "C:\VulkanSDK\1.3.261.1"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            & "C:\Qt\Tools\CMake_64\bin\cmake.exe" `
              -S gpt4all-chat -B build -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              "-DCMAKE_PREFIX_PATH:PATH=C:\Qt\6.8.2\msvc2022_64" `
              "-DCMAKE_MAKE_PROGRAM:FILEPATH=C:\Qt\Tools\Ninja\ninja.exe" `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache `
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON
            & "C:\Qt\Tools\Ninja\ninja.exe" -C build
            ccache -s
      - save_cache:
          key: ccache-gpt4all-win-amd64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache

  build-gpt4all-chat-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-macos-
      - run:
          <<: *job-macos-install-deps
      - run:
          name: Install Rosetta
          command: softwareupdate --install-rosetta --agree-to-license  # needed for QtIFW
      - run:
          name: Installing Qt
          command: |
            wget "https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-macOS-x64-4.8.1.dmg"
            hdiutil attach qt-online-installer-macOS-x64-4.8.1.dmg
            /Volumes/qt-online-installer-macOS-x64-4.8.1/qt-online-installer-macOS-x64-4.8.1.app/Contents/MacOS/qt-online-installer-macOS-x64-4.8.1 \
              --no-force-installations --no-default-installations --no-size-checking --default-answer \
              --accept-licenses --confirm-command --accept-obligations --email "$QT_EMAIL" --password "$QT_PASSWORD" \
              install \
              qt.tools.cmake qt.tools.ifw.48 qt.tools.ninja qt.qt6.682.clang_64 qt.qt6.682.addons.qt5compat \
              extensions.qtpdf.682 qt.qt6.682.addons.qthttpserver
            hdiutil detach /Volumes/qt-online-installer-macOS-x64-4.8.1
      - run:
          name: Build
          no_output_timeout: 30m
          command: |
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake \
              -S gpt4all-chat -B build -G Ninja \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_PREFIX_PATH:PATH=~/Qt/6.8.2/macos/lib/cmake \
              -DCMAKE_MAKE_PROGRAM:FILEPATH=~/Qt/Tools/Ninja/ninja \
              -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
              -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
              -DCMAKE_RANLIB=/usr/bin/ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DBUILD_UNIVERSAL=ON \
              -DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
              -DGGML_METAL_MACOSX_VERSION_MIN=12.6
            ~/Qt/Tools/CMake/CMake.app/Contents/bin/cmake --build build --target all
            ccache -s
      - save_cache:
          key: ccache-gpt4all-macos-{{ epoch }}
          when: always
          paths:
            - ../.ccache

  build-ts-docs:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - node/install:
          node-version: "18.16"
      - run: node --version
      - run: corepack enable
      - node/install-packages:
          pkg-manager: npm
          app-dir: gpt4all-bindings/typescript
          override-ci-command: npm install --ignore-scripts
      - run:
          name: build docs ts yo
          command: |
            cd gpt4all-bindings/typescript
            npm run docs:build

  deploy-docs:
    docker:
      - image: circleci/python:3.8
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: |
            sudo apt-get update
            sudo apt-get -y install python3 python3-pip
            sudo pip3 install awscli --upgrade
            sudo pip3 install mkdocs mkdocs-material mkautodoc 'mkdocstrings[python]' markdown-captions pillow cairosvg
      - run:
          name: Make Documentation
          command: |
            cd gpt4all-bindings/python
            mkdocs build
      - run:
          name: Deploy Documentation
          command: |
            cd gpt4all-bindings/python
            aws s3 sync --delete site/ s3://docs.gpt4all.io/
      - run:
          name: Invalidate docs.gpt4all.io cloudfront
          command: aws cloudfront create-invalidation --distribution-id E1STQOW63QL2OH --paths "/*"

  build-py-linux:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - restore_cache:
          keys:
            - ccache-gpt4all-linux-amd64-
      - run:
          <<: *job-linux-install-backend-deps
      - run:
          name: Build C library
          no_output_timeout: 30m
          command: |
            export PATH=$PATH:/usr/local/cuda/bin
            git submodule update --init --recursive
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            cmake -B build -G Ninja \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=clang-19 \
              -DCMAKE_CXX_COMPILER=clang++-19 \
              -DCMAKE_CXX_COMPILER_AR=ar \
              -DCMAKE_CXX_COMPILER_RANLIB=ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON \
              -DCMAKE_CUDA_ARCHITECTURES='50-virtual;52-virtual;61-virtual;70-virtual;75-virtual'
            cmake --build build -j$(nproc)
            ccache -s
      - run:
          name: Build wheel
          command: |
            cd gpt4all-bindings/python/
            python setup.py bdist_wheel --plat-name=manylinux1_x86_64
      - store_artifacts:
          path: gpt4all-bindings/python/dist
      - save_cache:
          key: ccache-gpt4all-linux-amd64-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - persist_to_workspace:
          root: gpt4all-bindings/python/dist
          paths:
            - "*.whl"

  build-py-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - restore_cache:
          keys:
            - ccache-gpt4all-macos-
      - run:
          <<: *job-macos-install-deps
      - run:
          name: Install dependencies
          command: |
            pip install setuptools wheel cmake
      - run:
          name: Build C library
          no_output_timeout: 30m
          command: |
            git submodule update --init  # don't use --recursive because macOS doesn't use Kompute
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            cmake -B build \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
              -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
              -DCMAKE_RANLIB=/usr/bin/ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DBUILD_UNIVERSAL=ON \
              -DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
              -DGGML_METAL_MACOSX_VERSION_MIN=12.6
            cmake --build build --parallel
            ccache -s
      - run:
          name: Build wheel
          command: |
            cd gpt4all-bindings/python
            python setup.py bdist_wheel --plat-name=macosx_10_15_universal2
      - store_artifacts:
          path: gpt4all-bindings/python/dist
      - save_cache:
          key: ccache-gpt4all-macos-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - persist_to_workspace:
          root: gpt4all-bindings/python/dist
          paths:
            - "*.whl"

  build-py-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-amd64-
      - run:
          name: Install dependencies
          command:
            choco install -y ccache cmake ninja wget --installargs 'ADD_CMAKE_TO_PATH=System'
      - run:
          name: Install VulkanSDK
          command: |
            wget.exe "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe"
            .\VulkanSDK-1.3.261.1-Installer.exe --accept-licenses --default-answer --confirm-command install
      - run:
          name: Install CUDA Toolkit
          command: |
            wget.exe "https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe"
            .\cuda_11.8.0_windows_network.exe -s cudart_11.8 nvcc_11.8 cublas_11.8 cublas_dev_11.8
      - run:
          name: Install Python dependencies
          command: pip install setuptools wheel cmake
      - run:
          name: Build C library
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'

            $Env:PATH += ";C:\VulkanSDK\1.3.261.1\bin"
            $Env:VULKAN_SDK = "C:\VulkanSDK\1.3.261.1"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            cmake -B build -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache `
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON `
              -DCMAKE_CUDA_ARCHITECTURES='50-virtual;52-virtual;61-virtual;70-virtual;75-virtual'
            cmake --build build --parallel
            ccache -s
      - run:
          name: Build wheel
          command: |
            cd gpt4all-bindings/python
            python setup.py bdist_wheel --plat-name=win_amd64
      - store_artifacts:
          path: gpt4all-bindings/python/dist
      - save_cache:
          key: ccache-gpt4all-win-amd64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      - persist_to_workspace:
          root: gpt4all-bindings/python/dist
          paths:
            - "*.whl"

  deploy-wheels:
    docker:
      - image: circleci/python:3.8
    steps:
      - setup_remote_docker
      - attach_workspace:
          at: /tmp/workspace
      - run:
          name: Install dependencies
          command: |
            sudo apt-get update
            sudo apt-get install -y build-essential cmake
            pip install setuptools wheel twine
      - run:
          name: Upload Python package
          command: |
            twine upload /tmp/workspace/*.whl --username __token__ --password $PYPI_CRED
      - store_artifacts:
          path: /tmp/workspace

  build-bindings-backend-linux:
    machine:
      image: ubuntu-2204:current
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-linux-amd64-
      - run:
          <<: *job-linux-install-backend-deps
      - run:
          name: Build Libraries
          no_output_timeout: 30m
          command: |
            export PATH=$PATH:/usr/local/cuda/bin
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            mkdir -p runtimes/build
            cd runtimes/build
            cmake ../.. -G Ninja \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=clang-19 \
              -DCMAKE_CXX_COMPILER=clang++-19 \
              -DCMAKE_CXX_COMPILER_AR=ar \
              -DCMAKE_CXX_COMPILER_RANLIB=ranlib \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON
            cmake --build . -j$(nproc)
            ccache -s
            mkdir ../linux-x64
            cp -L *.so ../linux-x64 # otherwise persist_to_workspace seems to mess symlinks
      - save_cache:
          key: ccache-gpt4all-linux-amd64-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - runtimes/linux-x64/*.so

  build-bindings-backend-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-macos-
      - run:
          <<: *job-macos-install-deps
      - run:
          name: Build Libraries
          no_output_timeout: 30m
          command: |
            ccache -o "cache_dir=${PWD}/../.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            mkdir -p runtimes/build
            cd runtimes/build
            cmake ../.. \
              -DCMAKE_BUILD_TYPE=Release \
              -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
              -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
              -DCMAKE_RANLIB=/usr/bin/ranlib \
              -DCMAKE_C_COMPILER_LAUNCHER=ccache \
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
              -DBUILD_UNIVERSAL=ON \
              -DCMAKE_OSX_DEPLOYMENT_TARGET=12.6 \
              -DGGML_METAL_MACOSX_VERSION_MIN=12.6
            cmake --build . --parallel
            ccache -s
            mkdir ../osx-x64
            cp -L *.dylib ../osx-x64
            cp ../../llama.cpp-mainline/*.metal ../osx-x64
            ls ../osx-x64
      - save_cache:
          key: ccache-gpt4all-macos-{{ epoch }}
          when: always
          paths:
            - ../.ccache
      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - runtimes/osx-x64/*.dylib
            - runtimes/osx-x64/*.metal

  build-bindings-backend-windows:
    machine:
      image: windows-server-2022-gui:2024.04.1
      resource_class: windows.large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - run:
          name: Update Submodules
          command: |
            git submodule sync
            git submodule update --init --recursive
      - restore_cache:
          keys:
            - ccache-gpt4all-win-amd64-
      - run:
          name: Install dependencies
          command: |
            choco install -y ccache cmake ninja wget --installargs 'ADD_CMAKE_TO_PATH=System'
      - run:
          name: Install VulkanSDK
          command: |
            wget.exe "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe"
            .\VulkanSDK-1.3.261.1-Installer.exe --accept-licenses --default-answer --confirm-command install
      - run:
          name: Install CUDA Toolkit
          command: |
            wget.exe "https://developer.download.nvidia.com/compute/cuda/11.8.0/network_installers/cuda_11.8.0_windows_network.exe"
            .\cuda_11.8.0_windows_network.exe -s cudart_11.8 nvcc_11.8 cublas_11.8 cublas_dev_11.8
      - run:
          name: Build Libraries
          no_output_timeout: 30m
          command: |
            $vsInstallPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property installationpath
            Import-Module "${vsInstallPath}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
            Enter-VsDevShell -VsInstallPath "$vsInstallPath" -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -no_logo'

            $Env:Path += ";C:\VulkanSDK\1.3.261.1\bin"
            $Env:VULKAN_SDK = "C:\VulkanSDK\1.3.261.1"
            ccache -o "cache_dir=${pwd}\..\.ccache" -o max_size=500M -p -z
            cd gpt4all-backend
            mkdir runtimes/win-x64_msvc
            cd runtimes/win-x64_msvc
            cmake -S ../.. -B . -G Ninja `
              -DCMAKE_BUILD_TYPE=Release `
              -DCMAKE_C_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CXX_COMPILER_LAUNCHER=ccache `
              -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache `
              -DKOMPUTE_OPT_DISABLE_VULKAN_VERSION_CHECK=ON
            cmake --build . --parallel
            ccache -s
            cp bin/Release/*.dll .
      - save_cache:
          key: ccache-gpt4all-win-amd64-{{ epoch }}
          when: always
          paths:
            - ..\.ccache
      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - runtimes/win-x64_msvc/*.dll

  build-nodejs-linux:
    docker:
      - image: cimg/base:stable
    steps:
      - checkout
      - attach_workspace:
          at: /tmp/gpt4all-backend
      - node/install:
          install-yarn: true
          node-version: "18.16"
      - run: node --version
      - run: corepack enable
      - node/install-packages:
          app-dir: gpt4all-bindings/typescript
          pkg-manager: yarn
          override-ci-command: yarn install
      - run:
          command: |
            cd gpt4all-bindings/typescript
            yarn prebuildify -t 18.16.0 --napi
      - run:
          command: |
            mkdir -p gpt4all-backend/prebuilds/linux-x64
            mkdir -p gpt4all-backend/runtimes/linux-x64
            cp /tmp/gpt4all-backend/runtimes/linux-x64/*-*.so gpt4all-backend/runtimes/linux-x64
            cp gpt4all-bindings/typescript/prebuilds/linux-x64/*.node gpt4all-backend/prebuilds/linux-x64
      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - prebuilds/linux-x64/*.node
            - runtimes/linux-x64/*-*.so

  build-nodejs-macos:
    <<: *job-macos-executor
    steps:
      - checkout
      - attach_workspace:
          at: /tmp/gpt4all-backend
      - node/install:
          install-yarn: true
          node-version: "18.16"
      - run: node --version
      - run: corepack enable
      - node/install-packages:
          app-dir: gpt4all-bindings/typescript
          pkg-manager: yarn
          override-ci-command: yarn install
      - run:
          command: |
            cd gpt4all-bindings/typescript
            yarn prebuildify -t 18.16.0 --napi
      - run:
          name: "Persisting all necessary things to workspace"
          command: |
            mkdir -p gpt4all-backend/prebuilds/darwin-x64
            mkdir -p gpt4all-backend/runtimes/darwin
            cp /tmp/gpt4all-backend/runtimes/osx-x64/*-*.* gpt4all-backend/runtimes/darwin
            cp gpt4all-bindings/typescript/prebuilds/darwin-x64/*.node gpt4all-backend/prebuilds/darwin-x64
      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - prebuilds/darwin-x64/*.node
            - runtimes/darwin/*-*.*

  build-nodejs-windows:
    executor:
      name: win/default
      size: large
      shell: powershell.exe -ExecutionPolicy Bypass
    steps:
      - checkout
      - attach_workspace:
          at: /tmp/gpt4all-backend
      - run: choco install wget -y
      - run:
          command: |
            wget.exe "https://nodejs.org/dist/v18.16.0/node-v18.16.0-x86.msi" -P C:\Users\circleci\Downloads\
            MsiExec.exe /i C:\Users\circleci\Downloads\node-v18.16.0-x86.msi /qn
      - run:
          command: |
            Start-Process powershell -verb runAs -Args "-start GeneralProfile"
            nvm install 18.16.0
            nvm use 18.16.0
      - run: node --version
      - run: corepack enable
      - run:
          command: |
            npm install -g yarn
            cd gpt4all-bindings/typescript
            yarn install
      - run:
          command: |
            cd gpt4all-bindings/typescript
            yarn prebuildify -t 18.16.0 --napi
      - run:
          command: |
            mkdir -p gpt4all-backend/prebuilds/win32-x64
            mkdir -p gpt4all-backend/runtimes/win32-x64
            cp /tmp/gpt4all-backend/runtimes/win-x64_msvc/*-*.dll gpt4all-backend/runtimes/win32-x64
            cp gpt4all-bindings/typescript/prebuilds/win32-x64/*.node gpt4all-backend/prebuilds/win32-x64

      - persist_to_workspace:
          root: gpt4all-backend
          paths:
            - prebuilds/win32-x64/*.node
            - runtimes/win32-x64/*-*.dll

  deploy-npm-pkg:
    docker:
      - image: cimg/base:stable
    steps:
      - attach_workspace:
          at: /tmp/gpt4all-backend
      - checkout
      - node/install:
          install-yarn: true
          node-version: "18.16"
      - run: node --version
      - run: corepack enable
      - run:
          command: |
            cd gpt4all-bindings/typescript
            # excluding llmodel. nodejs bindings dont need llmodel.dll
            mkdir -p runtimes/win32-x64/native
            mkdir -p prebuilds/win32-x64/
            cp /tmp/gpt4all-backend/runtimes/win-x64_msvc/*-*.dll runtimes/win32-x64/native/
            cp /tmp/gpt4all-backend/prebuilds/win32-x64/*.node prebuilds/win32-x64/

            mkdir -p runtimes/linux-x64/native
            mkdir -p prebuilds/linux-x64/
            cp /tmp/gpt4all-backend/runtimes/linux-x64/*-*.so runtimes/linux-x64/native/
            cp /tmp/gpt4all-backend/prebuilds/linux-x64/*.node prebuilds/linux-x64/

            # darwin has univeral runtime libraries
            mkdir -p runtimes/darwin/native
            mkdir -p prebuilds/darwin-x64/

            cp /tmp/gpt4all-backend/runtimes/darwin/*-*.* runtimes/darwin/native/

            cp /tmp/gpt4all-backend/prebuilds/darwin-x64/*.node prebuilds/darwin-x64/

            # Fallback build if user is not on above prebuilds
            mv -f binding.ci.gyp binding.gyp

            mkdir gpt4all-backend
            cd ../../gpt4all-backend
            mv llmodel.h llmodel.cpp llmodel_c.cpp llmodel_c.h sysinfo.h dlhandle.h ../gpt4all-bindings/typescript/gpt4all-backend/

      # Test install
      - node/install-packages:
          app-dir: gpt4all-bindings/typescript
          pkg-manager: yarn
          override-ci-command: yarn install
      - run:
          command: |
            cd gpt4all-bindings/typescript
            yarn run test
      - run:
          command: |
            cd gpt4all-bindings/typescript
            npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
            npm publish

# only run a job on the main branch
job_only_main: &job_only_main
  filters:
    branches:
      only: main

# allow a job to run on tags as well as commits
job_allow_tags: &job_allow_tags
  filters:
    tags:
      only:
        - /.*/

# standard chat workflow filter
workflow-when-chat-requested: &workflow-when-chat-requested
  when:
    and:
      - or: [ << pipeline.parameters.run-all-workflows >>, << pipeline.parameters.run-chat-workflow >> ]
      - not:
          equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]

workflows:
  version: 2
  noop:
    when:
      not:
        or:
          - << pipeline.parameters.run-all-workflows >>
          - << pipeline.parameters.run-python-workflow >>
          - << pipeline.parameters.run-ts-workflow >>
          - << pipeline.parameters.run-chat-workflow >>
          - equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - noop
  schedule:
    # only run when scheduled by CircleCI
    when:
      equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - build-offline-chat-installer-macos:
          context: gpt4all
      - build-offline-chat-installer-windows:
          context: gpt4all
      - build-offline-chat-installer-windows-arm:
          context: gpt4all
      - build-offline-chat-installer-linux:
          context: gpt4all
      - sign-offline-chat-installer-macos:
          context: gpt4all
          requires:
            - build-offline-chat-installer-macos
      - notarize-offline-chat-installer-macos:
          context: gpt4all
          requires:
            - sign-offline-chat-installer-macos
      - sign-offline-chat-installer-windows:
          context: gpt4all
          requires:
            - build-offline-chat-installer-windows
      - sign-offline-chat-installer-windows-arm:
          context: gpt4all
          requires:
            - build-offline-chat-installer-windows-arm
  build-chat-installers-release:
    # only run on main branch tags that start with 'v' and a digit
    when:
      and:
        - matches: { pattern: '^v\d.*', value: << pipeline.git.tag >> }
        - not:
            equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - validate-commit-on-main:
          <<: *job_allow_tags
      - build-offline-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-offline-chat-installer-windows:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-offline-chat-installer-windows-arm:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-offline-chat-installer-linux:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - sign-offline-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-offline-chat-installer-macos
      - notarize-offline-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - sign-offline-chat-installer-macos
      - sign-offline-chat-installer-windows:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-offline-chat-installer-windows
      - sign-offline-chat-installer-windows-arm:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-offline-chat-installer-windows-arm
      - build-online-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-online-chat-installer-windows:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-online-chat-installer-windows-arm:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - build-online-chat-installer-linux:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - validate-commit-on-main
      - sign-online-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-online-chat-installer-macos
      - notarize-online-chat-installer-macos:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - sign-online-chat-installer-macos
      - sign-online-chat-installer-windows:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-online-chat-installer-windows
      - sign-online-chat-installer-windows-arm:
          <<: *job_allow_tags
          context: gpt4all
          requires:
            - build-online-chat-installer-windows-arm
  build-chat-offline-installers:
    <<: *workflow-when-chat-requested
    jobs:
      - build-hold:
          type: approval
      - sign-hold:
          type: approval
      - build-offline-chat-installer-macos:
          context: gpt4all
          requires:
            - build-hold
      - sign-offline-chat-installer-macos:
          context: gpt4all
          requires:
            - sign-hold
            - build-offline-chat-installer-macos
      - notarize-offline-chat-installer-macos:
          context: gpt4all
          requires:
            - sign-offline-chat-installer-macos
      - build-offline-chat-installer-windows:
          context: gpt4all
          requires:
            - build-hold
      - sign-offline-chat-installer-windows:
          context: gpt4all
          requires:
            - sign-hold
            - build-offline-chat-installer-windows
      - build-offline-chat-installer-windows-arm:
          context: gpt4all
          requires:
            - build-hold
      - sign-offline-chat-installer-windows-arm:
          context: gpt4all
          requires:
            - sign-hold
            - build-offline-chat-installer-windows-arm
      - build-offline-chat-installer-linux:
          context: gpt4all
          requires:
            - build-hold
  build-chat-online-installers:
    <<: *workflow-when-chat-requested
    jobs:
      - build-hold:
          type: approval
      - sign-hold:
          type: approval
      - build-online-chat-installer-macos:
          context: gpt4all
          requires:
            - build-hold
      - sign-online-chat-installer-macos:
          context: gpt4all
          requires:
            - sign-hold
            - build-online-chat-installer-macos
      - notarize-online-chat-installer-macos:
          context: gpt4all
          requires:
            - sign-online-chat-installer-macos
      - build-online-chat-installer-windows:
          context: gpt4all
          requires:
            - build-hold
      - sign-online-chat-installer-windows:
          context: gpt4all
          requires:
            - sign-hold
            - build-online-chat-installer-windows
      - build-online-chat-installer-windows-arm:
          context: gpt4all
          requires:
            - build-hold
      - sign-online-chat-installer-windows-arm:
          context: gpt4all
          requires:
            - sign-hold
            - build-online-chat-installer-windows-arm
      - build-online-chat-installer-linux:
          context: gpt4all
          requires:
            - build-hold
  build-and-test-gpt4all-chat:
    <<: *workflow-when-chat-requested
    jobs:
      - hold:
          type: approval
      - build-gpt4all-chat-linux:
          context: gpt4all
          requires:
            - hold
      - build-gpt4all-chat-windows:
          context: gpt4all
          requires:
            - hold
      - build-gpt4all-chat-macos:
          context: gpt4all
          requires:
            - hold
  deploy-docs:
    when:
      and:
        - equal: [ << pipeline.git.branch >>, main ]
        - or:
            - << pipeline.parameters.run-all-workflows >>
            - << pipeline.parameters.run-python-workflow >>
        - not:
            equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - deploy-docs:
          context: gpt4all
  build-python:
    when:
      and:
        - or: [ << pipeline.parameters.run-all-workflows >>, << pipeline.parameters.run-python-workflow >> ]
        - not:
            equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - pypi-hold:
          <<: *job_only_main
          type: approval
      - hold:
          type: approval
      - build-py-linux:
          requires:
            - hold
      - build-py-macos:
          requires:
            - hold
      - build-py-windows:
          requires:
            - hold
      - deploy-wheels:
          <<: *job_only_main
          context: gpt4all
          requires:
            - pypi-hold
            - build-py-windows
            - build-py-linux
            - build-py-macos
  build-bindings:
    when:
      and:
        - or: [ << pipeline.parameters.run-all-workflows >>, << pipeline.parameters.run-ts-workflow >> ]
        - not:
            equal: [ << pipeline.trigger_source >>, scheduled_pipeline ]
    jobs:
      - backend-hold:
          type: approval
      - nodejs-hold:
          type: approval
      - npm-hold:
          <<: *job_only_main
          type: approval
      - docs-hold:
          type: approval
      - build-bindings-backend-linux:
          requires:
            - backend-hold
      - build-bindings-backend-macos:
          requires:
            - backend-hold
      - build-bindings-backend-windows:
          requires:
            - backend-hold
      - build-nodejs-linux:
          requires:
            - nodejs-hold
            - build-bindings-backend-linux
      - build-nodejs-windows:
          requires:
            - nodejs-hold
            - build-bindings-backend-windows
      - build-nodejs-macos:
          requires:
            - nodejs-hold
            - build-bindings-backend-macos
      - build-ts-docs:
          requires:
            - docs-hold
      - deploy-npm-pkg:
          <<: *job_only_main
          requires:
            - npm-hold
            - build-nodejs-linux
            - build-nodejs-windows
            - build-nodejs-macos


================================================
FILE: .circleci/grab_notary_id.py
================================================
import re
import sys

ID_REG = r"id: (.*)"

def main() -> None:
    notary_log = sys.argv[1]
    with open(notary_log, "r") as f:
        notary_output = f.read()
        id_m = re.search(ID_REG, notary_output)
        if id_m:
            print(id_m.group(1))
        else:
            raise RuntimeError("Unable to parse ID from notarization logs")

if __name__ == "__main__":
    main()

================================================
FILE: .codespellrc
================================================
[codespell]
ignore-words-list = blong, afterall, assistent, crasher, requestor
skip = ./.git,./gpt4all-chat/translations,*.pdf,*.svg,*.lock


================================================
FILE: .github/ISSUE_TEMPLATE/bindings-bug.md
================================================
---
name: "\U0001F6E0 Bindings Bug Report"
about: A bug report for the GPT4All Bindings
labels: ["bindings", "bug-unconfirmed"]
---

<!-- Before creating a new issue, please make sure to take a few moments to check the issue tracker for existing issues about the bug. -->

### Bug Report

<!-- A clear and concise description of what the bug is. -->

### Example Code

<!-- Please provide a minimal code example that can be used to experience this issue. Delete this section if it does not apply. -->

### Steps to Reproduce

<!-- List the steps that should be taken to experience this issue. -->

1.
2.
3.

### Expected Behavior

<!-- In a few words, what did you expect to happen? -->

### Your Environment

- Bindings version (e.g. "Version" from `pip show gpt4all`):
- Operating System:
- Chat model used (if applicable):

<!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->


================================================
FILE: .github/ISSUE_TEMPLATE/chat-bug.md
================================================
---
name: "\U0001F4AC GPT4All Bug Report"
about: A bug report for GPT4All Chat
labels: ["chat", "bug-unconfirmed"]
---

<!-- Before creating a new issue, please make sure to take a few moments to check the issue tracker for existing issues about the bug. -->

### Bug Report

<!-- A clear and concise description of what the bug is. -->

### Steps to Reproduce

<!-- List the steps that should be taken to experience this issue. Provide any relevant information about your configuration, and describe anything that was unexpected. -->

1.
2.
3.

### Expected Behavior

<!-- In a few words, what did you expect to happen? -->

### Your Environment

- GPT4All version:
- Operating System:
- Chat model used (if applicable):

<!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->


================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
version: 2.1


================================================
FILE: .github/ISSUE_TEMPLATE/documentation.md
================================================
---
name: "\U0001F4C4 Documentation"
about: An issue related to the GPT4All documentation
labels: ["documentation"]
---

### Documentation

<!-- Please describe the issue with the documentation as clearly as possible. -->


================================================
FILE: .github/ISSUE_TEMPLATE/feature-request.md
================================================
---
name: "\U0001F680 Feature Request"
about: Submit a proposal/request for a new GPT4All feature
title: "[Feature] Feature request title..."
labels: ["enhancement"]
---

### Feature Request

<!-- A clear and concise description of the feature proposal. -->


================================================
FILE: .github/ISSUE_TEMPLATE/other-bug.md
================================================
---
name: "\U0001F41B Other Bug Report"
about: A bug in another component of GPT4All
labels: ["bug-unconfirmed"]
---

<!-- Before creating a new issue, please make sure to take a few moments to check the issue tracker for existing issues about the bug. -->

### Bug Report

<!-- A clear and concise description of what the bug is. -->

### Steps to Reproduce

<!-- List the steps that should be taken to experience this issue. Provide any relevant information about your configuration, and describe anything that was unexpected. If this bug involves original code, please provide a minimal version that can reproduce the issue. -->

1.
2.
3.

### Expected Behavior

<!-- In a few words, what did you expect to happen? -->

### Your Environment

- GPT4All version (if applicable):
- Operating System:
- Chat model used (if applicable):

<!-- You can freely edit this text, please remove all the lines you believe are unnecessary. -->



================================================
FILE: .github/pull_request_template.md
================================================
## Describe your changes

## Issue ticket number and link

## Checklist before requesting a review
- [ ] I have performed a self-review of my code.
- [ ] If it is a core feature, I have added thorough tests.
- [ ] I have added thorough documentation for my code.
- [ ] I have tagged PR with relevant project labels. I acknowledge that a PR without labels may be dismissed.
- [ ] If this PR addresses a bug, I have provided both a screenshot/video of the original bug and the working solution.

## Demo
<!-- Screenshots or video of new or updated code changes !-->

### Steps to Reproduce
<!-- Steps to reproduce demo !-->

## Notes
<!-- Any other relevant information to include about PR !-->


================================================
FILE: .github/workflows/close_issues.yml
================================================
# This workflow will close issues that do not have labels or additional comments.
# Trigger manually.

name: "Close Issues"
on:
  workflow_dispatch:

jobs:
  close_issues:
    runs-on: ubuntu-latest
    steps:
    - name: Close issues without label or comment
      uses: actions/github-script@v3
      with:
        github-token: ${{secrets.GITHUB_TOKEN}}
        script: |
          const repo = context.repo;
          let page = 1;
          let issues = [];
          while (true) {
            const result = await github.issues.listForRepo({...repo, per_page: 100, page: page});
            if (result.data.length === 0) break;
            issues = issues.concat(result.data);
            page += 1;
          }
          for (let { number } of issues) {
            const issueData = await github.issues.get({...repo, issue_number: number});
            const comments = await github.issues.listComments({...repo, issue_number: number});
            if (issueData.data.labels.length === 0 && comments.data.length < 1) {
              await github.issues.update({...repo, issue_number: number, state: 'closed'});
              await github.issues.createComment({...repo, issue_number: number, body: 'Issue closed as it does not have any labels or comments.'});
            }
          }


================================================
FILE: .github/workflows/codespell.yml
================================================
---
name: Codespell

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  codespell:
    name: Check for spelling errors
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Codespell
        uses: codespell-project/actions-codespell@v2


================================================
FILE: .gitignore
================================================
*.arrow
squad_*
*sbert_embedded*
*.pkl
ckpts*
.deepspeed_env
*.jsonl
*tar.gz
ckpts**
wandb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
#   For a library or package, you might want to ignore these files since the code is
#   intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
#   However, in case of collaboration, if having platform-specific dependencies or dependencies
#   having no cross-platform support, pipenv may install dependencies that don't work, or not
#   install all needed dependencies.
#Pipfile.lock

# poetry
#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
#   This is especially recommended for binary packages to ensure reproducibility, and is more
#   commonly ignored for libraries.
#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
#   Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
#   pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
#   in version control.
#   https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
#  and can be added to the global gitignore or merged into this file.  For a more nuclear
#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


# vs code
.vscode
*.bin

.DS_Store

# gpt4all-chat
CMakeLists.txt.user
gpt4all-chat/models/*
build_*
build-*
cmake-build-*
/gpt4all-chat/tests/python/config.py

# IntelliJ
.idea/

# LLM models
*.gguf


================================================
FILE: .gitmodules
================================================
[submodule "llama.cpp-mainline"]
	path = gpt4all-backend/deps/llama.cpp-mainline
	url = https://github.com/nomic-ai/llama.cpp.git
	branch = master
[submodule "gpt4all-chat/usearch"]
	path = gpt4all-chat/deps/usearch
	url = https://github.com/nomic-ai/usearch.git
[submodule "gpt4all-chat/deps/SingleApplication"]
	path = gpt4all-chat/deps/SingleApplication
	url = https://github.com/nomic-ai/SingleApplication.git
[submodule "gpt4all-chat/deps/fmt"]
	path = gpt4all-chat/deps/fmt
	url = https://github.com/fmtlib/fmt.git
[submodule "gpt4all-chat/deps/DuckX"]
	path = gpt4all-chat/deps/DuckX
	url = https://github.com/nomic-ai/DuckX.git
[submodule "gpt4all-chat/deps/QXlsx"]
	path = gpt4all-chat/deps/QXlsx
	url = https://github.com/nomic-ai/QXlsx.git
[submodule "gpt4all-chat/deps/minja"]
	path = gpt4all-chat/deps/minja
	url = https://github.com/nomic-ai/minja.git
[submodule "gpt4all-chat/deps/json"]
	path = gpt4all-chat/deps/json
	url = https://github.com/nlohmann/json.git


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change. 

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
2. Make sure Pull Request is tagged with appropriate project identifiers and has a clear description of contribution.
3. Any new or updated code must have documentation and preferably tests included with Pull Request.
4. Significant feature or code changes should provide a short video or screenshot demo.
4. Fill out relevant parts of Pull Request template. 
4. Pull requests must have sign-off from one other developer. Reach out to a repository owner once your
   code is ready to be merged into `main`.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
  address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
  professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@nomic.ai. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

================================================
FILE: LICENSE.txt
================================================
Copyright (c) 2023 Nomic, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: MAINTAINERS.md
================================================
# MAINTAINERS

## Rules

* All content inside GPT4All shall have a documented maintainer
* If a maintainer decides to retire or resign a call for volunteers will go
  out
* If no further maintainer can be found in a reasonable time frame, then the
  content will be marked deprecated and removed in time

## Job

Maintainers will be...

1. Responsible for overseeing content under their stewardship
2. Responsible for triaging new issues, reviewing PRs, assigning priority
   to tasks
3. Responsible for keeping content in sufficient quality in a timely fashion

## List

Adam Treat ([@manyoso](https://github.com/manyoso))<br/>
E-mail: adam@nomic.ai<br/>
Discord: `@gonzochess75`
- Overall project maintainer
- Chat UI

Jared Van Bortel ([@cebtenzzre](https://github.com/cebtenzzre))<br/>
E-mail: jared@nomic.ai<br/>
Discord: `@cebtenzzre`
- gpt4all-backend
- Python binding
- Python CLI app

Jacob Nguyen ([@jacoobes](https://github.com/jacoobes))<br/>
Discord: `@jacoobes`<br/>
E-mail: `jacoobes@sern.dev`
- TypeScript binding

Dominik ([@cosmic-snow](https://github.com/cosmic-snow))<br/>
E-mail: cosmic-snow@mailfence.com<br/>
Discord: `@cosmic__snow`
- Community documentation (GitHub Wiki)

Max Cembalest ([@mcembalest](https://github.com/mcembalest))<br/>
E-mail: max@nomic.ai<br/>
Discord: `@maxcembalest.`
- Official documentation (gpt4all-bindings/python/docs -> https://docs.gpt4all.io/)

Thiago Ramos ([@thiagojramos](https://github.com/thiagojramos))<br/>
E-mail: thiagojramos@outlook.com<br/>
- pt\_BR translation

不知火 Shiranui ([@supersonictw](https://github.com/supersonictw))<br/>
E-mail: supersonic@livemail.tw<br/>
Discord: `@supersonictw`
- zh\_TW translation

Jeremy Tayco ([@jstayco](https://github.com/jstayco))<br/>
E-mail: jstayco@protonmail.ch<br/>
Discord: `@vertana`
- es\_MX translation

Riccardo Giovanetti ([@Harvester62](https://github.com/Harvester62))<br/>
E-mail: riccardo.giovanetti@gmail.com<br/>
Discord: `@harvester62`
- it\_IT translation

Tim ([@Tim453](https://github.com/Tim453))<br/>
E-mail: tim453@mailbox.org<br/>
Discord: `@Tim453`
- Flatpak

Jack ([@wuodoo](https://github.com/wuodoo))<br/>
E-mail: 2296103047@qq.com<br/>
Discord: `@mikage`
- zh\_CN translation


================================================
FILE: README.md
================================================
<h1 align="center">GPT4All</h1>

<p align="center">
  Now with support for DeepSeek R1 Distillations
</p>

<p align="center">
  <a href="https://www.nomic.ai/gpt4all">Website</a> &bull; <a href="https://docs.gpt4all.io">Documentation</a> &bull; <a href="https://discord.gg/mGZE39AS3e">Discord</a> &bull; <a href="https://www.youtube.com/watch?v=gQcZDXRVJok">YouTube Tutorial</a>
</p>

<p align="center">
  GPT4All runs large language models (LLMs) privately on everyday desktops & laptops.
</p>
<p align="center">
  No API calls or GPUs required - you can just download the application and <a href="https://docs.gpt4all.io/gpt4all_desktop/quickstart.html#quickstart">get started</a>.
</p>

<p align="center">
  Read about what's new in <a href="https://www.nomic.ai/blog/tag/gpt4all">our blog</a>.
</p>
<p align="center">
  <a href="https://nomic.ai/gpt4all/#newsletter-form">Subscribe to the newsletter</a>
</p>

https://github.com/nomic-ai/gpt4all/assets/70534565/513a0f15-4964-4109-89e4-4f9a9011f311

<p align="center">
GPT4All is made possible by our compute partner <a href="https://www.paperspace.com/">Paperspace</a>.
</p>

## Download Links

<p>
  &mdash; <a href="https://gpt4all.io/installers/gpt4all-installer-win64.exe">
    <img src="gpt4all-bindings/python/docs/assets/windows.png" style="height: 1em; width: auto" /> Windows Installer
  </a> &mdash;
</p>
<p>
  &mdash; <a href="https://gpt4all.io/installers/gpt4all-installer-win64-arm.exe">
    <img src="gpt4all-bindings/python/docs/assets/windows.png" style="height: 1em; width: auto" /> Windows ARM Installer
  </a> &mdash;
</p>
<p>
  &mdash; <a href="https://gpt4all.io/installers/gpt4all-installer-darwin.dmg">
    <img src="gpt4all-bindings/python/docs/assets/mac.png" style="height: 1em; width: auto" /> macOS Installer
  </a> &mdash;
</p>
<p>
  &mdash; <a href="https://gpt4all.io/installers/gpt4all-installer-linux.run">
    <img src="gpt4all-bindings/python/docs/assets/ubuntu.svg" style="height: 1em; width: auto" /> Ubuntu Installer
  </a> &mdash;
</p>
<p>
  The Windows and Linux builds require Intel Core i3 2nd Gen / AMD Bulldozer, or better.
</p>
<p>
  The Windows ARM build supports Qualcomm Snapdragon and Microsoft SQ1/SQ2 processors.
</p>
<p>
  The Linux build is x86-64 only (no ARM).
</p>
<p>
  The macOS build requires Monterey 12.6 or newer. Best results with Apple Silicon M-series processors.
</p>

See the full [System Requirements](gpt4all-chat/system_requirements.md) for more details.

<br/>
<br/>
<p>
  <a href='https://flathub.org/apps/io.gpt4all.gpt4all'>
    <img style="height: 2em; width: auto" alt='Get it on Flathub' src='https://flathub.org/api/badge'><br/>
    Flathub (community maintained)
  </a>
</p>

## Install GPT4All Python

`gpt4all` gives you access to LLMs with our Python client around [`llama.cpp`](https://github.com/ggerganov/llama.cpp) implementations. 

Nomic contributes to open source software like [`llama.cpp`](https://github.com/ggerganov/llama.cpp) to make LLMs accessible and efficient **for all**.

```bash
pip install gpt4all
```

```python
from gpt4all import GPT4All
model = GPT4All("Meta-Llama-3-8B-Instruct.Q4_0.gguf") # downloads / loads a 4.66GB LLM
with model.chat_session():
    print(model.generate("How can I run LLMs efficiently on my laptop?", max_tokens=1024))
```


## Integrations

:parrot::link: [Langchain](https://python.langchain.com/v0.2/docs/integrations/providers/gpt4all/)
:card_file_box: [Weaviate Vector Database](https://github.com/weaviate/weaviate) - [module docs](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-gpt4all)
:telescope: [OpenLIT (OTel-native Monitoring)](https://github.com/openlit/openlit) - [Docs](https://docs.openlit.io/latest/integrations/gpt4all)

## Release History
- **July 2nd, 2024**: V3.0.0 Release
    - Fresh redesign of the chat application UI
    - Improved user workflow for LocalDocs
    - Expanded access to more model architectures
- **October 19th, 2023**: GGUF Support Launches with Support for:
    - Mistral 7b base model, an updated model gallery on our website, several new local code models including Rift Coder v1.5
    - [Nomic Vulkan](https://blog.nomic.ai/posts/gpt4all-gpu-inference-with-vulkan) support for Q4\_0 and Q4\_1 quantizations in GGUF.
    - Offline build support for running old versions of the GPT4All Local LLM Chat Client.
- **September 18th, 2023**: [Nomic Vulkan](https://blog.nomic.ai/posts/gpt4all-gpu-inference-with-vulkan) launches supporting local LLM inference on NVIDIA and AMD GPUs.
- **July 2023**: Stable support for LocalDocs, a feature that allows you to privately and locally chat with your data.
- **June 28th, 2023**: [Docker-based API server] launches allowing inference of local LLMs from an OpenAI-compatible HTTP endpoint.

[Docker-based API server]: https://github.com/nomic-ai/gpt4all/tree/cef74c2be20f5b697055d5b8b506861c7b997fab/gpt4all-api

## Contributing
GPT4All welcomes contributions, involvement, and discussion from the open source community!
Please see CONTRIBUTING.md and follow the issues, bug reports, and PR markdown templates.

Check project discord, with project owners, or through existing issues/PRs to avoid duplicate work.
Please make sure to tag all of the above with relevant project identifiers or your contribution could potentially get lost.
Example tags: `backend`, `bindings`, `python-bindings`, `documentation`, etc.

## Citation

If you utilize this repository, models or data in a downstream project, please consider citing it with:
```
@misc{gpt4all,
  author = {Yuvanesh Anand and Zach Nussbaum and Brandon Duderstadt and Benjamin Schmidt and Andriy Mulyar},
  title = {GPT4All: Training an Assistant-style Chatbot with Large Scale Data Distillation from GPT-3.5-Turbo},
  year = {2023},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/nomic-ai/gpt4all}},
}
```


================================================
FILE: common/common.cmake
================================================
function(gpt4all_add_warning_options target)
    if (MSVC)
        return()
    endif()
    target_compile_options("${target}" PRIVATE
        # base options
        -Wall
        -Wextra
        # extra options
        -Wcast-align
        -Wextra-semi
        -Wformat=2
        -Wmissing-include-dirs
        -Wsuggest-override
        -Wvla
        # errors
        -Werror=format-security
        -Werror=init-self
        -Werror=pointer-arith
        -Werror=undef
        # disabled warnings
        -Wno-sign-compare
        -Wno-unused-parameter
    )
    if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
        target_compile_options("${target}" PRIVATE
            -Wduplicated-branches
            -Wduplicated-cond
            -Wlogical-op
            -Wno-reorder
            -Wno-null-dereference
        )
    elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
        target_compile_options("${target}" PRIVATE
            -Wunreachable-code-break
            -Wunreachable-code-return
            -Werror=pointer-integer-compare
            -Wno-reorder-ctor
        )
    endif()
endfunction()


================================================
FILE: gpt4all-backend/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.23)  # for FILE_SET

include(../common/common.cmake)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (APPLE)
    option(BUILD_UNIVERSAL "Build a Universal binary on macOS" ON)
else()
    option(LLMODEL_KOMPUTE "llmodel: use Kompute"              ON)
    option(LLMODEL_VULKAN  "llmodel: use Vulkan"               OFF)
    option(LLMODEL_CUDA    "llmodel: use CUDA"                 ON)
    option(LLMODEL_ROCM    "llmodel: use ROCm"                 OFF)
endif()

if (APPLE)
  if (BUILD_UNIVERSAL)
    # Build a Universal binary on macOS
    # This requires that the found Qt library is compiled as Universal binaries.
    set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
  else()
    # Build for the host architecture on macOS
    if (NOT CMAKE_OSX_ARCHITECTURES)
      set(CMAKE_OSX_ARCHITECTURES "${CMAKE_HOST_SYSTEM_PROCESSOR}" CACHE STRING "" FORCE)
    endif()
  endif()
endif()

# Include the binary directory for the generated header file
include_directories("${CMAKE_CURRENT_BINARY_DIR}")

set(LLMODEL_VERSION_MAJOR 0)
set(LLMODEL_VERSION_MINOR 5)
set(LLMODEL_VERSION_PATCH 0)
set(LLMODEL_VERSION "${LLMODEL_VERSION_MAJOR}.${LLMODEL_VERSION_MINOR}.${LLMODEL_VERSION_PATCH}")
project(llmodel VERSION ${LLMODEL_VERSION} LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(BUILD_SHARED_LIBS ON)

# Check for IPO support
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if (NOT IPO_SUPPORTED)
    message(WARNING "Interprocedural optimization is not supported by your toolchain! This will lead to bigger file sizes and worse performance: ${IPO_ERROR}")
else()
    message(STATUS "Interprocedural optimization support detected")
endif()

set(DIRECTORY deps/llama.cpp-mainline)
include(llama.cpp.cmake)

set(BUILD_VARIANTS)
if (APPLE)
    list(APPEND BUILD_VARIANTS metal)
endif()
if (LLMODEL_KOMPUTE)
    list(APPEND BUILD_VARIANTS kompute kompute-avxonly)
else()
    list(PREPEND BUILD_VARIANTS cpu cpu-avxonly)
endif()
if (LLMODEL_VULKAN)
    list(APPEND BUILD_VARIANTS vulkan vulkan-avxonly)
endif()
if (LLMODEL_CUDA)
    cmake_minimum_required(VERSION 3.18)  # for CMAKE_CUDA_ARCHITECTURES

    # Defaults must be set before enable_language(CUDA).
    # Keep this in sync with the arch list in ggml/src/CMakeLists.txt (plus 5.0 for non-F16 branch).
    if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
        # 52 == lowest CUDA 12 standard
        # 60 == f16 CUDA intrinsics
        # 61 == integer CUDA intrinsics
        # 70 == compute capability at which unrolling a loop in mul_mat_q kernels is faster
        if (GGML_CUDA_F16 OR GGML_CUDA_DMMV_F16)
            set(CMAKE_CUDA_ARCHITECTURES "60;61;70;75") # needed for f16 CUDA intrinsics
        else()
            set(CMAKE_CUDA_ARCHITECTURES "50;52;61;70;75") # lowest CUDA 12 standard + lowest for integer intrinsics
            #set(CMAKE_CUDA_ARCHITECTURES "OFF") # use this to compile much faster, but only F16 models work
        endif()
    endif()
    message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")

    include(CheckLanguage)
    check_language(CUDA)
    if (NOT CMAKE_CUDA_COMPILER)
        message(WARNING "CUDA Toolkit not found. To build without CUDA, use -DLLMODEL_CUDA=OFF.")
    endif()
    enable_language(CUDA)
    list(APPEND BUILD_VARIANTS cuda cuda-avxonly)
endif()
if (LLMODEL_ROCM)
    enable_language(HIP)
    list(APPEND BUILD_VARIANTS rocm rocm-avxonly)
endif()

# Go through each build variant
foreach(BUILD_VARIANT IN LISTS BUILD_VARIANTS)
    # Determine flags
    if (BUILD_VARIANT MATCHES avxonly)
        set(GPT4ALL_ALLOW_NON_AVX OFF)
    else()
        set(GPT4ALL_ALLOW_NON_AVX ON)
    endif()
    set(GGML_AVX2 ${GPT4ALL_ALLOW_NON_AVX})
    set(GGML_F16C ${GPT4ALL_ALLOW_NON_AVX})
    set(GGML_FMA  ${GPT4ALL_ALLOW_NON_AVX})

    set(GGML_METAL   OFF)
    set(GGML_KOMPUTE OFF)
    set(GGML_VULKAN  OFF)
    set(GGML_CUDA    OFF)
    set(GGML_ROCM    OFF)
    if (BUILD_VARIANT MATCHES metal)
        set(GGML_METAL   ON)
    elseif (BUILD_VARIANT MATCHES kompute)
        set(GGML_KOMPUTE ON)
    elseif (BUILD_VARIANT MATCHES vulkan)
        set(GGML_VULKAN  ON)
    elseif (BUILD_VARIANT MATCHES cuda)
        set(GGML_CUDA    ON)
    elseif (BUILD_VARIANT MATCHES rocm)
        set(GGML_HIPBLAS ON)
    endif()

    # Include GGML
    include_ggml(-mainline-${BUILD_VARIANT})

    if (BUILD_VARIANT MATCHES metal)
        set(GGML_METALLIB "${GGML_METALLIB}" PARENT_SCOPE)
    endif()

    # Function for preparing individual implementations
    function(prepare_target TARGET_NAME BASE_LIB)
        set(TARGET_NAME ${TARGET_NAME}-${BUILD_VARIANT})
        message(STATUS "Configuring model implementation target ${TARGET_NAME}")
        # Link to ggml/llama
        target_link_libraries(${TARGET_NAME}
            PRIVATE ${BASE_LIB}-${BUILD_VARIANT})
        # Let it know about its build variant
        target_compile_definitions(${TARGET_NAME}
            PRIVATE GGML_BUILD_VARIANT="${BUILD_VARIANT}")
        # Enable IPO if possible
# FIXME: Doesn't work with msvc reliably. See https://github.com/nomic-ai/gpt4all/issues/841
#        set_property(TARGET ${TARGET_NAME}
#                     PROPERTY INTERPROCEDURAL_OPTIMIZATION ${IPO_SUPPORTED})
    endfunction()

    # Add each individual implementations
    add_library(llamamodel-mainline-${BUILD_VARIANT} SHARED
        src/llamamodel.cpp src/llmodel_shared.cpp)
    gpt4all_add_warning_options(llamamodel-mainline-${BUILD_VARIANT})
    target_compile_definitions(llamamodel-mainline-${BUILD_VARIANT} PRIVATE
        LLAMA_VERSIONS=>=3 LLAMA_DATE=999999)
    target_include_directories(llamamodel-mainline-${BUILD_VARIANT} PRIVATE
        src include/gpt4all-backend
    )
    prepare_target(llamamodel-mainline llama-mainline)

    if (NOT PROJECT_IS_TOP_LEVEL AND BUILD_VARIANT STREQUAL cuda)
        set(CUDAToolkit_BIN_DIR ${CUDAToolkit_BIN_DIR} PARENT_SCOPE)
    endif()
endforeach()

add_library(llmodel
    src/dlhandle.cpp
    src/llmodel.cpp
    src/llmodel_c.cpp
    src/llmodel_shared.cpp
)
gpt4all_add_warning_options(llmodel)
target_sources(llmodel PUBLIC
    FILE_SET public_headers TYPE HEADERS BASE_DIRS include
    FILES include/gpt4all-backend/llmodel.h
          include/gpt4all-backend/llmodel_c.h
          include/gpt4all-backend/sysinfo.h
)
target_compile_definitions(llmodel PRIVATE LIB_FILE_EXT="${CMAKE_SHARED_LIBRARY_SUFFIX}")
target_include_directories(llmodel PRIVATE src include/gpt4all-backend)

set_target_properties(llmodel PROPERTIES
                              VERSION ${PROJECT_VERSION}
                              SOVERSION ${PROJECT_VERSION_MAJOR})

set(COMPONENT_NAME_MAIN ${PROJECT_NAME})
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)


================================================
FILE: gpt4all-backend/README.md
================================================
# GPT4ALL Backend
This directory contains the C/C++ model backend used by GPT4All for inference on the CPU. This backend acts as a universal library/wrapper for all models that the GPT4All ecosystem supports. Language bindings are built on top of this universal library. The native GPT4all Chat application directly uses this library for all inference.

# What models are supported by the GPT4All ecosystem?

Currently, there are three different model architectures that are supported:

1. GPTJ - Based off of the GPT-J architecture with examples found [here](https://huggingface.co/EleutherAI/gpt-j-6b)
2. LLAMA - Based off of the LLAMA architecture with examples found [here](https://huggingface.co/models?sort=downloads&search=llama)
3. MPT - Based off of Mosaic ML's MPT architecture with examples found [here](https://huggingface.co/mosaicml/mpt-7b)

# Why so many different architectures? What differentiates them?

One of the major differences is license. Currently, the LLAMA based models are subject to a non-commercial license, whereas the GPTJ and MPT base models allow commercial usage. In the early advent of the recent explosion of activity in open source local models, the llama models have generally been seen as performing better, but that is changing quickly. Every week - even every day! - new models are released with some of the GPTJ and MPT models competitive in performance/quality with LLAMA. What's more, there are some very nice architectural innovations with the MPT models that could lead to new performance/quality gains.

# How does GPT4All make these models available for CPU inference?

By leveraging the ggml library written by Georgi Gerganov and a growing community of developers. There are currently multiple different versions of this library. The original github repo can be found [here](https://github.com/ggerganov/ggml), but the developer of the library has also created a LLAMA based version [here](https://github.com/ggerganov/llama.cpp). Currently, this backend is using the latter as a submodule.

# Does that mean GPT4All is compatible with all llama.cpp models and vice versa?

Unfortunately, no for three reasons:

1. The upstream [llama.cpp](https://github.com/ggerganov/llama.cpp) project has introduced [a compatibility breaking](https://github.com/ggerganov/llama.cpp/commit/b9fd7eee57df101d4a3e3eabc9fd6c2cb13c9ca1) re-quantization method recently. This is a breaking change that renders all previous models (including the ones that GPT4All uses) inoperative with newer versions of llama.cpp since that change.
2. The GPT4All backend has the llama.cpp submodule specifically pinned to a version prior to this breaking change.
3. The GPT4All backend currently supports MPT based models as an added feature. Neither llama.cpp nor the original ggml repo support this architecture as of this writing, however efforts are underway to make MPT available in the ggml repo which you can follow [here.](https://github.com/ggerganov/ggml/pull/145)

# What is being done to make them more compatible?

A few things. Number one, we are maintaining compatibility with our current model zoo by way of the submodule pinning. However, we are also exploring how we can update to newer versions of llama.cpp without breaking our current models. This might involve an additional magic header check or it could possibly involve keeping the currently pinned submodule and also adding a new submodule with later changes and differentiating them with namespaces or some other manner. Investigations continue.

# What about GPU inference?

In newer versions of llama.cpp, there has been some added support for NVIDIA GPU's for inference. We're investigating how to incorporate this into our downloadable installers.

# Ok, so bottom line... how do I make my model on Hugging Face compatible with GPT4All ecosystem right now?

1. Check to make sure the Hugging Face model is available in one of our three supported architectures
2. If it is, then you can use the conversion script inside of our pinned llama.cpp submodule for GPTJ and LLAMA based models
3. Or if your model is an MPT model you can use the conversion script located directly in this backend directory under the scripts subdirectory 

# Check back for updates as we'll try to keep this updated as things change!


================================================
FILE: gpt4all-backend/include/gpt4all-backend/llmodel.h
================================================
#ifndef LLMODEL_H
#define LLMODEL_H

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <expected>
#include <functional>
#include <optional>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>

class Dlhandle;

using namespace std::string_literals;

#define LLMODEL_MAX_PROMPT_BATCH 128

class LLModel {
public:
    using Token = int32_t;
    using PromptCallback      = std::function<bool(std::span<const Token> batch, bool cached)>;
    using ResponseCallback    = std::function<bool(Token token, std::string_view piece)>;
    using EmbedCancelCallback = bool(unsigned *batchSizes, unsigned nBatch, const char *backend);
    using ProgressCallback    = std::function<bool(float progress)>;

    class BadArchError: public std::runtime_error {
    public:
        BadArchError(std::string arch)
            : runtime_error("Unsupported model architecture: " + arch)
            , m_arch(std::move(arch))
            {}

        const std::string &arch() const noexcept { return m_arch; }

    private:
        std::string m_arch;
    };

    class MissingImplementationError: public std::runtime_error {
    public:
        using std::runtime_error::runtime_error;
    };

    class UnsupportedModelError: public std::runtime_error {
    public:
        using std::runtime_error::runtime_error;
    };

    struct GPUDevice {
        const char *backend;
        int index;
        int type;
        size_t heapSize;
        std::string name;
        std::string vendor;

        GPUDevice(const char *backend, int index, int type, size_t heapSize, std::string name, std::string vendor):
            backend(backend), index(index), type(type), heapSize(heapSize), name(std::move(name)),
            vendor(std::move(vendor)) {}

        std::string selectionName() const
        {
            assert(backend == "cuda"s || backend == "kompute"s);
            return backendName() + ": " + name;
        }

        std::string backendName() const { return backendIdToName(backend); }

        static std::string backendIdToName(const std::string &backend) { return s_backendNames.at(backend); }

        static std::string updateSelectionName(const std::string &name) {
            if (name == "Auto" || name == "CPU" || name == "Metal")
                return name;
            auto it = std::find_if(s_backendNames.begin(), s_backendNames.end(), [&name](const auto &entry) {
                return name.starts_with(entry.second + ": ");
            });
            if (it != s_backendNames.end())
                return name;
            return "Vulkan: " + name; // previously, there were only Vulkan devices
        }

    private:
        static inline const std::unordered_map<std::string, std::string> s_backendNames {
            {"cpu", "CPU"}, {"metal", "Metal"}, {"cuda", "CUDA"}, {"kompute", "Vulkan"},
        };
    };

    class Implementation {
    public:
        Implementation(const Implementation &) = delete;
        Implementation(Implementation &&);
        ~Implementation();

        std::string_view modelType() const { return m_modelType; }
        std::string_view buildVariant() const { return m_buildVariant; }

        static LLModel *construct(const std::string &modelPath, const std::string &backend = "auto", int n_ctx = 2048);
        static std::vector<GPUDevice> availableGPUDevices(size_t memoryRequired = 0);
        static int32_t maxContextLength(const std::string &modelPath);
        static int32_t layerCount(const std::string &modelPath);
        static bool isEmbeddingModel(const std::string &modelPath);
        static auto chatTemplate(const char *modelPath) -> std::expected<std::string, std::string>;
        static void setImplementationsSearchPath(const std::string &path);
        static const std::string &implementationsSearchPath();
        static bool hasSupportedCPU();
        // 0 for no, 1 for yes, -1 for non-x86_64
        static int cpuSupportsAVX2();

    private:
        Implementation(Dlhandle &&);

        static const std::vector<Implementation> &implementationList();
        static const Implementation *implementation(const char *fname, const std::string &buildVariant);
        static LLModel *constructGlobalLlama(const std::optional<std::string> &backend = std::nullopt);

        char *(*m_getFileArch)(const char *fname);
        bool (*m_isArchSupported)(const char *arch);
        LLModel *(*m_construct)();

        std::string_view m_modelType;
        std::string_view m_buildVariant;
        Dlhandle *m_dlhandle;
    };

    struct PromptContext {
        int32_t n_predict = 200;
        int32_t top_k = 40;
        float   top_p = 0.9f;
        float   min_p = 0.0f;
        float   temp = 0.9f;
        int32_t n_batch = 9;
        float   repeat_penalty = 1.10f;
        int32_t repeat_last_n = 64;     // last n tokens to penalize
        float   contextErase = 0.5f;    // percent of context to erase if we exceed the context window
    };

    explicit LLModel() {}
    virtual ~LLModel() {}

    virtual bool supportsEmbedding() const = 0;
    virtual bool supportsCompletion() const = 0;
    virtual bool loadModel(const std::string &modelPath, int n_ctx, int ngl) = 0;
    virtual bool isModelBlacklisted(const std::string &modelPath) const { (void)modelPath; return false; }
    virtual bool isEmbeddingModel(const std::string &modelPath) const { (void)modelPath; return false; }
    virtual bool isModelLoaded() const = 0;
    virtual size_t requiredMem(const std::string &modelPath, int n_ctx, int ngl) = 0;
    virtual size_t stateSize() const = 0;
    virtual size_t saveState(std::span<uint8_t> stateOut, std::vector<Token> &inputTokensOut) const = 0;
    virtual size_t restoreState(std::span<const uint8_t> state, std::span<const Token> inputTokens) = 0;

    // This method requires the model to return true from supportsCompletion otherwise it will throw
    // an error
    virtual void prompt(std::string_view        prompt,
                        const PromptCallback   &promptCallback,
                        const ResponseCallback &responseCallback,
                        const PromptContext    &ctx);

    virtual int32_t countPromptTokens(std::string_view prompt) const;

    virtual size_t embeddingSize() const {
        throw std::logic_error(std::string(implementation().modelType()) + " does not support embeddings");
    }
    // user-specified prefix
    virtual void embed(const std::vector<std::string> &texts, float *embeddings, std::optional<std::string> prefix,
                       int dimensionality = -1, size_t *tokenCount = nullptr, bool doMean = true, bool atlas = false,
                       EmbedCancelCallback *cancelCb = nullptr);
    // automatic prefix
    virtual void embed(const std::vector<std::string> &texts, float *embeddings, bool isRetrieval,
                       int dimensionality = -1, size_t *tokenCount = nullptr, bool doMean = true, bool atlas = false);

    virtual void setThreadCount(int32_t n_threads) { (void)n_threads; }
    virtual int32_t threadCount() const { return 1; }

    const Implementation &implementation() const {
        return *m_implementation;
    }

    virtual std::vector<GPUDevice> availableGPUDevices(size_t memoryRequired) const {
        (void)memoryRequired;
        return {};
    }

    virtual bool initializeGPUDevice(size_t memoryRequired, const std::string &name) const {
        (void)memoryRequired;
        (void)name;
        return false;
    }

    virtual bool initializeGPUDevice(int device, std::string *unavail_reason = nullptr) const {
        (void)device;
        if (unavail_reason) {
            *unavail_reason = "model has no GPU support";
        }
        return false;
    }

    virtual bool usingGPUDevice() const { return false; }
    virtual const char *backendName() const { return "cpu"; }
    virtual const char *gpuDeviceName() const { return nullptr; }

    void setProgressCallback(ProgressCallback callback) { m_progressCallback = callback; }

    virtual int32_t contextLength() const = 0;
    virtual auto specialTokens() -> std::unordered_map<std::string, std::string> const = 0;

protected:
    // These are pure virtual because subclasses need to implement as the default implementation of
    // 'prompt' above calls these functions
    virtual std::vector<Token> tokenize(std::string_view str) const = 0;
    virtual bool isSpecialToken(Token id) const = 0;
    virtual std::string tokenToString(Token id) const = 0;
    virtual void initSampler(const PromptContext &ctx) = 0;
    virtual Token sampleToken() const = 0;
    virtual bool evalTokens(int32_t nPast, std::span<const Token> tokens) const = 0;
    virtual void shiftContext(const PromptContext &promptCtx, int32_t *nPast) = 0;
    virtual int32_t inputLength() const = 0;
    virtual int32_t computeModelInputPosition(std::span<const Token> input) const = 0;
    virtual void setModelInputPosition(int32_t pos) = 0;
    virtual void appendInputToken(Token tok) = 0;
    virtual std::span<const Token> inputTokens() const = 0;
    virtual const std::vector<Token> &endTokens() const = 0;
    virtual bool shouldAddBOS() const = 0;

    virtual int32_t maxContextLength(std::string const &modelPath) const
    {
        (void)modelPath;
        return -1;
    }

    virtual int32_t layerCount(std::string const &modelPath) const
    {
        (void)modelPath;
        return -1;
    }

    virtual auto chatTemplate(const char *modelPath) const -> std::expected<std::string, std::string>
    {
        (void)modelPath;
        return std::unexpected("not implemented");
    }

    const Implementation *m_implementation = nullptr;

    ProgressCallback m_progressCallback;
    static bool staticProgressCallback(float progress, void* ctx)
    {
        LLModel* model = static_cast<LLModel*>(ctx);
        if (model && model->m_progressCallback)
            return model->m_progressCallback(progress);
        return true;
    }

    // prefill context with prompt
    auto decodePrompt(const PromptCallback &promptCallback,
                      const PromptContext  &promptCtx,
                      std::vector<Token>    embd_inp)
        -> std::optional<int32_t>;
    // generate a response
    void generateResponse(const ResponseCallback &responseCallback,
                          const PromptContext    &promptCtx,
                          int32_t                 nPast);

    friend class LLMImplementation;
};

#endif // LLMODEL_H


================================================
FILE: gpt4all-backend/include/gpt4all-backend/llmodel_c.h
================================================
#ifndef LLMODEL_C_H
#define LLMODEL_C_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#ifdef __GNUC__
#define DEPRECATED __attribute__ ((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Opaque pointer to the underlying model.
 */
typedef void *llmodel_model;

/**
 * A token.
 */
typedef int32_t token_t;

/**
 * llmodel_prompt_context structure for holding the prompt context.
 * NOTE: The implementation takes care of all the memory handling of the raw logits pointer and the
 * raw tokens pointer. Attempting to resize them or modify them in any way can lead to undefined
 * behavior.
 */
struct llmodel_prompt_context {
    int32_t n_predict;      // number of tokens to predict
    int32_t top_k;          // top k logits to sample from
    float   top_p;          // nucleus sampling probability threshold
    float   min_p;          // Min P sampling
    float   temp;           // temperature to adjust model's output distribution
    int32_t n_batch;        // number of predictions to generate in parallel
    float   repeat_penalty; // penalty factor for repeated tokens
    int32_t repeat_last_n;  // last n tokens to penalize
    float   context_erase;  // percent of context to erase if we exceed the context window
};

struct llmodel_gpu_device {
    const char * backend;
    int index;
    int type; // same as VkPhysicalDeviceType
    size_t heapSize;
    const char * name;
    const char * vendor;
};

#ifndef __cplusplus
typedef struct llmodel_prompt_context llmodel_prompt_context;
typedef struct llmodel_gpu_device llmodel_gpu_device;
#endif

/**
 * Callback type for prompt processing.
 * @param token_ids An array of token ids of the prompt.
 * @param n_token_ids The number of tokens in the array.
 * @param cached Whether the tokens were already in cache.
 * @return a bool indicating whether the model should keep processing.
 */
typedef bool (*llmodel_prompt_callback)(const token_t *token_ids, size_t n_token_ids, bool cached);

/**
 * Callback type for response.
 * @param token_id The token id of the response.
 * @param response The response string. NOTE: a token_id of -1 indicates the string is an error string.
 * @return a bool indicating whether the model should keep generating.
 */
typedef bool (*llmodel_response_callback)(token_t token_id, const char *response);

/**
 * Embedding cancellation callback for use with llmodel_embed.
 * @param batch_sizes The number of tokens in each batch that will be embedded.
 * @param n_batch The number of batches that will be embedded.
 * @param backend The backend that will be used for embedding. One of "cpu", "kompute", "cuda", or "metal".
 * @return True to cancel llmodel_embed, false to continue.
 */
typedef bool (*llmodel_emb_cancel_callback)(unsigned *batch_sizes, unsigned n_batch, const char *backend);

typedef void (*llmodel_special_token_callback)(const char *name, const char *token);

/**
 * Create a llmodel instance.
 * Recognises correct model type from file at model_path
 * @param model_path A string representing the path to the model file.
 * @return A pointer to the llmodel_model instance; NULL on error.
 */
DEPRECATED llmodel_model llmodel_model_create(const char *model_path);

/**
 * Create a llmodel instance.
 * Recognises correct model type from file at model_path
 * @param model_path A string representing the path to the model file; will only be used to detect model type.
 * @param backend A string representing the implementation to use. One of 'auto', 'cpu', 'metal', 'kompute', or 'cuda'.
 * @param error A pointer to a string; will only be set on error.
 * @return A pointer to the llmodel_model instance; NULL on error.
 */
llmodel_model llmodel_model_create2(const char *model_path, const char *backend, const char **error);

/**
 * Destroy a llmodel instance.
 * Recognises correct model type using type info
 * @param model a pointer to a llmodel_model instance.
 */
void llmodel_model_destroy(llmodel_model model);

/**
 * Estimate RAM requirement for a model file
 * @param model A pointer to the llmodel_model instance.
 * @param model_path A string representing the path to the model file.
 * @param n_ctx Maximum size of context window
 * @param ngl Number of GPU layers to use (Vulkan)
 * @return size greater than 0 if the model was parsed successfully, 0 if file could not be parsed.
 */
size_t llmodel_required_mem(llmodel_model model, const char *model_path, int n_ctx, int ngl);

/**
 * Load a model from a file.
 * @param model A pointer to the llmodel_model instance.
 * @param model_path A string representing the path to the model file.
 * @param n_ctx Maximum size of context window
 * @param ngl Number of GPU layers to use (Vulkan)
 * @return true if the model was loaded successfully, false otherwise.
 */
bool llmodel_loadModel(llmodel_model model, const char *model_path, int n_ctx, int ngl);

/**
 * Check if a model is loaded.
 * @param model A pointer to the llmodel_model instance.
 * @return true if the model is loaded, false otherwise.
 */
bool llmodel_isModelLoaded(llmodel_model model);

/**
 * Get the size of the internal state of the model.
 * NOTE: This state data is specific to the type of model you have created.
 * @param model A pointer to the llmodel_model instance.
 * @return the size in bytes of the internal state of the model
 */
uint64_t llmodel_state_get_size(llmodel_model model);

/**
 * Saves the internal state of the model.
 * NOTE: This state data is specific to the type of model you have created.
 * @param model A pointer to the llmodel_model instance.
 * @param state Where to store the state. This must be a buffer of at least llmodel_state_get_size() bytes.
 * @param state_size The size of the destination for the state.
 * @param input_tokens_out Where to store the address of the token cache state. This is dynamically allocated and must
 * be freed with llmodel_state_free_input_tokens.
 * @param n_input_tokens Where to store the size of the token cache state.
 * @return The number of bytes copied. On error, zero is returned, the token cache is set to NULL, and the token cache
 * size is set to zero.
 */
uint64_t llmodel_state_get_data(llmodel_model model, uint8_t *state_out, uint64_t state_size,
                                token_t **input_tokens_out, uint64_t *n_input_tokens);

/**
 * Frees the temporary token cache buffer created by a call to llmodel_state_get_data().
 * @param input_tokens The token cache buffer.
 */
void llmodel_state_free_input_tokens(token_t *input_tokens);

/**
 * Restores the internal state of the model using data from the specified address.
 * NOTE: This state data is specific to the type of model you have created.
 * @param model A pointer to the llmodel_model instance.
 * @param state A pointer to the state data.
 * @param state_size The size of the state data.
 * @param input_tokens The token cache associated with the saved state.
 * @param n_input_tokens The number of tokens in input_tokens.
 * @return The number of bytes read, or zero on error.
 */
uint64_t llmodel_state_set_data(llmodel_model model, const uint8_t *state, uint64_t state_size,
                                const token_t *input_tokens, uint64_t n_input_tokens);

/**
 * Generate a response using the model.
 * @param model A pointer to the llmodel_model instance.
 * @param prompt A string representing the input prompt.
 * @param prompt_callback A callback function for handling the processing of prompt.
 * @param response_callback A callback function for handling the generated response.
 * @param ctx A pointer to the llmodel_prompt_context structure.
 * @param error A pointer to a string; will only be set on error.
 */
bool llmodel_prompt(llmodel_model               model,
                    const char                 *prompt,
                    llmodel_prompt_callback     prompt_callback,
                    llmodel_response_callback   response_callback,
                    llmodel_prompt_context     *ctx,
                    const char                **error);

/**
 * Generate an embedding using the model.
 * NOTE: If given NULL pointers for the model or text, or an empty text, a NULL pointer will be
 * returned. Bindings should signal an error when NULL is the return value.
 * @param model A pointer to the llmodel_model instance.
 * @param texts A pointer to a NULL-terminated array of strings representing the texts to generate an
 * embedding for.
 * @param embedding_size A pointer to a size_t type that will be set by the call indicating the length
 * of the returned floating point array.
 * @param prefix The model-specific prefix representing the embedding task, without the trailing colon. NULL for no
 * prefix.
 * @param dimensionality The embedding dimension, for use with Matryoshka-capable models. Set to -1 to for full-size.
 * @param token_count Return location for the number of prompt tokens processed, or NULL.
 * @param do_mean True to average multiple embeddings if the text is longer than the model can accept, False to
 * truncate.
 * @param atlas Try to be fully compatible with the Atlas API. Currently, this means texts longer than 8192 tokens with
 * long_text_mode="mean" will raise an error. Disabled by default.
 * @param cancel_cb Cancellation callback, or NULL. See the documentation of llmodel_emb_cancel_callback.
 * @param error Return location for a malloc()ed string that will be set on error, or NULL.
 * @return A pointer to an array of floating point values passed to the calling method which then will
 * be responsible for lifetime of this memory. NULL if an error occurred.
 */
float *llmodel_embed(llmodel_model model, const char **texts, size_t *embedding_size, const char *prefix,
                     int dimensionality, size_t *token_count, bool do_mean, bool atlas,
                     llmodel_emb_cancel_callback cancel_cb, const char **error);

/**
 * Frees the memory allocated by the llmodel_embedding function.
 * @param ptr A pointer to the embedding as returned from llmodel_embedding.
 */
void llmodel_free_embedding(float *ptr);

/**
 * Set the number of threads to be used by the model.
 * @param model A pointer to the llmodel_model instance.
 * @param n_threads The number of threads to be used.
 */
void llmodel_setThreadCount(llmodel_model model, int32_t n_threads);

/**
 * Get the number of threads currently being used by the model.
 * @param model A pointer to the llmodel_model instance.
 * @return The number of threads currently being used.
 */
int32_t llmodel_threadCount(llmodel_model model);

/**
 * Set llmodel implementation search path.
 * Default is "."
 * @param path The path to the llmodel implementation shared objects. This can be a single path or
 * a list of paths separated by ';' delimiter.
 */
void llmodel_set_implementation_search_path(const char *path);

/**
 * Get llmodel implementation search path.
 * @return The current search path; lifetime ends on next set llmodel_set_implementation_search_path() call.
 */
const char *llmodel_get_implementation_search_path();

/**
 * Get a list of available GPU devices given the memory required.
 * @param memoryRequired The minimum amount of VRAM, in bytes
 * @return A pointer to an array of llmodel_gpu_device's whose number is given by num_devices.
 */
struct llmodel_gpu_device* llmodel_available_gpu_devices(size_t memoryRequired, int* num_devices);

/**
 * Initializes a GPU device based on a specified string criterion.
 *
 * This function initializes a GPU device based on a string identifier provided. The function
 * allows initialization based on general device type ("gpu"), vendor name ("amd", "nvidia", "intel"),
 * or any specific device name.
 *
 * @param memoryRequired The amount of memory (in bytes) required by the application or task
 *                       that will utilize the GPU device.
 * @param device A string specifying the desired criterion for GPU device selection. It can be:
 *               - "gpu": To initialize the best available GPU.
 *               - "amd", "nvidia", or "intel": To initialize the best available GPU from that vendor.
 *               - A specific GPU device name: To initialize a GPU with that exact name.
 *
 * @return True if the GPU device is successfully initialized based on the provided string
 *         criterion. Returns false if the desired GPU device could not be initialized.
 */
bool llmodel_gpu_init_gpu_device_by_string(llmodel_model model, size_t memoryRequired, const char *device);

/**
 * Initializes a GPU device by specifying a valid gpu device pointer.
 * @param device A gpu device pointer.
 * @return True if the GPU device is successfully initialized, false otherwise.
 */
bool llmodel_gpu_init_gpu_device_by_struct(llmodel_model model, const llmodel_gpu_device *device);

/**
 * Initializes a GPU device by its index.
 * @param device An integer representing the index of the GPU device to be initialized.
 * @return True if the GPU device is successfully initialized, false otherwise.
 */
bool llmodel_gpu_init_gpu_device_by_int(llmodel_model model, int device);

/**
 * @return The name of the llama.cpp backend currently in use. One of "cpu", "kompute", or "metal".
 */
const char *llmodel_model_backend_name(llmodel_model model);

/**
 * @return The name of the GPU device currently in use, or NULL for backends other than Kompute.
 */
const char *llmodel_model_gpu_device_name(llmodel_model model);

int32_t llmodel_count_prompt_tokens(llmodel_model model, const char *prompt, const char **error);

void llmodel_model_foreach_special_token(llmodel_model model, llmodel_special_token_callback callback);

#ifdef __cplusplus
}
#endif

#endif // LLMODEL_C_H


================================================
FILE: gpt4all-backend/include/gpt4all-backend/sysinfo.h
================================================
#ifndef SYSINFO_H
#define SYSINFO_H

#include <fstream>
#include <iomanip>
#include <sstream>
#include <string>

#if defined(__linux__)
#   include <unistd.h>
#elif defined(__APPLE__)
#   include <sys/types.h>
#   include <sys/sysctl.h>
#elif defined(_WIN32)
#   define WIN32_LEAN_AND_MEAN
#   ifndef NOMINMAX
#       define NOMINMAX
#   endif
#   include <windows.h>
#endif

static long long getSystemTotalRAMInBytes()
{
    long long totalRAM = 0;

#if defined(__linux__)
    std::ifstream file("/proc/meminfo");
    std::string line;
    while (std::getline(file, line)) {
        if (line.find("MemTotal") != std::string::npos) {
            std::string memTotalStr = line.substr(line.find(":") + 1);
            memTotalStr.erase(0, memTotalStr.find_first_not_of(" "));
            memTotalStr = memTotalStr.substr(0, memTotalStr.find(" "));
            totalRAM = std::stoll(memTotalStr) * 1024;  // Convert from KB to bytes
            break;
        }
    }
    file.close();
#elif defined(__APPLE__)
    int mib[2] = {CTL_HW, HW_MEMSIZE};
    size_t length = sizeof(totalRAM);
    sysctl(mib, 2, &totalRAM, &length, NULL, 0);
#elif defined(_WIN32)
    MEMORYSTATUSEX memoryStatus;
    memoryStatus.dwLength = sizeof(memoryStatus);
    GlobalMemoryStatusEx(&memoryStatus);
    totalRAM = memoryStatus.ullTotalPhys;
#endif

    return totalRAM;
}

static double getSystemTotalRAMInGB()
{
    return static_cast<double>(getSystemTotalRAMInBytes()) / (1024 * 1024 * 1024);
}

static std::string getSystemTotalRAMInGBString()
{
    std::stringstream ss;
    ss << std::fixed << std::setprecision(2) << getSystemTotalRAMInGB() << " GB";
    return ss.str();
}

#endif // SYSINFO_H


================================================
FILE: gpt4all-backend/llama.cpp.cmake
================================================
cmake_minimum_required(VERSION 3.14)  # for add_link_options and implicit target directories.

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

#
# Option list
#
# some of the options here are commented out so they can be set "dynamically" before calling include_ggml()

set(GGML_LLAMAFILE_DEFAULT ON)

# general
option(LLAMA_STATIC                     "llama: static link libraries"                          OFF)
option(LLAMA_NATIVE                     "llama: enable -march=native flag"                      OFF)

# debug
option(LLAMA_ALL_WARNINGS               "llama: enable all compiler warnings"                   ON)
option(LLAMA_ALL_WARNINGS_3RD_PARTY     "llama: enable all compiler warnings in 3rd party libs" OFF)
option(LLAMA_GPROF                      "llama: enable gprof"                                   OFF)

# build
option(LLAMA_FATAL_WARNINGS             "llama: enable -Werror flag"                            OFF)

# instruction set specific
#option(GGML_AVX                     "ggml: enable AVX"                                     ON)
#option(GGML_AVX2                    "ggml: enable AVX2"                                    ON)
#option(GGML_AVX512                  "ggml: enable AVX512"                                  OFF)
#option(GGML_AVX512_VBMI             "ggml: enable AVX512-VBMI"                             OFF)
#option(GGML_AVX512_VNNI             "ggml: enable AVX512-VNNI"                             OFF)
#option(GGML_FMA                     "ggml: enable FMA"                                     ON)
# in MSVC F16C is implied with AVX2/AVX512
#if (NOT MSVC)
#    option(GGML_F16C                "ggml: enable F16C"                                    ON)
#endif()

if (WIN32)
    set(LLAMA_WIN_VER "0x602" CACHE STRING "llama: Windows Version")
endif()

# 3rd party libs
option(GGML_ACCELERATE                      "ggml: enable Accelerate framework"               ON)
option(GGML_BLAS                            "ggml: use BLAS"                                  OFF)
option(GGML_LLAMAFILE                       "ggml: use llamafile SGEMM"                       ${GGML_LLAMAFILE_DEFAULT})
set(GGML_BLAS_VENDOR "Generic" CACHE STRING "ggml: BLAS library vendor")

#option(GGML_CUDA                            "ggml: use CUDA"                                  OFF)
option(GGML_CUDA_FORCE_DMMV                 "ggml: use dmmv instead of mmvq CUDA kernels"     OFF)
option(GGML_CUDA_FORCE_MMQ                  "ggml: use mmq kernels instead of cuBLAS"         OFF)
option(GGML_CUDA_FORCE_CUBLAS               "ggml: always use cuBLAS instead of mmq kernels"  OFF)
set   (GGML_CUDA_DMMV_X   "32" CACHE STRING "ggml: x stride for dmmv CUDA kernels")
set   (GGML_CUDA_MMV_Y     "1" CACHE STRING "ggml: y block size for mmv CUDA kernels")
option(GGML_CUDA_F16                        "ggml: use 16 bit floats for some calculations"   OFF)
set   (GGML_CUDA_KQUANTS_ITER "2" CACHE STRING
                                            "ggml: iters./thread per block for Q2_K/Q6_K")
set   (GGML_CUDA_PEER_MAX_BATCH_SIZE "128" CACHE STRING
                                            "ggml: max. batch size for using peer access")
option(GGML_CUDA_NO_PEER_COPY               "ggml: do not use peer to peer copies"            OFF)
option(GGML_CUDA_NO_VMM                     "ggml: do not try to use CUDA VMM"                OFF)
option(GGML_CUDA_FA_ALL_QUANTS              "ggml: compile all quants for FlashAttention"     OFF)
option(GGML_CUDA_USE_GRAPHS                 "ggml: use CUDA graphs (llama.cpp only)"          OFF)

#option(GGML_HIPBLAS                         "ggml: use hipBLAS"                               OFF)
option(GGML_HIP_UMA                         "ggml: use HIP unified memory architecture"       OFF)
#option(GGML_VULKAN                          "ggml: use Vulkan"                                OFF)
option(GGML_VULKAN_CHECK_RESULTS            "ggml: run Vulkan op checks"                      OFF)
option(GGML_VULKAN_DEBUG                    "ggml: enable Vulkan debug output"                OFF)
option(GGML_VULKAN_VALIDATE                 "ggml: enable Vulkan validation"                  OFF)
option(GGML_VULKAN_RUN_TESTS                "ggml: run Vulkan tests"                          OFF)
#option(GGML_METAL                           "ggml: use Metal"                                 ${GGML_METAL_DEFAULT})
option(GGML_METAL_NDEBUG                    "ggml: disable Metal debugging"                   OFF)
option(GGML_METAL_SHADER_DEBUG              "ggml: compile Metal with -fno-fast-math"         OFF)
set(GGML_METAL_MACOSX_VERSION_MIN "" CACHE STRING
                                            "ggml: metal minimum macOS version")
set(GGML_METAL_STD "" CACHE STRING          "ggml: metal standard version (-std flag)")
#option(GGML_KOMPUTE                        "ggml: use Kompute"                               OFF)
option(GGML_QKK_64                          "ggml: use super-block size of 64 for k-quants"   OFF)
set(GGML_SCHED_MAX_COPIES  "4" CACHE STRING "ggml: max input copies for pipeline parallelism")

# add perf arguments
option(LLAMA_PERF                           "llama: enable perf"                               OFF)

#
# Compile flags
#

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

list(APPEND GGML_COMPILE_DEFS GGML_SCHED_MAX_COPIES=${GGML_SCHED_MAX_COPIES})

# enable libstdc++ assertions for debug builds
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    list(APPEND GGML_COMPILE_DEFS $<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS>)
endif()

if (APPLE AND GGML_ACCELERATE)
    find_library(ACCELERATE_FRAMEWORK Accelerate)
    if (ACCELERATE_FRAMEWORK)
        message(STATUS "Accelerate framework found")

        list(APPEND GGML_COMPILE_DEFS GGML_USE_ACCELERATE)
        list(APPEND GGML_COMPILE_DEFS ACCELERATE_NEW_LAPACK)
        list(APPEND GGML_COMPILE_DEFS ACCELERATE_LAPACK_ILP64)
        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} ${ACCELERATE_FRAMEWORK})
    else()
        message(WARNING "Accelerate framework not found")
    endif()
endif()

if (GGML_BLAS)
    if (LLAMA_STATIC)
        set(BLA_STATIC ON)
    endif()
    if ($(CMAKE_VERSION) VERSION_GREATER_EQUAL 3.22)
        set(BLA_SIZEOF_INTEGER 8)
    endif()

    set(BLA_VENDOR ${GGML_BLAS_VENDOR})
    find_package(BLAS)

    if (BLAS_FOUND)
        message(STATUS "BLAS found, Libraries: ${BLAS_LIBRARIES}")

        if ("${BLAS_INCLUDE_DIRS}" STREQUAL "")
            # BLAS_INCLUDE_DIRS is missing in FindBLAS.cmake.
            # see https://gitlab.kitware.com/cmake/cmake/-/issues/20268
            find_package(PkgConfig REQUIRED)
            if (${GGML_BLAS_VENDOR} MATCHES "Generic")
                pkg_check_modules(DepBLAS REQUIRED blas)
            elseif (${GGML_BLAS_VENDOR} MATCHES "OpenBLAS")
                # As of openblas v0.3.22, the 64-bit is named openblas64.pc
                pkg_check_modules(DepBLAS openblas64)
                if (NOT DepBLAS_FOUND)
                    pkg_check_modules(DepBLAS REQUIRED openblas)
                endif()
            elseif (${GGML_BLAS_VENDOR} MATCHES "FLAME")
                pkg_check_modules(DepBLAS REQUIRED blis)
            elseif (${GGML_BLAS_VENDOR} MATCHES "ATLAS")
                pkg_check_modules(DepBLAS REQUIRED blas-atlas)
            elseif (${GGML_BLAS_VENDOR} MATCHES "FlexiBLAS")
                pkg_check_modules(DepBLAS REQUIRED flexiblas_api)
            elseif (${GGML_BLAS_VENDOR} MATCHES "Intel")
                # all Intel* libraries share the same include path
                pkg_check_modules(DepBLAS REQUIRED mkl-sdl)
            elseif (${GGML_BLAS_VENDOR} MATCHES "NVHPC")
                # this doesn't provide pkg-config
                # suggest to assign BLAS_INCLUDE_DIRS on your own
                if ("${NVHPC_VERSION}" STREQUAL "")
                    message(WARNING "Better to set NVHPC_VERSION")
                else()
                    set(DepBLAS_FOUND ON)
                    set(DepBLAS_INCLUDE_DIRS "/opt/nvidia/hpc_sdk/${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}/${NVHPC_VERSION}/math_libs/include")
                endif()
            endif()
            if (DepBLAS_FOUND)
                set(BLAS_INCLUDE_DIRS ${DepBLAS_INCLUDE_DIRS})
            else()
                message(WARNING "BLAS_INCLUDE_DIRS neither been provided nor been automatically"
                " detected by pkgconfig, trying to find cblas.h from possible paths...")
                find_path(BLAS_INCLUDE_DIRS
                    NAMES cblas.h
                    HINTS
                        /usr/include
                        /usr/local/include
                        /usr/include/openblas
                        /opt/homebrew/opt/openblas/include
                        /usr/local/opt/openblas/include
                        /usr/include/x86_64-linux-gnu/openblas/include
                )
            endif()
        endif()

        message(STATUS "BLAS found, Includes: ${BLAS_INCLUDE_DIRS}")

        list(APPEND GGML_COMPILE_OPTS ${BLAS_LINKER_FLAGS})

        list(APPEND GGML_COMPILE_DEFS GGML_USE_OPENBLAS)

        if (${BLAS_INCLUDE_DIRS} MATCHES "mkl" AND (${GGML_BLAS_VENDOR} MATCHES "Generic" OR ${GGML_BLAS_VENDOR} MATCHES "Intel"))
            list(APPEND GGML_COMPILE_DEFS GGML_BLAS_USE_MKL)
        endif()

        set(LLAMA_EXTRA_LIBS     ${LLAMA_EXTRA_LIBS}     ${BLAS_LIBRARIES})
        set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${BLAS_INCLUDE_DIRS})
    else()
        message(WARNING "BLAS not found, please refer to "
        "https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors"
        " to set correct GGML_BLAS_VENDOR")
    endif()
endif()

if (GGML_LLAMAFILE)
    list(APPEND GGML_COMPILE_DEFS GGML_USE_LLAMAFILE)

    set(GGML_HEADERS_LLAMAFILE ${DIRECTORY}/ggml/src/llamafile/sgemm.h)
    set(GGML_SOURCES_LLAMAFILE ${DIRECTORY}/ggml/src/llamafile/sgemm.cpp)
endif()

if (GGML_QKK_64)
    list(APPEND GGML_COMPILE_DEFS GGML_QKK_64)
endif()

if (LLAMA_PERF)
    list(APPEND GGML_COMPILE_DEFS GGML_PERF)
endif()

function(get_flags CCID CCVER)
    set(C_FLAGS "")
    set(CXX_FLAGS "")

    if (CCID MATCHES "Clang")
        set(C_FLAGS   -Wunreachable-code-break -Wunreachable-code-return)
        set(CXX_FLAGS -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi)

        if (
            (CCID STREQUAL "Clang"      AND CCVER VERSION_GREATER_EQUAL 3.8.0) OR
            (CCID STREQUAL "AppleClang" AND CCVER VERSION_GREATER_EQUAL 7.3.0)
        )
            list(APPEND C_FLAGS -Wdouble-promotion)
        endif()
    elseif (CCID STREQUAL "GNU")
        set(C_FLAGS   -Wdouble-promotion)
        set(CXX_FLAGS -Wno-array-bounds)

        if (CCVER VERSION_GREATER_EQUAL 7.1.0)
            list(APPEND CXX_FLAGS -Wno-format-truncation)
        endif()
        if (CCVER VERSION_GREATER_EQUAL 8.1.0)
            list(APPEND CXX_FLAGS -Wextra-semi)
        endif()
    endif()

    set(GF_C_FLAGS   ${C_FLAGS}   PARENT_SCOPE)
    set(GF_CXX_FLAGS ${CXX_FLAGS} PARENT_SCOPE)
endfunction()

if (LLAMA_FATAL_WARNINGS)
    if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        list(APPEND C_FLAGS   -Werror)
        list(APPEND CXX_FLAGS -Werror)
    elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
        list(APPEND GGML_COMPILE_OPTS /WX)
    endif()
endif()

if (LLAMA_ALL_WARNINGS)
    if (NOT MSVC)
        list(APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function)
        list(APPEND C_FLAGS       -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes
                                  -Werror=implicit-int -Werror=implicit-function-declaration)
        list(APPEND CXX_FLAGS     -Wmissing-declarations -Wmissing-noreturn)

        list(APPEND C_FLAGS   ${WARNING_FLAGS})
        list(APPEND CXX_FLAGS ${WARNING_FLAGS})

        get_flags(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})

        list(APPEND GGML_COMPILE_OPTS "$<$<COMPILE_LANGUAGE:C>:${C_FLAGS};${GF_C_FLAGS}>"
                                      "$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS};${GF_CXX_FLAGS}>")
    else()
        # todo : msvc
        set(C_FLAGS   "")
        set(CXX_FLAGS "")
    endif()
endif()

if (WIN32)
    list(APPEND GGML_COMPILE_DEFS _CRT_SECURE_NO_WARNINGS)

    if (BUILD_SHARED_LIBS)
        set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
    endif()
endif()

# this version of Apple ld64 is buggy
execute_process(
    COMMAND ${CMAKE_C_COMPILER} ${CMAKE_EXE_LINKER_FLAGS} -Wl,-v
    ERROR_VARIABLE output
    OUTPUT_QUIET
)

if (output MATCHES "dyld-1015\.7")
    list(APPEND GGML_COMPILE_DEFS HAVE_BUGGY_APPLE_LINKER)
endif()

# Architecture specific
# TODO: probably these flags need to be tweaked on some architectures
#       feel free to update the Makefile for your architecture and send a pull request or issue
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
if (MSVC)
    string(TOLOWER "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_PLATFORM_LWR)
    message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}")
else ()
    set(CMAKE_GENERATOR_PLATFORM_LWR "")
endif ()

if (NOT MSVC)
    if (LLAMA_STATIC)
        list(APPEND GGML_LINK_OPTS -static)
        if (MINGW)
            list(APPEND GGML_LINK_OPTS -static-libgcc -static-libstdc++)
        endif()
    endif()
    if (LLAMA_GPROF)
        list(APPEND GGML_COMPILE_OPTS -pg)
    endif()
endif()

if (MINGW)
    # Target Windows 8 for PrefetchVirtualMemory
    list(APPEND GGML_COMPILE_DEFS _WIN32_WINNT=${LLAMA_WIN_VER})
endif()

#
# POSIX conformance
#

# clock_gettime came in POSIX.1b (1993)
# CLOCK_MONOTONIC came in POSIX.1-2001 / SUSv3 as optional
# posix_memalign came in POSIX.1-2001 / SUSv3
# M_PI is an XSI extension since POSIX.1-2001 / SUSv3, came in XPG1 (1985)
list(APPEND GGML_COMPILE_DEFS _XOPEN_SOURCE=600)

# Somehow in OpenBSD whenever POSIX conformance is specified
# some string functions rely on locale_t availability,
# which was introduced in POSIX.1-2008, forcing us to go higher
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
    list(REMOVE_ITEM GGML_COMPILE_DEFS _XOPEN_SOURCE=600)
    list(APPEND GGML_COMPILE_DEFS _XOPEN_SOURCE=700)
endif()

# Data types, macros and functions related to controlling CPU affinity and
# some memory allocation are available on Linux through GNU extensions in libc
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
    list(APPEND GGML_COMPILE_DEFS _GNU_SOURCE)
endif()

# RLIMIT_MEMLOCK came in BSD, is not specified in POSIX.1,
# and on macOS its availability depends on enabling Darwin extensions
# similarly on DragonFly, enabling BSD extensions is necessary
if (
    CMAKE_SYSTEM_NAME MATCHES "Darwin" OR
    CMAKE_SYSTEM_NAME MATCHES "iOS" OR
    CMAKE_SYSTEM_NAME MATCHES "tvOS" OR
    CMAKE_SYSTEM_NAME MATCHES "DragonFly"
)
    list(APPEND GGML_COMPILE_DEFS _DARWIN_C_SOURCE)
endif()

# alloca is a non-standard interface that is not visible on BSDs when
# POSIX conformance is specified, but not all of them provide a clean way
# to enable it in such cases
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
    list(APPEND GGML_COMPILE_DEFS __BSD_VISIBLE)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
    list(APPEND GGML_COMPILE_DEFS _NETBSD_SOURCE)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
    list(APPEND GGML_COMPILE_DEFS _BSD_SOURCE)
endif()

function(include_ggml SUFFIX)
    message(STATUS "Configuring ggml implementation target llama${SUFFIX} in ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY}")

    #
    # libraries
    #

    if (GGML_CUDA)
        cmake_minimum_required(VERSION 3.18)  # for CMAKE_CUDA_ARCHITECTURES

        get_property(LANGS GLOBAL PROPERTY ENABLED_LANGUAGES)
        if (NOT CUDA IN_LIST LANGS)
            message(FATAL_ERROR "The CUDA language must be enabled.")
        endif()

        find_package(CUDAToolkit REQUIRED)
        set(CUDAToolkit_BIN_DIR ${CUDAToolkit_BIN_DIR} PARENT_SCOPE)

        # architectures are set in gpt4all-backend/CMakeLists.txt

        set(GGML_HEADERS_CUDA ${DIRECTORY}/ggml/include/ggml-cuda.h)
        file(GLOB   GGML_HEADERS_CUDA "${DIRECTORY}/ggml/src/ggml-cuda/*.cuh")
        list(APPEND GGML_HEADERS_CUDA "${DIRECTORY}/ggml/include/ggml-cuda.h")

        file(GLOB   GGML_SOURCES_CUDA "${DIRECTORY}/ggml/src/ggml-cuda/*.cu")
        list(APPEND GGML_SOURCES_CUDA "${DIRECTORY}/ggml/src/ggml-cuda.cu")
        file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/fattn-wmma*.cu")
        list(APPEND GGML_SOURCES_CUDA ${SRCS})
        file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/mmq*.cu")
        list(APPEND GGML_SOURCES_CUDA ${SRCS})

        if (GGML_CUDA_FA_ALL_QUANTS)
            file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/fattn-vec*.cu")
            list(APPEND GGML_SOURCES_CUDA ${SRCS})
            add_compile_definitions(GGML_CUDA_FA_ALL_QUANTS)
        else()
            file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/fattn-vec*q4_0-q4_0.cu")
            list(APPEND GGML_SOURCES_CUDA ${SRCS})
            file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/fattn-vec*q8_0-q8_0.cu")
            list(APPEND GGML_SOURCES_CUDA ${SRCS})
            file(GLOB   SRCS "${DIRECTORY}/ggml/src/ggml-cuda/template-instances/fattn-vec*f16-f16.cu")
            list(APPEND GGML_SOURCES_CUDA ${SRCS})
        endif()

        list(APPEND GGML_COMPILE_DEFS_PUBLIC GGML_USE_CUDA)

        list(APPEND GGML_COMPILE_DEFS GGML_CUDA_DMMV_X=${GGML_CUDA_DMMV_X})
        list(APPEND GGML_COMPILE_DEFS GGML_CUDA_MMV_Y=${GGML_CUDA_MMV_Y})
        list(APPEND GGML_COMPILE_DEFS K_QUANTS_PER_ITERATION=${GGML_CUDA_KQUANTS_ITER})
        list(APPEND GGML_COMPILE_DEFS GGML_CUDA_PEER_MAX_BATCH_SIZE=${GGML_CUDA_PEER_MAX_BATCH_SIZE})

        if (GGML_CUDA_USE_GRAPHS)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_USE_GRAPHS)
        endif()

        if (GGML_CUDA_FORCE_DMMV)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_FORCE_DMMV)
        endif()

        if (GGML_CUDA_FORCE_MMQ)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_FORCE_MMQ)
        endif()

        if (GGML_CUDA_FORCE_CUBLAS)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_FORCE_CUBLAS)
        endif()

        if (GGML_CUDA_NO_VMM)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_NO_VMM)
        endif()

        if (GGML_CUDA_F16)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_F16)
        endif()

        if (GGML_CUDA_NO_PEER_COPY)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_NO_PEER_COPY)
        endif()

        if (LLAMA_STATIC)
            if (WIN32)
                # As of 12.3.1 CUDA Toolkit for Windows does not offer a static cublas library
                set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} CUDA::cudart_static CUDA::cublas CUDA::cublasLt)
            else ()
                set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} CUDA::cudart_static CUDA::cublas_static CUDA::cublasLt_static)
            endif()
        else()
            set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} CUDA::cudart CUDA::cublas CUDA::cublasLt)
        endif()

        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} CUDA::cuda_driver)
    endif()

    if (GGML_VULKAN)
        find_package(Vulkan REQUIRED)

        set(GGML_HEADERS_VULKAN ${DIRECTORY}/ggml/include/ggml-vulkan.h)
        set(GGML_SOURCES_VULKAN ${DIRECTORY}/ggml/src/ggml-vulkan.cpp)

        list(APPEND GGML_COMPILE_DEFS_PUBLIC GGML_USE_VULKAN)

        if (GGML_VULKAN_CHECK_RESULTS)
            list(APPEND GGML_COMPILE_DEFS GGML_VULKAN_CHECK_RESULTS)
        endif()

        if (GGML_VULKAN_DEBUG)
            list(APPEND GGML_COMPILE_DEFS GGML_VULKAN_DEBUG)
        endif()

        if (GGML_VULKAN_VALIDATE)
            list(APPEND GGML_COMPILE_DEFS GGML_VULKAN_VALIDATE)
        endif()

        if (GGML_VULKAN_RUN_TESTS)
            list(APPEND GGML_COMPILE_DEFS GGML_VULKAN_RUN_TESTS)
        endif()

        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} Vulkan::Vulkan)
    endif()

    if (GGML_HIPBLAS)
        if ($ENV{ROCM_PATH})
            set(ROCM_PATH $ENV{ROCM_PATH})
        else()
            set(ROCM_PATH /opt/rocm)
        endif()
        list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})

        string(REGEX MATCH "hipcc(\.bat)?$" CXX_IS_HIPCC "${CMAKE_CXX_COMPILER}")

        if (CXX_IS_HIPCC AND UNIX)
            message(WARNING "Setting hipcc as the C++ compiler is legacy behavior."
                " Prefer setting the HIP compiler directly. See README for details.")
        else()
            # Forward AMDGPU_TARGETS to CMAKE_HIP_ARCHITECTURES.
            if (AMDGPU_TARGETS AND NOT CMAKE_HIP_ARCHITECTURES)
                set(CMAKE_HIP_ARCHITECTURES ${AMDGPU_ARGETS})
            endif()
            cmake_minimum_required(VERSION 3.21)
            get_property(LANGS GLOBAL PROPERTY ENABLED_LANGUAGES)
            if (NOT HIP IN_LIST LANGS)
                message(FATAL_ERROR "The HIP language must be enabled.")
            endif()
        endif()
        find_package(hip     REQUIRED)
        find_package(hipblas REQUIRED)
        find_package(rocblas REQUIRED)

        message(STATUS "HIP and hipBLAS found")

        set(GGML_HEADERS_ROCM ${DIRECTORY}/ggml/include/ggml-cuda.h)

        file(GLOB GGML_SOURCES_ROCM "${DIRECTORY}/ggml/src/ggml-rocm/*.cu")
        list(APPEND GGML_SOURCES_ROCM "${DIRECTORY}/ggml/src/ggml-rocm.cu")

        list(APPEND GGML_COMPILE_DEFS_PUBLIC GGML_USE_HIPBLAS GGML_USE_CUDA)

        if (GGML_HIP_UMA)
            list(APPEND GGML_COMPILE_DEFS GGML_HIP_UMA)
        endif()

        if (GGML_CUDA_FORCE_DMMV)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_FORCE_DMMV)
        endif()

        if (GGML_CUDA_FORCE_MMQ)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_FORCE_MMQ)
        endif()

        if (GGML_CUDA_NO_PEER_COPY)
            list(APPEND GGML_COMPILE_DEFS GGML_CUDA_NO_PEER_COPY)
        endif()

        list(APPEND GGML_COMPILE_DEFS GGML_CUDA_DMMV_X=${GGML_CUDA_DMMV_X})
        list(APPEND GGML_COMPILE_DEFS GGML_CUDA_MMV_Y=${GGML_CUDA_MMV_Y})
        list(APPEND GGML_COMPILE_DEFS K_QUANTS_PER_ITERATION=${GGML_CUDA_KQUANTS_ITER})

        if (CXX_IS_HIPCC)
            set_source_files_properties(${GGML_SOURCES_ROCM} PROPERTIES LANGUAGE CXX)
            set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} hip::device)
        else()
            set_source_files_properties(${GGML_SOURCES_ROCM} PROPERTIES LANGUAGE HIP)
        endif()

        if (LLAMA_STATIC)
            message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
        endif()

        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} PUBLIC hip::host roc::rocblas roc::hipblas)
    endif()

    set(LLAMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${DIRECTORY})

    if (GGML_KOMPUTE AND NOT GGML_KOMPUTE_ONCE)
        set(GGML_KOMPUTE_ONCE ON PARENT_SCOPE)
        if (NOT EXISTS "${LLAMA_DIR}/ggml/src/kompute/CMakeLists.txt")
            message(FATAL_ERROR "Kompute not found")
        endif()
        message(STATUS "Kompute found")

        find_package(Vulkan COMPONENTS glslc)
        if (NOT Vulkan_FOUND)
            message(FATAL_ERROR "Vulkan not found. To build without Vulkan, use -DLLMODEL_KOMPUTE=OFF.")
        endif()
        find_program(glslc_executable NAMES glslc HINTS Vulkan::glslc)
        if (NOT glslc_executable)
            message(FATAL_ERROR "glslc not found. To build without Vulkan, use -DLLMODEL_KOMPUTE=OFF.")
        endif()

        function(compile_shader)
            set(options)
            set(oneValueArgs)
            set(multiValueArgs SOURCES)
            cmake_parse_arguments(compile_shader "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
            foreach(source ${compile_shader_SOURCES})
                get_filename_component(OP_FILE ${source} NAME)
                set(spv_file ${CMAKE_CURRENT_BINARY_DIR}/${OP_FILE}.spv)
                add_custom_command(
                    OUTPUT ${spv_file}
                    DEPENDS ${LLAMA_DIR}/ggml/src/kompute-shaders/${source}
                        ${LLAMA_DIR}/ggml/src/kompute-shaders/common.comp
                        ${LLAMA_DIR}/ggml/src/kompute-shaders/op_getrows.comp
                        ${LLAMA_DIR}/ggml/src/kompute-shaders/op_mul_mv_q_n_pre.comp
                        ${LLAMA_DIR}/ggml/src/kompute-shaders/op_mul_mv_q_n.comp
                    COMMAND ${glslc_executable} --target-env=vulkan1.2 -o ${spv_file} ${LLAMA_DIR}/ggml/src/kompute-shaders/${source}
                    COMMENT "Compiling ${source} to ${source}.spv"
                    )

                get_filename_component(RAW_FILE_NAME ${spv_file} NAME)
                set(FILE_NAME "shader${RAW_FILE_NAME}")
                string(REPLACE ".comp.spv" ".h" HEADER_FILE ${FILE_NAME})
                string(TOUPPER ${HEADER_FILE} HEADER_FILE_DEFINE)
                string(REPLACE "." "_" HEADER_FILE_DEFINE "${HEADER_FILE_DEFINE}")
                set(OUTPUT_HEADER_FILE "${HEADER_FILE}")
                message(STATUS "${HEADER_FILE} generating ${HEADER_FILE_DEFINE}")
                if(CMAKE_GENERATOR MATCHES "Visual Studio")
                    add_custom_command(
                        OUTPUT ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "/*THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT*/" > ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#ifndef ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "namespace kp {" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "namespace shader_data {" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/xxd -i ${RAW_FILE_NAME} >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "}}" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#endif // define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        DEPENDS ${spv_file} xxd
                        COMMENT "Converting to hpp: ${FILE_NAME} ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/xxd"
                        )
                else()
                    add_custom_command(
                        OUTPUT ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "/*THIS FILE HAS BEEN AUTOMATICALLY GENERATED - DO NOT EDIT*/" > ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#ifndef ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "namespace kp {" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "namespace shader_data {" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_BINARY_DIR}/bin/xxd -i ${RAW_FILE_NAME} >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo "}}" >> ${OUTPUT_HEADER_FILE}
                        COMMAND ${CMAKE_COMMAND} -E echo \"\#endif // define ${HEADER_FILE_DEFINE}\" >> ${OUTPUT_HEADER_FILE}
                        DEPENDS ${spv_file} xxd
                        COMMENT "Converting to hpp: ${FILE_NAME} ${CMAKE_BINARY_DIR}/bin/xxd"
                        )
                endif()
            endforeach()
        endfunction()

        set(KOMPUTE_OPT_BUILT_IN_VULKAN_HEADER_TAG "v1.3.239" CACHE STRING "Kompute Vulkan headers tag")
        set(KOMPUTE_OPT_LOG_LEVEL Critical CACHE STRING "Kompute log level")
        set(FMT_INSTALL OFF)
        add_subdirectory(${LLAMA_DIR}/ggml/src/kompute)

        # Compile our shaders
        compile_shader(SOURCES
            op_scale.comp
            op_scale_8.comp
            op_add.comp
            op_addrow.comp
            op_mul.comp
            op_silu.comp
            op_relu.comp
            op_gelu.comp
            op_softmax.comp
            op_norm.comp
            op_rmsnorm.comp
            op_diagmask.comp
            op_mul_mat_mat_f32.comp
            op_mul_mat_f16.comp
            op_mul_mat_q8_0.comp
            op_mul_mat_q4_0.comp
            op_mul_mat_q4_1.comp
            op_mul_mat_q6_k.comp
            op_getrows_f32.comp
            op_getrows_f16.comp
            op_getrows_q4_0.comp
            op_getrows_q4_1.comp
            op_getrows_q6_k.comp
            op_rope_f16.comp
            op_rope_f32.comp
            op_cpy_f16_f16.comp
            op_cpy_f16_f32.comp
            op_cpy_f32_f16.comp
            op_cpy_f32_f32.comp
        )

        # Create a custom target for our generated shaders
        add_custom_target(generated_shaders DEPENDS
            shaderop_scale.h
            shaderop_scale_8.h
            shaderop_add.h
            shaderop_addrow.h
            shaderop_mul.h
            shaderop_silu.h
            shaderop_relu.h
            shaderop_gelu.h
            shaderop_softmax.h
            shaderop_norm.h
            shaderop_rmsnorm.h
            shaderop_diagmask.h
            shaderop_mul_mat_mat_f32.h
            shaderop_mul_mat_f16.h
            shaderop_mul_mat_q8_0.h
            shaderop_mul_mat_q4_0.h
            shaderop_mul_mat_q4_1.h
            shaderop_mul_mat_q6_k.h
            shaderop_getrows_f32.h
            shaderop_getrows_f16.h
            shaderop_getrows_q4_0.h
            shaderop_getrows_q4_1.h
            shaderop_getrows_q6_k.h
            shaderop_rope_f16.h
            shaderop_rope_f32.h
            shaderop_cpy_f16_f16.h
            shaderop_cpy_f16_f32.h
            shaderop_cpy_f32_f16.h
            shaderop_cpy_f32_f32.h
        )

        # Create a custom command that depends on the generated_shaders
        add_custom_command(
            OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp
            COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp
            DEPENDS generated_shaders
            COMMENT "Ensuring shaders are generated before compiling ggml-kompute.cpp"
        )
    endif()

    if (GGML_KOMPUTE)
        list(APPEND GGML_COMPILE_DEFS VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1)

        # Add the stamp to the main sources to ensure dependency tracking
        set(GGML_SOURCES_KOMPUTE ${LLAMA_DIR}/ggml/src/ggml-kompute.cpp ${CMAKE_CURRENT_BINARY_DIR}/ggml-kompute.stamp)
        set(GGML_HEADERS_KOMPUTE ${LLAMA_DIR}/ggml/include/ggml-kompute.h)

        list(APPEND GGML_COMPILE_DEFS_PUBLIC GGML_USE_KOMPUTE)

        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} kompute)
    endif()

    set(CUDA_CXX_FLAGS "")

    if (GGML_CUDA)
        set(CUDA_FLAGS -use_fast_math)

        if (LLAMA_FATAL_WARNINGS)
            list(APPEND CUDA_FLAGS -Werror all-warnings)
        endif()

        if (LLAMA_ALL_WARNINGS AND NOT MSVC)
            set(NVCC_CMD ${CMAKE_CUDA_COMPILER} .c)
            if (NOT CMAKE_CUDA_HOST_COMPILER STREQUAL "")
                list(APPEND NVCC_CMD -ccbin ${CMAKE_CUDA_HOST_COMPILER})
            endif()

            execute_process(
                COMMAND ${NVCC_CMD} -Xcompiler --version
                OUTPUT_VARIABLE CUDA_CCFULLVER
                ERROR_QUIET
            )

            if (NOT CUDA_CCFULLVER MATCHES clang)
                set(CUDA_CCID "GNU")
                execute_process(
                    COMMAND ${NVCC_CMD} -Xcompiler "-dumpfullversion -dumpversion"
                    OUTPUT_VARIABLE CUDA_CCVER
                    OUTPUT_STRIP_TRAILING_WHITESPACE
                    ERROR_QUIET
                )
            else()
                if (CUDA_CCFULLVER MATCHES Apple)
                    set(CUDA_CCID "AppleClang")
                else()
                    set(CUDA_CCID "Clang")
                endif()
                string(REGEX REPLACE "^.* version ([0-9.]*).*$" "\\1" CUDA_CCVER ${CUDA_CCFULLVER})
            endif()

            message("-- CUDA host compiler is ${CUDA_CCID} ${CUDA_CCVER}")

            get_flags(${CUDA_CCID} ${CUDA_CCVER})
            list(APPEND CUDA_CXX_FLAGS ${CXX_FLAGS} ${GF_CXX_FLAGS})  # This is passed to -Xcompiler later
        endif()

        if (NOT MSVC)
            list(APPEND CUDA_CXX_FLAGS -Wno-pedantic)
        endif()
    endif()

    if (GGML_METAL)
        find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
        find_library(METAL_FRAMEWORK    Metal      REQUIRED)
        find_library(METALKIT_FRAMEWORK MetalKit   REQUIRED)

        message(STATUS "Metal framework found")
        set(GGML_HEADERS_METAL ${DIRECTORY}/ggml/include/ggml-metal.h)
        set(GGML_SOURCES_METAL ${DIRECTORY}/ggml/src/ggml-metal.m)

        list(APPEND GGML_COMPILE_DEFS_PUBLIC GGML_USE_METAL)
        if (GGML_METAL_NDEBUG)
            list(APPEND GGML_COMPILE_DEFS GGML_METAL_NDEBUG)
        endif()

        # copy ggml-common.h and ggml-metal.metal to bin directory
        configure_file(${DIRECTORY}/ggml/src/ggml-common.h    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-common.h    COPYONLY)
        configure_file(${DIRECTORY}/ggml/src/ggml-metal.metal ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.metal COPYONLY)

        if (GGML_METAL_SHADER_DEBUG)
            # custom command to do the following:
            #   xcrun -sdk macosx metal    -fno-fast-math -c ggml-metal.metal -o ggml-metal.air
            #   xcrun -sdk macosx metallib                   ggml-metal.air   -o default.metallib
            #
            # note: this is the only way I found to disable fast-math in Metal. it's ugly, but at least it works
            #       disabling fast math is needed in order to pass tests/test-backend-ops
            # note: adding -fno-inline fixes the tests when using MTL_SHADER_VALIDATION=1
            # note: unfortunately, we have to call it default.metallib instead of ggml.metallib
            #       ref: https://github.com/ggerganov/whisper.cpp/issues/1720
            set(XC_FLAGS -fno-fast-math -fno-inline -g)
        else()
            set(XC_FLAGS -O3)
        endif()

        # Append macOS metal versioning flags
        if (GGML_METAL_MACOSX_VERSION_MIN)
            message(STATUS "Adding -mmacosx-version-min=${GGML_METAL_MACOSX_VERSION_MIN} flag to metal compilation")
            list(APPEND XC_FLAGS -mmacosx-version-min=${GGML_METAL_MACOSX_VERSION_MIN})
        endif()
        if (GGML_METAL_STD)
            message(STATUS "Adding -std=${GGML_METAL_STD} flag to metal compilation")
            list(APPEND XC_FLAGS -std=${GGML_METAL_STD})
        endif()

        set(GGML_METALLIB "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/default.metallib")
        set(GGML_METALLIB "${GGML_METALLIB}" PARENT_SCOPE)
        add_custom_command(
            OUTPUT ${GGML_METALLIB}
            COMMAND xcrun -sdk macosx metal    ${XC_FLAGS} -c ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.metal -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.air
            COMMAND xcrun -sdk macosx metallib                ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.air   -o ${GGML_METALLIB}
            COMMAND rm -f ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.air
            COMMAND rm -f ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-common.h
            COMMAND rm -f ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-metal.metal
            DEPENDS ${DIRECTORY}/ggml/src/ggml-metal.metal ${DIRECTORY}/ggml/src/ggml-common.h
            COMMENT "Compiling Metal kernels"
            )

        add_custom_target(
            ggml-metal ALL
            DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/default.metallib
            )

        set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS}
            ${FOUNDATION_LIBRARY}
            ${METAL_FRAMEWORK}
            ${METALKIT_FRAMEWORK}
            )
    endif()

    set(ARCH_FLAGS "")

    if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" OR CMAKE_GENERATOR_PLATFORM_LWR STREQUAL "arm64" OR
        (NOT CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_GENERATOR_PLATFORM_LWR AND
         CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm.*|ARM64)$"))
        message(STATUS "ARM detected")
        if (MSVC)
            # TODO: arm msvc?
        else()
            check_cxx_compiler_flag(-mfp16-format=ieee COMPILER_SUPPORTS_FP16_FORMAT_I3E)
            if (NOT "${COMPILER_SUPPORTS_FP16_FORMAT_I3E}" STREQUAL "")
                list(APPEND ARCH_FLAGS -mfp16-format=ieee)
            endif()
            if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv6")
                # Raspberry Pi 1, Zero
                list(APPEND ARCH_FLAGS -mfpu=neon-fp-armv8 -mno-unaligned-access)
            endif()
            if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7")
                if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
                    # Android armeabi-v7a
                    list(APPEND ARCH_FLAGS -mfpu=neon-vfpv4 -mno-unaligned-access -funsafe-math-optimizations)
                else()
                    # Raspberry Pi 2
                    list(APPEND ARCH_FLAGS -mfpu=neon-fp-armv8 -mno-unaligned-access -funsafe-math-optimizations)
                endif()
            endif()
            if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv8")
                # Android arm64-v8a
                # Raspberry Pi 3, 4, Zero 2 (32-bit)
                list(APPEND ARCH_FLAGS -mno-unaligned-access)
            endif()
        endif()
    elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR CMAKE_GENERATOR_PLATFORM_LWR MATCHES "^(x86_64|i686|amd64|x64|win32)$" OR
            (NOT CMAKE_OSX_ARCHITECTURES AND NOT CMAKE_GENERATOR_PLATFORM_LWR AND
             CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|i686|AMD64)$"))
        message(STATUS "x86 detected")
        if (MSVC)
            if (GGML_AVX512)
                list(APPEND ARCH_FLAGS /arch:AVX512)
                # MSVC has no compile-time flags enabling specific
                # AVX512 extensions, neither it defines the
                # macros corresponding to the extensions.
                # Do it manually.
                if (GGML_AVX512_VBMI)
                    list(APPEND GGML_COMPILE_DEFS $<$<COMPILE_LANGUAGE:C>:__AVX512VBMI__>)
                    list(APPEND GGML_COMPILE_DEFS $<$<COMPILE_LANGUAGE:CXX>:__AVX512VBMI__>)
                endif()
                if (GGML_AVX512_VNNI)
                    list(APPEND GGML_COMPILE_DEFS $<$<COMPILE_LANGUAGE:C>:__AVX512VNNI__>)
                    list(APPEND GGML_COMPILE_DEFS $<$<COMPILE_LANGUAGE:CXX>:__AVX512VNNI__>)
                endif()
            elseif (GGML_AVX2)
                list(APPEND ARCH_FLAGS /arch:AVX2)
            elseif (GGML_AVX)
                list(APPEND ARCH_FLAGS /arch:AVX)
            endif()
        else()
            if (GGML_NATIVE)
                list(APPEND ARCH_FLAGS -march=native)
            endif()
            if (GGML_F16C)
                list(APPEND ARCH_FLAGS -mf16c)
            endif()
            if (GGML_FMA)
                list(APPEND ARCH_FLAGS -mfma)
            endif()
            if (GGML_AVX)
                list(APPEND ARCH_FLAGS -mavx)
            endif()
            if (GGML_AVX2)
                list(APPEND ARCH_FLAGS -mavx2)
            endif()
            if (GGML_AVX512)
                list(APPEND ARCH_FLAGS -mavx512f)
                list(APPEND ARCH_FLAGS -mavx512bw)
            endif()
            if (GGML_AVX512_VBMI)
                list(APPEND ARCH_FLAGS -mavx512vbmi)
            endif()
            if (GGML_AVX512_VNNI)
                list(APPEND ARCH_FLAGS -mavx512vnni)
            endif()
        endif()
    elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64")
        message(STATUS "PowerPC detected")
        if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "ppc64le")
            list(APPEND ARCH_FLAGS -mcpu=powerpc64le)
        else()
            list(APPEND ARCH_FLAGS -mcpu=native -mtune=native)
            #TODO: Add  targets for Power8/Power9 (Altivec/VSX) and Power10(MMA) and query for big endian systems (ppc64/le/be)
        endif()
    else()
        message(STATUS "Unknown architecture")
    endif()

    list(APPEND GGML_COMPILE_OPTS "$<$<COMPILE_LANGUAGE:CXX>:${ARCH_FLAGS}>")
    list(APPEND GGML_COMPILE_OPTS "$<$<COMPILE_LANGUAGE:C>:${ARCH_FLAGS}>")

    if (GGML_CUDA)
        list(APPEND CUDA_CXX_FLAGS ${ARCH_FLAGS})
        list(JOIN CUDA_CXX_FLAGS " " CUDA_CXX_FLAGS_JOINED)  # pass host compiler flags as a single argument
        if (NOT CUDA_CXX_FLAGS_JOINED STREQUAL "")
            list(APPEND CUDA_FLAGS -Xcompiler ${CUDA_CXX_FLAGS_JOINED})
        endif()
        list(APPEND GGML_COMPILE_OPTS "$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>")
    endif()

    # ggml

    add_library(ggml${SUFFIX} OBJECT
                ${DIRECTORY}/ggml/include/ggml.h
                ${DIRECTORY}/ggml/include/ggml-alloc.h
                ${DIRECTORY}/ggml/include/ggml-backend.h
                ${DIRECTORY}/ggml/src/ggml.c
                ${DIRECTORY}/ggml/src/ggml-alloc.c
                ${DIRECTORY}/ggml/src/ggml-backend.c
                ${DIRECTORY}/ggml/src/ggml-quants.c
                ${DIRECTORY}/ggml/src/ggml-quants.h
                ${GGML_SOURCES_CUDA}      ${GGML_HEADERS_CUDA}
                ${GGML_SOURCES_METAL}     ${GGML_HEADERS_METAL}
                ${GGML_SOURCES_KOMPUTE}   ${GGML_HEADERS_KOMPUTE}
                ${GGML_SOURCES_VULKAN}    ${GGML_HEADERS_VULKAN}
                ${GGML_SOURCES_ROCM}      ${GGML_HEADERS_ROCM}
                ${GGML_SOURCES_LLAMAFILE} ${GGML_HEADERS_LLAMAFILE}
                ${DIRECTORY}/ggml/src/ggml-aarch64.c
                ${DIRECTORY}/ggml/src/ggml-aarch64.h
                )

    target_include_directories(ggml${SUFFIX} PUBLIC ${DIRECTORY}/ggml/include ${LLAMA_EXTRA_INCLUDES})
    target_include_directories(ggml${SUFFIX} PRIVATE ${DIRECTORY}/ggml/src)
    target_compile_features(ggml${SUFFIX} PUBLIC c_std_11) # don't bump

    target_link_libraries(ggml${SUFFIX} PUBLIC Threads::Threads ${LLAMA_EXTRA_LIBS})

    if (BUILD_SHARED_LIBS)
        set_target_properties(ggml${SUFFIX} PROPERTIES POSITION_INDEPENDENT_CODE ON)
    endif()

    # llama

    add_library(llama${SUFFIX} STATIC
                ${DIRECTORY}/include/llama.h
                ${DIRECTORY}/src/llama-grammar.cpp
                ${DIRECTORY}/src/llama-sampling.cpp
                ${DIRECTORY}/src/llama-vocab.cpp
                ${DIRECTORY}/src/llama.cpp
                ${DIRECTORY}/src/unicode-data.cpp
                ${DIRECTORY}/src/unicode.cpp
                ${DIRECTORY}/src/unicode.h
                )

    target_include_directories(llama${SUFFIX} PUBLIC  ${DIRECTORY}/include ${DIRECTORY}/ggml/include)
    target_include_directories(llama${SUFFIX} PRIVATE ${DIRECTORY}/src)
    target_compile_features   (llama${SUFFIX} PUBLIC cxx_std_11) # don't bump

    target_link_libraries(llama${SUFFIX} PRIVATE
        ggml${SUFFIX}
        ${LLAMA_EXTRA_LIBS}
        )

    if (BUILD_SHARED_LIBS)
        set_target_properties(llama${SUFFIX} PROPERTIES POSITION_INDEPENDENT_CODE ON)
        target_compile_definitions(llama${SUFFIX} PRIVATE LLAMA_SHARED LLAMA_BUILD)
    endif()

    # target options

    set_target_properties(ggml${SUFFIX} llama${SUFFIX} PROPERTIES
        CXX_STANDARD 11
        CXX_STANDARD_REQUIRED true
        C_STANDARD 11
        C_STANDARD_REQUIRED true
        )

    target_compile_options(ggml${SUFFIX} PRIVATE "${GGML_COMPILE_OPTS}")
    target_compile_options(llama${SUFFIX} PRIVATE "${GGML_COMPILE_OPTS}")

    target_compile_definitions(ggml${SUFFIX} PRIVATE "${GGML_COMPILE_DEFS}")
    target_compile_definitions(llama${SUFFIX} PRIVATE "${GGML_COMPILE_DEFS}")

    target_compile_definitions(ggml${SUFFIX} PUBLIC "${GGML_COMPILE_DEFS_PUBLIC}")
    target_compile_definitions(llama${SUFFIX} PUBLIC "${GGML_COMPILE_DEFS_PUBLIC}")

    target_link_options(ggml${SUFFIX} PRIVATE "${GGML_LINK_OPTS}")
    target_link_options(llama${SUFFIX} PRIVATE "${GGML_LINK_OPTS}")
endfunction()


================================================
FILE: gpt4all-backend/src/dlhandle.cpp
================================================
#include "dlhandle.h"

#include <string>

#ifndef _WIN32
#   include <dlfcn.h>
#else
#   include <cassert>
#   include <sstream>
#   define WIN32_LEAN_AND_MEAN
#   ifndef NOMINMAX
#       define NOMINMAX
#   endif
#   include <windows.h>
#endif

using namespace std::strin
Download .txt
gitextract_o3o4fycr/

├── .circleci/
│   ├── config.yml
│   ├── continue_config.yml
│   └── grab_notary_id.py
├── .codespellrc
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bindings-bug.md
│   │   ├── chat-bug.md
│   │   ├── config.yml
│   │   ├── documentation.md
│   │   ├── feature-request.md
│   │   └── other-bug.md
│   ├── pull_request_template.md
│   └── workflows/
│       ├── close_issues.yml
│       └── codespell.yml
├── .gitignore
├── .gitmodules
├── CONTRIBUTING.md
├── LICENSE.txt
├── MAINTAINERS.md
├── README.md
├── common/
│   └── common.cmake
├── gpt4all-backend/
│   ├── CMakeLists.txt
│   ├── README.md
│   ├── include/
│   │   └── gpt4all-backend/
│   │       ├── llmodel.h
│   │       ├── llmodel_c.h
│   │       └── sysinfo.h
│   ├── llama.cpp.cmake
│   └── src/
│       ├── dlhandle.cpp
│       ├── dlhandle.h
│       ├── llamamodel.cpp
│       ├── llamamodel_impl.h
│       ├── llmodel.cpp
│       ├── llmodel_c.cpp
│       ├── llmodel_shared.cpp
│       └── utils.h
├── gpt4all-bindings/
│   ├── README.md
│   ├── cli/
│   │   ├── README.md
│   │   ├── app.py
│   │   └── developer_notes.md
│   ├── python/
│   │   ├── .gitignore
│   │   ├── .isort.cfg
│   │   ├── CHANGELOG.md
│   │   ├── LICENSE.txt
│   │   ├── MANIFEST.in
│   │   ├── README.md
│   │   ├── docs/
│   │   │   ├── css/
│   │   │   │   └── custom.css
│   │   │   ├── gpt4all_api_server/
│   │   │   │   └── home.md
│   │   │   ├── gpt4all_desktop/
│   │   │   │   ├── chat_templates.md
│   │   │   │   ├── chats.md
│   │   │   │   ├── cookbook/
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-Obsidian.md
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-One-Drive.md
│   │   │   │   │   ├── use-local-ai-models-to-privately-chat-with-google-drive.md
│   │   │   │   │   └── use-local-ai-models-to-privately-chat-with-microsoft-excel.md
│   │   │   │   ├── localdocs.md
│   │   │   │   ├── models.md
│   │   │   │   ├── quickstart.md
│   │   │   │   └── settings.md
│   │   │   ├── gpt4all_help/
│   │   │   │   ├── faq.md
│   │   │   │   └── troubleshooting.md
│   │   │   ├── gpt4all_python/
│   │   │   │   ├── home.md
│   │   │   │   ├── monitoring.md
│   │   │   │   └── ref.md
│   │   │   ├── index.md
│   │   │   └── old/
│   │   │       ├── gpt4all_chat.md
│   │   │       ├── gpt4all_cli.md
│   │   │       ├── gpt4all_faq.md
│   │   │       ├── gpt4all_monitoring.md
│   │   │       ├── gpt4all_nodejs.md
│   │   │       ├── gpt4all_python.md
│   │   │       ├── gpt4all_python_embedding.md
│   │   │       └── index.md
│   │   ├── gpt4all/
│   │   │   ├── __init__.py
│   │   │   ├── _pyllmodel.py
│   │   │   ├── gpt4all.py
│   │   │   └── tests/
│   │   │       ├── __init__.py
│   │   │       ├── test_embed_timings.py
│   │   │       └── test_gpt4all.py
│   │   ├── makefile
│   │   ├── mkdocs.yml
│   │   └── setup.py
│   └── typescript/
│       ├── .clang-format
│       ├── .gitignore
│       ├── .npmignore
│       ├── .yarnrc.yml
│       ├── README.md
│       ├── binding.ci.gyp
│       ├── binding.gyp
│       ├── index.cc
│       ├── index.h
│       ├── package.json
│       ├── prompt.cc
│       ├── prompt.h
│       ├── scripts/
│       │   ├── build.js
│       │   ├── docs.js
│       │   ├── mkclangd.js
│       │   └── prebuild.js
│       ├── spec/
│       │   ├── callbacks.mjs
│       │   ├── chat-memory.mjs
│       │   ├── chat-minimal.mjs
│       │   ├── concurrency.mjs
│       │   ├── embed-jsonl.mjs
│       │   ├── embed.mjs
│       │   ├── llmodel.mjs
│       │   ├── long-context.mjs
│       │   ├── model-switching.mjs
│       │   ├── stateless.mjs
│       │   ├── streaming.mjs
│       │   └── system.mjs
│       ├── src/
│       │   ├── chat-session.js
│       │   ├── config.js
│       │   ├── gpt4all.d.ts
│       │   ├── gpt4all.js
│       │   ├── models.js
│       │   └── util.js
│       └── test/
│           ├── gpt4all.test.js
│           └── models.json
├── gpt4all-chat/
│   ├── .flake8
│   ├── CHANGELOG.md
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── cmake/
│   │   ├── Modules/
│   │   │   ├── SignMacOSBinaries.cmake
│   │   │   └── SignWindowsBinaries.cmake
│   │   ├── cpack-steal-config.cmake.in
│   │   ├── cpack_config.cmake
│   │   ├── deploy-qt-linux.cmake.in
│   │   ├── deploy-qt-mac.cmake.in
│   │   ├── deploy-qt-windows.cmake.in
│   │   ├── download_model.cmake
│   │   ├── installer_control.qs
│   │   ├── installer_gpt4all_component.qs
│   │   ├── installer_maintenancetool_component.qs
│   │   └── sign_dmg.py
│   ├── contributing_translations.md
│   ├── deps/
│   │   └── CMakeLists.txt
│   ├── dev-requirements.txt
│   ├── flatpak-manifest/
│   │   ├── io.gpt4all.gpt4all.appdata.xml
│   │   └── io.gpt4all.gpt4all.desktop
│   ├── main.qml
│   ├── metadata/
│   │   ├── latestnews.md
│   │   ├── models.json
│   │   ├── models2.json
│   │   ├── models3.json
│   │   └── release.json
│   ├── pyproject.toml
│   ├── qa_checklist.md
│   ├── qml/
│   │   ├── AddCollectionView.qml
│   │   ├── AddGPT4AllModelView.qml
│   │   ├── AddHFModelView.qml
│   │   ├── AddModelView.qml
│   │   ├── AddRemoteModelView.qml
│   │   ├── ApplicationSettings.qml
│   │   ├── ChatCollapsibleItem.qml
│   │   ├── ChatDrawer.qml
│   │   ├── ChatItemView.qml
│   │   ├── ChatMessageButton.qml
│   │   ├── ChatTextItem.qml
│   │   ├── ChatView.qml
│   │   ├── CollectionsDrawer.qml
│   │   ├── ConfirmationDialog.qml
│   │   ├── HomeView.qml
│   │   ├── LocalDocsSettings.qml
│   │   ├── LocalDocsView.qml
│   │   ├── ModelSettings.qml
│   │   ├── ModelsView.qml
│   │   ├── MyBusyIndicator.qml
│   │   ├── MyButton.qml
│   │   ├── MyCheckBox.qml
│   │   ├── MyComboBox.qml
│   │   ├── MyDialog.qml
│   │   ├── MyDirectoryField.qml
│   │   ├── MyFancyLink.qml
│   │   ├── MyFileDialog.qml
│   │   ├── MyFileIcon.qml
│   │   ├── MyFolderDialog.qml
│   │   ├── MyMenu.qml
│   │   ├── MyMenuItem.qml
│   │   ├── MyMiniButton.qml
│   │   ├── MySettingsButton.qml
│   │   ├── MySettingsDestructiveButton.qml
│   │   ├── MySettingsLabel.qml
│   │   ├── MySettingsStack.qml
│   │   ├── MySettingsTab.qml
│   │   ├── MySlug.qml
│   │   ├── MyTabButton.qml
│   │   ├── MyTextArea.qml
│   │   ├── MyTextButton.qml
│   │   ├── MyTextField.qml
│   │   ├── MyToolButton.qml
│   │   ├── MyWelcomeButton.qml
│   │   ├── NetworkDialog.qml
│   │   ├── NewVersionDialog.qml
│   │   ├── PopupDialog.qml
│   │   ├── RemoteModelCard.qml
│   │   ├── SettingsView.qml
│   │   ├── StartupDialog.qml
│   │   ├── Theme.qml
│   │   ├── ThumbsDownDialog.qml
│   │   ├── Toast.qml
│   │   └── ToastManager.qml
│   ├── resources/
│   │   ├── gpt4all.icns
│   │   └── gpt4all.rc
│   ├── src/
│   │   ├── chat.cpp
│   │   ├── chat.h
│   │   ├── chatapi.cpp
│   │   ├── chatapi.h
│   │   ├── chatlistmodel.cpp
│   │   ├── chatlistmodel.h
│   │   ├── chatllm.cpp
│   │   ├── chatllm.h
│   │   ├── chatmodel.cpp
│   │   ├── chatmodel.h
│   │   ├── chatviewtextprocessor.cpp
│   │   ├── chatviewtextprocessor.h
│   │   ├── codeinterpreter.cpp
│   │   ├── codeinterpreter.h
│   │   ├── config.h.in
│   │   ├── database.cpp
│   │   ├── database.h
│   │   ├── download.cpp
│   │   ├── download.h
│   │   ├── embllm.cpp
│   │   ├── embllm.h
│   │   ├── jinja_helpers.cpp
│   │   ├── jinja_helpers.h
│   │   ├── jinja_replacements.cpp
│   │   ├── jinja_replacements.h
│   │   ├── llm.cpp
│   │   ├── llm.h
│   │   ├── localdocs.cpp
│   │   ├── localdocs.h
│   │   ├── localdocsmodel.cpp
│   │   ├── localdocsmodel.h
│   │   ├── logger.cpp
│   │   ├── logger.h
│   │   ├── macosdock.h
│   │   ├── macosdock.mm
│   │   ├── main.cpp
│   │   ├── modellist.cpp
│   │   ├── modellist.h
│   │   ├── mysettings.cpp
│   │   ├── mysettings.h
│   │   ├── network.cpp
│   │   ├── network.h
│   │   ├── server.cpp
│   │   ├── server.h
│   │   ├── tool.cpp
│   │   ├── tool.h
│   │   ├── toolcallparser.cpp
│   │   ├── toolcallparser.h
│   │   ├── toolmodel.cpp
│   │   ├── toolmodel.h
│   │   ├── utils.h
│   │   ├── utils.inl
│   │   ├── xlsxtomd.cpp
│   │   └── xlsxtomd.h
│   ├── system_requirements.md
│   ├── test-requirements.txt
│   ├── tests/
│   │   ├── CMakeLists.txt
│   │   ├── cpp/
│   │   │   ├── basic_test.cpp
│   │   │   └── test_main.cpp
│   │   └── python/
│   │       ├── __init__.py
│   │       ├── config.py.in
│   │       └── test_server_api.py
│   └── translations/
│       ├── gpt4all_en_US.ts
│       ├── gpt4all_es_MX.ts
│       ├── gpt4all_it_IT.ts
│       ├── gpt4all_pt_BR.ts
│       ├── gpt4all_ro_RO.ts
│       ├── gpt4all_zh_CN.ts
│       └── gpt4all_zh_TW.ts
├── gpt4all-training/
│   ├── GPT-J_MAP.md
│   ├── README.md
│   ├── TRAINING_LOG.md
│   ├── clean.py
│   ├── configs/
│   │   ├── deepspeed/
│   │   │   ├── ds_config.json
│   │   │   ├── ds_config_gptj.json
│   │   │   ├── ds_config_gptj_lora.json
│   │   │   ├── ds_config_mpt.json
│   │   │   └── ds_config_pythia.json
│   │   ├── eval/
│   │   │   ├── generate_baseline.yaml
│   │   │   ├── generate_gpt4all_gptj.yaml
│   │   │   ├── generate_gpt4all_gptj_lora.yaml
│   │   │   └── generate_gpt4all_llama_lora.yaml
│   │   ├── generate/
│   │   │   ├── generate.yaml
│   │   │   ├── generate_gptj.yaml
│   │   │   ├── generate_gptj_lora.yaml
│   │   │   └── generate_llama.yaml
│   │   ├── inference/
│   │   │   └── gptj.yaml
│   │   └── train/
│   │       ├── finetune.yaml
│   │       ├── finetune_falcon.yaml
│   │       ├── finetune_gptj.yaml
│   │       ├── finetune_gptj_lora.yaml
│   │       ├── finetune_lora.yaml
│   │       ├── finetune_mpt.yaml
│   │       └── finetune_openllama.yaml
│   ├── create_hostname.sh
│   ├── data.py
│   ├── env.yaml
│   ├── eval_figures.py
│   ├── eval_self_instruct.py
│   ├── generate.py
│   ├── inference.py
│   ├── launcher.sh
│   ├── old-README.md
│   ├── read.py
│   ├── requirements.txt
│   └── train.py
└── roadmap.md
Download .txt
SYMBOL INDEX (647 symbols across 83 files)

FILE: .circleci/grab_notary_id.py
  function main (line 6) | def main() -> None:

FILE: gpt4all-backend/include/gpt4all-backend/llmodel.h
  function class (line 25) | class LLModel {
  function class (line 46) | class MissingImplementationError: public std::runtime_error {
  function class (line 51) | class UnsupportedModelError: public std::runtime_error {
  function backendIdToName (line 56) | struct GPUDevice {
  function std (line 78) | static std::string updateSelectionName(const std::string &name) {
  function class (line 95) | class Implementation {
  type PromptContext (line 132) | struct PromptContext {
  function explicit (line 144) | explicit LLModel() {}
  function virtual (line 145) | virtual ~LLModel() {}
  function virtual (line 147) | virtual bool supportsEmbedding() const = 0;
  function virtual (line 151) | virtual bool isEmbeddingModel(const std::string &modelPath) const { (voi...
  function virtual (line 152) | virtual bool isModelLoaded() const = 0;
  function virtual (line 185) | virtual std::vector<GPUDevice> availableGPUDevices(size_t memoryRequired...
  function virtual (line 190) | virtual bool initializeGPUDevice(size_t memoryRequired, const std::strin...
  function virtual (line 205) | virtual const char *backendName() const { return "cpu"; }
  function virtual (line 206) | virtual const char *gpuDeviceName() const { return nullptr; }
  function setProgressCallback (line 208) | void setProgressCallback(ProgressCallback callback) { m_progressCallback...
  function virtual (line 210) | virtual int32_t contextLength() const = 0;
  function virtual (line 237) | virtual int32_t layerCount(std::string const &modelPath) const
  function virtual (line 243) | virtual auto chatTemplate(const char *modelPath) const -> std::expected<...
  function staticProgressCallback (line 252) | static bool staticProgressCallback(float progress, void* ctx)

FILE: gpt4all-backend/include/gpt4all-backend/llmodel_c.h
  type token_t (line 29) | typedef int32_t token_t;
  type llmodel_prompt_context (line 37) | struct llmodel_prompt_context {
  type llmodel_gpu_device (line 49) | struct llmodel_gpu_device {
  type llmodel_prompt_context (line 59) | typedef struct llmodel_prompt_context llmodel_prompt_context;
  type llmodel_gpu_device (line 60) | typedef struct llmodel_gpu_device llmodel_gpu_device;
  type llmodel_gpu_device (line 266) | struct llmodel_gpu_device

FILE: gpt4all-backend/include/gpt4all-backend/sysinfo.h
  function getSystemTotalRAMInBytes (line 22) | static long long getSystemTotalRAMInBytes()
  function getSystemTotalRAMInGB (line 53) | static double getSystemTotalRAMInGB()
  function std (line 58) | static std::string getSystemTotalRAMInGBString()

FILE: gpt4all-backend/src/dlhandle.h
  function class (line 11) | class Dlhandle {

FILE: gpt4all-backend/src/llamamodel.cpp
  function is_embedding_arch (line 99) | static bool is_embedding_arch(const std::string &arch)
  function llama_verbose (line 104) | static bool llama_verbose()
  function llama_log_callback (line 110) | static void llama_log_callback(ggml_log_level level, const char *text, v...
  type gpt_params (line 137) | struct gpt_params {
    type ggml_type (line 146) | enum ggml_type
  type gguf_type (line 158) | enum gguf_type
  function gguf_context (line 165) | static gguf_context *load_gguf(const char *fname)
  function get_arch_key_u32 (line 187) | static int32_t get_arch_key_u32(std::string const &modelPath, std::strin...
  type LLamaPrivate (line 217) | struct LLamaPrivate {
  type llama_file_hparams (line 241) | struct llama_file_hparams {
    type llama_ftype (line 248) | enum llama_ftype
  type llama_sampler (line 585) | struct llama_sampler
  type gguf_type (line 738) | enum gguf_type
  function llama_batch_add (line 921) | void llama_batch_add(
  function batch_add_seq (line 938) | static void batch_add_seq(llama_batch &batch, const std::vector<LLModel:...
  type EmbModelSpec (line 950) | struct EmbModelSpec {
  type EmbModelGroup (line 958) | struct EmbModelGroup {
  function EmbModelSpec (line 997) | static const EmbModelSpec *getEmbedSpec(const std::string &modelName) {
  function product (line 1066) | auto product(double a) -> std::function<double(double)>
  function getL2NormScale (line 1072) | double getL2NormScale(T *start, T *end)
  type split_batch (line 1157) | struct split_batch { unsigned idx; TokenString batch; }
  type llama_batch (line 1194) | struct llama_batch
  function DLL_EXPORT (line 1284) | DLL_EXPORT bool is_g4a_backend_model_implementation()
  function DLL_EXPORT (line 1289) | DLL_EXPORT const char *get_model_type()
  function DLL_EXPORT (line 1294) | DLL_EXPORT const char *get_build_variant()
  function DLL_EXPORT (line 1299) | DLL_EXPORT char *get_file_arch(const char *fname)
  function DLL_EXPORT (line 1325) | DLL_EXPORT bool is_arch_supported(const char *arch)
  function DLL_EXPORT (line 1330) | DLL_EXPORT LLModel *construct()

FILE: gpt4all-backend/src/llamamodel_impl.h
  type LLamaPrivate (line 16) | struct LLamaPrivate
  type EmbModelSpec (line 17) | struct EmbModelSpec
  function class (line 19) | class LLamaModel : public LLModel {

FILE: gpt4all-backend/src/llmodel.cpp
  function get_cpu_info (line 53) | static int get_cpu_info(int func_id, int reg_id) {
  function isImplementation (line 100) | static bool isImplementation(const Dlhandle &dl)
  function addCudaSearchPath (line 107) | static void addCudaSearchPath()
  function applyCPUVariant (line 181) | static std::string applyCPUVariant(const std::string &buildVariant)
  function LLModel (line 214) | LLModel *LLModel::Implementation::construct(const std::string &modelPath...
  function LLModel (line 255) | LLModel *LLModel::Implementation::constructGlobalLlama(const std::option...

FILE: gpt4all-backend/src/llmodel_c.cpp
  type LLModelWrapper (line 22) | struct LLModelWrapper {
  function llmodel_model (line 27) | llmodel_model llmodel_model_create(const char *model_path)
  function llmodel_set_error (line 37) | static void llmodel_set_error(const char **errptr, const char *message)
  function llmodel_model (line 46) | llmodel_model llmodel_model_create2(const char *model_path, const char *...
  function llmodel_model_destroy (line 61) | void llmodel_model_destroy(llmodel_model model)
  function llmodel_required_mem (line 66) | size_t llmodel_required_mem(llmodel_model model, const char *model_path,...
  function llmodel_loadModel (line 72) | bool llmodel_loadModel(llmodel_model model, const char *model_path, int ...
  function llmodel_isModelLoaded (line 85) | bool llmodel_isModelLoaded(llmodel_model model)
  function llmodel_state_get_size (line 91) | uint64_t llmodel_state_get_size(llmodel_model model)
  function llmodel_state_get_data (line 97) | uint64_t llmodel_state_get_data(llmodel_model model, uint8_t *state_out,...
  function llmodel_state_free_input_tokens (line 115) | void llmodel_state_free_input_tokens(LLModel::Token *input_tokens)
  function llmodel_state_set_data (line 120) | uint64_t llmodel_state_set_data(llmodel_model model, const uint8_t *stat...
  function llmodel_prompt (line 127) | bool llmodel_prompt(llmodel_model               model,
  function llmodel_free_embedding (line 205) | void llmodel_free_embedding(float *ptr)
  function llmodel_setThreadCount (line 210) | void llmodel_setThreadCount(llmodel_model model, int32_t n_threads)
  function llmodel_threadCount (line 216) | int32_t llmodel_threadCount(llmodel_model model)
  function llmodel_set_implementation_search_path (line 222) | void llmodel_set_implementation_search_path(const char *path)
  type llmodel_gpu_device_cpp (line 233) | struct llmodel_gpu_device_cpp: llmodel_gpu_device {
    method llmodel_gpu_device_cpp (line 234) | llmodel_gpu_device_cpp() = default;
    method llmodel_gpu_device_cpp (line 236) | llmodel_gpu_device_cpp(const llmodel_gpu_device_cpp  &) = delete;
    method llmodel_gpu_device_cpp (line 237) | llmodel_gpu_device_cpp(      llmodel_gpu_device_cpp &&) = delete;
    method llmodel_gpu_device_cpp (line 239) | const llmodel_gpu_device_cpp &operator=(const llmodel_gpu_device_cpp  ...
    method llmodel_gpu_device_cpp (line 240) | llmodel_gpu_device_cpp &operator=(      llmodel_gpu_device_cpp &&) = d...
  type llmodel_gpu_device (line 250) | struct llmodel_gpu_device
  function llmodel_gpu_init_gpu_device_by_string (line 274) | bool llmodel_gpu_init_gpu_device_by_string(llmodel_model model, size_t m...
  function llmodel_gpu_init_gpu_device_by_struct (line 280) | bool llmodel_gpu_init_gpu_device_by_struct(llmodel_model model, const ll...
  function llmodel_gpu_init_gpu_device_by_int (line 286) | bool llmodel_gpu_init_gpu_device_by_int(llmodel_model model, int device)
  function llmodel_count_prompt_tokens (line 304) | int32_t llmodel_count_prompt_tokens(llmodel_model model, const char *pro...
  function llmodel_model_foreach_special_token (line 315) | void llmodel_model_foreach_special_token(llmodel_model model, llmodel_sp...

FILE: gpt4all-backend/src/llmodel_shared.cpp
  function stringsOverlap (line 130) | static std::string::size_type stringsOverlap(const std::string &s, const...

FILE: gpt4all-bindings/cli/app.py
  function repl (line 53) | def repl(
  function _old_loop (line 99) | def _old_loop(gpt4all_instance):
  function _new_loop (line 135) | def _new_loop(gpt4all_instance):
  function version (line 178) | def version():

FILE: gpt4all-bindings/python/gpt4all/_pyllmodel.py
  function _operator_call (line 36) | def _operator_call(obj: Callable[P, T], /, *args: P.args, **kwargs: P.kw...
  function check_rosetta (line 42) | def check_rosetta() -> None:
  function find_cuda (line 67) | def find_cuda() -> None:
  function load_llmodel_library (line 101) | def load_llmodel_library():
  class LLModelPromptContext (line 119) | class LLModelPromptContext(ctypes.Structure):
  class LLModelGPUDevice (line 133) | class LLModelGPUDevice(ctypes.Structure):
  function empty_response_callback (line 235) | def empty_response_callback(token_id: int, response: str) -> bool:
  class Sentinel (line 240) | class Sentinel(Enum):
  class EmbedResult (line 244) | class EmbedResult(Generic[EmbeddingsType], TypedDict):
  class CancellationError (line 249) | class CancellationError(Exception):
  class LLModel (line 253) | class LLModel:
    method __init__ (line 270) | def __init__(self, model_path: str, n_ctx: int, ngl: int, backend: str):
    method __del__ (line 298) | def __del__(self, llmodel=llmodel):
    method close (line 302) | def close(self) -> None:
    method _raise_closed (line 307) | def _raise_closed(self) -> NoReturn:
    method backend (line 311) | def backend(self) -> Literal["cpu", "kompute", "cuda", "metal"]:
    method device (line 317) | def device(self) -> str | None:
    method count_prompt_tokens (line 323) | def count_prompt_tokens(self, prompt: str) -> int:
    method list_gpus (line 337) | def list_gpus(mem_required: int = 0) -> list[str]:
    method init_gpu (line 353) | def init_gpu(self, device: str):
    method load_model (line 372) | def load_model(self) -> bool:
    method set_thread_count (line 385) | def set_thread_count(self, n_threads):
    method thread_count (line 392) | def thread_count(self):
    method generate_embeddings (line 400) | def generate_embeddings(
    method generate_embeddings (line 405) | def generate_embeddings(
    method generate_embeddings (line 410) | def generate_embeddings(
    method generate_embeddings (line 415) | def generate_embeddings(
    method prompt_model (line 466) | def prompt_model(
    method prompt_model_streaming (line 531) | def prompt_model_streaming(
    method _callback_decoder (line 572) | def _callback_decoder(self, callback: ResponseCallbackType) -> RawResp...
    method _prompt_callback (line 615) | def _prompt_callback(token_ids: ctypes._Pointer[ctypes.c_int32], n_tok...

FILE: gpt4all-bindings/python/gpt4all/gpt4all.py
  function _jinja_env (line 42) | def _jinja_env() -> ImmutableSandboxedEnvironment:
  class MessageType (line 59) | class MessageType(TypedDict):
  class ChatSession (line 64) | class ChatSession(NamedTuple):
  class Embed4All (line 69) | class Embed4All:
    method __init__ (line 76) | def __init__(self, model_name: str | None = None, *, n_threads: int | ...
    method __enter__ (line 89) | def __enter__(self) -> Self:
    method __exit__ (line 92) | def __exit__(
    method close (line 97) | def close(self) -> None:
    method embed (line 103) | def embed(
    method embed (line 108) | def embed(
    method embed (line 113) | def embed(
    method embed (line 121) | def embed(
    method embed (line 126) | def embed(
    method embed (line 131) | def embed(
    method embed (line 139) | def embed(
    method embed (line 145) | def embed(
  class GPT4All (line 191) | class GPT4All:
    method __init__ (line 196) | def __init__(
    method __enter__ (line 271) | def __enter__(self) -> Self:
    method __exit__ (line 274) | def __exit__(
    method close (line 279) | def close(self) -> None:
    method backend (line 284) | def backend(self) -> Literal["cpu", "kompute", "cuda", "metal"]:
    method device (line 289) | def device(self) -> str | None:
    method current_chat_session (line 294) | def current_chat_session(self) -> list[MessageType] | None:
    method current_chat_session (line 298) | def current_chat_session(self, history: list[MessageType]) -> None:
    method list_models (line 304) | def list_models() -> list[ConfigType]:
    method retrieve_model (line 317) | def retrieve_model(
    method download_model (line 378) | def download_model(
    method generate (line 494) | def generate(
    method generate (line 500) | def generate(
    method generate (line 506) | def generate(
    method generate (line 512) | def generate(
    method chat_session (line 602) | def chat_session(
    method list_gpus (line 641) | def list_gpus() -> list[str]:
  function append_extension_if_missing (line 651) | def append_extension_if_missing(model_name):
  class _HasFileno (line 657) | class _HasFileno(Protocol):
    method fileno (line 658) | def fileno(self) -> int: ...
  function _fsync (line 661) | def _fsync(fd: int | _HasFileno) -> None:
  function _remove_prefix (line 673) | def _remove_prefix(s: str, prefix: str) -> str:

FILE: gpt4all-bindings/python/gpt4all/tests/test_embed_timings.py
  function time_embedding (line 9) | def time_embedding(i, embedder):

FILE: gpt4all-bindings/python/gpt4all/tests/test_gpt4all.py
  function test_inference (line 10) | def test_inference():
  function do_long_input (line 36) | def do_long_input(model):
  function test_inference_long_orca_3b (line 45) | def test_inference_long_orca_3b():
  function test_inference_long_falcon (line 50) | def test_inference_long_falcon():
  function test_inference_long_llama_7b (line 55) | def test_inference_long_llama_7b():
  function test_inference_long_llama_13b (line 60) | def test_inference_long_llama_13b():
  function test_inference_long_mpt (line 65) | def test_inference_long_mpt():
  function test_inference_long_replit (line 70) | def test_inference_long_replit():
  function test_inference_hparams (line 75) | def test_inference_hparams():
  function test_inference_falcon (line 82) | def test_inference_falcon():
  function test_inference_mpt (line 90) | def test_inference_mpt():
  function test_embedding (line 98) | def test_embedding():
  function test_empty_embedding (line 107) | def test_empty_embedding():
  function test_download_model (line 113) | def test_download_model(tmp_path: Path):

FILE: gpt4all-bindings/python/setup.py
  function get_c_shared_lib_extension (line 20) | def get_c_shared_lib_extension():
  function copy_prebuilt_C_lib (line 33) | def copy_prebuilt_C_lib(src_dir, dest_dir, dest_build_dir):
  function get_long_description (line 64) | def get_long_description():

FILE: gpt4all-bindings/typescript/index.cc
  function ChunkedFloatPtr (line 194) | Napi::Array ChunkedFloatPtr(float *embedding_ptr, int embedding_size, in...
  function llmodel_model (line 440) | llmodel_model NodeModelWrapper::GetInference()
  function Init (line 446) | Napi::Object Init(Napi::Env env, Napi::Object exports)

FILE: gpt4all-bindings/typescript/index.h
  function class (line 14) | class NodeModelWrapper : public Napi::ObjectWrap<NodeModelWrapper>

FILE: gpt4all-bindings/typescript/prompt.h
  type ResponseCallbackData (line 13) | struct ResponseCallbackData
  type PromptCallbackData (line 19) | struct PromptCallbackData
  type LLModelWrapper (line 24) | struct LLModelWrapper
  type PromptWorkerConfig (line 34) | struct PromptWorkerConfig
  function class (line 50) | class PromptWorker : public Napi::AsyncWorker

FILE: gpt4all-bindings/typescript/scripts/prebuild.js
  function createPrebuilds (line 3) | async function createPrebuilds(combinations) {
  function createPrebuild (line 25) | function createPrebuild(opts) {

FILE: gpt4all-bindings/typescript/spec/llmodel.mjs
  class Extended (line 16) | class Extended extends LLModel {}

FILE: gpt4all-bindings/typescript/src/chat-session.js
  class ChatSession (line 4) | class ChatSession {
    method constructor (line 24) | constructor(model, chatSessionOpts = {}) {
    method initialize (line 39) | async initialize(completionOpts = {}) {
    method ingestMessages (line 73) | async ingestMessages(messages, completionOpts = {}) {
    method generate (line 91) | async generate(input, completionOpts = {}) {

FILE: gpt4all-bindings/typescript/src/config.js
  constant DEFAULT_DIRECTORY (line 4) | const DEFAULT_DIRECTORY = path.resolve(os.homedir(), ".cache/gpt4all");
  constant DEFAULT_LIBRARIES_DIRECTORY (line 23) | const DEFAULT_LIBRARIES_DIRECTORY = librarySearchPaths.join(";");
  constant DEFAULT_MODEL_CONFIG (line 25) | const DEFAULT_MODEL_CONFIG = {
  constant DEFAULT_MODEL_LIST_URL (line 30) | const DEFAULT_MODEL_LIST_URL = "https://gpt4all.io/models/models3.json";
  constant DEFAULT_PROMPT_CONTEXT (line 32) | const DEFAULT_PROMPT_CONTEXT = {

FILE: gpt4all-bindings/typescript/src/gpt4all.d.ts
  type LLModelOptions (line 4) | interface LLModelOptions {
  type ModelConfig (line 14) | interface ModelConfig {
  type ChatSessionOptions (line 24) | interface ChatSessionOptions extends Partial<LLModelPromptContext> {
  class ChatSession (line 39) | class ChatSession implements CompletionProvider {
  type InferenceResult (line 93) | interface InferenceResult extends LLModelInferenceResult {
  class InferenceModel (line 101) | class InferenceModel implements CompletionProvider {
  type EmbedddingOptions (line 142) | interface EmbedddingOptions {
  type EmbeddingResult (line 198) | interface EmbeddingResult<T> {
  class EmbeddingModel (line 209) | class EmbeddingModel {
  type LLModelInferenceResult (line 258) | interface LLModelInferenceResult {
  type LLModelInferenceOptions (line 263) | interface LLModelInferenceOptions extends Partial<LLModelPromptContext> {
  class LLModel (line 281) | class LLModel {
  type GpuDevice (line 408) | interface GpuDevice {
  type LoadModelOptions (line 422) | interface LoadModelOptions {
  type InferenceModelOptions (line 467) | interface InferenceModelOptions extends LoadModelOptions {
  type EmbeddingModelOptions (line 471) | interface EmbeddingModelOptions extends LoadModelOptions {
  type CompletionProvider (line 502) | interface CompletionProvider {
  type CompletionOptions (line 513) | interface CompletionOptions extends LLModelInferenceOptions {
  type CompletionInput (line 524) | type CompletionInput = string | ChatMessage[];
  type CompletionStreamReturn (line 555) | interface CompletionStreamReturn {
  type ChatMessage (line 576) | interface ChatMessage {
  type CompletionResult (line 587) | interface CompletionResult {
  type LLModelPromptContext (line 615) | interface LLModelPromptContext {
  type DownloadModelOptions (line 770) | interface DownloadModelOptions {
  type ListModelsOptions (line 795) | interface ListModelsOptions {
  type RetrieveModelOptions (line 804) | interface RetrieveModelOptions {
  type DownloadController (line 819) | interface DownloadController {

FILE: gpt4all-bindings/typescript/src/gpt4all.js
  function loadModel (line 33) | async function loadModel(modelName, options = {}) {
  function createEmbedding (line 87) | function createEmbedding(model, text, options={}) {
  function createCompletion (line 131) | async function createCompletion(
  function createCompletionStream (line 166) | function createCompletionStream(

FILE: gpt4all-bindings/typescript/src/models.js
  class InferenceModel (line 5) | class InferenceModel {
    method constructor (line 11) | constructor(llmodel, config) {
    method createChatSession (line 17) | async createChatSession(options) {
    method generate (line 24) | async generate(input, options = DEFAULT_PROMPT_CONTEXT) {
    method dispose (line 139) | dispose() {
  class EmbeddingModel (line 144) | class EmbeddingModel {
    method constructor (line 148) | constructor(llmodel, config) {
    method embed (line 153) | embed(text, prefix, dimensionality, do_mean, atlas) {
    method dispose (line 157) | dispose() {

FILE: gpt4all-bindings/typescript/src/util.js
  function listModels (line 12) | async function listModels(
  function appendBinSuffixIfMissing (line 44) | function appendBinSuffixIfMissing(name) {
  function prepareMessagesForIngest (line 52) | function prepareMessagesForIngest(messages) {
  function readChunks (line 111) | function readChunks(reader) {
  function downloadModel (line 123) | function downloadModel(modelName, options = {}) {
  function retrieveModel (line 243) | async function retrieveModel(modelName, options = {}) {

FILE: gpt4all-bindings/typescript/test/gpt4all.test.js
  method start (line 109) | start(controller) {

FILE: gpt4all-chat/cmake/sign_dmg.py
  function sign_dmg (line 25) | def sign_dmg(input_dmg: str, output_dmg: str, signing_identity: Optional...

FILE: gpt4all-chat/src/chat.cpp
  function QVariant (line 176) | QVariant Chat::popPrompt(int index)
  function ModelInfo (line 320) | ModelInfo Chat::modelInfo() const
  function QString (line 415) | QString Chat::deviceBackend() const
  function QString (line 420) | QString Chat::device() const
  function QString (line 425) | QString Chat::fallbackReason() const

FILE: gpt4all-chat/src/chat.h
  function class (line 26) | class Chat : public QObject

FILE: gpt4all-chat/src/chatapi.cpp
  function parsePrompt (line 81) | static auto parsePrompt(QXmlStreamReader &xml) -> std::expected<QJsonArr...

FILE: gpt4all-chat/src/chatapi.h
  function class (line 26) | class ChatAPIWorker : public QObject {
  function isModelLoaded (line 62) | bool isModelLoaded() const override;
  function saveState (line 68) | size_t saveState(std::span<uint8_t> stateOut, std::vector<Token> &inputT...
  function restoreState (line 70) | size_t restoreState(std::span<const uint8_t> state, std::span<const Toke...
  function countPromptTokens (line 79) | int32_t countPromptTokens(std::string_view prompt) const override
  function threadCount (line 83) | int32_t threadCount() const override;
  function setAPIKey (line 86) | void setAPIKey(const QString &apiKey) { m_apiKey = apiKey; }
  function setRequestURL (line 87) | void setRequestURL(const QString &requestURL) { m_requestURL = requestUR...
  function contextLength (line 92) | [[noreturn]]
  function override (line 111) | const override
  function isSpecialToken (line 114) | [[noreturn]]
  function initSampler (line 122) | [[noreturn]]
  function Token (line 126) | [[noreturn]]
  function shiftContext (line 134) | [[noreturn]]
  function inputLength (line 138) | [[noreturn]]
  function setModelInputPosition (line 146) | [[noreturn]]
  function appendInputToken (line 150) | [[noreturn]]
  function std (line 154) | [[noreturn]]
  function override (line 163) | const override

FILE: gpt4all-chat/src/chatlistmodel.cpp
  class MyChatListModel (line 26) | class MyChatListModel: public ChatListModel { }
  function ChatListModel (line 28) | ChatListModel *ChatListModel::globalInstance()
  type FileInfo (line 175) | struct FileInfo {

FILE: gpt4all-chat/src/chatlistmodel.h
  function class (line 28) | class ChatsRestoreThread : public QThread
  function class (line 38) | class ChatSaver : public QObject
  function class (line 56) | class ChatListModel : public QAbstractListModel
  function override (line 113) | const override
  function shouldSaveChats (line 122) | bool shouldSaveChats() const;
  function Q_INVOKABLE (line 152) | Q_INVOKABLE void addServerChat()
  function Q_INVOKABLE (line 165) | Q_INVOKABLE void removeChat(Chat* chat)
  function Chat (line 203) | Chat *currentChat() const
  function setCurrentChat (line 208) | void setCurrentChat(Chat *chat)
  function Q_INVOKABLE (line 223) | Q_INVOKABLE Chat* get(int index)
  function destroyChats (line 232) | void destroyChats()
  function newChatCountChanged (line 260) | void newChatCountChanged()
  function nameChanged (line 267) | void nameChanged()

FILE: gpt4all-chat/src/chatllm.cpp
  class BaseResponseHandler (line 104) | class BaseResponseHandler {
  function promptModelWithTools (line 117) | static auto promptModelWithTools(
  class LLModelStore (line 168) | class LLModelStore {
    method LLModelStore (line 177) | LLModelStore()
  class MyLLModelStore (line 189) | class MyLLModelStore : public LLModelStore { }
  function LLModelStore (line 191) | LLModelStore *LLModelStore::globalInstance()
    method LLModelStore (line 177) | LLModelStore()
  function LLModelInfo (line 196) | LLModelInfo LLModelStore::acquireModel()
  function QString (line 698) | static QString &removeLeadingWhitespace(QString &s)
  function isAllSpace (line 707) | bool isAllSpace(R &&r)
  function ModelInfo (line 727) | ModelInfo ChatLLM::modelInfo() const
  function promptContextFromSettings (line 759) | static LLModel::PromptContext promptContextFromSettings(const ModelInfo ...
  function uint (line 813) | static uint parseJinjaTemplateVersion(QStringView tmpl)
  function loadJinjaTemplate (line 826) | static std::shared_ptr<minja::TemplateNode> loadJinjaTemplate(const std:...
  class ChatViewResponseHandler (line 958) | class ChatViewResponseHandler : public BaseResponseHandler {
    method ChatViewResponseHandler (line 960) | ChatViewResponseHandler(ChatLLM *cllm, QElapsedTimer *totalTime, ChatL...
    method onSplitIntoTwo (line 963) | void onSplitIntoTwo(const QString &startTag, const QString &firstBuffe...
    method onSplitIntoThree (line 971) | void onSplitIntoThree(const QString &secondBuffer, const QString &thir...
    method onOldResponseChunk (line 976) | void onOldResponseChunk(const QByteArray &chunk) override
    method onBufferResponse (line 983) | bool onBufferResponse(const QString &response, int bufferIdx) override
    method onRegularResponse (line 1000) | bool onRegularResponse() override
    method getStopGenerating (line 1006) | bool getStopGenerating() const override
  class SimpleResponseHandler (line 1176) | class SimpleResponseHandler : public BaseResponseHandler {
    method SimpleResponseHandler (line 1178) | SimpleResponseHandler(ChatLLM *cllm)
    method onSplitIntoTwo (line 1181) | void onSplitIntoTwo(const QString &startTag, const QString &firstBuffe...
    method onSplitIntoThree (line 1184) | void onSplitIntoThree(const QString &secondBuffer, const QString &thir...
    method onOldResponseChunk (line 1187) | void onOldResponseChunk(const QByteArray &chunk) override
    method onBufferResponse (line 1190) | bool onBufferResponse(const QString &response, int bufferIdx) override
    method onRegularResponse (line 1197) | bool onRegularResponse() override
    method getStopGenerating (line 1200) | bool getStopGenerating() const override
  class NameResponseHandler (line 1211) | class NameResponseHandler : public SimpleResponseHandler {
    method onSimpleResponse (line 1220) | bool onSimpleResponse(const QString &response) override
  class QuestionResponseHandler (line 1271) | class QuestionResponseHandler : public SimpleResponseHandler {
    method onSimpleResponse (line 1276) | bool onSimpleResponse(const QString &response) override

FILE: gpt4all-chat/src/chatllm.h
  type class (line 38) | enum class
  type class (line 48) | enum class
  function LLModelTypeV1 (line 61) | inline LLModelTypeV1 parseLLModelTypeV1(int type)
  function LLModelTypeV1 (line 78) | inline LLModelTypeV1 parseLLModelTypeV0(int v0)
  type LLModelInfo (line 93) | struct LLModelInfo {
  function class (line 104) | class TokenTimer : public QObject {
  function class (line 145) | class ChatLLM : public QObject

FILE: gpt4all-chat/src/chatmodel.h
  type PromptAttachment (line 50) | struct PromptAttachment {
  function MessageInput (line 87) | Q_DECLARE_METATYPE(PromptAttachment)
  function std (line 569) | static std::optional<qsizetype> getPeerInternal(const MessageItem *arr, ...
  function const_iterator (line 593) | auto getPeerUnlocked(QList<ChatItem *>::const_iterator item) const -> st...
  function appendResponse (line 691) | void appendResponse()
  function qsizetype (line 712) | qsizetype appendResponseWithHistory(std::span<const MessageInput> history)
  function hasError (line 1156) | bool hasError() const { QMutexLocker locker(&m_mutex); return hasErrorUn...
  function deserialize (line 1189) | bool deserialize(QDataStream &stream, int version)

FILE: gpt4all-chat/src/chatviewtextprocessor.cpp
  type Language (line 31) | enum Language {
  function Language (line 47) | static Language stringToLanguage(const QString &language)
  type Code (line 84) | enum Code {
  type HighlightingRule (line 107) | struct HighlightingRule {
  function QColor (line 112) | static QColor formatToColor(Code c, const CodeColors &colors)
  function pythonHighlightingRules (line 140) | static QVector<HighlightingRule> pythonHighlightingRules()
  function csharpHighlightingRules (line 192) | static QVector<HighlightingRule> csharpHighlightingRules()
  function cppHighlightingRules (line 252) | static QVector<HighlightingRule> cppHighlightingRules()
  function typescriptHighlightingRules (line 320) | static QVector<HighlightingRule> typescriptHighlightingRules()
  function javaHighlightingRules (line 392) | static QVector<HighlightingRule> javaHighlightingRules()
  function goHighlightingRules (line 453) | static QVector<HighlightingRule> goHighlightingRules()
  function bashHighlightingRules (line 510) | static QVector<HighlightingRule> bashHighlightingRules()
  function latexHighlightingRules (line 569) | static QVector<HighlightingRule> latexHighlightingRules()
  function htmlHighlightingRules (line 591) | static QVector<HighlightingRule> htmlHighlightingRules()
  function phpHighlightingRules (line 625) | static QVector<HighlightingRule> phpHighlightingRules()
  function jsonHighlightingRules (line 684) | static QVector<HighlightingRule> jsonHighlightingRules()
  function QQuickTextDocument (line 784) | QQuickTextDocument* ChatViewTextProcessor::textDocument() const
  function qreal (line 828) | qreal ChatViewTextProcessor::fontPixelSize() const
  function CodeColors (line 842) | CodeColors ChatViewTextProcessor::codeColors() const
  function traverseDocument (line 853) | void traverseDocument(QTextDocument *doc, QTextFrame *frame)
  function replaceAndInsertMarkdown (line 1066) | void replaceAndInsertMarkdown(int startIndex, int endIndex, QTextDocumen...

FILE: gpt4all-chat/src/chatviewtextprocessor.h
  type CodeColors (line 16) | struct CodeColors {
  function setCodeColors (line 63) | void setCodeColors(const CodeColors &colors) { m_codeColors = colors; }
  type ContextLink (line 69) | struct ContextLink {
  type CodeCopy (line 76) | struct CodeCopy {
  function class (line 82) | class ChatViewTextProcessor : public QObject

FILE: gpt4all-chat/src/codeinterpreter.cpp
  function QString (line 62) | QString CodeInterpreter::symbolicFormat() const
  function QString (line 67) | QString CodeInterpreter::examplePrompt() const
  function QString (line 72) | QString CodeInterpreter::exampleCall() const
  function QString (line 93) | QString CodeInterpreter::exampleReply() const

FILE: gpt4all-chat/src/codeinterpreter.h
  function class (line 15) | class JavaScriptConsoleCapture : public QObject
  function class (line 39) | class CodeInterpreterWorker : public QObject {
  function class (line 66) | class CodeInterpreter : public Tool

FILE: gpt4all-chat/src/database.cpp
  class BinaryDetectingFile (line 57) | class BinaryDetectingFile: public QFile {
    method binarySeen (line 61) | bool binarySeen() const { return m_binarySeen; }
    method qint64 (line 64) | qint64 readData(char *data, qint64 maxSize) override {
    method qint64 (line 69) | qint64 readLineData(char *data, qint64 maxSize) override {
    method qint64 (line 75) | qint64 checkData(const char *data, qint64 size) {
  function NAMED_PAIR (line 265) | NAMED_PAIR(EmbeddingKey, QString, embedding_model, int, chunk_id)
  function selectAllUncompletedChunks (line 271) | static bool selectAllUncompletedChunks(QSqlQuery &q, QHash<IncompleteChu...
  function selectCountChunks (line 290) | static bool selectCountChunks(QSqlQuery &q, int folder_id, int &count)
  function selectChunk (line 305) | static bool selectChunk(QSqlQuery &q, const QList<int> &chunk_ids)
  function addCollection (line 373) | static bool addCollection(QSqlQuery &q, const QString &collection_name, ...
  function selectFoldersFromCollection (line 390) | static bool selectFoldersFromCollection(QSqlQuery &q, const QString &col...
  function sqlExtractCollections (line 402) | static QList<CollectionItem> sqlExtractCollections(QSqlQuery &q, bool wi...
  function selectAllFromCollections (line 437) | static bool selectAllFromCollections(QSqlQuery &q, QList<CollectionItem>...
  function selectCollectionByName (line 461) | static bool selectCollectionByName(QSqlQuery &q, const QString &name, st...
  function setCollectionEmbeddingModel (line 476) | static bool setCollectionEmbeddingModel(QSqlQuery &q, const QString &col...
  function updateStartUpdateTime (line 485) | static bool updateStartUpdateTime(QSqlQuery &q, int id, qint64 update_time)
  function updateLastUpdateTime (line 494) | static bool updateLastUpdateTime(QSqlQuery &q, int id, qint64 update_time)
  function addFolderToDB (line 551) | static bool addFolderToDB(QSqlQuery &q, const QString &folder_path, int ...
  function removeFolderFromDB (line 562) | static bool removeFolderFromDB(QSqlQuery &q, int folder_id)
  function selectFolder (line 570) | static bool selectFolder(QSqlQuery &q, const QString &folder_path, int *id)
  function sqlGetFolderEmbeddingModel (line 583) | static bool sqlGetFolderEmbeddingModel(QSqlQuery &q, int id, QString &em...
  function addCollectionItem (line 614) | static int addCollectionItem(QSqlQuery &q, int collection_id, int folder...
  function removeCollectionFolder (line 626) | static int removeCollectionFolder(QSqlQuery &q, const QString &collectio...
  function sqlPruneCollections (line 637) | static bool sqlPruneCollections(QSqlQuery &q)
  function addDocument (line 673) | static bool addDocument(QSqlQuery &q, int folder_id, qint64 document_tim...
  function removeDocument (line 686) | static bool removeDocument(QSqlQuery &q, int document_id)
  function updateDocument (line 694) | static bool updateDocument(QSqlQuery &q, int id, qint64 document_time)
  function selectDocument (line 703) | static bool selectDocument(QSqlQuery &q, const QString &document_path, i...
  function selectDocuments (line 718) | static bool selectDocuments(QSqlQuery &q, int folder_id, QList<int> *doc...
  function selectCountStatistics (line 730) | static bool selectCountStatistics(QSqlQuery &q, int folder_id, int *tota...
  type Embedding (line 777) | struct Embedding { QString model; int folder_id; int chunk_id; QByteArra...
  type EmbeddingStat (line 778) | struct EmbeddingStat { QString lastFile; int nAdded; int nSkipped; }
  function sqlAddEmbeddings (line 783) | static bool sqlAddEmbeddings(QSqlQuery &q, const QList<Embedding> &embed...
  function CollectionItem (line 1061) | CollectionItem Database::guiCollectionItem(int folder_id) const
  function handleDocumentError (line 1108) | static void handleDocumentError(const QString &errorMessage, int documen...
  class DocumentReader (line 1114) | class DocumentReader {
    type Metadata (line 1116) | struct Metadata { QString title, author, subject, keywords; }
    method DocumentInfo (line 1120) | const DocumentInfo           &doc     () const { return m_info; }
    method Metadata (line 1121) | const Metadata               &metadata() const { return m_metadata; }
    method getError (line 1124) | virtual std::optional<ChunkStreamer::Status> getError() const { return...
    method page (line 1125) | virtual int page() const { return -1; }
    method DocumentReader (line 1130) | explicit DocumentReader(DocumentInfo info)
    method postInit (line 1133) | void postInit(Metadata &&metadata = {})
  class PdfDocumentReader (line 1149) | class PdfDocumentReader final : public DocumentReader {
    method PdfDocumentReader (line 1151) | explicit PdfDocumentReader(DocumentInfo info)
    method page (line 1166) | int page() const override { return m_currentPage; }
    method advance (line 1169) | std::optional<QString> advance() override
    method PdfDocumentReader (line 1192) | explicit PdfDocumentReader(DocumentInfo info)
    method page (line 1218) | int page() const override { return m_currentPage; }
    method advance (line 1221) | std::optional<QString> advance() override
    method QString (line 1243) | QString getMetadata(FPDF_BYTESTRING key)
    method QString (line 1256) | QString extractTextFromPage(FPDF_PAGE page)
  class PdfDocumentReader (line 1190) | class PdfDocumentReader final : public DocumentReader {
    method PdfDocumentReader (line 1151) | explicit PdfDocumentReader(DocumentInfo info)
    method page (line 1166) | int page() const override { return m_currentPage; }
    method advance (line 1169) | std::optional<QString> advance() override
    method PdfDocumentReader (line 1192) | explicit PdfDocumentReader(DocumentInfo info)
    method page (line 1218) | int page() const override { return m_currentPage; }
    method advance (line 1221) | std::optional<QString> advance() override
    method QString (line 1243) | QString getMetadata(FPDF_BYTESTRING key)
    method QString (line 1256) | QString extractTextFromPage(FPDF_PAGE page)
  class WordDocumentReader (line 1282) | class WordDocumentReader final : public DocumentReader {
    method WordDocumentReader (line 1284) | explicit WordDocumentReader(DocumentInfo info)
    method advance (line 1299) | std::optional<QString> advance() override
    method fillBuffer (line 1334) | bool fillBuffer()
  class TxtDocumentReader (line 1375) | class TxtDocumentReader final : public DocumentReader {
    method TxtDocumentReader (line 1377) | explicit TxtDocumentReader(DocumentInfo info)
    method advance (line 1389) | std::optional<QString> advance() override
    method getError (line 1404) | std::optional<ChunkStreamer::Status> getError() const override
  function DocumentInfo (line 1702) | DocumentInfo Database::dequeueDocument()
  type Result (line 2325) | struct Result { int chunkId; us::distance_punned_t dist; }
  type SearchResult (line 2454) | struct SearchResult { int chunkId; float score; }

FILE: gpt4all-chat/src/database.h
  type DocumentInfo (line 62) | struct DocumentInfo
  function CollectionItem (line 132) | Q_DECLARE_METATYPE(ResultInfo)
  function ChunkStreamer (line 166) | Q_DECLARE_METATYPE(CollectionItem)
  function class (line 198) | class Database : public QObject

FILE: gpt4all-chat/src/download.cpp
  class MyDownload (line 44) | class MyDownload: public Download { }
  function Download (line 46) | Download *Download::globalInstance()
  function ReleaseInfo (line 120) | ReleaseInfo Download::releaseInfo() const

FILE: gpt4all-chat/src/download.h
  type ReleaseInfo (line 24) | struct ReleaseInfo {
  function class (line 36) | class HashAndSaveFile : public QObject
  function class (line 54) | class Download : public QObject

FILE: gpt4all-chat/src/embllm.cpp
  function jsonArrayToVector (line 306) | std::vector<float> jsonArrayToVector(const QJsonArray &jsonArray)
  function jsonArrayToEmbeddingResults (line 323) | QVector<EmbeddingResult> jsonArrayToEmbeddingResults(const QVector<Embed...
  function QString (line 423) | QString EmbeddingLLM::model()

FILE: gpt4all-chat/src/embllm.h
  type EmbeddingChunk (line 20) | struct EmbeddingChunk {
  function EmbeddingResult (line 27) | Q_DECLARE_METATYPE(EmbeddingChunk)
  function class (line 36) | class EmbeddingLLMWorker : public QObject {
  function class (line 77) | class EmbeddingLLM : public QObject

FILE: gpt4all-chat/src/jinja_helpers.h
  function class (line 23) | class JinjaResultInfo : public JinjaHelper<JinjaResultInfo> {
  function class (line 34) | class JinjaPromptAttachment : public JinjaHelper<JinjaPromptAttachment> {
  function class (line 45) | class JinjaMessage : public JinjaHelper<JinjaMessage> {

FILE: gpt4all-chat/src/llm.cpp
  class MyLLM (line 32) | class MyLLM: public LLM { }
  function LLM (line 34) | LLM *LLM::globalInstance()
  function qint64 (line 101) | qint64 LLM::systemTotalRAMInGB() const
  function QString (line 106) | QString LLM::systemTotalRAMInGBString() const

FILE: gpt4all-chat/src/llm.h
  function class (line 9) | class LLM : public QObject

FILE: gpt4all-chat/src/localdocs.cpp
  class MyLocalDocs (line 17) | class MyLocalDocs: public LocalDocs { }
  function LocalDocs (line 19) | LocalDocs *LocalDocs::globalInstance()

FILE: gpt4all-chat/src/localdocs.h
  function class (line 14) | class LocalDocs : public QObject

FILE: gpt4all-chat/src/localdocsmodel.cpp
  function QVariant (line 77) | QVariant LocalDocsModel::data(const QModelIndex &index, int role) const

FILE: gpt4all-chat/src/localdocsmodel.h
  function Q_OBJECT (line 51) | Q_OBJECT

FILE: gpt4all-chat/src/logger.cpp
  class MyLogger (line 18) | class MyLogger: public Logger { }
  function Logger (line 20) | Logger *Logger::globalInstance()

FILE: gpt4all-chat/src/logger.h
  function class (line 10) | class Logger {

FILE: gpt4all-chat/src/macosdock.h
  type MacOSDock (line 4) | struct MacOSDock {

FILE: gpt4all-chat/src/main.cpp
  function raiseWindow (line 55) | static void raiseWindow(QWindow *window)
  function main (line 73) | int main(int argc, char *argv[])

FILE: gpt4all-chat/src/modellist.cpp
  function QString (line 83) | QString ModelInfo::id() const
  function QString (line 93) | QString ModelInfo::name() const
  function QString (line 104) | QString ModelInfo::filename() const
  function QString (line 115) | QString ModelInfo::description() const
  function QString (line 126) | QString ModelInfo::url() const
  function QString (line 137) | QString ModelInfo::quant() const
  function QString (line 148) | QString ModelInfo::type() const
  function QDateTime (line 203) | QDateTime ModelInfo::recency() const
  function QVariant (line 350) | QVariant ModelInfo::defaultChatTemplate() const
  function QString (line 391) | QString ModelInfo::defaultSystemMessage() const
  function QString (line 401) | QString ModelInfo::chatNamePrompt() const
  function QString (line 412) | QString ModelInfo::suggestedFollowUpPrompt() const
  function QVariant (line 429) | QVariant ModelInfo::getField(QLatin1StringView name) const
  class MyModelList (line 548) | class MyModelList: public ModelList { }
  function ModelList (line 550) | ModelList *ModelList::globalInstance()
  function QString (line 618) | QString ModelList::compatibleModelNameHash(QUrl baseUrl, QString modelNa...
  function QString (line 624) | QString ModelList::compatibleModelFilename(QUrl baseUrl, QString modelNa...
  function QString (line 636) | QString ModelList::incompleteDownloadPath(const QString &modelFile)
  function ModelInfo (line 652) | ModelInfo ModelList::defaultModelInfo() const
  function QVariant (line 793) | QVariant ModelList::dataInternal(const ModelInfo *info, int role) const
  function QVariant (line 898) | QVariant ModelList::data(const QString &id, int role) const
  function QVariant (line 905) | QVariant ModelList::dataByFilename(const QString &filename, int role) const
  function QVariant (line 914) | QVariant ModelList::data(const QModelIndex &index, int role) const
  function ModelInfo (line 1150) | ModelInfo ModelList::modelInfo(const QString &id) const
  function ModelInfo (line 1158) | ModelInfo ModelList::modelInfoByFilename(const QString &filename, bool a...
  function QString (line 1177) | QString ModelList::clone(const ModelInfo &model)
  function QString (line 1282) | QString ModelList::uniqueModelName(const ModelInfo &model) const
  function QString (line 1464) | static QString modelsJsonFilename()
  function modelsJsonCacheFile (line 1469) | static std::optional<QFile> modelsJsonCacheFile()
  type QuantType (line 2177) | enum QuantType {
  function QuantType (line 2185) | QuantType toQuantType(const QString& filename)
  function QString (line 2195) | QString toQuantString(const QString& filename)
  function QStringList (line 2361) | QStringList ModelList::remoteModelList(const QString &apiKey, const QUrl...

FILE: gpt4all-chat/src/modellist.h
  function class (line 34) | class UpgradeableSetting {
  type ModelInfo (line 75) | struct ModelInfo {
  function QString (line 137) | QString id() const;
  function temperature (line 210) | double temperature() const;
  type DiscoverSort (line 364) | enum DiscoverSort {
  type Roles (line 371) | enum Roles {
  function override (line 422) | const override
  function ModelInfo (line 493) | ModelInfo defaultModelInfo() const;
  function GPT4AllDownloadableModels (line 502) | GPT4AllDownloadableModels *gpt4AllDownloadableModels() const { return m_...
  function HuggingFaceDownloadableModels (line 503) | HuggingFaceDownloadableModels *huggingFaceDownloadableModels() const { r...
  function QString (line 505) | static inline QString toFileSize(quint64 sz) {
  function discoverLimit (line 523) | int discoverLimit() const;

FILE: gpt4all-chat/src/mysettings.cpp
  type ModelSettingsKey (line 41) | namespace ModelSettingsKey { namespace {
  type defaults (line 48) | namespace defaults {
  function QString (line 78) | static QString defaultLocalModelsPath()
  function QStringList (line 105) | static QStringList getDevices(bool skipKompute = false)
  function QString (line 121) | static QString getUiLanguage(const QString directory, const QString file...
  function QStringList (line 135) | static QStringList getUiLanguages(const QString &modelPath)
  function QString (line 162) | static QString modelSettingName(const ModelInfo &info, auto &&name)
  class MyPrivateSettings (line 167) | class MyPrivateSettings: public MySettings { }
  function MySettings (line 169) | MySettings *MySettings::globalInstance()
  function QVariant (line 182) | QVariant MySettings::checkJinjaTemplateError(const QString &tmpl)
  function QVariant (line 210) | QVariant MySettings::getBasicSetting(const QString &name) const
  function QString (line 280) | QString MySettings::modelName(const ModelInfo &info) const
  function QVariant (line 299) | QVariant MySettings::getModelSetting(QLatin1StringView name, const Model...
  function QVariant (line 305) | QVariant MySettings::getModelSetting(const char *name, const ModelInfo &...
  function QString (line 332) | QString   MySettings::modelFilename               (const ModelInfo &info...
  function QString (line 333) | QString   MySettings::modelDescription            (const ModelInfo &info...
  function QString (line 334) | QString   MySettings::modelUrl                    (const ModelInfo &info...
  function QString (line 335) | QString   MySettings::modelQuant                  (const ModelInfo &info...
  function QString (line 336) | QString   MySettings::modelType                   (const ModelInfo &info...
  function QDateTime (line 341) | QDateTime MySettings::modelRecency                (const ModelInfo &info...
  function QString (line 352) | QString   MySettings::modelChatNamePrompt         (const ModelInfo &info...
  function QString (line 353) | QString   MySettings::modelSuggestedFollowUpPrompt(const ModelInfo &info...
  function QString (line 623) | QString     MySettings::userDefaultModel() const        { return getBasi...
  function QString (line 624) | QString     MySettings::lastVersionStarted() const      { return getBasi...
  function QStringList (line 628) | QStringList MySettings::localDocsFileExtensions() const { return getBasi...
  function QString (line 630) | QString     MySettings::localDocsNomicAPIKey() const    { return getBasi...
  function QString (line 631) | QString     MySettings::localDocsEmbedDevice() const    { return getBasi...
  function QString (line 632) | QString     MySettings::networkAttribution() const      { return getBasi...
  function ChatTheme (line 634) | ChatTheme      MySettings::chatTheme() const      { return ChatTheme    ...
  function FontSize (line 635) | FontSize       MySettings::fontSize() const       { return FontSize     ...
  function SuggestionMode (line 636) | SuggestionMode MySettings::suggestionMode() const { return SuggestionMod...
  function QString (line 656) | QString MySettings::modelPath()
  function QString (line 681) | QString MySettings::device()
  function QString (line 760) | QString MySettings::languageAndLocale() const
  function QString (line 768) | QString MySettings::filePathForLocale(const QLocale &locale)

FILE: gpt4all-chat/src/mysettings.h
  function class (line 45) | class FontSize {

FILE: gpt4all-chat/src/network.cpp
  function getSysctl (line 72) | static std::optional<QString> getSysctl(const char *name)
  function QString (line 84) | static QString getCPUModel() { return getSysctl("machdep.cpu.brand_strin...
  function get_cpuid (line 89) | static void get_cpuid(int level, int *regs)
  function QString (line 97) | static QString getCPUModel()
  function QString (line 120) | static QString getCPUModel() { return "(non-x86)"; }
  class MyNetwork (line 125) | class MyNetwork: public Network { }
  function Network (line 127) | Network *Network::globalInstance()
  function QString (line 178) | QString Network::generateUniqueId() const

FILE: gpt4all-chat/src/network.h
  type KeyValue (line 23) | struct KeyValue {
  function class (line 28) | class Network : public QObject

FILE: gpt4all-chat/src/server.cpp
  class InvalidRequestError (line 60) | class InvalidRequestError: public std::invalid_argument {
    method QHttpServerResponse (line 64) | QHttpServerResponse asResponse() const
  function QJsonObject (line 82) | static inline QJsonObject modelToJson(const ModelInfo &info)
  function QJsonObject (line 111) | static inline QJsonObject resultToJson(const ResultInfo &info)
  function BaseCompletionRequest (line 135) | BaseCompletionRequest() = default;
  function BaseCompletionRequest (line 138) | virtual BaseCompletionRequest &parse(QCborMap request)
  function parseImpl (line 149) | virtual void parseImpl(QCborMap &request)
  type Type (line 205) | enum class Type : uint8_t {
  function typeMatches (line 216) | static bool typeMatches(const QCborValue &value, Type type) noexcept {
  function QCborValue (line 229) | static QCborValue takeValue(
  class CompletionRequest (line 255) | class CompletionRequest : public BaseCompletionRequest {
    method CompletionRequest (line 261) | CompletionRequest &parse(QCborMap request) override
    method parseImpl (line 268) | void parseImpl(QCborMap &request) override
  class ChatRequest (line 321) | class ChatRequest : public BaseCompletionRequest {
    type Message (line 323) | struct Message {
      type Role (line 324) | enum class Role { System, User, Assistant }
    method ChatRequest (line 331) | ChatRequest &parse(QCborMap request) override
    method parseImpl (line 338) | void parseImpl(QCborMap &request) override
  function T (line 431) | T &parseRequest(T &request, QJsonObject &&obj)
  function QJsonObject (line 446) | static QJsonObject requestFromJson(const QByteArray &request)
  function makeError (line 621) | static auto makeError(auto &&...args) -> std::pair<QHttpServerResponse, ...

FILE: gpt4all-chat/src/server.h
  function class (line 23) | class Server : public ChatLLM

FILE: gpt4all-chat/src/tool.h
  function class (line 28) | class ParamType { String, Number, Integer, Object, Array, Boolean, Null ...

FILE: gpt4all-chat/src/toolcallparser.cpp
  function QByteArray (line 71) | QByteArray ToolCallParser::startTag() const
  function QByteArray (line 78) | QByteArray ToolCallParser::endTag() const
  function QByteArray (line 85) | QByteArray &ToolCallParser::currentBuffer()
  function QStringList (line 195) | QStringList ToolCallParser::buffers() const

FILE: gpt4all-chat/src/toolcallparser.h
  function namespace (line 9) | namespace ToolEnums { enum class ParseState; }
  function class (line 14) | class ToolCallParser
  function namespace (line 56) | namespace ToolCallConstants

FILE: gpt4all-chat/src/toolmodel.cpp
  class MyToolModel (line 10) | class MyToolModel: public ToolModel { }
  function ToolModel (line 12) | ToolModel *ToolModel::globalInstance()

FILE: gpt4all-chat/src/toolmodel.h
  function class (line 15) | class ToolModel : public QAbstractListModel
  function override (line 68) | const override
  function Q_INVOKABLE (line 82) | Q_INVOKABLE Tool* get(int index) const
  function Q_INVOKABLE (line 88) | Q_INVOKABLE Tool *get(const QString &id) const

FILE: gpt4all-chat/src/xlsxtomd.cpp
  function QString (line 27) | static QString formatCellText(const QXlsx::Cell *cell)
  function QString (line 75) | static QString getCellValue(QXlsx::Worksheet *sheet, int row, int col)
  function QString (line 102) | QString XLSXToMD::toMarkdown(QIODevice *xlsxDevice)

FILE: gpt4all-chat/src/xlsxtomd.h
  function class (line 8) | class XLSXToMD

FILE: gpt4all-chat/tests/cpp/basic_test.cpp
  function TEST (line 3) | TEST(BasicTest, TestInitialization) {

FILE: gpt4all-chat/tests/cpp/test_main.cpp
  function main (line 3) | int main(int argc, char **argv) {

FILE: gpt4all-chat/tests/python/test_server_api.py
  class Requestor (line 20) | class Requestor:
    method __init__ (line 21) | def __init__(self) -> None:
    method get (line 25) | def get(self, path: str, *, raise_for_status: bool = True, wait: bool ...
    method post (line 28) | def post(self, path: str, data: dict[str, Any] | None, *, raise_for_st...
    method _request (line 31) | def _request(
  function create_chat_server_config (line 55) | def create_chat_server_config(tmpdir: Path, model_copied: bool = False) ...
  function prepare_chat_server (line 88) | def prepare_chat_server(model_copied: bool = False) -> Iterator[dict[str...
  function start_chat_server (line 98) | def start_chat_server(config: dict[str, str]) -> Iterator[None]:
  function chat_server (line 112) | def chat_server() -> Iterator[None]:
  function chat_server_with_model (line 118) | def chat_server_with_model() -> Iterator[None]:
  function test_with_models_empty (line 123) | def test_with_models_empty(chat_server: None) -> None:
  function test_with_models (line 223) | def test_with_models(chat_server_with_model: None) -> None:
  function test_with_models_temperature (line 255) | def test_with_models_temperature(chat_server_with_model: None) -> None:

FILE: gpt4all-training/data.py
  function tokenize_inputs (line 10) | def tokenize_inputs(config, tokenizer, examples):
  function load_data (line 62) | def load_data(config, tokenizer):
  function load_data_for_inference (line 127) | def load_data_for_inference(config, tokenizer):

FILE: gpt4all-training/eval_self_instruct.py
  function read_jsonl_file (line 17) | def read_jsonl_file(file_path):
  function setup_model (line 25) | def setup_model(config):
  function eval_example (line 44) | def eval_example(model, tokenizer, example, config):
  function do_eval (line 87) | def do_eval(config):

FILE: gpt4all-training/generate.py
  function generate (line 10) | def generate(tokenizer, prompt, model, config):
  function setup_model (line 20) | def setup_model(config):

FILE: gpt4all-training/inference.py
  function calc_cross_entropy_no_reduction (line 20) | def calc_cross_entropy_no_reduction(lm_logits, labels):
  function rank0_print (line 31) | def rank0_print(msg):
  function inference (line 36) | def inference(config):
  function main (line 191) | def main():

FILE: gpt4all-training/read.py
  function read_config (line 4) | def read_config(path):

FILE: gpt4all-training/train.py
  function format_metrics (line 18) | def format_metrics(metrics, split, prefix=""):
  function evaluate (line 25) | def evaluate(model, val_dataloader):
  function train (line 40) | def train(accelerator, config):
Condensed preview — 307 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (3,269K chars).
[
  {
    "path": ".circleci/config.yml",
    "chars": 631,
    "preview": "version: 2.1\nsetup: true\norbs:\n  path-filtering: circleci/path-filtering@1.3.0\n\nworkflows:\n  version: 2.1\n  generate-con"
  },
  {
    "path": ".circleci/continue_config.yml",
    "chars": 89393,
    "preview": "version: 2.1\norbs:\n  win: circleci/windows@5.0\n  python: circleci/python@1.2\n  node: circleci/node@5.1\n\nparameters:\n  ru"
  },
  {
    "path": ".circleci/grab_notary_id.py",
    "chars": 389,
    "preview": "import re\nimport sys\n\nID_REG = r\"id: (.*)\"\n\ndef main() -> None:\n    notary_log = sys.argv[1]\n    with open(notary_log, \""
  },
  {
    "path": ".codespellrc",
    "chars": 140,
    "preview": "[codespell]\nignore-words-list = blong, afterall, assistent, crasher, requestor\nskip = ./.git,./gpt4all-chat/translations"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bindings-bug.md",
    "chars": 924,
    "preview": "---\nname: \"\\U0001F6E0 Bindings Bug Report\"\nabout: A bug report for the GPT4All Bindings\nlabels: [\"bindings\", \"bug-unconf"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/chat-bug.md",
    "chars": 820,
    "preview": "---\nname: \"\\U0001F4AC GPT4All Bug Report\"\nabout: A bug report for GPT4All Chat\nlabels: [\"chat\", \"bug-unconfirmed\"]\n---\n\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "chars": 13,
    "preview": "version: 2.1\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/documentation.md",
    "chars": 222,
    "preview": "---\nname: \"\\U0001F4C4 Documentation\"\nabout: An issue related to the GPT4All documentation\nlabels: [\"documentation\"]\n---\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature-request.md",
    "chars": 258,
    "preview": "---\nname: \"\\U0001F680 Feature Request\"\nabout: Submit a proposal/request for a new GPT4All feature\ntitle: \"[Feature] Feat"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/other-bug.md",
    "chars": 934,
    "preview": "---\nname: \"\\U0001F41B Other Bug Report\"\nabout: A bug in another component of GPT4All\nlabels: [\"bug-unconfirmed\"]\n---\n\n<!"
  },
  {
    "path": ".github/pull_request_template.md",
    "chars": 693,
    "preview": "## Describe your changes\n\n## Issue ticket number and link\n\n## Checklist before requesting a review\n- [ ] I have performe"
  },
  {
    "path": ".github/workflows/close_issues.yml",
    "chars": 1294,
    "preview": "# This workflow will close issues that do not have labels or additional comments.\n# Trigger manually.\n\nname: \"Close Issu"
  },
  {
    "path": ".github/workflows/codespell.yml",
    "chars": 320,
    "preview": "---\nname: Codespell\n\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\n\njobs:\n  codespell:\n    name:"
  },
  {
    "path": ".gitignore",
    "chars": 3371,
    "preview": "*.arrow\nsquad_*\n*sbert_embedded*\n*.pkl\nckpts*\n.deepspeed_env\n*.jsonl\n*tar.gz\nckpts**\nwandb\n# Byte-compiled / optimized /"
  },
  {
    "path": ".gitmodules",
    "chars": 978,
    "preview": "[submodule \"llama.cpp-mainline\"]\n\tpath = gpt4all-backend/deps/llama.cpp-mainline\n\turl = https://github.com/nomic-ai/llam"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 4148,
    "preview": "# Contributing\n\nWhen contributing to this repository, please first discuss the change you wish to make via issue,\nemail,"
  },
  {
    "path": "LICENSE.txt",
    "chars": 1055,
    "preview": "Copyright (c) 2023 Nomic, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this sof"
  },
  {
    "path": "MAINTAINERS.md",
    "chars": 2211,
    "preview": "# MAINTAINERS\n\n## Rules\n\n* All content inside GPT4All shall have a documented maintainer\n* If a maintainer decides to re"
  },
  {
    "path": "README.md",
    "chars": 5925,
    "preview": "<h1 align=\"center\">GPT4All</h1>\n\n<p align=\"center\">\n  Now with support for DeepSeek R1 Distillations\n</p>\n\n<p align=\"cen"
  },
  {
    "path": "common/common.cmake",
    "chars": 1114,
    "preview": "function(gpt4all_add_warning_options target)\n    if (MSVC)\n        return()\n    endif()\n    target_compile_options(\"${ta"
  },
  {
    "path": "gpt4all-backend/CMakeLists.txt",
    "chars": 6904,
    "preview": "cmake_minimum_required(VERSION 3.23)  # for FILE_SET\n\ninclude(../common/common.cmake)\n\nset(CMAKE_WINDOWS_EXPORT_ALL_SYMB"
  },
  {
    "path": "gpt4all-backend/README.md",
    "chars": 4305,
    "preview": "# GPT4ALL Backend\nThis directory contains the C/C++ model backend used by GPT4All for inference on the CPU. This backend"
  },
  {
    "path": "gpt4all-backend/include/gpt4all-backend/llmodel.h",
    "chars": 10565,
    "preview": "#ifndef LLMODEL_H\n#define LLMODEL_H\n\n#include <algorithm>\n#include <cassert>\n#include <cstddef>\n#include <cstdint>\n#incl"
  },
  {
    "path": "gpt4all-backend/include/gpt4all-backend/llmodel_c.h",
    "chars": 13825,
    "preview": "#ifndef LLMODEL_C_H\n#define LLMODEL_C_H\n\n#include <stdbool.h>\n#include <stddef.h>\n#include <stdint.h>\n\n#ifdef __GNUC__\n#"
  },
  {
    "path": "gpt4all-backend/include/gpt4all-backend/sysinfo.h",
    "chars": 1684,
    "preview": "#ifndef SYSINFO_H\n#define SYSINFO_H\n\n#include <fstream>\n#include <iomanip>\n#include <sstream>\n#include <string>\n\n#if def"
  },
  {
    "path": "gpt4all-backend/llama.cpp.cmake",
    "chars": 43964,
    "preview": "cmake_minimum_required(VERSION 3.14)  # for add_link_options and implicit target directories.\n\nset(CMAKE_RUNTIME_OUTPUT_"
  },
  {
    "path": "gpt4all-backend/src/dlhandle.cpp",
    "chars": 1564,
    "preview": "#include \"dlhandle.h\"\n\n#include <string>\n\n#ifndef _WIN32\n#   include <dlfcn.h>\n#else\n#   include <cassert>\n#   include <"
  },
  {
    "path": "gpt4all-backend/src/dlhandle.h",
    "chars": 954,
    "preview": "#pragma once\n\n#include <filesystem>\n#include <stdexcept>\n#include <string>\n#include <utility>\n\nnamespace fs = std::files"
  },
  {
    "path": "gpt4all-backend/src/llamamodel.cpp",
    "chars": 42501,
    "preview": "#define LLAMAMODEL_H_I_KNOW_WHAT_I_AM_DOING_WHEN_INCLUDING_THIS_FILE\n#include \"llamamodel_impl.h\"\n\n#include \"llmodel.h\"\n"
  },
  {
    "path": "gpt4all-backend/src/llamamodel_impl.h",
    "chars": 4090,
    "preview": "#ifndef LLAMAMODEL_H_I_KNOW_WHAT_I_AM_DOING_WHEN_INCLUDING_THIS_FILE\n#error This file is NOT meant to be included outsid"
  },
  {
    "path": "gpt4all-backend/src/llmodel.cpp",
    "chars": 11724,
    "preview": "#include \"llmodel.h\"\n\n#include \"dlhandle.h\"\n\n#include <cassert>\n#include <cstdlib>\n#include <filesystem>\n#include <fstre"
  },
  {
    "path": "gpt4all-backend/src/llmodel_c.cpp",
    "chars": 10282,
    "preview": "#include \"llmodel_c.h\"\n\n#include \"llmodel.h\"\n\n#include <algorithm>\n#include <cstdio>\n#include <cstdlib>\n#include <cstrin"
  },
  {
    "path": "gpt4all-backend/src/llmodel_shared.cpp",
    "chars": 10791,
    "preview": "#include \"llmodel.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <cstddef>\n#include <cstdint>\n#include <iostream>\n"
  },
  {
    "path": "gpt4all-backend/src/utils.h",
    "chars": 400,
    "preview": "#pragma once\n\n#include <cassert>\n\n#ifdef NDEBUG\n#   ifdef __has_builtin\n#       if __has_builtin(__builtin_unreachable)\n"
  },
  {
    "path": "gpt4all-bindings/README.md",
    "chars": 1483,
    "preview": "# GPT4All Language Bindings\nThese are the language bindings for the GPT4All backend. They provide functionality to load "
  },
  {
    "path": "gpt4all-bindings/cli/README.md",
    "chars": 1788,
    "preview": "# GPT4All Command-Line Interface (CLI)\r\n\r\nGPT4All on the command-line.\r\n\r\nMore details on the [wiki](https://github.com/"
  },
  {
    "path": "gpt4all-bindings/cli/app.py",
    "chars": 5890,
    "preview": "#!/usr/bin/env python3\n\"\"\"GPT4All CLI\n\nThe GPT4All CLI is a self-contained script based on the `gpt4all` and `typer` pac"
  },
  {
    "path": "gpt4all-bindings/cli/developer_notes.md",
    "chars": 1038,
    "preview": "# Developing the CLI\r\n## Documentation\r\nDocumentation can be found in three places:\r\n- `app.py` docstrings & comments\r\n-"
  },
  {
    "path": "gpt4all-bindings/python/.gitignore",
    "chars": 3108,
    "preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
  },
  {
    "path": "gpt4all-bindings/python/.isort.cfg",
    "chars": 158,
    "preview": "[settings]\nknown_third_party=geopy,nltk,np,numpy,pandas,pysbd,fire,torch\n\nline_length=120\ninclude_trailing_comma=True\nmu"
  },
  {
    "path": "gpt4all-bindings/python/CHANGELOG.md",
    "chars": 5396,
    "preview": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Change"
  },
  {
    "path": "gpt4all-bindings/python/LICENSE.txt",
    "chars": 1054,
    "preview": "Copyright (c) 2023 Nomic, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this sof"
  },
  {
    "path": "gpt4all-bindings/python/MANIFEST.in",
    "chars": 49,
    "preview": "recursive-include gpt4all/llmodel_DO_NOT_MODIFY *"
  },
  {
    "path": "gpt4all-bindings/python/README.md",
    "chars": 3102,
    "preview": "# Python GPT4All\n\nThis package contains a set of Python bindings around the `llmodel` C-API.\n\nPackage on PyPI: https://p"
  },
  {
    "path": "gpt4all-bindings/python/docs/css/custom.css",
    "chars": 80,
    "preview": ".md-content h1,\n.md-content h2 {\n  margin-top: 0.5em;\n  margin-bottom: 0.5em;\n}\n"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_api_server/home.md",
    "chars": 3259,
    "preview": "# GPT4All API Server\n\nGPT4All provides a local API server that allows you to run LLMs over an HTTP API. \n\n## Key Feature"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/chat_templates.md",
    "chars": 12817,
    "preview": "## What are chat templates?\nNatively, large language models only know how to complete plain text and do not know the dif"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/chats.md",
    "chars": 5762,
    "preview": "# Chats\n\nChats are conversations with [language models](models.md) that run locally on your device.\n\n!!! note \"Example C"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/cookbook/use-local-ai-models-to-privately-chat-with-Obsidian.md",
    "chars": 5187,
    "preview": "# Using GPT4All to Privately Chat with your Obsidian Vault\n\nObsidian for Desktop is a powerful management and note-takin"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/cookbook/use-local-ai-models-to-privately-chat-with-One-Drive.md",
    "chars": 4643,
    "preview": "# Using GPT4All to Privately Chat with your OneDrive Data\n\nLocal and Private AI Chat with your OneDrive Data\n\nOneDrive f"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/cookbook/use-local-ai-models-to-privately-chat-with-google-drive.md",
    "chars": 4736,
    "preview": "# Using GPT4All to Privately Chat with your Google Drive Data\nLocal and Private AI Chat with your Google Drive Data\n\nGoo"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/cookbook/use-local-ai-models-to-privately-chat-with-microsoft-excel.md",
    "chars": 3319,
    "preview": "# Using GPT4All to Privately Chat with your Microsoft Excel Spreadsheets\nLocal and Private AI Chat with your Microsoft E"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/localdocs.md",
    "chars": 1945,
    "preview": "# LocalDocs\n\nLocalDocs brings the information you have from files on-device into your LLM chats - **privately**.\n\n## Cre"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/models.md",
    "chars": 4471,
    "preview": "# Models\n\nGPT4All is optimized to run LLMs in the 3-13B parameter range on consumer-grade hardware.\n\nLLMs are downloaded"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/quickstart.md",
    "chars": 1762,
    "preview": "# GPT4All Desktop\n\nThe GPT4All Desktop Application allows you to download and run large language models (LLMs) locally &"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_desktop/settings.md",
    "chars": 5324,
    "preview": "# Settings\n\n## Application Settings\n\n!!! note \"General Application Settings\"\n\n    | Setting | Description | Default Valu"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_help/faq.md",
    "chars": 1730,
    "preview": "# Frequently Asked Questions\n\n## Models\n\n### Which language models are supported?\n\nWe support models with a `llama.cpp` "
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_help/troubleshooting.md",
    "chars": 1950,
    "preview": "# Troubleshooting\n\n## Error Loading Models\n\nIt is possible you are trying to load a model from HuggingFace whose weights"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_python/home.md",
    "chars": 8095,
    "preview": "# GPT4All Python SDK\n\n## Installation\n\nTo get started, pip-install the `gpt4all` package into your python environment.\n\n"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_python/monitoring.md",
    "chars": 2173,
    "preview": "# GPT4All Monitoring\n\nGPT4All integrates with [OpenLIT](https://github.com/openlit/openlit) OpenTelemetry auto-instrumen"
  },
  {
    "path": "gpt4all-bindings/python/docs/gpt4all_python/ref.md",
    "chars": 89,
    "preview": "# GPT4All Python SDK Reference\n::: gpt4all.gpt4all.GPT4All\n\n::: gpt4all.gpt4all.Embed4All"
  },
  {
    "path": "gpt4all-bindings/python/docs/index.md",
    "chars": 1575,
    "preview": "# GPT4All Documentation\n\nGPT4All runs large language models (LLMs) privately on everyday desktops & laptops. \n\nNo API ca"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_chat.md",
    "chars": 6503,
    "preview": "# GPT4All Chat UI\n\nThe [GPT4All Chat Client](https://gpt4all.io) lets you easily interact with any local large language "
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_cli.md",
    "chars": 8222,
    "preview": "# GPT4All CLI\r\n\r\nThe GPT4All command-line interface (CLI) is a Python script which is built on top of the\r\n[Python bindi"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_faq.md",
    "chars": 6123,
    "preview": "# GPT4All FAQ\n\n## What models are supported by the GPT4All ecosystem?\n\nCurrently, there are six different model architec"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_monitoring.md",
    "chars": 3450,
    "preview": "# Monitoring\n\nLeverage OpenTelemetry to perform real-time monitoring of your LLM application and GPUs using [OpenLIT](ht"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_nodejs.md",
    "chars": 35434,
    "preview": "# GPT4All Node.js API\n\nNative Node.js LLM bindings for all.\n\n```sh\nyarn add gpt4all@latest\n\nnpm install gpt4all@latest\n\n"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_python.md",
    "chars": 10414,
    "preview": "# GPT4All Python Generation API\nThe `GPT4All` python package provides bindings to our C/C++ model backend libraries.\nThe"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/gpt4all_python_embedding.md",
    "chars": 6474,
    "preview": "# Embeddings\nGPT4All supports generating high quality embeddings of arbitrary length text using any embedding model supp"
  },
  {
    "path": "gpt4all-bindings/python/docs/old/index.md",
    "chars": 4661,
    "preview": "# GPT4All\nWelcome to the GPT4All documentation LOCAL EDIT\n\nGPT4All is an open-source software ecosystem for anyone to ru"
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/__init__.py",
    "chars": 104,
    "preview": "from .gpt4all import CancellationError as CancellationError, Embed4All as Embed4All, GPT4All as GPT4All\n"
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/_pyllmodel.py",
    "chars": 22096,
    "preview": "from __future__ import annotations\n\nimport ctypes\nimport os\nimport platform\nimport subprocess\nimport sys\nimport textwrap"
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/gpt4all.py",
    "chars": 29307,
    "preview": "\"\"\"\nPython only API for running all GPT4All models.\n\"\"\"\nfrom __future__ import annotations\n\nimport hashlib\nimport json\ni"
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/tests/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/tests/test_embed_timings.py",
    "chars": 562,
    "preview": "#!/usr/bin/env python3\nimport sys\nimport time\nfrom io import StringIO\n\nfrom gpt4all import Embed4All, GPT4All\n\n\ndef time"
  },
  {
    "path": "gpt4all-bindings/python/gpt4all/tests/test_gpt4all.py",
    "chars": 5979,
    "preview": "import sys\nfrom io import StringIO\nfrom pathlib import Path\n\nfrom gpt4all import GPT4All, Embed4All\nimport time\nimport p"
  },
  {
    "path": "gpt4all-bindings/python/makefile",
    "chars": 843,
    "preview": "SHELL:=/bin/bash -o pipefail\nROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))\nPYTHON:=python3\n\nenv:\n\t"
  },
  {
    "path": "gpt4all-bindings/python/mkdocs.yml",
    "chars": 2811,
    "preview": "site_name: GPT4All\nrepo_url: https://github.com/nomic-ai/gpt4all\nrepo_name: nomic-ai/gpt4all\nsite_url: https://docs.gpt4"
  },
  {
    "path": "gpt4all-bindings/python/setup.py",
    "chars": 3845,
    "preview": "from setuptools import setup, find_packages\nimport os\nimport pathlib\nimport platform\nimport shutil\n\npackage_name = \"gpt4"
  },
  {
    "path": "gpt4all-bindings/typescript/.clang-format",
    "chars": 58,
    "preview": "---\nLanguage: Cpp\nBasedOnStyle: Microsoft\nColumnLimit: 120"
  },
  {
    "path": "gpt4all-bindings/typescript/.gitignore",
    "chars": 142,
    "preview": "node_modules/\nbuild/\nprebuilds/\n.yarn/*\n!.yarn/patches\n!.yarn/plugins\n!.yarn/releases\n!.yarn/sdks\n!.yarn/versions\nruntim"
  },
  {
    "path": "gpt4all-bindings/typescript/.npmignore",
    "chars": 26,
    "preview": "test/\nspec/\nscripts/\nbuild"
  },
  {
    "path": "gpt4all-bindings/typescript/.yarnrc.yml",
    "chars": 25,
    "preview": "nodeLinker: node-modules\n"
  },
  {
    "path": "gpt4all-bindings/typescript/README.md",
    "chars": 9042,
    "preview": "# GPT4All Node.js API\n\nNative Node.js LLM bindings for all.\n\n```sh\nyarn add gpt4all@latest\n\nnpm install gpt4all@latest\n\n"
  },
  {
    "path": "gpt4all-bindings/typescript/binding.ci.gyp",
    "chars": 1760,
    "preview": "{\n  \"targets\": [\n    {\n      \"target_name\": \"gpt4all\", # gpt4all-ts will cause compile error\n      \"include_dirs\": [\n   "
  },
  {
    "path": "gpt4all-bindings/typescript/binding.gyp",
    "chars": 1778,
    "preview": "{\n  \"targets\": [\n    {\n      \"target_name\": \"gpt4all\", # gpt4all-ts will cause compile error\n      \"include_dirs\": [\n   "
  },
  {
    "path": "gpt4all-bindings/typescript/index.cc",
    "chars": 17915,
    "preview": "#include \"index.h\"\n#include \"napi.h\"\n\nNapi::Function NodeModelWrapper::GetClass(Napi::Env env)\n{\n    Napi::Function self"
  },
  {
    "path": "gpt4all-bindings/typescript/index.h",
    "chars": 2038,
    "preview": "#include \"llmodel.h\"\n#include \"llmodel_c.h\"\n#include \"prompt.h\"\n#include <atomic>\n#include <filesystem>\n#include <iostre"
  },
  {
    "path": "gpt4all-bindings/typescript/package.json",
    "chars": 1235,
    "preview": "{\n  \"name\": \"gpt4all\",\n  \"version\": \"4.0.0\",\n  \"packageManager\": \"yarn@3.6.1\",\n  \"main\": \"src/gpt4all.js\",\n  \"repository"
  },
  {
    "path": "gpt4all-bindings/typescript/prompt.cc",
    "chars": 6353,
    "preview": "#include \"prompt.h\"\n#include <future>\n\nPromptWorker::PromptWorker(Napi::Env env, PromptWorkerConfig config)\n    : promis"
  },
  {
    "path": "gpt4all-bindings/typescript/prompt.h",
    "chars": 1577,
    "preview": "#ifndef PREDICT_WORKER_H\n#define PREDICT_WORKER_H\n\n#include \"llmodel.h\"\n#include \"llmodel_c.h\"\n#include \"napi.h\"\n#includ"
  },
  {
    "path": "gpt4all-bindings/typescript/scripts/build.js",
    "chars": 636,
    "preview": "const { spawn } = require(\"node:child_process\");\nconst { resolve } = require(\"path\");\nconst args = process.argv.slice(2)"
  },
  {
    "path": "gpt4all-bindings/typescript/scripts/docs.js",
    "chars": 305,
    "preview": "//Maybe some command line piping would work better, but can't think of platform independent command line tool\n\nconst fs "
  },
  {
    "path": "gpt4all-bindings/typescript/scripts/mkclangd.js",
    "chars": 1238,
    "preview": "/// makes compile_flags.txt for clangd server support with this project\n/// run this with typescript as your cwd\n//\n//fo"
  },
  {
    "path": "gpt4all-bindings/typescript/scripts/prebuild.js",
    "chars": 1596,
    "preview": "const prebuildify = require(\"prebuildify\");\n\nasync function createPrebuilds(combinations) {\n    for (const { platform, a"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/callbacks.mjs",
    "chars": 918,
    "preview": "import { promises as fs } from \"node:fs\";\nimport { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model "
  },
  {
    "path": "gpt4all-bindings/typescript/spec/chat-memory.mjs",
    "chars": 1796,
    "preview": "import { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model = await loadModel(\"Nous-Hermes-2-Mistral-7"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/chat-minimal.mjs",
    "chars": 429,
    "preview": "import { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model = await loadModel(\"orca-mini-3b-gguf2-q4_0"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/concurrency.mjs",
    "chars": 985,
    "preview": "import {\n    loadModel,\n    createCompletion,\n} from \"../src/gpt4all.js\";\n\nconst modelOptions = {\n    verbose: true,\n};\n"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/embed-jsonl.mjs",
    "chars": 959,
    "preview": "import { loadModel, createEmbedding } from '../src/gpt4all.js'\nimport { createGunzip, createGzip, createUnzip } from 'no"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/embed.mjs",
    "chars": 358,
    "preview": "import { loadModel, createEmbedding } from '../src/gpt4all.js'\n\nconst embedder = await loadModel(\"nomic-embed-text-v1.5."
  },
  {
    "path": "gpt4all-bindings/typescript/spec/llmodel.mjs",
    "chars": 1800,
    "preview": "import {\n    LLModel,\n    createCompletion,\n    DEFAULT_DIRECTORY,\n    DEFAULT_LIBRARIES_DIRECTORY,\n    loadModel,\n} fro"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/long-context.mjs",
    "chars": 606,
    "preview": "import { promises as fs } from \"node:fs\";\nimport { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model "
  },
  {
    "path": "gpt4all-bindings/typescript/spec/model-switching.mjs",
    "chars": 1510,
    "preview": "import { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model1 = await loadModel(\"Nous-Hermes-2-Mistral-"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/stateless.mjs",
    "chars": 1130,
    "preview": "import { loadModel, createCompletion } from \"../src/gpt4all.js\";\n\nconst model = await loadModel(\"orca-mini-3b-gguf2-q4_0"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/streaming.mjs",
    "chars": 1523,
    "preview": "import {\n    loadModel,\n    createCompletion,\n    createCompletionStream,\n    createCompletionGenerator,\n} from \"../src/"
  },
  {
    "path": "gpt4all-bindings/typescript/spec/system.mjs",
    "chars": 649,
    "preview": "import {\n    loadModel,\n    createCompletion,\n} from \"../src/gpt4all.js\";\n\nconst model = await loadModel(\"Nous-Hermes-2-"
  },
  {
    "path": "gpt4all-bindings/typescript/src/chat-session.js",
    "chars": 4951,
    "preview": "const { DEFAULT_PROMPT_CONTEXT } = require(\"./config\");\nconst { prepareMessagesForIngest } = require(\"./util\");\n\nclass C"
  },
  {
    "path": "gpt4all-bindings/typescript/src/config.js",
    "chars": 1134,
    "preview": "const os = require(\"node:os\");\nconst path = require(\"node:path\");\n\nconst DEFAULT_DIRECTORY = path.resolve(os.homedir(), "
  },
  {
    "path": "gpt4all-bindings/typescript/src/gpt4all.d.ts",
    "chars": 28152,
    "preview": "/// <reference types=\"node\" />\ndeclare module \"gpt4all\";\n\ninterface LLModelOptions {\n    /**\n     * Model architecture. "
  },
  {
    "path": "gpt4all-bindings/typescript/src/gpt4all.js",
    "chars": 6348,
    "preview": "\"use strict\";\n\n/// This file implements the gpt4all.d.ts file endings.\n/// Written in commonjs to support both ESM and C"
  },
  {
    "path": "gpt4all-bindings/typescript/src/models.js",
    "chars": 5570,
    "preview": "const { DEFAULT_PROMPT_CONTEXT } = require(\"./config\");\nconst { ChatSession } = require(\"./chat-session\");\nconst { prepa"
  },
  {
    "path": "gpt4all-bindings/typescript/src/util.js",
    "chars": 9677,
    "preview": "const { createWriteStream, existsSync, statSync, mkdirSync } = require(\"node:fs\");\nconst fsp = require(\"node:fs/promises"
  },
  {
    "path": "gpt4all-bindings/typescript/test/gpt4all.test.js",
    "chars": 6779,
    "preview": "const path = require(\"node:path\");\nconst os = require(\"node:os\");\nconst fsp = require(\"node:fs/promises\");\nconst { exist"
  },
  {
    "path": "gpt4all-bindings/typescript/test/models.json",
    "chars": 192,
    "preview": "[\n  {\n    \"order\": \"a\",\n    \"md5sum\": \"08d6c05a21512a79a1dfeb9d2a8f262f\",\n    \"name\": \"Not a real model\",\n    \"filename\""
  },
  {
    "path": "gpt4all-chat/.flake8",
    "chars": 658,
    "preview": "# vim: set syntax=dosini:\n[flake8]\nexclude = .*,__pycache__\nmax-line-length = 120\nextend-ignore = B001,C408,D,DAR,E221,E"
  },
  {
    "path": "gpt4all-chat/CHANGELOG.md",
    "chars": 25348,
    "preview": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Change"
  },
  {
    "path": "gpt4all-chat/CMakeLists.txt",
    "chars": 22832,
    "preview": "cmake_minimum_required(VERSION 3.25)  # for try_compile SOURCE_FROM_VAR\n\ninclude(../common/common.cmake)\n\nset(APP_VERSIO"
  },
  {
    "path": "gpt4all-chat/LICENSE",
    "chars": 1433,
    "preview": "Copyright 2023-2024 Nomic, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this so"
  },
  {
    "path": "gpt4all-chat/cmake/Modules/SignMacOSBinaries.cmake",
    "chars": 181,
    "preview": "function(install_sign_osx tgt)\n    install(CODE \"execute_process(COMMAND codesign --options runtime --timestamp -s \\\"${M"
  },
  {
    "path": "gpt4all-chat/cmake/Modules/SignWindowsBinaries.cmake",
    "chars": 589,
    "preview": "function(sign_target_windows tgt)\n    if(WIN32 AND GPT4ALL_SIGN_INSTALL)\n        add_custom_command(TARGET ${tgt}\n      "
  },
  {
    "path": "gpt4all-chat/cmake/cpack-steal-config.cmake.in",
    "chars": 131,
    "preview": "set(OUTPUT_DIR \"@CMAKE_BINARY_DIR@\")\nfile(COPY ${CPACK_TEMPORARY_INSTALL_DIRECTORY}/config DESTINATION ${OUTPUT_DIR}/cpa"
  },
  {
    "path": "gpt4all-chat/cmake/cpack_config.cmake",
    "chars": 2638,
    "preview": "set(COMPONENT_NAME_MAIN \"gpt4all\")\n\nset(CPACK_GENERATOR \"IFW\")\nset(CPACK_VERBATIM_VARIABLES YES)\nset(CPACK_IFW_VERBOSE O"
  },
  {
    "path": "gpt4all-chat/cmake/deploy-qt-linux.cmake.in",
    "chars": 727,
    "preview": "set(LINUXDEPLOYQT \"@LINUXDEPLOYQT@\")\nset(COMPONENT_NAME_MAIN \"@COMPONENT_NAME_MAIN@\")\nset(CMAKE_CURRENT_SOURCE_DIR \"@CMA"
  },
  {
    "path": "gpt4all-chat/cmake/deploy-qt-mac.cmake.in",
    "chars": 1450,
    "preview": "set(MACDEPLOYQT \"@MACDEPLOYQT@\")\nset(COMPONENT_NAME_MAIN \"@COMPONENT_NAME_MAIN@\")\nset(CMAKE_CURRENT_SOURCE_DIR \"@CMAKE_C"
  },
  {
    "path": "gpt4all-chat/cmake/deploy-qt-windows.cmake.in",
    "chars": 756,
    "preview": "set(WINDEPLOYQT \"@WINDEPLOYQT@\")\nset(COMPONENT_NAME_MAIN \"@COMPONENT_NAME_MAIN@\")\nset(CMAKE_CURRENT_SOURCE_DIR \"@CMAKE_C"
  },
  {
    "path": "gpt4all-chat/cmake/download_model.cmake",
    "chars": 490,
    "preview": "if(NOT DEFINED URL OR NOT DEFINED OUTPUT_PATH OR NOT DEFINED EXPECTED_MD5)\n    message(FATAL_ERROR \"Usage: cmake -DURL=<"
  },
  {
    "path": "gpt4all-chat/cmake/installer_control.qs",
    "chars": 1675,
    "preview": "var finishedText = null;\n\nfunction cancelInstaller(message) {\n    installer.setDefaultPageVisible(QInstaller.Introductio"
  },
  {
    "path": "gpt4all-chat/cmake/installer_gpt4all_component.qs",
    "chars": 2896,
    "preview": "function Component() {\n}\n\nvar targetDirectory;\nComponent.prototype.beginInstallation = function() {\n    targetDirectory "
  },
  {
    "path": "gpt4all-chat/cmake/installer_maintenancetool_component.qs",
    "chars": 803,
    "preview": "function Component()\n{\n    component.ifwVersion = installer.value(\"FrameworkVersion\");\n    installer.installationStarted"
  },
  {
    "path": "gpt4all-chat/cmake/sign_dmg.py",
    "chars": 4539,
    "preview": "#!/usr/bin/env python3\nimport os\nimport subprocess\nimport tempfile\nimport shutil\nimport click\nimport re\nfrom typing impo"
  },
  {
    "path": "gpt4all-chat/contributing_translations.md",
    "chars": 3593,
    "preview": "# Contributing Foreign Language Translations of GPT4All\n\n## Overview\n\nTo contribute foreign language translations to the"
  },
  {
    "path": "gpt4all-chat/deps/CMakeLists.txt",
    "chars": 1988,
    "preview": "include(FetchContent)\n\n\nset(BUILD_SHARED_LIBS OFF)\n\nset(FMT_INSTALL OFF)\nadd_subdirectory(fmt)\n\nset(QAPPLICATION_CLASS Q"
  },
  {
    "path": "gpt4all-chat/dev-requirements.txt",
    "chars": 190,
    "preview": "-r test-requirements.txt\n\n# dev tools\nflake8~=7.1\nmypy~=1.12\npytype>=2024.10.11\nwemake-python-styleguide~=0.19.2\n\n# type"
  },
  {
    "path": "gpt4all-chat/flatpak-manifest/io.gpt4all.gpt4all.appdata.xml",
    "chars": 2579,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<component type=\"desktop\">\n    <id>io.gpt4all.gpt4all</id>\n    <metadata_license>"
  },
  {
    "path": "gpt4all-chat/flatpak-manifest/io.gpt4all.gpt4all.desktop",
    "chars": 433,
    "preview": "[Desktop Entry]\nName=GPT4ALL\nGenericName=Open-source assistant-style large language models that run locally on your CPU\n"
  },
  {
    "path": "gpt4all-chat/main.qml",
    "chars": 25356,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport Qt5Comp"
  },
  {
    "path": "gpt4all-chat/metadata/latestnews.md",
    "chars": 899,
    "preview": "## Latest News\n\nGPT4All v3.10.0 was released on February 24th. Changes include:\n\n* **Remote Models:**\n  * The Add Model "
  },
  {
    "path": "gpt4all-chat/metadata/models.json",
    "chars": 9091,
    "preview": "[\n  {\n    \"order\": \"a\",\n    \"md5sum\": \"e8d47924f433bd561cb5244557147793\",\n    \"name\": \"Wizard v1.1\",\n    \"filename\": \"wi"
  },
  {
    "path": "gpt4all-chat/metadata/models2.json",
    "chars": 10274,
    "preview": "[\n  {\n    \"order\": \"a\",\n    \"md5sum\": \"f692417a22405d80573ac10cb0cd6c6a\",\n    \"name\": \"Mistral OpenOrca\",\n    \"filename\""
  },
  {
    "path": "gpt4all-chat/metadata/models3.json",
    "chars": 40907,
    "preview": "[\n  {\n    \"order\": \"a\",\n    \"md5sum\": \"a54c08a7b90e4029a8c2ab5b5dc936aa\",\n    \"name\": \"Reasoner v1\",\n    \"filename\": \"qw"
  },
  {
    "path": "gpt4all-chat/metadata/release.json",
    "chars": 43597,
    "preview": "[\n  {\n    \"version\": \"2.2.2\",\n    \"notes\": \"* repeat penalty for both gptj and llama models\\n* scroll the context window"
  },
  {
    "path": "gpt4all-chat/pyproject.toml",
    "chars": 701,
    "preview": "[tool.pytest.ini_options]\naddopts = ['--import-mode=importlib']\n\n[tool.mypy]\nfiles = 'tests/python'\npretty = true\nstrict"
  },
  {
    "path": "gpt4all-chat/qa_checklist.md",
    "chars": 2134,
    "preview": "## QA Checklist\n\n1. Ensure you have a fresh install by **backing up** and then deleting the following directories:\n\n    "
  },
  {
    "path": "gpt4all-chat/qml/AddCollectionView.qml",
    "chars": 6616,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/AddGPT4AllModelView.qml",
    "chars": 23066,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/AddHFModelView.qml",
    "chars": 34010,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/AddModelView.qml",
    "chars": 4424,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/AddRemoteModelView.qml",
    "chars": 6368,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/ApplicationSettings.qml",
    "chars": 21809,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/ChatCollapsibleItem.qml",
    "chars": 5536,
    "preview": "import Qt5Compat.GraphicalEffects\nimport QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimp"
  },
  {
    "path": "gpt4all-chat/qml/ChatDrawer.qml",
    "chars": 13942,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport chatlis"
  },
  {
    "path": "gpt4all-chat/qml/ChatItemView.qml",
    "chars": 29158,
    "preview": "import Qt5Compat.GraphicalEffects\nimport QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimp"
  },
  {
    "path": "gpt4all-chat/qml/ChatMessageButton.qml",
    "chars": 357,
    "preview": "import QtQuick\nimport QtQuick.Controls\n\nimport gpt4all\n\nMyToolButton {\n    property string name\n\n    width: 24\n    heigh"
  },
  {
    "path": "gpt4all-chat/qml/ChatTextItem.qml",
    "chars": 4570,
    "preview": "import Qt5Compat.GraphicalEffects\nimport QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimp"
  },
  {
    "path": "gpt4all-chat/qml/ChatView.qml",
    "chars": 64902,
    "preview": "import Qt5Compat.GraphicalEffects\nimport QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimp"
  },
  {
    "path": "gpt4all-chat/qml/CollectionsDrawer.qml",
    "chars": 5410,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/ConfirmationDialog.qml",
    "chars": 1673,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\n\nMyDialog {\n  "
  },
  {
    "path": "gpt4all-chat/qml/HomeView.qml",
    "chars": 10455,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport Qt5Comp"
  },
  {
    "path": "gpt4all-chat/qml/LocalDocsSettings.qml",
    "chars": 12178,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/LocalDocsView.qml",
    "chars": 19966,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport Qt5Comp"
  },
  {
    "path": "gpt4all-chat/qml/ModelSettings.qml",
    "chars": 41646,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport modelli"
  },
  {
    "path": "gpt4all-chat/qml/ModelsView.qml",
    "chars": 30800,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Dialogs\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/MyBusyIndicator.qml",
    "chars": 1886,
    "preview": "import QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nBusyIndicator {\n    id: control\n\n    property real"
  },
  {
    "path": "gpt4all-chat/qml/MyButton.qml",
    "chars": 1557,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport mysettings\nimport mysettingsen"
  },
  {
    "path": "gpt4all-chat/qml/MyCheckBox.qml",
    "chars": 980,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nCheckBox {\n    id: myCheckBox\n\n    b"
  },
  {
    "path": "gpt4all-chat/qml/MyComboBox.qml",
    "chars": 3257,
    "preview": "import QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport Qt5Compat.GraphicalEf"
  },
  {
    "path": "gpt4all-chat/qml/MyDialog.qml",
    "chars": 1210,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Dialogs\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/MyDirectoryField.qml",
    "chars": 522,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport llm\n\nTextField {\n    id: myDir"
  },
  {
    "path": "gpt4all-chat/qml/MyFancyLink.qml",
    "chars": 1095,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport Qt5Compat.GraphicalEffects\nimp"
  },
  {
    "path": "gpt4all-chat/qml/MyFileDialog.qml",
    "chars": 566,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Dialogs\n\nFileDialog {\n    id: fileDialog\n    title: qsTr(\"Please choose a fi"
  },
  {
    "path": "gpt4all-chat/qml/MyFileIcon.qml",
    "chars": 1298,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport Qt5Compat.GraphicalEffects\n\nIt"
  },
  {
    "path": "gpt4all-chat/qml/MyFolderDialog.qml",
    "chars": 379,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Dialogs\n\nFolderDialog {\n    id: folderDialog\n    title: qsTr(\"Please choose "
  },
  {
    "path": "gpt4all-chat/qml/MyMenu.qml",
    "chars": 2307,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nMenu {\n    id: menu\n\n    implicitWid"
  },
  {
    "path": "gpt4all-chat/qml/MyMenuItem.qml",
    "chars": 1434,
    "preview": "import Qt5Compat.GraphicalEffects\nimport QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimp"
  },
  {
    "path": "gpt4all-chat/qml/MyMiniButton.qml",
    "chars": 1370,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport Qt5Compat.GraphicalEffects\n\nBu"
  },
  {
    "path": "gpt4all-chat/qml/MySettingsButton.qml",
    "chars": 1422,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport mysettings\n\nButton {\n    id: m"
  },
  {
    "path": "gpt4all-chat/qml/MySettingsDestructiveButton.qml",
    "chars": 1215,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport mysettings\n\nButton {\n    id: m"
  },
  {
    "path": "gpt4all-chat/qml/MySettingsLabel.qml",
    "chars": 2338,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\n\nColumnLayout "
  },
  {
    "path": "gpt4all-chat/qml/MySettingsStack.qml",
    "chars": 2313,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Controls.impl\nimport Q"
  },
  {
    "path": "gpt4all-chat/qml/MySettingsTab.qml",
    "chars": 2371,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\n\nItem {\n    id"
  },
  {
    "path": "gpt4all-chat/qml/MySlug.qml",
    "chars": 504,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nLabel {\n    id: mySlug\n    padding: "
  },
  {
    "path": "gpt4all-chat/qml/MyTabButton.qml",
    "chars": 724,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport mysettings\nimport mysettingsen"
  },
  {
    "path": "gpt4all-chat/qml/MyTextArea.qml",
    "chars": 871,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nTextArea {\n    id: myTextArea\n\n    p"
  },
  {
    "path": "gpt4all-chat/qml/MyTextButton.qml",
    "chars": 437,
    "preview": "import QtQuick\nimport QtQuick.Controls\n\nText {\n    id: text\n\n    signal click()\n    property string tooltip\n\n    HoverHa"
  },
  {
    "path": "gpt4all-chat/qml/MyTextField.qml",
    "chars": 541,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\n\nTextField {\n    id: myTextField\n    "
  },
  {
    "path": "gpt4all-chat/qml/MyToolButton.qml",
    "chars": 1883,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport Qt5Compat.GraphicalEffects\n\nBu"
  },
  {
    "path": "gpt4all-chat/qml/MyWelcomeButton.qml",
    "chars": 2477,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport Qt5Compat.GraphicalEffects\nimp"
  },
  {
    "path": "gpt4all-chat/qml/NetworkDialog.qml",
    "chars": 4263,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport downloa"
  },
  {
    "path": "gpt4all-chat/qml/NewVersionDialog.qml",
    "chars": 1336,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport downloa"
  },
  {
    "path": "gpt4all-chat/qml/PopupDialog.qml",
    "chars": 2117,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\n\nDialog {\n    "
  },
  {
    "path": "gpt4all-chat/qml/RemoteModelCard.qml",
    "chars": 7593,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/SettingsView.qml",
    "chars": 4818,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Dialogs\nimport QtQuick"
  },
  {
    "path": "gpt4all-chat/qml/StartupDialog.qml",
    "chars": 13910,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport Qt5Comp"
  },
  {
    "path": "gpt4all-chat/qml/Theme.qml",
    "chars": 39915,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls.Basic\nimport mysettings\nimport mysettingsenums\n\nQtObject {\n    // b"
  },
  {
    "path": "gpt4all-chat/qml/ThumbsDownDialog.qml",
    "chars": 2090,
    "preview": "import QtCore\nimport QtQuick\nimport QtQuick.Controls\nimport QtQuick.Controls.Basic\nimport QtQuick.Layouts\nimport downloa"
  },
  {
    "path": "gpt4all-chat/qml/Toast.qml",
    "chars": 2136,
    "preview": "/*\n * SPDX-License-Identifier: MIT\n * Source: https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129\n * Ada"
  },
  {
    "path": "gpt4all-chat/qml/ToastManager.qml",
    "chars": 1256,
    "preview": "/*\n * SPDX-License-Identifier: MIT\n * Source: https://gist.github.com/jonmcclung/bae669101d17b103e94790341301c129\n * Ada"
  },
  {
    "path": "gpt4all-chat/resources/gpt4all.rc",
    "chars": 29,
    "preview": "IDI_ICON1 ICON \"gpt4all.ico\"\n"
  },
  {
    "path": "gpt4all-chat/src/chat.cpp",
    "chars": 16200,
    "preview": "#include \"chat.h\"\n\n#include \"chatlistmodel.h\"\n#include \"network.h\"\n#include \"server.h\"\n#include \"tool.h\"\n#include \"toolc"
  }
]

// ... and 107 more files (download for full content)

About this extraction

This page contains the full source code of the nomic-ai/gpt4all GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 307 files (3.0 MB), approximately 797.1k tokens, and a symbol index with 647 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!