remove eslint disable for max line error

This commit is contained in:
Patrick Erichsen 2025-04-08 21:54:34 -07:00
parent ab0e6b22ef
commit ae72f3a293
7 changed files with 45 additions and 42 deletions

View file

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

View file

@ -30,7 +30,8 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
return;
}
const defaultModel = selectSelectedChatModel(state);
const selectedChatModel = selectSelectedChatModel(state);
if (!defaultModel) {
throw new Error("No model selected");
}

View file

@ -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 ?? [];

View file

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

View file

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

View file

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

View file

@ -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");