From b0deabaf3f541d986500dedcd8498ca9b15471dd Mon Sep 17 00:00:00 2001 From: Per Stark Date: Wed, 29 Oct 2025 12:06:31 +0100 Subject: [PATCH] release: 0.2.6 --- .github/build-setup.yml | 49 +++++++++++++++ CHANGELOG.md | 2 + Cargo.lock | 103 +++++--------------------------- Cargo.toml | 3 +- Dockerfile | 2 +- common/src/utils/config.rs | 33 ++++++++++ devenv.lock | 88 ++++++++++++++++++++++++--- devenv.nix | 10 ++++ devenv.yaml | 18 +++--- dist-workspace.toml | 5 +- docker-compose.yml | 2 - flake.lock | 6 +- flake.nix | 119 +++++++++++++++++++------------------ main/Cargo.toml | 2 +- 14 files changed, 267 insertions(+), 175 deletions(-) create mode 100644 .github/build-setup.yml diff --git a/.github/build-setup.yml b/.github/build-setup.yml new file mode 100644 index 0000000..c6aa02f --- /dev/null +++ b/.github/build-setup.yml @@ -0,0 +1,49 @@ +- name: Prepare lib dir + run: mkdir -p lib + +# Linux +- name: Fetch ONNX Runtime (Linux) + if: runner.os == 'Linux' + env: + ORT_VER: 1.22.0 + run: | + set -euo pipefail + ARCH="$(uname -m)" + case "$ARCH" in + x86_64) URL="https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VER}/onnxruntime-linux-x64-${ORT_VER}.tgz" ;; + aarch64) URL="https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VER}/onnxruntime-linux-aarch64-${ORT_VER}.tgz" ;; + *) echo "Unsupported arch $ARCH"; exit 1 ;; + esac + curl -fsSL -o ort.tgz "$URL" + tar -xzf ort.tgz + cp -v onnxruntime-*/lib/libonnxruntime.so* lib/ + +# macOS +- name: Fetch ONNX Runtime (macOS) + if: runner.os == 'macOS' + env: + ORT_VER: 1.22.0 + run: | + set -euo pipefail + curl -fsSL -o ort.tgz "https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VER}/onnxruntime-osx-universal2-${ORT_VER}.tgz" + tar -xzf ort.tgz + # copy the main dylib; rename to stable name if needed + cp -v onnxruntime-*/lib/libonnxruntime*.dylib lib/ + # optional: ensure a stable name + if [ ! -f lib/libonnxruntime.dylib ]; then + cp -v lib/libonnxruntime*.dylib lib/libonnxruntime.dylib + fi + +# Windows +- name: Fetch ONNX Runtime (Windows) + if: runner.os == 'Windows' + shell: pwsh + env: + ORT_VER: 1.22.0 + run: | + $url = "https://github.com/microsoft/onnxruntime/releases/download/v$env:ORT_VER/onnxruntime-win-x64-$env:ORT_VER.zip" + Invoke-WebRequest $url -OutFile ort.zip + Expand-Archive ort.zip -DestinationPath ort + $dll = Get-ChildItem -Recurse -Path ort -Filter onnxruntime.dll | Select-Object -First 1 + Copy-Item $dll.FullName lib\onnxruntime.dll + diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ecd6e..922aa51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog ## Unreleased + +## Version 0.2.6 (2025-10-29) - Added an opt-in FastEmbed-based reranking stage behind `reranking_enabled`. It improves retrieval accuracy by re-scoring hybrid results. ## Version 0.2.5 (2025-10-24) diff --git a/Cargo.lock b/Cargo.lock index 515a3c0..30dedd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -574,7 +574,7 @@ dependencies = [ "quote", "serde", "serde_json", - "ureq 2.12.1", + "ureq", ] [[package]] @@ -1811,16 +1811,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" -[[package]] -name = "der" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" -dependencies = [ - "pem-rfc7468", - "zeroize", -] - [[package]] name = "deranged" version = "0.4.0" @@ -1938,7 +1928,7 @@ dependencies = [ "libc", "option-ext", "redox_users 0.5.2", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -2768,7 +2758,7 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.12", - "ureq 2.12.1", + "ureq", "windows-sys 0.60.2", ] @@ -3547,6 +3537,16 @@ dependencies = [ "cc", ] +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link 0.2.1", +] + [[package]] name = "libm" version = "0.2.13" @@ -3697,7 +3697,7 @@ checksum = "670fdfda89751bc4a84ac13eaa63e205cf0fd22b4c9a5fbfa085b63c1f1d3a30" [[package]] name = "main" -version = "0.2.5" +version = "0.2.6" dependencies = [ "anyhow", "api-router", @@ -4402,6 +4402,7 @@ version = "2.0.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fa7e49bd669d32d7bc2a15ec540a527e7764aec722a45467814005725bcd721" dependencies = [ + "libloading", "ndarray 0.16.1", "ort-sys", "smallvec 2.0.0-alpha.10", @@ -4414,11 +4415,7 @@ version = "2.0.0-rc.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2aba9f5c7c479925205799216e7e5d07cc1d4fa76ea8058c60a9a30f6a4e890" dependencies = [ - "flate2", "pkg-config", - "sha2", - "tar", - "ureq 3.1.2", ] [[package]] @@ -4539,15 +4536,6 @@ dependencies = [ "serde", ] -[[package]] -name = "pem-rfc7468" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -6549,17 +6537,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tar" -version = "0.4.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d863878d212c87a19c1a610eb53bb01fe12951c0501cf5a0d65f724914a667a" -dependencies = [ - "filetime", - "libc", - "xattr", -] - [[package]] name = "target-lexicon" version = "0.12.16" @@ -7312,37 +7289,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "ureq" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ba1025f18a4a3fc3e9b48c868e9beb4f24f4b4b1a325bada26bd4119f46537" -dependencies = [ - "base64 0.22.1", - "der", - "log", - "native-tls", - "percent-encoding", - "rustls-pemfile", - "rustls-pki-types", - "socks", - "ureq-proto", - "utf-8", - "webpki-root-certs", -] - -[[package]] -name = "ureq-proto" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b4531c118335662134346048ddb0e54cc86bd7e81866757873055f0e38f5d2" -dependencies = [ - "base64 0.22.1", - "http", - "httparse", - "log", -] - [[package]] name = "url" version = "2.5.4" @@ -7613,15 +7559,6 @@ dependencies = [ "string_cache_codegen", ] -[[package]] -name = "webpki-root-certs" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d651ec480de84b762e7be71e6efa7461699c19d9e2c272c8d93455f567786e" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "webpki-roots" version = "0.26.10" @@ -8048,16 +7985,6 @@ dependencies = [ "tap", ] -[[package]] -name = "xattr" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156" -dependencies = [ - "libc", - "rustix", -] - [[package]] name = "xml-rs" version = "0.8.26" diff --git a/Cargo.toml b/Cargo.toml index 66a09e7..6a8e1ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,8 +56,7 @@ base64 = "0.22.1" object_store = { version = "0.11.2" } bytes = "1.7.1" state-machines = "0.2.0" -fastembed = "5.2.0" -ort = { version = "=2.0.0-rc.8", default-features = false, features = ["load-dynamic"] } +fastembed = { version = "5.2.0", default-features = false, features = ["hf-hub-native-tls", "ort-load-dynamic"] } [profile.dist] inherits = "release" diff --git a/Dockerfile b/Dockerfile index c7ee56d..ae9d11f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # ONNX Runtime (CPU). Change if you bump ort. -ARG ORT_VERSION=1.21.0 +ARG ORT_VERSION=1.22.0 RUN mkdir -p /opt/onnxruntime && \ curl -fsSL -o /tmp/ort.tgz \ "https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-${ORT_VERSION}.tgz" && \ diff --git a/common/src/utils/config.rs b/common/src/utils/config.rs index 51c21bf..0aa79d4 100644 --- a/common/src/utils/config.rs +++ b/common/src/utils/config.rs @@ -1,5 +1,6 @@ use config::{Config, ConfigError, Environment, File}; use serde::Deserialize; +use std::env; #[derive(Clone, Deserialize, Debug)] #[serde(rename_all = "lowercase")] @@ -66,6 +67,36 @@ fn default_reranking_enabled() -> bool { false } +pub fn ensure_ort_path() { + if env::var_os("ORT_DYLIB_PATH").is_some() { + return; + } + if let Ok(mut exe) = env::current_exe() { + exe.pop(); + + if cfg!(target_os = "windows") { + for p in [ + exe.join("onnxruntime.dll"), + exe.join("lib").join("onnxruntime.dll"), + ] { + if p.exists() { + env::set_var("ORT_DYLIB_PATH", p); + return; + } + } + } + let name = if cfg!(target_os = "macos") { + "libonnxruntime.dylib" + } else { + "libonnxruntime.so" + }; + let p = exe.join("lib").join(name); + if p.exists() { + env::set_var("ORT_DYLIB_PATH", p); + } + } +} + impl Default for AppConfig { fn default() -> Self { Self { @@ -90,6 +121,8 @@ impl Default for AppConfig { } pub fn get_config() -> Result { + ensure_ort_path(); + let config = Config::builder() .add_source(File::with_name("config").required(false)) .add_source(Environment::default()) diff --git a/devenv.lock b/devenv.lock index 77380f9..4862f1b 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,10 +3,10 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1746681099, + "lastModified": 1761839147, "owner": "cachix", "repo": "devenv", - "rev": "a7f2ea275621391209fd702f5ddced32dd56a4e2", + "rev": "bb7849648b68035f6b910120252c22b28195cf54", "type": "github" }, "original": { @@ -16,13 +16,31 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1761893049, + "owner": "nix-community", + "repo": "fenix", + "rev": "c2ac9a5c0d6d16630c3b225b874bd14528d1abe6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1733328505, + "lastModified": 1761588595, "owner": "edolstra", "repo": "flake-compat", - "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5", "type": "github" }, "original": { @@ -40,10 +58,10 @@ ] }, "locked": { - "lastModified": 1746537231, + "lastModified": 1760663237, "owner": "cachix", "repo": "git-hooks.nix", - "rev": "fa466640195d38ec97cf0493d6d6882bc4d14969", + "rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37", "type": "github" }, "original": { @@ -74,10 +92,25 @@ }, "nixpkgs": { "locked": { - "lastModified": 1746576598, + "lastModified": 1761672384, "owner": "nixos", "repo": "nixpkgs", - "rev": "b3582c75c7f21ce0b429898980eddbbf05c68e55", + "rev": "08dacfca559e1d7da38f3cf05f1f45ee9bfd213c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761880412, + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a7fc11be66bdfb5cdde611ee5ce381c183da8386", "type": "github" }, "original": { @@ -90,11 +123,48 @@ "root": { "inputs": { "devenv": "devenv", + "fenix": "fenix", "git-hooks": "git-hooks", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "pre-commit-hooks": [ "git-hooks" + ], + "rust-overlay": "rust-overlay" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1761849405, + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "f7de8ae045a5fe80f1203c5a1c3015b05f7c3550", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" ] + }, + "locked": { + "lastModified": 1761878277, + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "6604534e44090c917db714faa58d47861657690c", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/devenv.nix b/devenv.nix index 719b169..d61a2c9 100644 --- a/devenv.nix +++ b/devenv.nix @@ -11,14 +11,24 @@ pkgs.openssl pkgs.nodejs pkgs.vscode-langservers-extracted + pkgs.cargo-dist + pkgs.cargo-xwin + pkgs.clang + pkgs.onnxruntime ]; languages.rust = { enable = true; components = ["rustc" "clippy" "rustfmt" "cargo" "rust-analyzer"]; + channel = "nightly"; + targets = ["x86_64-unknown-linux-gnu" "x86_64-pc-windows-msvc"]; mold.enable = true; }; + env = { + ORT_DYLIB_PATH = "${pkgs.onnxruntime}/lib/libonnxruntime.so"; + }; + processes = { surreal_db.exec = "docker run --rm --pull always -p 8000:8000 --net=host --user $(id -u) -v $(pwd)/database:/database surrealdb/surrealdb:latest-dev start rocksdb:/database/database.db --user root_user --pass root_password"; }; diff --git a/devenv.yaml b/devenv.yaml index f06d9d4..84838c2 100644 --- a/devenv.yaml +++ b/devenv.yaml @@ -1,15 +1,11 @@ -# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json inputs: + fenix: + url: github:nix-community/fenix nixpkgs: url: github:nixos/nixpkgs/nixpkgs-unstable - -# If you're using non-OSS software, you can set allowUnfree to true. + rust-overlay: + url: github:oxalica/rust-overlay + inputs: + nixpkgs: + follows: nixpkgs allowUnfree: true - -# If you're willing to use a package that's vulnerable -# permittedInsecurePackages: -# - "openssl-1.1.1w" - -# If you have more than one devenv you can merge them -#imports: -# - ./backend diff --git a/dist-workspace.toml b/dist-workspace.toml index fed452b..106b44f 100644 --- a/dist-workspace.toml +++ b/dist-workspace.toml @@ -4,9 +4,12 @@ members = ["cargo:."] # Config for 'dist' [dist] # The preferred dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.28.0" +cargo-dist-version = "0.30.0" # CI backends to support ci = "github" +# Extra static files to include in each App (path relative to this Cargo.toml's dir) +include = [] +github-build-setup = "../build-setup.yml" # The installers to generate for each app installers = [] # Target platforms to build apps for (Rust target-triple syntax) diff --git a/docker-compose.yml b/docker-compose.yml index 79cf8b4..3d9b75f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: minne: build: . diff --git a/flake.lock b/flake.lock index 5cd5259..13ef3ca 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1746232882, - "narHash": "sha256-MHmBH2rS8KkRRdoU/feC/dKbdlMkcNkB5mwkuipVHeQ=", + "lastModified": 1761672384, + "narHash": "sha256-o9KF3DJL7g7iYMZq9SWgfS1BFlNbsm6xplRjVlOCkXI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7a2622e2c0dbad5c4493cb268aba12896e28b008", + "rev": "08dacfca559e1d7da38f3cf05f1f45ee9bfd213c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 1a2dd86..82292a2 100644 --- a/flake.nix +++ b/flake.nix @@ -13,69 +13,74 @@ flake-utils, crane, }: - flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}; - craneLib = crane.mkLib pkgs; + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + lib = pkgs.lib; + craneLib = crane.mkLib pkgs; + libExt = + if pkgs.stdenv.isDarwin + then "dylib" + else "so"; + minne-pkg = craneLib.buildPackage { + src = lib.cleanSourceWith { + src = ./.; + filter = let + extraPaths = [ + (toString ./common/migrations) + (toString ./common/schemas) + (toString ./html-router/templates) + (toString ./html-router/assets) + ]; + in + path: type: let + p = toString path; + in + craneLib.filterCargoSources path type + || lib.any (x: lib.hasPrefix x p) extraPaths; + }; - minne-pkg = craneLib.buildPackage { - src = craneLib.cleanCargoSource ./.; - pname = "minne"; - version = "0.1.0"; + pname = "minne"; + version = "0.2.6"; + doCheck = false; - doCheck = false; + nativeBuildInputs = [pkgs.pkg-config pkgs.rustfmt pkgs.makeWrapper]; + buildInputs = [pkgs.openssl pkgs.chromium pkgs.onnxruntime]; - nativeBuildInputs = [ - pkgs.pkg-config - pkgs.rustfmt - pkgs.makeWrapper - ]; - - buildInputs = [ - pkgs.openssl - pkgs.chromium - pkgs.onnxruntime - ]; - - ORT_STRATEGY = "system"; - ORT_LIB_LOCATION = "${pkgs.onnxruntime}/lib"; - ORT_SKIP_DOWNLOAD = "1"; - - postInstall = '' - wrapProgram $out/bin/main \ - --set CHROME ${pkgs.chromium}/bin/chromium \ - --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so - if [ -f $out/bin/worker ]; then - wrapProgram $out/bin/worker \ + postInstall = '' + wrapProgram $out/bin/main \ + --set CHROME ${pkgs.chromium}/bin/chromium \ + --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.${libExt} + for b in worker server; do + if [ -x "$out/bin/$b" ]; then + wrapProgram $out/bin/$b \ --set CHROME ${pkgs.chromium}/bin/chromium \ - --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so + --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.${libExt} fi - if [ -f $out/bin/server]; then - wrapProgram $out/bin/server\ - --set ORT_DYLIB_PATH ${pkgs.onnxruntime}/lib/libonnxruntime.so - fi - ''; + done + ''; + }; + in { + packages = { + minne-pkg = minne-pkg; + default = minne-pkg; + }; + apps = { + main = flake-utils.lib.mkApp { + drv = minne-pkg; + name = "main"; }; - in { - packages = { - default = self.packages.${system}.minne-pkg; + worker = flake-utils.lib.mkApp { + drv = minne-pkg; + name = "worker"; }; - - apps = { - main = flake-utils.lib.mkApp { - drv = minne-pkg; - name = "main"; - }; - worker = flake-utils.lib.mkApp { - drv = minne-pkg; - name = "worker"; - }; - server = flake-utils.lib.mkApp { - drv = minne-pkg; - name = "server"; - }; - default = self.apps.${system}.main; + server = flake-utils.lib.mkApp { + drv = minne-pkg; + name = "server"; }; - } - ); + default = flake-utils.lib.mkApp { + drv = minne-pkg; + name = "main"; + }; + }; + }); } diff --git a/main/Cargo.toml b/main/Cargo.toml index d06f430..87a0fb6 100644 --- a/main/Cargo.toml +++ b/main/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "main" -version = "0.2.5" +version = "0.2.6" edition = "2021" repository = "https://github.com/perstarkse/minne" license = "AGPL-3.0-or-later"