### Run Example Script Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Instructions on how to build the project and run the example script to list downloaded Ollama versions. ```bash npm run build npx tsx examples/list-downloaded.ts ``` -------------------------------- ### Run Example: Download for Multiple Platforms Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Commands to build the project and run the 'download-windows-mac-linux.ts' example using tsx. This tests the functionality of downloading Ollama for various platforms. ```bash npm run build npx tsx examples/download-windows-mac-linux.ts ``` -------------------------------- ### Run Example: Serve Latest Ollama Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Commands to build the project and run the 'serve-latest.ts' example using tsx. This allows you to test the functionality of serving the latest Ollama version. ```bash npm run build npx tsx examples/serve-latest.ts ``` -------------------------------- ### Run Example: Serve Specific Ollama Version Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Commands to build the project and run the 'serve-version.ts' example using tsx. This allows testing the functionality of serving a specific Ollama version. ```bash npm run build npx tsx examples/serve-version.ts ``` -------------------------------- ### Install electron-ollama Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Installs the electron-ollama package using npm. This is the first step to integrating Ollama into your Electron application. ```bash npm install electron-ollama ``` -------------------------------- ### Download Ollama for Multiple Platforms Source: https://github.com/antarasi/electron-ollama/blob/main/README.md This example demonstrates downloading Ollama executables for different platforms (Windows, macOS, Linux) with a specific architecture (arm64). It fetches metadata for the latest version and then initiates the download for each specified platform configuration. ```typescript import { ElectronOllama } from '../dist' // replace with: import { ElectronOllama } from 'electron-ollama' import { app } from './mock/electron' // on electron app replace with: import { app } from 'electron' async function main() { const eo = new ElectronOllama({ basePath: app.getPath('userData'), }) const metadata = await eo.getMetadata('latest') await eo.download(metadata.version, { os: 'windows', arch: 'arm64' }) await eo.download(metadata.version, { os: 'darwin', arch: 'arm64' }) await eo.download(metadata.version, { os: 'linux', arch: 'arm64' }) console.log('Downloaded', metadata.version, 'for windows, mac and linux') } main() ``` -------------------------------- ### Serve Latest Ollama Version Source: https://github.com/antarasi/electron-ollama/blob/main/README.md This example demonstrates how to serve the latest version of Ollama if it's not already running. It initializes ElectronOllama, checks if Ollama is running, and if not, downloads and serves the latest version with optional logging for server and download progress. ```typescript import { ElectronOllama } from '../dist' // replace with: import { ElectronOllama } from 'electron-ollama' import { app } from './mock/electron' // on electron app replace with: import { app } from 'electron' async function main() { const eo = new ElectronOllama({ basePath: app.getPath('userData'), }) if (!(await eo.isRunning())) { const metadata = await eo.getMetadata('latest') await eo.serve(metadata.version, { serverLog: (message) => console.log('[Ollama]', message), downloadLog: (percent, message) => console.log('[Ollama Download]', `${percent}%`, message) }) } else { console.log('Ollama server is already running') } } main() ``` -------------------------------- ### Serve Specific Ollama Version Source: https://github.com/antarasi/electron-ollama/blob/main/README.md This example shows how to serve a specific version of Ollama. It initializes ElectronOllama, checks if Ollama is running, and if not, serves a specified version (e.g., 'v0.11.0') with logging. It also demonstrates fetching the currently running Ollama version and gracefully stopping the server. ```typescript import { ElectronOllama } from '../dist' // replace with: import { ElectronOllama } from 'electron-ollama' import { app } from './mock/electron' // on electron app replace with: import { app } from 'electron' async function main() { const eo = new ElectronOllama({ basePath: app.getPath('userData'), }) if (!(await eo.isRunning())) { // Welcome OpenAI's gpt-oss models await eo.serve('v0.11.0', { serverLog: (message) => console.log('[Ollama]', message), downloadLog: (percent, message) => console.log('[Ollama Download]', `${percent}%`, message) }) const liveVersion = await fetch('http://localhost:11434/api/version').then(res => res.json()) console.log('Currently running Ollama', liveVersion) await eo.getServer()?.stop() // gracefully stop the server with 5s timeout } else { console.log('Ollama server is already running') } } main() ``` -------------------------------- ### Electron Ollama API Reference Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Comprehensive API reference for the Electron Ollama library, detailing methods for managing Ollama binaries within Electron applications. Includes configuration, downloading, serving, and checking Ollama status. ```APIDOC import { ElectronOllamaConfig, OllamaServerConfig, PlatformConfig, OllamaAssetMetadata, SpecificVersion, Version } from './types'; import { ElectronOllamaServer } from './server'; export type { ElectronOllamaConfig, OllamaServerConfig, PlatformConfig, OllamaAssetMetadata, SpecificVersion, Version }; export { ElectronOllamaServer }; export declare class ElectronOllama { private config; private server; constructor(config: ElectronOllamaConfig); /** * Get the current platform configuration */ currentPlatformConfig(): PlatformConfig; /** * Get the name of the asset for the given platform configuration (e.g. "ollama-windows-amd64.zip" or "ollama-darwin.tgz") */ getAssetName(platformConfig: PlatformConfig): string; /** * Get metadata for a specific version ('latest' by default) and platform */ getMetadata(version?: Version, platformConfig?: PlatformConfig): Promise; /** * Download Ollama for the specified version ('latest' by default) and platform */ download(version?: Version, platformConfig?: PlatformConfig, { log }?: { log?: (percent: number, message: string) => void; }): Promise; /** * Check if a version is downloaded for the given platform configuration */ isDownloaded(version: SpecificVersion, platformConfig?: PlatformConfig): Promise; /** * List all downloaded versions for the given platform configuration */ downloadedVersions(platformConfig?: PlatformConfig): Promise; /** * Get the path to the directory for the given version and platform configuration */ getBinPath(version: SpecificVersion, platformConfig?: PlatformConfig): string; /** * Get the name of the executable for the given platform configuration */ getExecutableName(platformConfig: PlatformConfig): string; /** * Start serving Ollama with the specified version and wait until it is running */ serve(version: SpecificVersion, { serverLog, downloadLog, timeoutSec }?: { serverLog?: (message: string) => void; downloadLog?: (percent: number, message: string) => void; timeoutSec?: number; }): Promise; /** * Get the server instance started by serve() */ getServer(): ElectronOllamaServer | null; /** * Check if Ollama is running */ isRunning(): Promise; } export default ElectronOllama; //# sourceMappingURL=index.d.ts.map ``` -------------------------------- ### List Downloaded Ollama Versions Source: https://github.com/antarasi/electron-ollama/blob/main/README.md Demonstrates how to list all downloaded Ollama versions for the current platform and a specific platform (Windows ARM64). This is useful for managing available Ollama binaries within an Electron application. ```ts import { ElectronOllama } from '../dist' // replace with: import { ElectronOllama } from 'electron-ollama' import { app } from './mock/electron' // on electron app replace with: import { app } from 'electron' async function main() { const eo = new ElectronOllama({ basePath: app.getPath('userData'), }) const currentVersion = await eo.downloadedVersions() console.log('current platform versions', currentVersion) // [ 'v0.11.0', 'v0.11.2', 'v0.11.4' ] const windowsVersions = await eo.downloadedVersions({ os: 'windows', arch: 'arm64' }) console.log('windows versions', windowsVersions) // [ 'v0.11.4' ] } main() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.