diff --git a/core/core.ts b/core/core.ts index 9bdf00750..68aa605ac 100644 --- a/core/core.ts +++ b/core/core.ts @@ -1,4 +1,3 @@ -/* eslint-disable max-lines-per-function */ import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as URI from "uri-js"; import { v4 as uuidv4 } from "uuid"; @@ -33,6 +32,7 @@ import { TTS } from "./util/tts"; import { DiffLine, IdeSettings, + ModelDescription, RangeInFile, type ContextItemId, type IDE, @@ -494,32 +494,7 @@ export class Core { on("completeOnboarding", this.handleCompleteOnboarding); - on("addAutocompleteModel", (msg) => { - const model = msg.data.model; - editConfigFile( - (config) => { - return { - ...config, - tabAutocompleteModel: model, - }; - }, - (config) => ({ - ...config, - models: [ - ...(config.models ?? []), - { - name: model.title, - provider: model.provider, - model: model.model, - apiKey: model.apiKey, - roles: ["autocomplete"], - apiBase: model.apiBase, - }, - ], - }), - ); - void this.configHandler.reloadConfig(); - }); + on("addAutocompleteModel", this.handleAddAutocompleteModel); on("stats/getTokensPerDay", async (msg) => { const rows = await DevDataSqliteDb.getTokensPerDay(); @@ -530,7 +505,6 @@ export class Core { return rows; }); - // Codebase indexing on("index/forceReIndex", async ({ data }) => { const { config } = await this.configHandler.loadConfig(); if (!config || config.disableIndexing) { @@ -616,11 +590,7 @@ export class Core { } }); - on("files/opened", async ({ data }) => { - if (data?.uris?.length) { - // Do something on files opened - } - }); + on("files/opened", async () => {}); // Docs, etc. indexing on("indexing/reindex", async (msg) => { @@ -635,7 +605,6 @@ export class Core { }); on("indexing/setPaused", async (msg) => { if (msg.data.type === "docs") { - // this.docsService.setPaused(msg.data.id, msg.data.paused); // not supported yet } }); on("docs/initStatuses", async (msg) => { @@ -740,10 +709,8 @@ export class Core { throw new Error("No chat model selected"); } - // Count the size of the file tokenwise const tokens = countTokens(item.content); - // File exceeds context length of the model if (tokens > llm.contextLength - llm.completionOptions!.maxTokens!) { return true; } @@ -752,6 +719,37 @@ export class Core { }); } + private handleAddAutocompleteModel( + msg: Message<{ + model: ModelDescription; + }>, + ) { + const model = msg.data.model; + editConfigFile( + (config) => { + return { + ...config, + tabAutocompleteModel: model, + }; + }, + (config) => ({ + ...config, + models: [ + ...(config.models ?? []), + { + name: model.title, + provider: model.provider, + model: model.model, + apiKey: model.apiKey, + roles: ["autocomplete"], + apiBase: model.apiBase, + }, + ], + }), + ); + void this.configHandler.reloadConfig(); + } + private async handleFilesChanged({ data, }: Message<{ diff --git a/gui/src/redux/thunks/callTool.ts b/gui/src/redux/thunks/callTool.ts index 04d49007f..31e67b6d3 100644 --- a/gui/src/redux/thunks/callTool.ts +++ b/gui/src/redux/thunks/callTool.ts @@ -30,7 +30,8 @@ export const callTool = createAsyncThunk( return; } - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + if (!defaultModel) { throw new Error("No model selected"); } diff --git a/gui/src/redux/thunks/gatherContext.ts b/gui/src/redux/thunks/gatherContext.ts index e810e1025..abc547c41 100644 --- a/gui/src/redux/thunks/gatherContext.ts +++ b/gui/src/redux/thunks/gatherContext.ts @@ -37,7 +37,8 @@ export const gatherContext = createAsyncThunk< { dispatch, extra, getState }, ) => { const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const defaultContextProviders = state.config.config.experimental?.defaultContext ?? []; diff --git a/gui/src/redux/thunks/session.ts b/gui/src/redux/thunks/session.ts index 413c3c678..f5d40c4d4 100644 --- a/gui/src/redux/thunks/session.ts +++ b/gui/src/redux/thunks/session.ts @@ -167,7 +167,8 @@ export const saveCurrentSession = createAsyncThunk< // Now save previous session and update chat title if relevant let title = state.session.title; if (title === NEW_SESSION_TITLE) { - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + if (!state.config.config?.disableSessionTitles && defaultModel) { let assistantResponse = state.session.history ?.filter((h) => h.message.role === "assistant")[0] diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 47cccff2d..507382d3f 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -29,7 +29,8 @@ export const streamNormalInput = createAsyncThunk< ) => { // Gather state const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const toolSettings = state.ui.toolSettings; const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; diff --git a/gui/src/redux/thunks/streamResponse.ts b/gui/src/redux/thunks/streamResponse.ts index e7c013fca..b6c806a2e 100644 --- a/gui/src/redux/thunks/streamResponse.ts +++ b/gui/src/redux/thunks/streamResponse.ts @@ -34,7 +34,8 @@ export const streamResponseThunk = createAsyncThunk< await dispatch( streamThunkWrapper(async () => { const state = getState(); - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); + const slashCommands = state.config.config.slashCommands || []; const inputIndex = index ?? state.session.history.length; // Either given index or concat to end diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 8605d190d..cb0de2756 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -27,7 +27,7 @@ export const streamResponseAfterToolCall = createAsyncThunk< streamThunkWrapper(async () => { const state = getState(); const initialHistory = state.session.history; - const defaultModel = selectSelectedChatModel(state); + const selectedChatModel = selectSelectedChatModel(state); if (!defaultModel) { throw new Error("No model selected");