step one toward making tool use possible with slash commands
This commit is contained in:
parent
a187ff7dfe
commit
26bbb1087d
5 changed files with 26 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -736,6 +736,7 @@ export interface ContinueSDK {
|
|||
selectedCode: RangeInFile[];
|
||||
config: ContinueConfig;
|
||||
fetch: FetchFunction;
|
||||
completionOptions?: LLMFullCompletionOptions;
|
||||
}
|
||||
|
||||
export interface SlashCommand {
|
||||
|
|
|
|||
|
|
@ -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<string>,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue