diff --git a/core/commands/index.ts b/core/commands/index.ts index 2b44a4d66..72719d832 100644 --- a/core/commands/index.ts +++ b/core/commands/index.ts @@ -10,7 +10,7 @@ export function slashFromCustomCommand( return { name: customCommand.name, description: customCommand.description ?? "", - run: async function* ({ input, llm, history, ide }) { + run: async function* ({ input, llm, history, ide, completionOptions }) { // Remove slash command prefix from input let userInput = input; if (userInput.startsWith(`/${customCommand.name}`)) { @@ -72,6 +72,7 @@ export function slashFromCustomCommand( for await (const chunk of llm.streamChat( messages, new AbortController().signal, + completionOptions, )) { yield renderChatMessage(chunk); } diff --git a/core/core.ts b/core/core.ts index dbadb82c0..28e3af79a 100644 --- a/core/core.ts +++ b/core/core.ts @@ -20,6 +20,8 @@ import { recentlyEditedFilesCache } from "./context/retrieval/recentlyEditedFile import { ContinueServerClient } from "./continueServer/stubs/client"; import { getAuthUrlForTokenPage } from "./control-plane/auth/index"; import { getControlPlaneEnv } from "./control-plane/env"; +import { DevDataSqliteDb } from "./data/devdataSqlite"; +import { DataLogger } from "./data/log"; import { streamDiffLines } from "./edit/streamDiffLines"; import { CodebaseIndexer, PauseToken } from "./indexing/CodebaseIndexer"; import DocsService from "./indexing/docs/DocsService"; @@ -30,8 +32,6 @@ import { createNewPromptFileV2 } from "./promptFiles/v2/createNewPromptFile"; import { callTool } from "./tools/callTool"; import { ChatDescriber } from "./util/chatDescriber"; import { clipboardCache } from "./util/clipboardCache"; -import { DataLogger } from "./data/log"; -import { DevDataSqliteDb } from "./data/devdataSqlite"; import { GlobalContext } from "./util/GlobalContext"; import historyManager from "./util/history"; import { @@ -131,7 +131,8 @@ export class Core { }); // update additional submenu context providers registered via VSCode API - const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders(); + const additionalProviders = + this.configHandler.getAdditionalSubmenuContextProviders(); if (additionalProviders.length > 0) { this.messenger.send("refreshSubmenuItems", { providers: additionalProviders, @@ -651,6 +652,7 @@ export class Core { params, historyIndex, selectedCode, + completionOptions, } = msg.data; const { config } = await configHandler.loadConfig(); @@ -699,6 +701,7 @@ export class Core { config, fetch: (url, init) => fetchwithRequestOptions(url, init, config.requestOptions), + completionOptions, })) { if (abortedMessageIds.has(msg.messageId)) { abortedMessageIds.delete(msg.messageId); diff --git a/core/index.d.ts b/core/index.d.ts index ceb6e796b..159cc022b 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -736,6 +736,7 @@ export interface ContinueSDK { selectedCode: RangeInFile[]; config: ContinueConfig; fetch: FetchFunction; + completionOptions?: LLMFullCompletionOptions; } export interface SlashCommand { diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 53c052894..0a3913590 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -5,6 +5,7 @@ import { ProfileDescription } from "../config/ConfigHandler"; import { OrganizationDescription } from "../config/ProfileLifecycleManager"; import { SharedConfigSchema } from "../config/sharedConfig"; +import { DevDataLogEvent } from "@continuedev/config-yaml"; import type { BrowserSerializedContinueConfig, ChatMessage, @@ -27,7 +28,6 @@ import type { SiteIndexingConfig, ToolCall, } from "../"; -import { DevDataLogEvent } from "@continuedev/config-yaml"; import { GlobalContextModelSelections } from "../util/GlobalContext"; export type OnboardingModes = "Local" | "Best" | "Custom" | "Quickstart"; @@ -107,6 +107,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { params: any; historyIndex: number; selectedCode: RangeInFile[]; + completionOptions?: LLMFullCompletionOptions; }, AsyncGenerator, ]; diff --git a/gui/src/redux/thunks/streamSlashCommand.ts b/gui/src/redux/thunks/streamSlashCommand.ts index 79336bb3d..720a7b03b 100644 --- a/gui/src/redux/thunks/streamSlashCommand.ts +++ b/gui/src/redux/thunks/streamSlashCommand.ts @@ -5,6 +5,7 @@ import { RangeInFile, SlashCommandDescription, } from "core"; +import { modelSupportsTools } from "core/llm/autodetect"; import { selectDefaultModel } from "../slices/configSlice"; import { abortStream, streamUpdate } from "../slices/sessionSlice"; import { ThunkApiType } from "../store"; @@ -30,11 +31,18 @@ export const streamSlashCommand = createAsyncThunk< const defaultModel = selectDefaultModel(state); const isStreaming = state.session.isStreaming; const streamAborter = state.session.streamAborter; + const toolSettings = state.ui.toolSettings; if (!defaultModel) { throw new Error("Default model not defined"); } + const useTools = state.ui.useTools; + const includeTools = + useTools && + modelSupportsTools(defaultModel) && + state.session.mode === "chat"; + const modelTitle = defaultModel.title; const checkActiveInterval = setInterval(() => { @@ -55,6 +63,13 @@ export const streamSlashCommand = createAsyncThunk< params: slashCommand.params, historyIndex, selectedCode, + completionOptions: includeTools + ? { + tools: state.config.config.tools.filter( + (tool) => toolSettings[tool.function.name] !== "disabled", + ), + } + : {}, }, streamAborter.signal, )) {