From 92c9cecf44862d33963762a90c1890e8f6905662 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Mon, 11 Nov 2024 15:38:08 -0300 Subject: [PATCH] - fix: ollama version empty when client and server version are equal (#530) --- .github/workflows/pr-ci-healchecks.yml | 2 +- .github/workflows/release-dev.yml | 2 +- .github/workflows/release-prod.yml | 2 +- README.md | 6 +++--- .../process_handlers/ollama_process_handler.rs | 18 +++++++++++++++++- ci-scripts/download-side-binaries.ts | 5 +---- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr-ci-healchecks.yml b/.github/workflows/pr-ci-healchecks.yml index f00fb1b3a..61acd018f 100644 --- a/.github/workflows/pr-ci-healchecks.yml +++ b/.github/workflows/pr-ci-healchecks.yml @@ -38,7 +38,7 @@ jobs: env: ARCH: x86_64-unknown-linux-gnu SHINKAI_NODE_VERSION: v0.8.14 - OLLAMA_VERSION: v0.4.0 + OLLAMA_VERSION: v0.4.1 run: | npx ts-node ./ci-scripts/download-side-binaries.ts diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 75b0844b7..1b1f37fd2 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -209,7 +209,7 @@ jobs: env: ARCH: ${{ matrix.arch }} SHINKAI_NODE_VERSION: v0.8.14 - OLLAMA_VERSION: v0.4.0 + OLLAMA_VERSION: v0.4.1 run: | npx ts-node ./ci-scripts/download-side-binaries.ts diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 4db9c623d..6a66b16b6 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -207,7 +207,7 @@ jobs: env: ARCH: ${{ matrix.arch }} SHINKAI_NODE_VERSION: v0.8.14 - OLLAMA_VERSION: v0.4.0 + OLLAMA_VERSION: v0.4.1 run: | npx ts-node ./ci-scripts/download-side-binaries.ts diff --git a/README.md b/README.md index 4fe9b47da..773ae0ed0 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ $ git clone https://github.com/dcSpark/shinkai-apps #### Macos ``` ARCH="aarch64-apple-darwin" \ -OLLAMA_VERSION="v0.4.0" \ +OLLAMA_VERSION="v0.4.1" \ SHINKAI_NODE_VERSION="v0.8.14" \ npx ts-node ./ci-scripts/download-side-binaries.ts ``` @@ -53,14 +53,14 @@ npx ts-node ./ci-scripts/download-side-binaries.ts #### Linux ``` ARCH="x86_64-unknown-linux-gnu" \ -OLLAMA_VERSION="v0.4.0"\ +OLLAMA_VERSION="v0.4.1"\ SHINKAI_NODE_VERSION="v0.8.14" \ npx ts-node ./ci-scripts/download-side-binaries.ts ``` #### Windows ``` -$ENV:OLLAMA_VERSION="v0.4.0" +$ENV:OLLAMA_VERSION="v0.4.1" $ENV:SHINKAI_NODE_VERSION="v0.8.14" $ENV:ARCH="x86_64-pc-windows-msvc" npx ts-node ./ci-scripts/download-side-binaries.ts diff --git a/apps/shinkai-desktop/src-tauri/src/local_shinkai_node/process_handlers/ollama_process_handler.rs b/apps/shinkai-desktop/src-tauri/src/local_shinkai_node/process_handlers/ollama_process_handler.rs index b36e9b84e..ba2a57672 100644 --- a/apps/shinkai-desktop/src-tauri/src/local_shinkai_node/process_handlers/ollama_process_handler.rs +++ b/apps/shinkai-desktop/src-tauri/src/local_shinkai_node/process_handlers/ollama_process_handler.rs @@ -214,12 +214,28 @@ impl OllamaProcessHandler { let stdout = String::from_utf8_lossy(&output.stdout); log::info!("capturing ollama version from stdout: {:?}", stdout); + /* + 'client version is *.*.*' is the real ollam version our app is running BUT + - when embedded and local ollama are equal the message says 'ollama version is *.*.*' + - when embedded and local are different, the message says 'ollama version is *.*.*... \nWarning client version is *.*.*' + + So we try to find the client version and if it doesn't exists we fallback to ollama version (that means client and local are equals) + */ let re = Regex::new(r"client version is (\S+)").unwrap(); - let version = re + let mut version = re .captures(&stdout) .and_then(|cap| cap.get(1)) .map(|m| m.as_str()) .unwrap_or(""); + + if version.is_empty() { + let re = Regex::new(r"ollama version is (\S+)").unwrap(); + version = re + .captures(&stdout) + .and_then(|cap| cap.get(1)) + .map(|m| m.as_str()) + .unwrap_or(""); + } log::info!("ollama version {}", version); Ok(version.to_string()) diff --git a/ci-scripts/download-side-binaries.ts b/ci-scripts/download-side-binaries.ts index 793b529c3..657c9e6e1 100644 --- a/ci-scripts/download-side-binaries.ts +++ b/ci-scripts/download-side-binaries.ts @@ -1,5 +1,5 @@ import { exec } from 'child_process'; -import { createWriteStream, existsSync } from 'fs'; +import { createWriteStream } from 'fs'; import path from 'path'; import axios from 'axios'; import { ensureFile } from 'fs-extra'; @@ -46,9 +46,6 @@ const addExecPermissions = (path: string) => { }; const downloadFile = async (url: string, path: string): Promise => { - if (existsSync(path)) { - return Promise.resolve(); - } console.log(`Downloading ${url}`); const response = await axios({ method: 'GET',