From fc950f4cd3ed92443fa6c49990b0d73942e1550f Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Mon, 16 Jun 2025 16:12:12 -0700 Subject: [PATCH 01/82] add llamastack support --- packages/openai-adapters/package-lock.json | 4 +- .../openai-adapters/src/apis/LlamaStack.ts | 55 +++++++ packages/openai-adapters/src/index.ts | 6 +- .../openai-adapters/src/test/main.test.ts | 146 +++--------------- packages/openai-adapters/src/types.ts | 7 + 5 files changed, 93 insertions(+), 125 deletions(-) create mode 100644 packages/openai-adapters/src/apis/LlamaStack.ts diff --git a/packages/openai-adapters/package-lock.json b/packages/openai-adapters/package-lock.json index 1d88a8b5e..efba3b949 100644 --- a/packages/openai-adapters/package-lock.json +++ b/packages/openai-adapters/package-lock.json @@ -1,12 +1,12 @@ { "name": "@continuedev/openai-adapters", - "version": "1.0.36", + "version": "1.0.38", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@continuedev/openai-adapters", - "version": "1.0.36", + "version": "1.0.38", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.5", diff --git a/packages/openai-adapters/src/apis/LlamaStack.ts b/packages/openai-adapters/src/apis/LlamaStack.ts new file mode 100644 index 000000000..fe0ee5daf --- /dev/null +++ b/packages/openai-adapters/src/apis/LlamaStack.ts @@ -0,0 +1,55 @@ +import { streamSse } from "@continuedev/fetch"; +import { ChatCompletionChunk } from "openai/resources/index"; +import { LlamastackConfig } from "../types.js"; +import { chatChunk, customFetch } from "../util.js"; +import { OpenAIApi } from "./OpenAI.js"; +import { FimCreateParamsStreaming } from "./base.js"; + +export const Llamastack_API_BASE = "http://localhost:8321/v1/openai/v1/"; +export class LlamastackApi extends OpenAIApi { + constructor(config: LlamastackConfig) { + super({ + ...config, + provider: "openai", + apiBase: config.apiBase ?? Llamastack_API_BASE, + apiKey: config.apiKey ?? 'dummy', + }); + } + + async *fimStream( + body: FimCreateParamsStreaming, + signal: AbortSignal, + ): AsyncGenerator { + const endpoint = new URL("completions", this.apiBase); + const resp = await customFetch(this.config.requestOptions)(endpoint, { + method: "POST", + body: JSON.stringify({ + model: body.model, + prompt: body.prompt, + suffix: body.suffix, + max_tokens: body.max_tokens, + max_completion_tokens: (body as any).max_completion_tokens, + temperature: body.temperature, + top_p: body.top_p, + frequency_penalty: body.frequency_penalty, + presence_penalty: body.presence_penalty, + stop: body.stop, + stream: true, + }), + headers: { + "Content-Type": "application/json", + Accept: "application/json", + "x-api-key": this.config.apiKey ?? "", + Authorization: `Bearer ${this.config.apiKey}`, + }, + signal, + }); + for await (const chunk of streamSse(resp as any)) { + yield chatChunk({ + content: chunk.choices[0].text, + finish_reason: chunk.finish_reason, + model: body.model, + }); + } +} +} \ No newline at end of file diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 9f0cf341c..70b9265b7 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -7,6 +7,7 @@ import { DeepSeekApi } from "./apis/DeepSeek.js"; import { GeminiApi } from "./apis/Gemini.js"; import { InceptionApi } from "./apis/Inception.js"; import { JinaApi } from "./apis/Jina.js"; +import { LlamastackApi } from "./apis/LlamaStack.js"; import { MockApi } from "./apis/Mock.js"; import { MoonshotApi } from "./apis/Moonshot.js"; import { OpenAIApi } from "./apis/OpenAI.js"; @@ -51,6 +52,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined { return new InceptionApi(config); case "watsonx": return new WatsonXApi(config); + case "llamastack": + return new LlamastackApi(config); case "x-ai": return openAICompatible("https://api.x.ai/v1/", config); case "voyage": @@ -117,9 +120,10 @@ export { type Completion, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, - type CompletionCreateParamsStreaming, + type CompletionCreateParamsStreaming } from "openai/resources/index"; // export export type { BaseLlmApi } from "./apis/base.js"; export type { LLMConfig } from "./types.js"; + diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index 1d68a7782..eec06cb27 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -1,10 +1,8 @@ import { ModelConfig } from "@continuedev/config-yaml"; import * as dotenv from "dotenv"; -import { DEEPSEEK_API_BASE } from "../apis/DeepSeek.js"; -import { INCEPTION_API_BASE } from "../apis/Inception.js"; import { OpenAIApi } from "../apis/OpenAI.js"; import { constructLlmApi } from "../index.js"; -import { getLlmApi, testChat, testEmbed } from "./util.js"; +import { getLlmApi, testChat, testEmbed, testFim } from "./util.js"; dotenv.config(); @@ -33,99 +31,30 @@ function testConfig(_config: ModelConfig & { options?: TestConfigOptions }) { if (config.roles?.includes("embed")) { testEmbed(api, model); } - - if (config.roles?.includes("embed")) { - testEmbed(api, model); + if (config.roles?.includes("autocomplete")) { + testFim(api, model); } + } - const TESTS: Omit[] = [ - { - provider: "openai", - model: "gpt-4o", - apiKey: process.env.OPENAI_API_KEY!, - roles: ["chat"], + { + provider: "llamastack", + model: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + apiBase: "http://localhost:8321/v1/openai/v1/", + roles: ["apply", "chat", "edit"], + options: { skipTools: false }, }, { - provider: "anthropic", - model: "claude-3-5-haiku-latest", - apiKey: process.env.ANTHROPIC_API_KEY!, - roles: ["chat"], - }, - { - provider: "gemini", - model: "gemini-1.5-flash-latest", - apiKey: process.env.GEMINI_API_KEY!, - roles: ["chat"], - }, - { - provider: "mistral", - model: "codestral-latest", - apiKey: process.env.MISTRAL_API_KEY!, - apiBase: "https://api.mistral.ai/v1", - roles: ["autocomplete"], - }, - { - provider: "deepseek", - model: "deepseek-coder", - apiKey: process.env.DEEPSEEK_API_KEY!, - roles: ["autocomplete"], - }, - { - provider: "openai", - model: "text-embedding-3-small", - apiKey: process.env.OPENAI_API_KEY!, + provider: "llamastack", + model: "all-MiniLM-L6-v2", + apiBase: "http://localhost:8321/v1/openai/v1/", roles: ["embed"], }, - { - provider: "voyage", - model: "voyage-code-3", - apiKey: process.env.VOYAGE_API_KEY!, - roles: ["embed"], - }, - // { - // provider: "cohere", - // model: "embed-v4.0", - // apiKey: process.env.COHERE_API_KEY!, - // roles: ["embed"], - // }, - // { - // provider: "gemini", - // model: "models/text-embedding-004", - // apiKey: process.env.GEMINI_API_KEY!, - // roles: ["embed"], - // }, - { - provider: "voyage", - model: "rerank-lite-1", - apiKey: process.env.VOYAGE_API_KEY!, - roles: ["rerank"], - }, - // { - // provider: "cohere", - // model: "rerank-v3.5", - // apiKey: process.env.COHERE_API_KEY!, - // roles: ["rerank"], - // }, - { - provider: "azure", - model: "gpt-4.1", - apiBase: "https://continue-openai.openai.azure.com", - apiKey: process.env.AZURE_OPENAI_GPT41_API_KEY, - env: { - deployment: "gpt-4.1", - apiVersion: "2024-02-15-preview", - apiType: "azure-openai", - }, - roles: ["chat"], - }, - { - provider: "azure", - model: "mistral-small-2503", - apiBase: "https://nate-0276-resource.services.ai.azure.com/models", - apiKey: process.env.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY, - roles: ["chat"], - options: { skipTools: true }, + { + provider: "llamastack", + model: "qwen2.5-coder:1.5b", + apiBase: "http://localhost:8321/v1/openai/v1/", + roles: ["autocomplete"], }, ]; @@ -136,41 +65,14 @@ TESTS.forEach((config) => { }); describe("Configuration", () => { - it("should configure DeepSeek OpenAI client with correct apiBase and apiKey", () => { - const deepseek = constructLlmApi({ - provider: "deepseek", + it("should configure OpenAI client with correct apiBase and apiKey", () => { + const openai = constructLlmApi({ + provider: "openai", apiKey: "sk-xxx", + apiBase: "http://localhost:8321/v1/openai/v1/", }); - expect((deepseek as OpenAIApi).openai.baseURL).toBe(DEEPSEEK_API_BASE); - expect((deepseek as OpenAIApi).openai.apiKey).toBe("sk-xxx"); - - const deepseek2 = constructLlmApi({ - provider: "deepseek", - apiKey: "sk-xxx", - apiBase: "https://api.example.com", - }); - expect((deepseek2 as OpenAIApi).openai.baseURL).toBe( - "https://api.example.com", - ); - }); - - it("should configure Inception OpenAI client with correct apiBase and apiKey", () => { - const inception = constructLlmApi({ - provider: "inception", - apiKey: "sk-xxx", - }); - - expect((inception as OpenAIApi).openai.baseURL).toBe(INCEPTION_API_BASE); - expect((inception as OpenAIApi).openai.apiKey).toBe("sk-xxx"); - - const inception2 = constructLlmApi({ - provider: "inception", - apiKey: "sk-xxx", - apiBase: "https://api.example.com", - }); - expect((inception2 as OpenAIApi).openai.baseURL).toBe( - "https://api.example.com", - ); + expect((openai as OpenAIApi).openai.baseURL).toBe("http://localhost:8321/v1/openai/v1/"); + expect((openai as OpenAIApi).openai.apiKey).toBe("sk-xxx"); }); }); diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index 2f26a4c80..3c79db7bf 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -71,9 +71,15 @@ export const DeepseekConfigSchema = OpenAIConfigSchema.extend({ }); export type DeepseekConfig = z.infer; +export const LlamastackConfigSchema = OpenAIConfigSchema.extend({ + provider: z.literal("llamastack"), +}); +export type LlamastackConfig = z.infer; + export const MockConfigSchema = BasePlusConfig.extend({ provider: z.literal("mock"), }); + export type MockConfig = z.infer; // Other APIs @@ -146,5 +152,6 @@ export const LLMConfigSchema = z.discriminatedUnion("provider", [ JinaConfigSchema, MockConfigSchema, InceptionConfigSchema, + LlamastackConfigSchema, ]); export type LLMConfig = z.infer; From e760f7ab753403e9d856dc45666b0fb4bac48fc5 Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Mon, 16 Jun 2025 16:13:13 -0700 Subject: [PATCH 02/82] revert main.ts --- .../openai-adapters/src/test/main.test.ts | 148 +++++++++++++++--- 1 file changed, 123 insertions(+), 25 deletions(-) diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index eec06cb27..9b3885b14 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -1,8 +1,10 @@ import { ModelConfig } from "@continuedev/config-yaml"; import * as dotenv from "dotenv"; +import { DEEPSEEK_API_BASE } from "../apis/DeepSeek.js"; +import { INCEPTION_API_BASE } from "../apis/Inception.js"; import { OpenAIApi } from "../apis/OpenAI.js"; import { constructLlmApi } from "../index.js"; -import { getLlmApi, testChat, testEmbed, testFim } from "./util.js"; +import { getLlmApi, testChat, testEmbed } from "./util.js"; dotenv.config(); @@ -31,30 +33,99 @@ function testConfig(_config: ModelConfig & { options?: TestConfigOptions }) { if (config.roles?.includes("embed")) { testEmbed(api, model); } - if (config.roles?.includes("autocomplete")) { - testFim(api, model); + + if (config.roles?.includes("embed")) { + testEmbed(api, model); } - } + const TESTS: Omit[] = [ - { - provider: "llamastack", - model: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", - apiBase: "http://localhost:8321/v1/openai/v1/", - roles: ["apply", "chat", "edit"], - options: { skipTools: false }, + { + provider: "openai", + model: "gpt-4o", + apiKey: process.env.OPENAI_API_KEY!, + roles: ["chat"], }, { - provider: "llamastack", - model: "all-MiniLM-L6-v2", - apiBase: "http://localhost:8321/v1/openai/v1/", + provider: "anthropic", + model: "claude-3-5-haiku-latest", + apiKey: process.env.ANTHROPIC_API_KEY!, + roles: ["chat"], + }, + { + provider: "gemini", + model: "gemini-1.5-flash-latest", + apiKey: process.env.GEMINI_API_KEY!, + roles: ["chat"], + }, + { + provider: "mistral", + model: "codestral-latest", + apiKey: process.env.MISTRAL_API_KEY!, + apiBase: "https://api.mistral.ai/v1", + roles: ["autocomplete"], + }, + { + provider: "deepseek", + model: "deepseek-coder", + apiKey: process.env.DEEPSEEK_API_KEY!, + roles: ["autocomplete"], + }, + { + provider: "openai", + model: "text-embedding-3-small", + apiKey: process.env.OPENAI_API_KEY!, roles: ["embed"], }, - { - provider: "llamastack", - model: "qwen2.5-coder:1.5b", - apiBase: "http://localhost:8321/v1/openai/v1/", - roles: ["autocomplete"], + { + provider: "voyage", + model: "voyage-code-3", + apiKey: process.env.VOYAGE_API_KEY!, + roles: ["embed"], + }, + // { + // provider: "cohere", + // model: "embed-v4.0", + // apiKey: process.env.COHERE_API_KEY!, + // roles: ["embed"], + // }, + // { + // provider: "gemini", + // model: "models/text-embedding-004", + // apiKey: process.env.GEMINI_API_KEY!, + // roles: ["embed"], + // }, + { + provider: "voyage", + model: "rerank-lite-1", + apiKey: process.env.VOYAGE_API_KEY!, + roles: ["rerank"], + }, + // { + // provider: "cohere", + // model: "rerank-v3.5", + // apiKey: process.env.COHERE_API_KEY!, + // roles: ["rerank"], + // }, + { + provider: "azure", + model: "gpt-4.1", + apiBase: "https://continue-openai.openai.azure.com", + apiKey: process.env.AZURE_OPENAI_GPT41_API_KEY, + env: { + deployment: "gpt-4.1", + apiVersion: "2024-02-15-preview", + apiType: "azure-openai", + }, + roles: ["chat"], + }, + { + provider: "azure", + model: "mistral-small-2503", + apiBase: "https://nate-0276-resource.services.ai.azure.com/models", + apiKey: process.env.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY, + roles: ["chat"], + options: { skipTools: true }, }, ]; @@ -65,14 +136,41 @@ TESTS.forEach((config) => { }); describe("Configuration", () => { - it("should configure OpenAI client with correct apiBase and apiKey", () => { - const openai = constructLlmApi({ - provider: "openai", + it("should configure DeepSeek OpenAI client with correct apiBase and apiKey", () => { + const deepseek = constructLlmApi({ + provider: "deepseek", apiKey: "sk-xxx", - apiBase: "http://localhost:8321/v1/openai/v1/", }); - expect((openai as OpenAIApi).openai.baseURL).toBe("http://localhost:8321/v1/openai/v1/"); - expect((openai as OpenAIApi).openai.apiKey).toBe("sk-xxx"); + expect((deepseek as OpenAIApi).openai.baseURL).toBe(DEEPSEEK_API_BASE); + expect((deepseek as OpenAIApi).openai.apiKey).toBe("sk-xxx"); + + const deepseek2 = constructLlmApi({ + provider: "deepseek", + apiKey: "sk-xxx", + apiBase: "https://api.example.com", + }); + expect((deepseek2 as OpenAIApi).openai.baseURL).toBe( + "https://api.example.com", + ); }); -}); + + it("should configure Inception OpenAI client with correct apiBase and apiKey", () => { + const inception = constructLlmApi({ + provider: "inception", + apiKey: "sk-xxx", + }); + + expect((inception as OpenAIApi).openai.baseURL).toBe(INCEPTION_API_BASE); + expect((inception as OpenAIApi).openai.apiKey).toBe("sk-xxx"); + + const inception2 = constructLlmApi({ + provider: "inception", + apiKey: "sk-xxx", + apiBase: "https://api.example.com", + }); + expect((inception2 as OpenAIApi).openai.baseURL).toBe( + "https://api.example.com", + ); + }); +}); \ No newline at end of file From a378350b7d7d1e024cd9bcf9cd0a127a12c65bc4 Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Mon, 16 Jun 2025 17:53:07 -0700 Subject: [PATCH 03/82] add LlamaStack as new model --- core/llm/llms/LlamaStack.ts | 57 +++++++++++++++++++++++++++++ core/llm/llms/index.ts | 3 +- extensions/vscode/package-lock.json | 4 +- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 core/llm/llms/LlamaStack.ts diff --git a/core/llm/llms/LlamaStack.ts b/core/llm/llms/LlamaStack.ts new file mode 100644 index 000000000..c4d83c248 --- /dev/null +++ b/core/llm/llms/LlamaStack.ts @@ -0,0 +1,57 @@ +import { streamSse } from "@continuedev/fetch"; +import { CompletionOptions, LLMOptions } from "../../index.js"; +import { osModelsEditPrompt } from "../templates/edit.js"; + +import OpenAI from "./OpenAI.js"; + +class LlamaStack extends OpenAI { + static providerName = "llamastack"; + static defaultOptions: Partial = { + apiBase: "http://localhost:8321/v1/openai/v1/", + model: "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + promptTemplates: { + edit: osModelsEditPrompt, + }, + useLegacyCompletionsEndpoint: false, + }; + maxStopWords: number | undefined = 16; + + supportsFim(): boolean { + return true; + } + + async *_streamFim( + prefix: string, + suffix: string, + signal: AbortSignal, + options: CompletionOptions, + ): AsyncGenerator { + const endpoint = new URL("completions", this.apiBase); + const resp = await this.fetch(endpoint, { + method: "POST", + body: JSON.stringify({ + model: options.model, + prompt: prefix, + suffix, + max_tokens: options.maxTokens, + temperature: options.temperature, + top_p: options.topP, + frequency_penalty: options.frequencyPenalty, + presence_penalty: options.presencePenalty, + stop: options.stop, + stream: true, + }), + headers: { + "Content-Type": "application/json", + Accept: "application/json", + Authorization: `Bearer ${this.apiKey}`, + }, + signal, + }); + for await (const chunk of streamSse(resp)) { + yield chunk.choices[0].text; + } + } +} + +export default Deepseek; \ No newline at end of file diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index a003ce0cf..17442e5f6 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -33,6 +33,7 @@ import Inception from "./Inception"; import Kindo from "./Kindo"; import LlamaCpp from "./LlamaCpp"; import Llamafile from "./Llamafile"; +import LlamaStack from "./LlamaStack"; import LMStudio from "./LMStudio"; import Mistral from "./Mistral"; import MockLLM from "./Mock"; @@ -62,7 +63,6 @@ import Vllm from "./Vllm"; import Voyage from "./Voyage"; import WatsonX from "./WatsonX"; import xAI from "./xAI"; - export const LLMClasses = [ Anthropic, Cohere, @@ -116,6 +116,7 @@ export const LLMClasses = [ Relace, Inception, Voyage, + LlamaStack, ]; export async function llmFromDescription( diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index ce706126c..199c669c7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.47", + "version": "1.1.48", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.47", + "version": "1.1.48", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14", From 94af0ee986eb54cba4bd43728df00daf7bed28cd Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Wed, 18 Jun 2025 10:41:10 -0700 Subject: [PATCH 04/82] add llama-stack doc --- .../model-providers/more/llamastack.mdx | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 docs/docs/customize/model-providers/more/llamastack.mdx diff --git a/docs/docs/customize/model-providers/more/llamastack.mdx b/docs/docs/customize/model-providers/more/llamastack.mdx new file mode 100644 index 000000000..4f21e9911 --- /dev/null +++ b/docs/docs/customize/model-providers/more/llamastack.mdx @@ -0,0 +1,113 @@ +import TabItem from "@theme/TabItem"; +import Tabs from "@theme/Tabs"; + +# Llama Stack + +[Llama Stack](https://llama-stack.readthedocs.io/en/latest/index.html) is an open-source library that standardizes the core building blocks that simplify AI application development. It codifies best practices across the Llama ecosystem. More specifically, it provides + +- **Unified API layer** for Inference, RAG, Agents, Tools, Safety, Evals, and Telemetry. +- **Plugin architecture** to support the rich ecosystem of different API implementations in various environments, including local development, on-premises, cloud, and mobile. +- **Prepackaged verified distributions** which offer a one-stop solution for developers to get started quickly and reliably in any environment. +- **Multiple developer interfaces** like CLI and SDKs for Python, Typescript, iOS, and Android. +- **Standalone applications** as examples for how to build production-grade AI applications with Llama Stack. + +To try Llama Stack locally, run: + +```shell +curl -LsSf https://github.com/meta-llama/llama-stack/raw/main/install.sh | bash +``` + +Learn more about how to get started with llama stack in this [guide](https://llama-stack.readthedocs.io/en/latest/getting_started/index.html) + +## Chat model + +We recommend configuring **Llama 4 Maverick** as your chat model. + + + + ```yaml title="config.yaml" + models: + - name: Llama4 Maverick + provider: llamastack + model: meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8 + apiBase: http:///v1/openai/v1/ + ``` + + + ```json title="config.json" + { + "models": [ + { + "title": "Llama4 Maverick", + "provider": "llamastack", + "model": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", + "apiBase": "http:///v1/openai/v1/" + } + ] + } + ``` + + + +## Autocomplete model + +We recommend configuring **CodeLlama 7B** as your autocomplete model. + + + + ```yaml title="config.yaml" + models: + - name: CodeLlama 7B + provider: llamastack + model: codellama:7b + apiBase: http:///v1/openai/v1/ + roles: + - autocomplete + ``` + + + ```json title="config.json" + { + "tabAutocompleteModel": { + "title": "CodeLlama 7B", + "provider": "llamastack", + "model": "codellama:7b", + "apiBase": "http:///v1/openai/v1/" + } + } + ``` + + + +## Embeddings model + +By default, Llama Stack uses **all-MiniLM-L6-v2** as the embeddings model. + + + + ```yaml title="config.yaml" + models: + - name: all-MiniLM-L6-v2 + provider: llamastack + model: all-MiniLM-L6-v2 + apiBase: http:///v1/openai/v1/ + roles: + - embed + ``` + + + ```json title="config.json" + { + "embeddingsProvider": { + "provider": "llamastack", + "model": "all-MiniLM-L6-v2", + "apiBase": "http:///v1/openai/v1/" + } + } + ``` + + + +## Reranking model + +Llama Stack currently did not support Reranking API yet. \ No newline at end of file From 3dbcce4793bf6a785db96ca4ff84eb65be84c11d Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Wed, 18 Jun 2025 11:01:28 -0700 Subject: [PATCH 05/82] fix core bug --- core/llm/llms/LlamaStack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/llm/llms/LlamaStack.ts b/core/llm/llms/LlamaStack.ts index c4d83c248..b0e0d4669 100644 --- a/core/llm/llms/LlamaStack.ts +++ b/core/llm/llms/LlamaStack.ts @@ -54,4 +54,4 @@ class LlamaStack extends OpenAI { } } -export default Deepseek; \ No newline at end of file +export default LlamaStack; \ No newline at end of file From 7254442f7e4ac3b249db86796367cf8b87eedc5c Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Wed, 18 Jun 2025 11:03:36 -0700 Subject: [PATCH 06/82] add llamastack to type.ts --- packages/openai-adapters/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index 3c79db7bf..f878a5e90 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -37,6 +37,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({ z.literal("deepinfra"), z.literal("groq"), z.literal("nvidia"), + z.literal("llamastack"), z.literal("ovhcloud"), z.literal("fireworks"), z.literal("together"), From ad90ac44f857b56c43540d80b2fe47a7766e9d3e Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Wed, 18 Jun 2025 11:10:13 -0700 Subject: [PATCH 07/82] fix style --- core/llm/llms/LlamaStack.ts | 2 +- packages/openai-adapters/src/apis/LlamaStack.ts | 4 ++-- packages/openai-adapters/src/index.ts | 3 +-- packages/openai-adapters/src/test/main.test.ts | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/llm/llms/LlamaStack.ts b/core/llm/llms/LlamaStack.ts index b0e0d4669..c246bdbdf 100644 --- a/core/llm/llms/LlamaStack.ts +++ b/core/llm/llms/LlamaStack.ts @@ -54,4 +54,4 @@ class LlamaStack extends OpenAI { } } -export default LlamaStack; \ No newline at end of file +export default LlamaStack; diff --git a/packages/openai-adapters/src/apis/LlamaStack.ts b/packages/openai-adapters/src/apis/LlamaStack.ts index fe0ee5daf..ba279e045 100644 --- a/packages/openai-adapters/src/apis/LlamaStack.ts +++ b/packages/openai-adapters/src/apis/LlamaStack.ts @@ -12,7 +12,7 @@ export class LlamastackApi extends OpenAIApi { ...config, provider: "openai", apiBase: config.apiBase ?? Llamastack_API_BASE, - apiKey: config.apiKey ?? 'dummy', + apiKey: config.apiKey ?? "dummy", }); } @@ -51,5 +51,5 @@ export class LlamastackApi extends OpenAIApi { model: body.model, }); } + } } -} \ No newline at end of file diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 70b9265b7..b4254046e 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -120,10 +120,9 @@ export { type Completion, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, - type CompletionCreateParamsStreaming + type CompletionCreateParamsStreaming, } from "openai/resources/index"; // export export type { BaseLlmApi } from "./apis/base.js"; export type { LLMConfig } from "./types.js"; - diff --git a/packages/openai-adapters/src/test/main.test.ts b/packages/openai-adapters/src/test/main.test.ts index 9b3885b14..1d68a7782 100644 --- a/packages/openai-adapters/src/test/main.test.ts +++ b/packages/openai-adapters/src/test/main.test.ts @@ -173,4 +173,4 @@ describe("Configuration", () => { "https://api.example.com", ); }); -}); \ No newline at end of file +}); From 16d3145702c2222851867e467b84070f46a4594f Mon Sep 17 00:00:00 2001 From: Hayden Cardwell <26019242+hayden-cardwell@users.noreply.github.com> Date: Wed, 18 Jun 2025 21:56:24 -0500 Subject: [PATCH 08/82] fix(autocomplete): trim trailing <|file_separator|> for Gemini/Gemma models Google Gemini/Gemma models sometimes append "<|file_separator|>" at the end of autocomplete completions, forcing users to remove it manually. Update postprocessCompletion to detect when llm.model includes "gemini" or "gemma" and the completion ends with "<|file_separator|>", then slice off the trailing 18 characters. See #6067 --- core/autocomplete/postprocessing/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/autocomplete/postprocessing/index.ts b/core/autocomplete/postprocessing/index.ts index bf0284cb2..3504a069d 100644 --- a/core/autocomplete/postprocessing/index.ts +++ b/core/autocomplete/postprocessing/index.ts @@ -132,6 +132,14 @@ export function postprocessCompletion({ completion = "\n" + completion; } + if ( + (llm.model.includes("gemini") || llm.model.includes("gemma")) && + completion.endsWith("<|file_separator|>") + ) { + // "<|file_separator|>" is 18 characters long + completion = completion.slice(0, -18); + } + // If prefix ends with space and so does completion, then remove the space from completion if (prefix.endsWith(" ") && completion.startsWith(" ")) { From 39e4546436d05c300b44c6ab7244671adba71a15 Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Thu, 26 Jun 2025 14:06:33 -0700 Subject: [PATCH 09/82] remove llamastack from OpenAIConfigSchema --- packages/openai-adapters/src/index.ts | 2 +- packages/openai-adapters/src/types.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index b4254046e..7544d2ef3 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -120,7 +120,7 @@ export { type Completion, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, - type CompletionCreateParamsStreaming, + type CompletionCreateParamsStreaming } from "openai/resources/index"; // export diff --git a/packages/openai-adapters/src/types.ts b/packages/openai-adapters/src/types.ts index f878a5e90..3c79db7bf 100644 --- a/packages/openai-adapters/src/types.ts +++ b/packages/openai-adapters/src/types.ts @@ -37,7 +37,6 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({ z.literal("deepinfra"), z.literal("groq"), z.literal("nvidia"), - z.literal("llamastack"), z.literal("ovhcloud"), z.literal("fireworks"), z.literal("together"), From 7485bbab776e6c0eeb7b8189a8822af64b2d24ff Mon Sep 17 00:00:00 2001 From: Kai Wu Date: Thu, 26 Jun 2025 14:09:43 -0700 Subject: [PATCH 10/82] fix style --- packages/openai-adapters/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index 7544d2ef3..b4254046e 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -120,7 +120,7 @@ export { type Completion, type CompletionCreateParams, type CompletionCreateParamsNonStreaming, - type CompletionCreateParamsStreaming + type CompletionCreateParamsStreaming, } from "openai/resources/index"; // export From 0db42801ecd96934b7007fc54b284eb975a94c68 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Jun 2025 22:52:31 -0700 Subject: [PATCH 11/82] enable diff syntax highlighting on diff tool output file --- core/tools/implementations/viewDiff.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tools/implementations/viewDiff.ts b/core/tools/implementations/viewDiff.ts index fd1dfdb8a..330172dff 100644 --- a/core/tools/implementations/viewDiff.ts +++ b/core/tools/implementations/viewDiff.ts @@ -7,7 +7,7 @@ export const viewDiffImpl: ToolImpl = async (args, extras) => { return [ { - name: "Diff", + name: ".diff", description: "The current git diff", content: diffs.join("\n"), }, From cbae30ad53f60aac966b4d66bd747180c514a976 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Jun 2025 23:38:16 -0700 Subject: [PATCH 12/82] refactor gradient border to its own file --- .../components/mainInput/ContinueInputBox.tsx | 40 +------------------ .../components/mainInput/GradientBorder.tsx | 38 ++++++++++++++++++ 2 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 gui/src/components/mainInput/GradientBorder.tsx diff --git a/gui/src/components/mainInput/ContinueInputBox.tsx b/gui/src/components/mainInput/ContinueInputBox.tsx index b50edfdbb..af7521666 100644 --- a/gui/src/components/mainInput/ContinueInputBox.tsx +++ b/gui/src/components/mainInput/ContinueInputBox.tsx @@ -1,12 +1,12 @@ import { Editor, JSONContent } from "@tiptap/react"; import { ContextItemWithId, InputModifiers, RuleWithSource } from "core"; import { useMemo } from "react"; -import styled, { keyframes } from "styled-components"; import { defaultBorderRadius, vscBackground } from ".."; import { useAppSelector } from "../../redux/hooks"; import { selectSlashCommandComboBoxInputs } from "../../redux/selectors"; import { ContextItemsPeek } from "./belowMainInput/ContextItemsPeek"; import { RulesPeek } from "./belowMainInput/RulesPeek"; +import { GradientBorder } from "./GradientBorder"; import { ToolbarOptions } from "./InputToolbar"; import { Lump } from "./Lump"; import { TipTapEditor } from "./TipTapEditor"; @@ -38,43 +38,6 @@ const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [ "repo-map", ]; -const gradient = keyframes` - 0% { - background-position: 0px 0; - } - 100% { - background-position: 100em 0; - } -`; - -const GradientBorder = styled.div<{ - borderRadius?: string; - borderColor?: string; - loading: 0 | 1; -}>` - border-radius: ${(props) => props.borderRadius || "0"}; - padding: 1px; - background: ${(props) => - props.borderColor - ? props.borderColor - : `repeating-linear-gradient( - 101.79deg, - #1BBE84 0%, - #331BBE 16%, - #BE1B55 33%, - #A6BE1B 55%, - #BE1B55 67%, - #331BBE 85%, - #1BBE84 99% - )`}; - animation: ${(props) => (props.loading ? gradient : "")} 6s linear infinite; - background-size: 200% 200%; - width: 100%; - display: flex; - flex-direction: row; - align-items: center; -`; - function ContinueInputBox(props: ContinueInputBoxProps) { const isStreaming = useAppSelector((state) => state.session.isStreaming); const availableSlashCommands = useAppSelector( @@ -146,6 +109,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) { /> + {(appliedRules.length > 0 || contextItems.length > 0) && (
diff --git a/gui/src/components/mainInput/GradientBorder.tsx b/gui/src/components/mainInput/GradientBorder.tsx new file mode 100644 index 000000000..6cbf263d5 --- /dev/null +++ b/gui/src/components/mainInput/GradientBorder.tsx @@ -0,0 +1,38 @@ +import styled, { keyframes } from "styled-components"; + +const gradient = keyframes` + 0% { + background-position: 0px 0; + } + 100% { + background-position: 100em 0; + } +`; + +export const GradientBorder = styled.div<{ + borderRadius?: string; + borderColor?: string; + loading: 0 | 1; +}>` + border-radius: ${(props) => props.borderRadius || "0"}; + padding: 1px; + background: ${(props) => + props.borderColor + ? props.borderColor + : `repeating-linear-gradient( + 101.79deg, + #1BBE84 0%, + #331BBE 16%, + #BE1B55 33%, + #A6BE1B 55%, + #BE1B55 67%, + #331BBE 85%, + #1BBE84 99% + )`}; + animation: ${(props) => (props.loading ? gradient : "")} 6s linear infinite; + background-size: 200% 200%; + width: 100%; + display: flex; + flex-direction: row; + align-items: center; +`; From 7addf2c9eab47d6d3ad4a31592bdc4f83e359c24 Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 26 Jun 2025 23:47:45 -0700 Subject: [PATCH 13/82] nicer hover effects on input boxes --- gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx index 8e659f1e8..a5f9dbc56 100644 --- a/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx @@ -179,7 +179,11 @@ export function TipTapEditor(props: TipTapEditorProps) { onBlur={handleBlur} onKeyDown={handleKeyDown} onKeyUp={handleKeyUp} - className={shouldHideToolbar ? "cursor-default" : "cursor-text"} + className={ + !props.isMainInput && shouldHideToolbar + ? "cursor-pointer hover:brightness-105" + : "cursor-text" + } onClick={() => { editor?.commands.focus(); }} From 4604369fb4cfe33756f33aa6b8f7a56fee106efa Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 27 Jun 2025 00:01:46 -0700 Subject: [PATCH 14/82] improve styling for links --- gui/src/components/StyledMarkdownPreview/index.tsx | 3 +-- gui/src/components/index.ts | 3 +++ gui/src/styles/theme.ts | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gui/src/components/StyledMarkdownPreview/index.tsx b/gui/src/components/StyledMarkdownPreview/index.tsx index f648dd61b..98ca83881 100644 --- a/gui/src/components/StyledMarkdownPreview/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/index.tsx @@ -77,14 +77,13 @@ const StyledMarkdown = styled.div<{ } word-wrap: break-word; border-radius: ${defaultBorderRadius}; - background-color: ${vscEditorBackground}; + background-color: var(--vscode-textCodeBlock-background); font-size: ${getFontSize() - 2}px; font-family: var(--vscode-editor-font-family); } code:not(pre > code) { font-family: var(--vscode-editor-font-family); - color: var(--vscode-input-placeholderForeground); } background-color: ${(props) => props.bgColor}; diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 71fd4ae0c..a1d2ed387 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -12,6 +12,9 @@ export const vscForeground = varWithFallback("foreground"); export const vscButtonBackground = varWithFallback("primary-background"); export const vscButtonForeground = varWithFallback("primary-foreground"); export const vscEditorBackground = varWithFallback("editor-background"); +export const vscTextCodeBlockBackground = varWithFallback( + "textCodeBlockBackground", +); export const vscListActiveBackground = varWithFallback("list-active"); export const vscFocusBorder = varWithFallback("border-focus"); export const vscListActiveForeground = varWithFallback( diff --git a/gui/src/styles/theme.ts b/gui/src/styles/theme.ts index ad0ee0bd7..144a9d8d6 100644 --- a/gui/src/styles/theme.ts +++ b/gui/src/styles/theme.ts @@ -140,6 +140,10 @@ export const THEME_COLORS = { vars: ["--vscode-textLink-foreground"], default: "#5c9ce6", // medium blue }, + textCodeBlockBackground: { + vars: ["--vscode-textCodeBlock-background"], + default: "#1e1e1e", // same as editor-background + }, accent: { vars: ["--vscode-tab-activeBorderTop", "--vscode-focusBorder"], default: "#4d8bf0", // bright blue From 1ce30606ae3e639a4b98f0235753e8a8b372165e Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 27 Jun 2025 00:26:05 -0700 Subject: [PATCH 15/82] update defaultBorderRadius and use rem instead of px --- .continue/rules/css-units.md | 5 +++++ gui/src/components/Layout.tsx | 3 +-- gui/src/components/StyledMarkdownPreview/index.tsx | 2 +- gui/src/components/index.ts | 2 +- gui/src/components/mainInput/InputToolbar/EnterButton.tsx | 3 +-- .../mainInput/TipTapEditor/components/StyledComponents.ts | 3 +-- gui/tailwind.config.cjs | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .continue/rules/css-units.md diff --git a/.continue/rules/css-units.md b/.continue/rules/css-units.md new file mode 100644 index 000000000..a270a383d --- /dev/null +++ b/.continue/rules/css-units.md @@ -0,0 +1,5 @@ +--- +globs: "gui/**/*.tsx" +--- + +You should try to use the `rem` CSS unit whenever possible for scalability instead of `px`. diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 1e2134e7a..20d750d42 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -2,7 +2,7 @@ import { OnboardingModes } from "core/protocol/core"; import { useContext, useEffect } from "react"; import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; -import { CustomScrollbarDiv, defaultBorderRadius } from "."; +import { CustomScrollbarDiv } from "."; import { AuthProvider } from "../context/Auth"; import { IdeMessengerContext } from "../context/IdeMessenger"; import { LocalStorageProvider } from "../context/LocalStorage"; @@ -30,7 +30,6 @@ import PostHogPageView from "./PosthogPageView"; const LayoutTopDiv = styled(CustomScrollbarDiv)` height: 100%; - border-radius: ${defaultBorderRadius}; position: relative; overflow-x: hidden; `; diff --git a/gui/src/components/StyledMarkdownPreview/index.tsx b/gui/src/components/StyledMarkdownPreview/index.tsx index 98ca83881..45dd743fb 100644 --- a/gui/src/components/StyledMarkdownPreview/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/index.tsx @@ -76,7 +76,7 @@ const StyledMarkdown = styled.div<{ display: none; } word-wrap: break-word; - border-radius: ${defaultBorderRadius}; + border-radius: 0.3125rem; background-color: var(--vscode-textCodeBlock-background); font-size: ${getFontSize() - 2}px; font-family: var(--vscode-editor-font-family); diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index a1d2ed387..ee20d7365 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -1,7 +1,7 @@ import styled from "styled-components"; import { varWithFallback } from "../styles/theme"; -export const defaultBorderRadius = "5px"; +export const defaultBorderRadius = "0.5rem"; export const lightGray = "#999998"; export const greenButtonColor = "#189e72"; diff --git a/gui/src/components/mainInput/InputToolbar/EnterButton.tsx b/gui/src/components/mainInput/InputToolbar/EnterButton.tsx index 21dae2642..6d26ca690 100644 --- a/gui/src/components/mainInput/InputToolbar/EnterButton.tsx +++ b/gui/src/components/mainInput/InputToolbar/EnterButton.tsx @@ -1,6 +1,5 @@ import styled from "styled-components"; import { - defaultBorderRadius, lightGray, vscButtonBackground, vscButtonForeground, @@ -18,7 +17,7 @@ export const EnterButton = styled.button<{ isPrimary?: boolean }>` !props.disabled && props.isPrimary ? vscButtonBackground : lightGray + "33"}; - border-radius: ${defaultBorderRadius}; + border-radius: 0.3125rem; color: ${(props) => !props.disabled && props.isPrimary ? vscButtonForeground : vscForeground}; cursor: pointer; diff --git a/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts b/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts index f994b53d6..3889a7ef9 100644 --- a/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts +++ b/gui/src/components/mainInput/TipTapEditor/components/StyledComponents.ts @@ -1,6 +1,5 @@ import styled from "styled-components"; import { - defaultBorderRadius, lightGray, vscBadgeBackground, vscCommandCenterActiveBorder, @@ -14,7 +13,7 @@ import { getFontSize } from "../../../../util"; export const InputBoxDiv = styled.div<{}>` resize: none; font-family: inherit; - border-radius: ${defaultBorderRadius}; + border-radius: 0.5rem; padding-bottom: 1px; margin: 0; height: auto; diff --git a/gui/tailwind.config.cjs b/gui/tailwind.config.cjs index ed91cee11..d5871cc80 100644 --- a/gui/tailwind.config.cjs +++ b/gui/tailwind.config.cjs @@ -27,7 +27,7 @@ module.exports = { "spin-slow": "spin 6s linear infinite", }, borderRadius: { - default: "5px", + default: "0.5rem", }, colors: { background: varWithFallback("background"), From 5df9aa2a2bb514a211ff79006a6ebf0eef7dc1e7 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 27 Jun 2025 00:30:31 -0700 Subject: [PATCH 16/82] increase lump x margin --- gui/src/components/mainInput/Lump/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index f6ff453ce..993ed64cc 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -10,8 +10,8 @@ import { SelectedSection } from "./sections/SelectedSection"; const LumpDiv = styled.div` background-color: ${vscInputBackground}; - margin-left: 4px; - margin-right: 4px; + margin-left: 6px; + margin-right: 6px; border-radius: ${defaultBorderRadius} ${defaultBorderRadius} 0 0; border-top: 1px solid ${vscCommandCenterInactiveBorder}; border-left: 1px solid ${vscCommandCenterInactiveBorder}; From 0d26551ae0e8779cfcec408915b7052fb2af15b6 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 27 Jun 2025 00:35:59 -0700 Subject: [PATCH 17/82] fix code bg --- gui/src/components/StyledMarkdownPreview/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/src/components/StyledMarkdownPreview/index.tsx b/gui/src/components/StyledMarkdownPreview/index.tsx index 45dd743fb..0f2d1af0d 100644 --- a/gui/src/components/StyledMarkdownPreview/index.tsx +++ b/gui/src/components/StyledMarkdownPreview/index.tsx @@ -77,7 +77,7 @@ const StyledMarkdown = styled.div<{ } word-wrap: break-word; border-radius: 0.3125rem; - background-color: var(--vscode-textCodeBlock-background); + background-color: ${vscEditorBackground}; font-size: ${getFontSize() - 2}px; font-family: var(--vscode-editor-font-family); } From 4d20c8ad50c86bb98306a7e76deacc24da1d3abb Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 30 Jun 2025 14:07:08 -0700 Subject: [PATCH 18/82] add textCodeBlcokBackground to GetTheme.kt --- .../continueintellijextension/continue/GetTheme.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt index 0ee4c2bd0..3a01f05fc 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/GetTheme.kt @@ -166,6 +166,9 @@ class GetTheme { val findMatchSelectedBackground = namedColor("SearchMatch.selectedBackground") ?: editorScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES)?.backgroundColor + // Use editor background with slight tint for code blocks + val textCodeBlockBackground = slightChange(editorBackground, 3) ?: editorBackground + // These should match the keys in GUI's theme.ts val theme = mapOf( "background" to background, @@ -197,6 +200,7 @@ class GetTheme { "warning" to warningColor, "error" to errorColor, "link" to link, + "textCodeBlockBackground" to textCodeBlockBackground, "accent" to accentColor, "find-match" to findMatchBackground, "find-match-selected" to findMatchSelectedBackground, From a2adf2fe982813edd23cd259e21ba154754df525 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 30 Jun 2025 18:11:36 -0700 Subject: [PATCH 19/82] feat: generate rule button + dialog scaffolding --- .../GenerateRuleDialog/RuleTemplateChip.tsx | 26 ++++++ .../components/GenerateRuleDialog/index.tsx | 84 +++++++++++++++++++ .../GenerateRuleDialog/ruleTemplates.ts | 15 ++++ .../StepContainer/ResponseActions.tsx | 28 ++++++- gui/src/components/ui/Button.tsx | 4 +- 5 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 gui/src/components/GenerateRuleDialog/RuleTemplateChip.tsx create mode 100644 gui/src/components/GenerateRuleDialog/index.tsx create mode 100644 gui/src/components/GenerateRuleDialog/ruleTemplates.ts diff --git a/gui/src/components/GenerateRuleDialog/RuleTemplateChip.tsx b/gui/src/components/GenerateRuleDialog/RuleTemplateChip.tsx new file mode 100644 index 000000000..dc102cb50 --- /dev/null +++ b/gui/src/components/GenerateRuleDialog/RuleTemplateChip.tsx @@ -0,0 +1,26 @@ +import React from "react"; +import { Button } from "../ui"; + +interface RuleTemplateChipProps { + icon: React.ComponentType<{ className?: string }>; + text: string; + onClick: () => void; +} + +export function RuleTemplateChip({ + icon: Icon, + text, + onClick, +}: RuleTemplateChipProps) { + return ( + + ); +} diff --git a/gui/src/components/GenerateRuleDialog/index.tsx b/gui/src/components/GenerateRuleDialog/index.tsx new file mode 100644 index 000000000..04802c7b6 --- /dev/null +++ b/gui/src/components/GenerateRuleDialog/index.tsx @@ -0,0 +1,84 @@ +import { useContext, useState } from "react"; +import { useDispatch } from "react-redux"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { useAppSelector } from "../../redux/hooks"; +import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; +import { Button } from "../ui"; +import { RuleTemplateChip } from "./RuleTemplateChip"; +import { RuleTemplate, ruleTemplates } from "./ruleTemplates"; + +function GenerateRuleDialog() { + const dispatch = useDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const [textareaValue, setTextareaValue] = useState(""); + + const lastChatMessage = useAppSelector( + (state) => state.session.history[state.session.history.length - 1], + ); + + const closeDialog = () => { + dispatch(setDialogMessage(undefined)); + dispatch(setShowDialog(false)); + }; + + function onSubmit(e: any) { + e.preventDefault(); + // Logic to generate rule will go here + closeDialog(); + } + + function handleRuleTemplateClick(ruleTemplate: RuleTemplate) { + setTextareaValue(ruleTemplate.template); + } + + return ( +
+
+
+

Generate Rule

+

+ This will generate a new rule using the content of your chat history +

+
+
+
+
+