diff --git a/binary/package-lock.json b/binary/package-lock.json index 92756d546..001e69a8e 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -56,6 +56,7 @@ "@continuedev/fetch": "file:../packages/fetch", "@continuedev/llm-info": "file:../packages/llm-info", "@continuedev/openai-adapters": "file:../packages/openai-adapters", + "@continuedev/terminal-security": "file:../packages/terminal-security", "@modelcontextprotocol/sdk": "^1.12.0", "@mozilla/readability": "^0.5.0", "@octokit/rest": "^20.1.1", diff --git a/core/core.ts b/core/core.ts index c340fb624..bfac300de 100644 --- a/core/core.ts +++ b/core/core.ts @@ -18,6 +18,7 @@ import { CodebaseIndexer } from "./indexing/CodebaseIndexer"; import DocsService from "./indexing/docs/DocsService"; import { countTokens } from "./llm/countTokens"; import Ollama from "./llm/llms/Ollama"; +import Lemonade from "./llm/llms/Lemonade"; import { EditAggregator } from "./nextEdit/context/aggregateEdits"; import { createNewPromptFileV2 } from "./promptFiles/createNewPromptFile"; import { callTool } from "./tools/callTool"; @@ -1263,6 +1264,9 @@ export class Core { if (msg.data.title === "Ollama") { const models = await new Ollama({ model: "" }).listModels(); return models; + } else if (msg.data.title === "Lemonade") { + const models = await new Lemonade({ model: "" }).listModels(); + return models; } else { return undefined; } diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 369a9cb9a..2ccc325cf 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -45,6 +45,7 @@ import { const PROVIDER_HANDLES_TEMPLATING: string[] = [ "lmstudio", + "lemonade", "openai", "nvidia", "ollama", @@ -67,6 +68,7 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [ const PROVIDER_SUPPORTS_IMAGES: string[] = [ "openai", "ollama", + "lemonade", "cohere", "gemini", "msty", diff --git a/core/llm/index.ts b/core/llm/index.ts index f8fefd381..191a3f324 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -30,6 +30,7 @@ import { TemplateType, Usage, } from "../index.js"; +import { isLemonadeInstalled } from "../util/lemonadeHelper.js"; import { Logger } from "../util/Logger.js"; import mergeJson from "../util/merge.js"; import { renderChatMessage } from "../util/messageContent.js"; @@ -503,6 +504,24 @@ export abstract class BaseLLM implements ILLM { : "Unable to connect to local Ollama instance. Ollama may not be installed or may not running."; throw new Error(message); } + if ( + e.code === "ECONNREFUSED" && + e.message.includes("http://localhost:8000") + ) { + const isInstalled = await isLemonadeInstalled(); + let message: string; + if (process.platform === "linux") { + // On Linux, isLemonadeInstalled checks if it's running (via health endpoint) + message = + "Unable to connect to local Lemonade instance. Please ensure Lemonade is running. Visit http://lemonade-server.ai for setup instructions."; + } else { + // On Windows, we can check if it's installed + message = isInstalled + ? "Unable to connect to local Lemonade instance. Lemonade server may not be running." + : "Unable to connect to local Lemonade instance. Lemonade may not be installed or may not be running."; + } + throw new Error(message); + } } throw e; } diff --git a/core/llm/llms/Lemonade.ts b/core/llm/llms/Lemonade.ts new file mode 100644 index 000000000..94860f929 --- /dev/null +++ b/core/llm/llms/Lemonade.ts @@ -0,0 +1,12 @@ +import { LLMOptions } from "../../index.js"; + +import OpenAI from "./OpenAI.js"; + +class Lemonade extends OpenAI { + static providerName = "lemonade"; + static defaultOptions: Partial = { + apiBase: "http://localhost:8000/api/v1/", + }; +} + +export default Lemonade; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 7a058ced7..bb4301576 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -33,6 +33,7 @@ import Kindo from "./Kindo"; import LlamaCpp from "./LlamaCpp"; import Llamafile from "./Llamafile"; import LlamaStack from "./LlamaStack"; +import Lemonade from "./Lemonade"; import LMStudio from "./LMStudio"; import Mistral from "./Mistral"; import MockLLM from "./Mock"; @@ -82,6 +83,7 @@ export const LLMClasses = [ LlamaCpp, OpenAI, OVHcloud, + Lemonade, LMStudio, Mistral, Bedrock, diff --git a/core/util/lemonadeHelper.ts b/core/util/lemonadeHelper.ts new file mode 100644 index 000000000..ff8d4dfbc --- /dev/null +++ b/core/util/lemonadeHelper.ts @@ -0,0 +1,59 @@ +import { exec } from "node:child_process"; +import { IDE } from ".."; + +export async function isLemonadeInstalled(): Promise { + // On Windows, check if lemonade-server command exists + if (process.platform === "win32") { + return new Promise((resolve, _reject) => { + exec("where.exe lemonade-server", (error, _stdout, _stderr) => { + resolve(!error); + }); + }); + } + + // On Linux, check if the health endpoint is accessible + try { + const response = await fetch("http://localhost:8000/api/v1/health", { + method: "GET", + signal: AbortSignal.timeout(3000), // 3 second timeout + }); + + if (response.ok) { + const data = await response.json(); + return data.status === "ok"; + } + return false; + } catch { + return false; + } +} + +export async function startLocalLemonade(ide: IDE): Promise { + let startCommand: string | undefined; + + switch (process.platform) { + case "linux": // Linux + // On Linux, direct users to start Lemonade manually + return ide.showToast( + "info", + "Please start Lemonade manually. Visit https://lemonade-server.ai for instructions.", + ); + + case "win32": // Windows + startCommand = "lemonade-server serve\n"; + break; + + default: + return ide.showToast( + "error", + "Cannot start Lemonade: platform not supported!", + ); + } + + if (startCommand) { + return ide.runCommand(startCommand, { + reuseTerminal: true, + terminalName: "Start Lemonade", + }); + } +} diff --git a/docs/customize/model-providers/more/lemonade.mdx b/docs/customize/model-providers/more/lemonade.mdx new file mode 100644 index 000000000..79afd957d --- /dev/null +++ b/docs/customize/model-providers/more/lemonade.mdx @@ -0,0 +1,81 @@ +--- +title: "Lemonade Server" +description: "Configure Lemonade Server with Continue for refreshingly fast local LLM inference on GPUs and NPUs" +--- + + + Get started with [Lemonade Server](https://lemonade-server.ai/) - Refreshingly fast LLMs on GPUs and NPUs with seamless Continue integration + + +## Overview + +Lemonade Server provides optimized local LLM inference with support for GPU and NPU hardware acceleration. It offers an OpenAI-compatible API that seamlessly integrates with Continue and other open-source platforms. + +## Installation + +Download and install Lemonade Server from [lemonade-server.ai](https://lemonade-server.ai/). + +## Configuration + +Lemonade Server is available directly in the Continue UI as a provider. You can select it from the model provider dropdown without manual configuration. + +### Option 1: Using the Continue UI (Recommended) + +1. Click on the model selector dropdown in Continue +2. Select "Add Model" +3. Choose "Lemonade Server" from the provider list +4. Continue will automatically configure the connection + +### Option 2: Manual Configuration + +If you need custom settings, you can manually configure Lemonade: + + + + ```yaml title="config.yaml" + models: + - name: Lemonade + provider: lemonade + model: + apiBase: http://localhost:8000/api/v1/ + ``` + + + ```json title="config.json" + { + "models": [ + { + "title": "Lemonade", + "provider": "lemonade", + "model": "", + "apiBase": "http://localhost:8000/api/v1/" + } + ] + } + ``` + + + +## Getting Started + +1. **Install Lemonade Server**: Download from [lemonade-server.ai](https://lemonade-server.ai/) +2. **Start the server**: Launch Lemonade Server (runs on `http://localhost:8000/api/v1/` by default) +3. **Add to Continue**: Select Lemonade Server from the model provider dropdown in Continue +4. **Load a model**: Choose your preferred model through the interface + +## Hardware Support + +Lemonade Server automatically detects and optimizes for available hardware: +- **NPU**: Neural Processing Unit acceleration for efficient inference +- **GPU**: Full GPU acceleration support +- **CPU**: Optimized CPU fallback when accelerators are unavailable + +## Key Features + +- OpenAI-compatible API for seamless integration +- Support for popular model formats +- Automatic hardware detection and optimization +- Integration with Continue, Open WebUI, Gaia, and AnythingLLM +- Active open-source community + +[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Lemonade.ts) \ No newline at end of file diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 2efb25f51..05dd18300 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -9,6 +9,7 @@ import { Core } from "core/core"; import { walkDirAsync } from "core/indexing/walkDir"; import { isModelInstaller } from "core/llm"; import { startLocalOllama } from "core/util/ollamaHelper"; +import { startLocalLemonade } from "core/util/lemonadeHelper"; import { getConfigJsonPath, getConfigYamlPath } from "core/util/paths"; import { Telemetry } from "core/util/posthog"; import * as vscode from "vscode"; @@ -620,6 +621,9 @@ const getCommandsMap: ( "continue.startLocalOllama": () => { startLocalOllama(ide); }, + "continue.startLocalLemonade": () => { + startLocalLemonade(ide); + }, "continue.installModel": async ( modelName: string, llmProvider: ILLM | undefined, diff --git a/extensions/vscode/src/util/errorHandling.ts b/extensions/vscode/src/util/errorHandling.ts index 40428cadd..c4b1f1c79 100644 --- a/extensions/vscode/src/util/errorHandling.ts +++ b/extensions/vscode/src/util/errorHandling.ts @@ -3,13 +3,41 @@ import { isModelInstaller } from "core/llm"; import * as vscode from "vscode"; /** - * @param error Handles common LLM errors. Currently only handles Ollama-related errors. + * @param error Handles common LLM errors. Currently handles Ollama and Lemonade-related errors. * @returns true if error is handled, false otherwise */ export async function handleLLMError(error: unknown): Promise { if (!error || !(error instanceof Error) || !error.message) { return false; } + + // Handle Lemonade errors + if (error.message.toLowerCase().includes("lemonade")) { + let message: string = error.message; + let options: string[] | undefined; + + // For Windows, offer to start Lemonade if it's installed but not running + if ( + process.platform === "win32" && + message.includes("Lemonade server may not be running") + ) { + options = ["Start Lemonade", "Setup Instructions"]; + } else { + // For all other cases (Linux, not installed, etc.), direct to setup instructions + options = ["Setup Instructions"]; + } + + vscode.window.showErrorMessage(message, ...options).then((val) => { + if (val === "Setup Instructions") { + vscode.env.openExternal(vscode.Uri.parse("https://lemonade-server.ai")); + } else if (val === "Start Lemonade") { + vscode.commands.executeCommand("continue.startLocalLemonade"); + } + }); + return true; + } + + // Handle Ollama errors if (!error.message.toLowerCase().includes("ollama")) { return false; } diff --git a/gui/public/logos/lemonade.png b/gui/public/logos/lemonade.png new file mode 100644 index 000000000..3e8347404 Binary files /dev/null and b/gui/public/logos/lemonade.png differ diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index e7b6d1bf0..cba89d3f3 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -566,6 +566,38 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n packages: [models.grokBeta], apiKeyUrl: "https://console.x.ai/", }, + lemonade: { + title: "Lemonade", + provider: "lemonade", + description: + "High-performance local LLM inference with AMD hardware optimization", + longDescription: + "Lemonade provides optimized local LLM inference with support for AMD NPU, GPU, and CPU acceleration. Visit [lemonade-server.ai](https://lemonade-server.ai/) for installation and setup instructions. Once the Lemonade server is running, you can begin using Continue with your local models.", + icon: "lemonade.png", + tags: [ModelProviderTags.Local, ModelProviderTags.OpenSource], + params: { + apiBase: "http://localhost:8000/api/v1/", + }, + packages: [ + { + ...models.AUTODETECT, + params: { + ...models.AUTODETECT.params, + title: "Lemonade", + }, + }, + ...openSourceModels, + ], + collectInputFor: [ + ...completionParamsInputsConfigs, + { + ...apiBaseInput, + defaultValue: "http://localhost:8000/api/v1/", + required: true, + }, + ], + downloadUrl: "http://lemonade-server.ai", + }, lmstudio: { title: "LM Studio", provider: "lmstudio",