Lemonade Integration (#7749)

This commit is contained in:
Tomasz Iniewicz 2025-09-17 13:15:33 -04:00 • committed by GitHub
parent 5f61d188e3
commit ca2a5d7f29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 245 additions and 1 deletions

View file

@ -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",

View file

@ -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;
}

View file

@ -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",

View file

@ -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;
}

12
core/llm/llms/Lemonade.ts Normal file
View file

@ -0,0 +1,12 @@
import { LLMOptions } from "../../index.js";
import OpenAI from "./OpenAI.js";
class Lemonade extends OpenAI {
static providerName = "lemonade";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "http://localhost:8000/api/v1/",
};
}
export default Lemonade;

View file

@ -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,

View file

@ -0,0 +1,59 @@
import { exec } from "node:child_process";
import { IDE } from "..";
export async function isLemonadeInstalled(): Promise<boolean> {
// 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<any> {
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",
});
}
}

View file

@ -0,0 +1,81 @@
---
title: "Lemonade Server"
description: "Configure Lemonade Server with Continue for refreshingly fast local LLM inference on GPUs and NPUs"
---
<Info>
Get started with [Lemonade Server](https://lemonade-server.ai/) - Refreshingly fast LLMs on GPUs and NPUs with seamless Continue integration
</Info>
## 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:
<Tabs>
<Tab title="YAML">
```yaml title="config.yaml"
models:
- name: Lemonade
provider: lemonade
model: <MODEL_NAME>
apiBase: http://localhost:8000/api/v1/
```
</Tab>
<Tab title="JSON (Deprecated)">
```json title="config.json"
{
"models": [
{
"title": "Lemonade",
"provider": "lemonade",
"model": "<MODEL_NAME>",
"apiBase": "http://localhost:8000/api/v1/"
}
]
}
```
</Tab>
</Tabs>
## 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)

View file

@ -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,

View file

@ -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<boolean> {
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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View file

@ -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",