diff --git a/app/README.md b/app/README.md index df9e4784..a09226af 100644 --- a/app/README.md +++ b/app/README.md @@ -6,10 +6,10 @@ This app builds upon Ollama to provide a desktop experience for running models. ## Developing -In the background run the ollama server `ollama.py`: +First, build the `ollama` binary: ``` -poetry -C .. run ollama serve +make -C .. ``` Then run the desktop app with `npm start`: diff --git a/app/forge.config.ts b/app/forge.config.ts index 08392dec..9fe59a97 100644 --- a/app/forge.config.ts +++ b/app/forge.config.ts @@ -8,6 +8,7 @@ import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-nati import { WebpackPlugin } from '@electron-forge/plugin-webpack' import * as path from 'path' import * as fs from 'fs' +import * as os from 'fs' import { mainConfig } from './webpack.main.config' import { rendererConfig } from './webpack.renderer.config' @@ -19,7 +20,7 @@ const config: ForgeConfig = { appVersion: process.env.VERSION || packageJson.version, asar: true, icon: './images/icon', - extraResource: ['../ollama', '../ggml-metal.metal'], + extraResource: ['../ollama', ...(process.platform === 'darwin' ? ['../ggml-metal.metal'] : [])], ...(process.env.SIGN ? { osxSign: { diff --git a/app/src/index.ts b/app/src/index.ts index b56532fe..1a89515e 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -57,6 +57,25 @@ if (app.isPackaged) { }) } +function server() { + const binary = app.isPackaged + ? path.join(process.resourcesPath, 'ollama') + : path.resolve(__dirname, '..', '..', 'ollama') + + console.log(`Starting server`) + const proc = spawn(binary, ['serve']) + proc.stdout.on('data', data => { + console.log(`server: ${data}`) + }) + proc.stderr.on('data', data => { + console.error(`server: ${data}`) + }) + + process.on('exit', () => { + proc.kill() + }) +} + function installCLI() { const symlinkPath = '/usr/local/bin/ollama' @@ -93,7 +112,10 @@ function installCLI() { // Some APIs can only be used after this event occurs. app.on('ready', () => { createWindow() - installCLI() + + if (app.isPackaged) { + installCLI() + } }) // Quit when all windows are closed, except on macOS. There, it's common