Merge branch 'continuedev:main' into update_autocomplete_examples

This commit is contained in:
Roger Öberg 2025-01-09 17:55:51 +01:00 • committed by GitHub
commit f1bd1e2b5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 1078 additions and 755 deletions

View file

@ -188,7 +188,7 @@ After you've written your context provider, make sure to complete the following:
### Adding an LLM Provider
Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps:
Continue has support for more than a dozen different LLM "providers", making it easy to use models running on OpenAI, Ollama, Together, Novita AI, LM Studio, Msty, and more. You can find all of the existing providers [here](https://github.com/continuedev/continue/tree/main/core/llm/llms), and if you see one missing, you can add it with the following steps:
1. Create a new file in the `core/llm/llms` directory. The name of the file should be the name of the provider, and it should export a class that extends `BaseLLM`. This class should contain the following minimal implementation. We recommend viewing pre-existing providers for more details. The [LlamaCpp Provider](./core/llm/llms/LlamaCpp.ts) is a good simple example.
@ -209,7 +209,7 @@ While any model that works with a supported provider can be used with Continue,
1. Add a `ModelPackage` entry for the model into [configs/models.ts](./gui/src/pages/AddNewModel/configs/models.ts), following the lead of the many examples near the top of the file
2. Add the model within its provider's array to [AddNewModel.tsx](./gui/src/pages/AddNewModel/AddNewModel.tsx) (add provider if needed)
- [index.d.ts](./core/index.d.ts) - This file defines the TypeScript types used throughout Continue. You'll find a `ModelName` type. Be sure to add the name of your model to this.
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Replicate](https://replicate.com/collections/streaming-language-models).
- LLM Providers: Since many providers use their own custom strings to identify models, you'll have to add the translation from Continue's model name (the one you added to `index.d.ts`) and the model string for each of these providers: [Ollama](./core/llm/llms/Ollama.ts), [Together](./core/llm/llms/Together.ts), [Novita AI](./core/llm/llms/Novita.ts), and [Replicate](./core/llm/llms/Replicate.ts). You can find their full model lists here: [Ollama](https://ollama.ai/library), [Together](https://docs.together.ai/docs/inference-models), [Novita AI](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), [Replicate](https://replicate.com/collections/streaming-language-models).
- [Prompt Templates](./core/llm/index.ts) - In this file you'll find the `autodetectTemplateType` function. Make sure that for the model name you just added, this function returns the correct template type. This is assuming that the chat template for that model is already built in Continue. If not, you will have to add the template type and corresponding edit and chat templates.
### Adding Pre-indexed Documentation

View file

@ -5,7 +5,7 @@ const CommitMessageCommand: SlashCommand = {
name: "commit",
description: "Generate a commit message for current changes",
run: async function* ({ ide, llm, params }) {
const includeUnstaged = params?.includeUnstaged ?? true;
const includeUnstaged = params?.includeUnstaged ?? false;
const diff = await ide.getDiff(includeUnstaged);
if (diff.length === 0) {

View file

@ -25,6 +25,7 @@ import {
ProfileDescription,
ProfileLifecycleManager,
} from "./ProfileLifecycleManager.js";
import { pathToFileURL } from "url";
export type { ProfileDescription };
@ -88,7 +89,7 @@ export class ConfigHandler {
async openConfigProfile(profileId?: string) {
let openProfileId = profileId || this.selectedProfileId;
if (openProfileId === "local") {
await this.ide.openFile(getConfigJsonPath());
await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString());
} else {
await this.ide.openUrl(
"https://app.continue.dev/",

View file

@ -0,0 +1,57 @@
import { BaseContextProvider } from "..";
import {
ContextItem,
ContextProviderDescription,
ContextProviderExtras,
ContextSubmenuItem,
LoadSubmenuItemsArgs,
} from "../..";
import { clipboardCache } from "../../util/clipboardCache";
const MAX_CLIPBOARD_ITEMS = 10;
class ClipboardContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
title: "clipboard",
displayTitle: "Clipboard",
description: "Recent copies",
type: "submenu",
};
async getContextItems(
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
// Assume the query is a cache id
const id = query.trim();
const content = clipboardCache.get(id);
if (content) {
clipboardCache.select(id);
return [
{
name: "Clipboard item",
description: content.slice(0, 20),
content,
},
];
}
return [];
}
async loadSubmenuItems(
args: LoadSubmenuItemsArgs,
): Promise<ContextSubmenuItem[]> {
const recentClipboardItems = clipboardCache.getNItems(MAX_CLIPBOARD_ITEMS);
console.log(recentClipboardItems);
return recentClipboardItems.map((item, index) => {
return {
id: item.id,
title: item.content.slice(0, 20),
description: `#${index + 1}`,
};
});
}
}
export default ClipboardContextProvider;

View file

@ -1,5 +1,6 @@
import { BaseContextProvider } from "../";
import { ContextProviderName } from "../../";
import ClipboardContextProvider from "./ClipboardContextProvider";
import CodeContextProvider from "./CodeContextProvider";
import ContinueProxyContextProvider from "./ContinueProxyContextProvider";
@ -62,6 +63,7 @@ export const Providers: (typeof BaseContextProvider)[] = [
GreptileContextProvider,
WebContextProvider,
MCPContextProvider,
ClipboardContextProvider,
];
export function contextProviderClassFromName(

View file

@ -46,6 +46,7 @@ import * as URI from "uri-js";
import { SYSTEM_PROMPT_DOT_FILE } from "./config/getSystemPromptDotFile";
import type { IMessenger, Message } from "./protocol/messenger";
import { localPathToUri } from "./util/pathToUri";
import { clipboardCache } from "./util/clipboardCache";
export class Core {
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
@ -298,6 +299,7 @@ export class Core {
});
on("context/loadSubmenuItems", async (msg) => {
console.log("Load SUMBENU ITEMS", msg);
const config = await this.config();
if (!config) {
return [];
@ -381,6 +383,12 @@ export class Core {
};
});
on("clipboardCache/add", (msg) => {
console.log("ADD TO CLIPBOARD", msg);
clipboardCache.add(uuidv4(), msg.data.content);
this.messenger.send("refreshSubmenuItems", undefined);
});
async function* llmStreamChat(
configHandler: ConfigHandler,
abortedMessageIds: Set<string>,
@ -421,7 +429,6 @@ export class Core {
const chunk = next.value;
// @ts-ignore
yield { content: chunk };
next = await gen.next();
}

1
core/index.d.ts vendored
View file

@ -751,6 +751,7 @@ export type ContextProviderName =
| "issue"
| "repo-map"
| "url"
| "clipboard"
| string;
export type TemplateType =

View file

@ -743,10 +743,17 @@ export default class DocsService {
}
async getFavicon(startUrl: string) {
if (!this.config.embeddingsProvider) {
console.warn(
"Attempting to get favicon without embeddings provider specified",
);
return;
}
const db = await this.getOrCreateSqliteDb();
const result = await db.get(
`SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`,
`SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
startUrl,
this.config.embeddingsProvider.embeddingId,
);
if (!result) {
@ -1011,10 +1018,18 @@ export default class DocsService {
}
private async deleteMetadataFromSqlite(startUrl: string) {
if (!this.config.embeddingsProvider) {
console.warn(
`Attempting to delete metadata for ${startUrl} without embeddings provider specified`,
);
return;
}
const db = await this.getOrCreateSqliteDb();
await db.run(
`DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`,
`DELETE FROM ${DocsService.sqlitebTableName} WHERE startUrl = ? AND embeddingsProviderId = ?`,
startUrl,
this.config.embeddingsProvider.embeddingId,
);
}

View file

@ -53,14 +53,6 @@ export async function runSqliteMigrations(db: Database) {
);
}
const hasEmbeddingsProviderColumn = pragma.some(
(pragma) => pragma.name === "embeddingsProviderId",
);
if (!hasEmbeddingsProviderColumn) {
// gotta just delete in this case since old docs will be unusable anyway
await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`);
}
const needsToUpdateConfig = !hasFaviconCol || hasBaseUrlCol;
if (needsToUpdateConfig) {
const sqliteDocs = await db.all<
@ -78,4 +70,27 @@ export async function runSqliteMigrations(db: Database) {
() => resolve(undefined),
);
});
await new Promise((resolve) => {
void migrate(
"sqlite_delete_docs_with_no_embeddingsProviderId",
async () => {
try {
const pragma = await db.all(
`PRAGMA table_info(${DocsService.sqlitebTableName});`,
);
const hasEmbeddingsProviderColumn = pragma.some(
(pragma) => pragma.name === "embeddingsProviderId",
);
if (!hasEmbeddingsProviderColumn) {
// gotta just delete in this case since old docs will be unusable anyway
await db.exec(`DROP TABLE ${DocsService.sqlitebTableName};`);
}
} finally {
resolve(undefined);
}
},
() => resolve(undefined),
);
});
}

View file

@ -41,6 +41,7 @@ const PROVIDER_HANDLES_TEMPLATING: string[] = [
"openai",
"ollama",
"together",
"novita",
"msty",
"anthropic",
"bedrock",
@ -130,6 +131,7 @@ const PARALLEL_PROVIDERS: string[] = [
"free-trial",
"replicate",
"together",
"novita",
"sambanova",
"nebius",
"vertexai",

View file

@ -10,7 +10,7 @@ class Anthropic extends BaseLLM {
contextLength: 200_000,
completionOptions: {
model: "claude-3-5-sonnet-latest",
maxTokens: 4096,
maxTokens: 8192,
},
apiBase: "https://api.anthropic.com/v1/",
};

44
core/llm/llms/Novita.ts Normal file
View file

@ -0,0 +1,44 @@
import OpenAI from "./OpenAI.js";
import type { CompletionOptions, LLMOptions } from "../../index.js";
class Novita extends OpenAI {
static providerName = "novita";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.novita.ai/v3/openai/",
};
private static MODEL_IDS: { [name: string]: string } = {
"llama3-8b": "meta-llama/llama-3-8b-instruct",
"llama3-70b": "meta-llama/llama-3-70b-instruct",
"llama3.1-8b": "meta-llama/llama-3.1-8b-instruct",
"llama3.1-70b": "meta-llama/llama-3.1-70b-instruct",
"llama3.1-405b": "meta-llama/llama-3.1-405b-instruct",
"llama3.2-1b": "meta-llama/llama-3.2-1b-instruct",
"llama3.2-3b": "meta-llama/llama-3.2-3b-instruct",
"llama3.2-11b": "meta-llama/llama-3.2-11b-vision-instruct",
"llama3.3-70b": "meta-llama/llama-3.3-70b-instruct",
"mistral-nemo": "mistralai/mistral-nemo",
"mistral-7b": "mistralai/mistral-7b-instruct",
};
protected _convertModelName(model: string) {
return Novita.MODEL_IDS[model] || this.model;
}
protected async *_streamComplete(
prompt: string,
signal: AbortSignal,
options: CompletionOptions,
): AsyncGenerator<string> {
for await (const chunk of this._legacystreamComplete(
prompt,
signal,
options,
)) {
yield chunk;
}
}
}
export default Novita;

View file

@ -48,6 +48,7 @@ import ContinueProxy from "./stubs/ContinueProxy";
import TestLLM from "./Test";
import TextGenWebUI from "./TextGenWebUI";
import Together from "./Together";
import Novita from "./Novita";
import VertexAI from "./VertexAI";
import Vllm from "./Vllm";
import WatsonX from "./WatsonX";
@ -65,6 +66,7 @@ export const LLMClasses = [
Replicate,
TextGenWebUI,
Together,
Novita,
HuggingFaceTGI,
HuggingFaceInferenceAPI,
Kindo,

View file

@ -23,10 +23,26 @@ import type {
} from "../";
import { ConfigResult } from "../config/load";
export type ProtocolGeneratorType<T> = AsyncGenerator<{
export type ProtocolGeneratorYield<T> = {
done?: boolean;
content: T;
}>;
};
export type ProtocolGeneratorType<Y> = AsyncGenerator<
ProtocolGeneratorYield<Y>
>;
export type AsyncGeneratorYieldType<T> =
T extends AsyncGenerator<infer Y, any, any>
? Y extends ProtocolGeneratorYield<infer PR>
? PR
: never
: never;
// export type AsyncGeneratorReturnType<T> =
// T extends AsyncGenerator<any, infer R, any>
// ? R extends ProtocolGeneratorYield<infer PR>
// ? PR
// : never
// : never;
export type OnboardingModes =
| "Local"
@ -195,4 +211,5 @@ export type ToCoreFromIdeOrWebviewProtocol = {
{ toolCall: ToolCall; selectedModelTitle: string },
{ contextItems: ContextItem[] },
];
"clipboardCache/add": [{ content: string }, void];
};

View file

@ -43,7 +43,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
vscMediaUrl: string;
},
];
"jetbrains/getColors": [undefined, void];
"jetbrains/getColors": [undefined, Record<string, string>];
"vscode/openMoveRightMarkdown": [undefined, void];
setGitHubAuthToken: [{ token: string }, void];
acceptDiff: [{ filepath: string; streamId?: string }, void];

View file

@ -3,13 +3,13 @@ import { inferResolvedUriFromRelativePath } from "../../util/ideUtils";
import { ToolImpl } from ".";
export const createNewFileImpl: ToolImpl = async (args, extras) => {
const resolvedFilepath = await inferResolvedUriFromRelativePath(
const resolvedFileUri = await inferResolvedUriFromRelativePath(
args.filepath,
extras.ide,
);
if (resolvedFilepath) {
await extras.ide.writeFile(resolvedFilepath, args.contents);
await extras.ide.openFile(resolvedFilepath);
if (resolvedFileUri) {
await extras.ide.writeFile(resolvedFileUri, args.contents);
await extras.ide.openFile(resolvedFileUri);
}
return [];
};

View file

@ -0,0 +1,54 @@
class ClipboardCache {
private cache: Map<string, string>;
private order: string[];
private readonly maxSize = 30;
constructor() {
this.cache = new Map();
this.order = [];
}
add(id: string, content: string): void {
if (!content) {
return;
}
if (this.order.length >= this.maxSize) {
const oldest = this.order.pop();
if (oldest) {
this.cache.delete(oldest);
}
}
this.cache.set(id, content);
this.order.unshift(id);
}
getNItems(count: number): {
id: string;
content: string;
}[] {
return this.order.slice(0, count).map((id) => ({
id,
content: this.cache.get(id) || "",
}));
}
get(id: string): string | undefined {
return this.cache.get(id);
}
select(id: string): void {
const index = this.order.indexOf(id);
if (index > -1) {
this.order.splice(index, 1);
this.order.unshift(id);
}
}
clear(): void {
this.cache.clear();
this.order = [];
}
}
export const clipboardCache = new ClipboardCache();

View file

@ -15,7 +15,7 @@ The highlighted code you’ve selected by pressing <kbd>cmd/ctrl</kbd> + <kbd>L<
## Active file
You can include the currently open file as context by pressing <kbd>cmd</kbd> + <kbd>opt</kbd> + <kbd>enter</kbd> (Mac) or <kbd>ctrl</kbd> + <kbd>alt</kbd> + <kbd>enter</kbd> (Windows) when you send your request.
You can include the currently open file as context by pressing <kbd>cmd</kbd> + <kbd>opt</kbd> + <kbd>enter</kbd> (Mac) or <kbd>alt</kbd> + <kbd>enter</kbd> (Windows) when you send your request at Chat window(Prompt can't be empty).
## Specific file

View file

@ -33,7 +33,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz
### Llama 3.1 405B from Meta
If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)).
If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your best option right now. You will need to decide if you use it through a SaaS model provider (e.g. [Together](../customize/model-providers/more/together.md) or [Novita AI](../customize/model-providers/more/novita.md) or [Groq](../customize/model-providers/more/groq.md)) or self-host it (e.g. using [vLLM](../customize/model-providers//more/vllm.md) or [Ollama](../customize/model-providers/top-level/ollama.md)).
<Tabs groupId="providers">
<TabItem value="Together">
@ -48,6 +48,18 @@ If you prefer to use an open-weight model, then Llama 3.1 405B from Meta is your
]
```
</TabItem>
<TabItem value="Novita">
```json title="config.json"
"models": [
{
"title": "Llama 3.1 405B",
"provider": "novita",
"model": "meta-llama/llama-3.1-405b-instruct",
"apiKey": "[NOVITA_API_KEY]"
}
]
```
</TabItem>
<TabItem value="Groq">
```json title="config.json"
"models": [

View file

@ -576,6 +576,20 @@ The response 200 OK should be a JSON object with the following structure:
}
```
### `@Clipboard`
Reference recent clipboard items
```json title="config.json"
{
"contextProviders": [
{
"name": "clipboard"
}
]
}
```
### Requesting Context Providers
Not seeing what you want? Create an issue [here](https://github.com/continuedev/continue/issues/new?assignees=TyDunn&labels=enhancement&projects=&template=feature-request-%F0%9F%92%AA.md&title=) to request a new Context Provider.

View file

@ -46,7 +46,7 @@ We recommend configuring **rerank-english-v3.0** as your reranking model.
```json title="config.json"
{
"reranker": {
"provider": "cohere",
"name": "cohere",
"params": {
"model": "rerank-english-v3.0",
"apiKey": "<COHERE_API_KEY>"

View file

@ -1,6 +1,6 @@
# Kindo
Kindo offers centralized control over your organization's AI operations, ensuring data protection and compliance with internal policies while supporting various commercial and open-source models. To get started, sign up [here](https://app.kindo.ai/), create your API key on the [API keys page](https://app.kindo.ai/settings/api), and choose a model from the list of supported models in the [plugins tab](https://app.kindo.ai/plugins).
Kindo offers centralized control over your organization's AI operations, ensuring data protection and compliance with internal policies while supporting various commercial and open-source models. To get started, sign up [here](https://app.kindo.ai/), create an API key in [Settings > API > API Keys](https://app.kindo.ai/settings/api), and choose a model from the list of supported models in the "Available Models" tab or copy and paste the config in [Plugins > Your Configuration](https://app.kindo.ai/plugins).
## Config Example
@ -10,7 +10,7 @@ Kindo offers centralized control over your organization's AI operations, ensurin
{
"title": "Claude 3.5 Sonnet",
"provider": "kindo",
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet",
"apiKey": "<KINDO_API_KEY>"
}
]
@ -26,13 +26,8 @@ Kindo offers centralized control over your organization's AI operations, ensurin
"title": "WhiteRabbitNeo",
"provider": "kindo",
"model": "/models/WhiteRabbitNeo-33B-DeepSeekCoder",
"apiKey": "<KINDO_API_KEY>"
},
{
"title": "DeepSeek",
"provider": "kindo",
"model": "deepseek-ai/deepseek-coder-33b-instruct",
"apiKey": "<KINDO_API_KEY>"
"apiKey": "<KINDO_API_KEY>",
"template": "none"
}
]
}

View file

@ -0,0 +1,18 @@
# Novita
[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today!. You can sign up [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), copy your API key on the [Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link), and then hit the play button on any model from the [Novita AI Models list](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link). Change `~/.continue/config.json` to look like this:
```json title="config.json"
{
"models": [
{
"title": "Llama 3.1 8B",
"provider": "novita",
"model": "meta-llama/llama-3.1-8b-instruct",
"apiKey": "YOUR_API_KEY"
}
]
}
```
[View the source](https://github.com/continuedev/continue/blob/main/core/llm/llms/Novita.ts)

View file

@ -1,7 +1,7 @@
---
title: Using Llama 3.1 with Continue
description: How to use Llama 3.1 with Continue
keywords: [llama, meta, togetherai, ollama, replicate]
keywords: [llama, meta, togetherai, novita, ollama, replicate]
---
Continue makes it easy to code with the latest open-source models, including the entire Llama 3.1 family of models. Llama 3.2 models are also supported but not recommended for chat, because they are specifically designed to be small or multi-modal.
@ -71,6 +71,28 @@ Together AI provides fast and reliable inference of open-source models. You'll b
}
```
## Novita AI
[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM API](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. Try the [Novita AI Llama 3 API Demo](https://novita.ai/model-api/product/llm-api/playground/meta-llama-llama-3.1-70b-instruct?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) today!
1. Create an account [here](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)
2. Copy your API key that appears on the welcome screen
3. Update your Continue config file like this:
```json title="config.json"
{
"models": [
{
"title": "Llama 3.1 405b",
"provider": "novita",
"model": "meta-llama/llama-3.1-405b-instruct",
"apiKey": "<API_KEY>"
}
]
}
```
## Replicate
Replicate makes it easy to host and run open-source AI with an API.

View file

@ -388,7 +388,11 @@ const config = {
},
{
to: "/customize/model-providers/more/together",
from: "/reference/Model Providers/togetherllm",
from: "/reference/Model Providers/together",
},
{
to: "/customize/model-providers/more/novita",
from: "/reference/Model Providers/novita",
},
{
to: "/customize/model-providers/more/vllm",

View file

@ -33,7 +33,7 @@ import TabItem from "@theme/TabItem";
### 来自 Meta 的 Llama 3.1 405B
如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。
如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 、[Novita AI](../customize/model-providers/more/novita.md)或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。
<Tabs groupId="providers">
<TabItem value="Together">
@ -48,6 +48,18 @@ import TabItem from "@theme/TabItem";
]
```
</TabItem>
<TabItem value="Novita">
```json title="config.json"
"models": [
{
"title": "Llama 3.1 405B",
"provider": "novita",
"model": "meta-llama/llama-3.1-405b-instruct",
"apiKey": "[NOVITA_API_KEY]"
}
]
```
</TabItem>
<TabItem value="Groq">
```json title="config.json"
"models": [

View file

@ -0,0 +1,18 @@
# Novita
[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以在 [这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 注册,在 [Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)复制你的 API key ,然后在 [Novita 模型列表](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 的任何模型上点击 Try it now 按钮。修改 `~/.continue/config.json` 像这样:
```json title="config.json"
{
"models": [
{
"title": "Llama 3.1 8b",
"provider": "Novita",
"model": "meta-llama/llama-3.1-8b-instruct",
"apiKey": "YOUR_API_KEY"
}
]
}
```
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Novita.ts)

View file

@ -1,7 +1,7 @@
---
title: Continue 使用 Llama 3.1
description: Continue 如何使用 Llama 3.1
keywords: [llama, meta, togetherai, ollama, replicate]
keywords: [llama, meta, togetherai, novita, ollama, replicate]
---
Continue 让使用最新的开元模型编码变得简单,包括整个 Llama 3.1 家族模型。
@ -71,6 +71,27 @@ Together AI 提供开源模型的快速和可信任的推理。你可以以良
}
```
## Novita AI
[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) 提供了一个经济实惠、可靠且简单的推理平台。你可以以良好的速度运行 405b 模型。
1. 创建账号 [在这里](https://novita.ai/user/login?&redirect=/&utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)
2. 复制[Key Management](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)中的你的 API key
3. 更新你的 Continue 配置文件,像这样:
```json title="config.json"
{
"models": [
{
"title": "Llama 3.1 405b",
"provider": "novita",
"model": "meta-llama/llama-3.1-405b-instruct",
"apiKey": "<API_KEY>"
}
]
}
```
## Replicate
Replicate 让使用 API 托管和运行开源 AI 变得简单。

View file

@ -469,6 +469,10 @@ class IdeProtocolClient(
}
val diffStreamService = project.service<DiffStreamService>()
// Clear all diff blocks before running the diff stream
diffStreamService.reject(editor)
val llmTitle = (llm as? Map<*, *>)?.get("title") as? String ?: ""
val prompt =
@ -501,7 +505,6 @@ class IdeProtocolClient(
rif?.range?.end?.line ?: (editor.document.lineCount - 1),
{}, {})
val diffStreamService = project.service<DiffStreamService>()
diffStreamService.register(diffStreamHandler, editor)
diffStreamHandler.streamDiffLinesToEditor(

View file

@ -125,7 +125,9 @@ class DiffStreamHandler(
diffBlocks.remove(diffBlock)
if (!didAccept) {
if (didAccept) {
updatePositionsOnAccept(diffBlock.startLine)
} else {
updatePositionsOnReject(diffBlock.startLine, diffBlock.addedLines.size, diffBlock.deletedLines.size)
}
@ -186,10 +188,16 @@ class DiffStreamHandler(
}
}
private fun updatePositionsOnAccept(startLine: Int) {
updatePositions(startLine, 0)
}
private fun updatePositionsOnReject(startLine: Int, numAdditions: Int, numDeletions: Int) {
val offset = -numAdditions + numDeletions
updatePositions(startLine, offset)
}
private fun updatePositions(startLine: Int, offset: Int) {
diffBlocks.forEach { block ->
if (block.startLine > startLine) {
block.updatePosition(block.startLine + offset)

View file

@ -3,6 +3,7 @@ package com.github.continuedev.continueintellijextension.editor
import com.github.continuedev.continueintellijextension.utils.getAltKeyLabel
import com.github.continuedev.continueintellijextension.utils.getShiftKeyLabel
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition
@ -11,6 +12,7 @@ import com.intellij.openapi.editor.markup.HighlighterLayer
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import com.intellij.ui.JBColor
import com.intellij.util.application
import java.awt.*
import javax.swing.BorderFactory
import javax.swing.JButton
@ -41,7 +43,14 @@ class VerticalDiffBlock(
}
fun clearEditorUI() {
deletionInlay?.dispose()
deletionInlay?.let {
// Ensure that dispose is executed on EDT
if (application.isDispatchThread) {
it.dispose()
} else {
invokeLater { it.dispose() }
}
}
removeGreenHighlighters()
removeButtons()
}

View file

@ -110,6 +110,19 @@ class ContinuePluginSelectionListener(
ApplicationManager.getApplication().invokeLater {
val document = editor.document
val (startLine, endLine, isFullLineSelection) = getSelectionInfo(model, document)
// Check if entire file is selected
val isEntireFileSelected = model.selectionStart == 0 &&
model.selectionEnd == document.textLength
// Scroll to top if entire file selected so that the user can see the input
if (isEntireFileSelected) {
editor.scrollingModel.scrollTo(
LogicalPosition(0, 0),
com.intellij.openapi.editor.ScrollType.CENTER
)
}
val selectionTopY = calculateSelectionTopY(editor, startLine, endLine, isFullLineSelection)
val tooltipX = calculateTooltipX(editor, document, startLine, endLine, isFullLineSelection)

View file

@ -180,6 +180,7 @@
"bedrockimport",
"sagemaker",
"together",
"novita",
"ollama",
"huggingface-tgi",
"huggingface-inference-api",
@ -222,6 +223,7 @@
"### Bedrock Imported Models\nTo get started with Bedrock you need to sign up on AWS [here](https://aws.amazon.com/bedrock)",
"### Sagemaker\nSagemaker is AWS' machine learning platform.",
"### Together\nTogether is a hosted service that provides extremely fast streaming of open-source language models. To get started with Together:\n1. Obtain an API key from [here](https://together.ai)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/togetherllm)",
"### Novita AI\n[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)\n2. Paste below\n3. Select a model preset\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/novita)",
"### Ollama\nTo get started with Ollama, follow these steps:\n1. Download from [ollama.ai](https://ollama.ai/) and open the application\n2. Open a terminal and run `ollama run <MODEL_NAME>`. Example model names are `codellama:7b-instruct` or `llama2:7b-text`. You can find the full list [here](https://ollama.ai/library).\n3. Make sure that the model name used in step 2 is the same as the one in config.json (e.g. `model=\"codellama:7b-instruct\"`)\n4. Once the model has finished downloading, you can start asking questions through Continue.\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/ollama)",
"### Huggingface TGI\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfacetgi)",
"### Huggingface Inference API\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/huggingfaceinferenceapi)",
@ -262,7 +264,7 @@
},
"apiKey": {
"title": "Api Key",
"description": "OpenAI, Anthropic, Cohere, Together, or other API key",
"description": "OpenAI, Anthropic, Cohere, Together, Novita AI, or other API key",
"type": "string"
},
"apiBase": {
@ -475,6 +477,7 @@
"huggingface-inference-api",
"replicate",
"together",
"novita",
"cloudflare",
"sambanova",
"nebius",
@ -980,6 +983,44 @@
}
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["novita"]
}
},
"required": ["provider"]
},
"then": {
"properties": {
"model": {
"anyOf": [
{
"enum": [
"llama3-8b",
"llama3-70b",
"llama3.1-8b",
"llama3.1-70b",
"llama3.1-405b",
"llama3.2-1b",
"llama3.2-3b",
"llama3.2-11b",
"llama3.3-70b",
"mistral-nemo",
"mistral-7b"
]
},
{
"type": "string"
}
],
"markdownDescription": "Select a pre-defined option, or find an exact model string from Novita AI [here](https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link).",
"x-intellij-html-description": "Select a pre-defined option, or find an exact model string from Novita AI <a href='https://novita.ai/llm-api?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link'>here</a>."
}
}
}
},
{
"if": {
"properties": {
@ -1864,7 +1905,8 @@
"os",
"repo-map",
"greptile",
"web"
"web",
"clipboard"
],
"markdownEnumDescriptions": [
"Reference the contents of the current changes as given by `git diff`",

View file

@ -1,12 +1,12 @@
{
"name": "continue",
"version": "0.9.248",
"version": "0.9.250",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "continue",
"version": "0.9.248",
"version": "0.9.250",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/fetch": "^1.0.3",

View file

@ -57,12 +57,6 @@
],
"main": "./out/extension.js",
"contributes": {
"authentication": [
{
"id": "continue",
"label": "Continue"
}
],
"languages": [
{
"filenames": [
@ -107,6 +101,11 @@
"default": true,
"description": "Show inline suggestion to use the Continue keyboard shortcuts (e.g. \"Cmd/Ctrl L to select code, Cmd/Ctrl I to edit\")."
},
"continue.disableQuickFix": {
"type": "boolean",
"default": false,
"description": "Disable the quick fix feature."
},
"continue.enableQuickActions": {
"type": "boolean",
"default": false,

View file

@ -1001,7 +1001,10 @@ const getCommandsMap: (
};
};
const registerCopyBufferSpy = (context: vscode.ExtensionContext) => {
const registerCopyBufferSpy = (
context: vscode.ExtensionContext,
core: Core,
) => {
const typeDisposable = vscode.commands.registerCommand(
"editor.action.clipboardCopyAction",
async (arg) => doCopy(typeDisposable),
@ -1014,6 +1017,12 @@ const registerCopyBufferSpy = (context: vscode.ExtensionContext) => {
const clipboardText = await vscode.env.clipboard.readText();
if (clipboardText) {
core.invoke("clipboardCache/add", {
content: clipboardText,
});
}
await context.workspaceState.update("continue.copyBuffer", {
text: clipboardText,
copiedAt: new Date().toISOString(),
@ -1043,7 +1052,7 @@ export function registerAllCommands(
core: Core,
editDecorationManager: EditDecorationManager,
) {
registerCopyBufferSpy(context);
registerCopyBufferSpy(context, core);
for (const [command, callback] of Object.entries(
getCommandsMap(

View file

@ -1,3 +1,4 @@
import { EXTENSION_NAME } from "core/control-plane/env";
import * as vscode from "vscode";
class ContinueQuickFixProvider implements vscode.CodeActionProvider {
@ -42,6 +43,15 @@ class ContinueQuickFixProvider implements vscode.CodeActionProvider {
}
export default function registerQuickFixProvider() {
const isDisabled =
!!vscode.workspace
.getConfiguration(EXTENSION_NAME)
.get<boolean>("disableQuickFix") === true;
if (isDisabled) {
return;
}
// In your extension's activate function:
vscode.languages.registerCodeActionsProvider(
{ language: "*" },

View file

@ -1,23 +1,16 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"strict-null-checks",
"eslint-plugin-react"
],
"plugins": ["@typescript-eslint", "eslint-plugin-react"],
"parserOptions": {
"project": "gui/tsconfig.strictNullChecks.json"
},
// "extends": [
// "eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
// "plugin:react/recommended"
// ],
"rules": {
"strict-null-checks/all": "warn"
"project": "gui/tsconfig.json"
},
"extends": [
// "eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
// "plugin:react/recommended"
],
"overrides": [
{
"files": ["src/**/*.{js,ts,jsx,tsx}"]

372
gui/package-lock.json generated
View file

@ -24,6 +24,7 @@
"@tiptap/react": "^2.1.13",
"@tiptap/starter-kit": "^2.1.13",
"@tiptap/suggestion": "^2.1.13",
"@types/uuid": "^10.0.0",
"@types/vscode-webview": "^1.57.1",
"core": "file:../core",
"dompurify": "^3.0.6",
@ -70,6 +71,7 @@
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/dompurify": "^3.2.0",
"@types/lodash": "^4.17.6",
"@types/mustache": "^4.2.5",
"@types/node": "^20.5.6",
@ -85,7 +87,6 @@
"autoprefixer": "^10.4.13",
"eslint": "^8",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-strict-null-checks": "^0.1.3",
"jsdom": "^25.0.1",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.7",
@ -2894,6 +2895,16 @@
"@types/ms": "*"
}
},
"node_modules/@types/dompurify": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.2.0.tgz",
"integrity": "sha512-Fgg31wv9QbLDA0SpTOXO3MaxySc4DKGLi8sna4/Utjo4r3ZRPdCt4UQee8BWr+Q5z21yifghREPJGYaEOEIACg==",
"deprecated": "This is a stub types definition. dompurify provides its own type definitions, so you do not need this installed.",
"dev": true,
"dependencies": {
"dompurify": "*"
}
},
"node_modules/@types/estree": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
@ -2936,12 +2947,6 @@
"integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==",
"dev": true
},
"node_modules/@types/json-schema": {
"version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"dev": true
},
"node_modules/@types/katex": {
"version": "0.16.7",
"resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz",
@ -3062,12 +3067,6 @@
"@types/node": "*"
}
},
"node_modules/@types/semver": {
"version": "7.5.8",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz",
"integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==",
"dev": true
},
"node_modules/@types/styled-components": {
"version": "5.1.34",
"resolved": "https://registry.npmjs.org/@types/styled-components/-/styled-components-5.1.34.tgz",
@ -3089,6 +3088,11 @@
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
},
"node_modules/@types/uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",
"integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ=="
},
"node_modules/@types/vscode-webview": {
"version": "1.57.5",
"resolved": "https://registry.npmjs.org/@types/vscode-webview/-/vscode-webview-1.57.5.tgz",
@ -3602,15 +3606,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/array.prototype.findlast": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz",
@ -4671,18 +4666,6 @@
"integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==",
"dev": true
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"dependencies": {
"path-type": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/direction": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz",
@ -5151,262 +5134,6 @@
"semver": "bin/semver.js"
}
},
"node_modules/eslint-plugin-strict-null-checks": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-strict-null-checks/-/eslint-plugin-strict-null-checks-0.1.3.tgz",
"integrity": "sha512-c0bByePJytPXxZF9jBH17UQO41aCK08zThIXcAO3EnkdLhqUqIr+LVMfPstrN/9dLNzh4YKIbkbRPhRXRnNfNQ==",
"dev": true,
"dependencies": {
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/experimental-utils": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"requireindex": "^1.2.0"
},
"peerDependencies": {
"typescript": ">=3.9.4"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz",
"integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==",
"dev": true,
"dependencies": {
"@eslint-community/regexpp": "^4.4.0",
"@typescript-eslint/scope-manager": "5.62.0",
"@typescript-eslint/type-utils": "5.62.0",
"@typescript-eslint/utils": "5.62.0",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.0",
"natural-compare-lite": "^1.4.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/experimental-utils": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-5.62.0.tgz",
"integrity": "sha512-RTXpeB3eMkpoclG3ZHft6vG/Z30azNHuqY6wKPBHlVMZFuEvrtlEDe8gMqDb+SO+9hjC/pLekeSCryf9vMZlCw==",
"dev": true,
"dependencies": {
"@typescript-eslint/utils": "5.62.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/parser": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz",
"integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.62.0",
"@typescript-eslint/types": "5.62.0",
"@typescript-eslint/typescript-estree": "5.62.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/scope-manager": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz",
"integrity": "sha512-VXuvVvZeQCQb5Zgf4HAxc04q5j+WrNAtNh9OwCsCgpKqESMTu3tF/jhZ3xG6T4NZwWl65Bg8KuS2uEvhSfLl0w==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.62.0",
"@typescript-eslint/visitor-keys": "5.62.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/type-utils": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz",
"integrity": "sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==",
"dev": true,
"dependencies": {
"@typescript-eslint/typescript-estree": "5.62.0",
"@typescript-eslint/utils": "5.62.0",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/types": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.62.0.tgz",
"integrity": "sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/typescript-estree": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz",
"integrity": "sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.62.0",
"@typescript-eslint/visitor-keys": "5.62.0",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/utils": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.62.0.tgz",
"integrity": "sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==",
"dev": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@types/json-schema": "^7.0.9",
"@types/semver": "^7.3.12",
"@typescript-eslint/scope-manager": "5.62.0",
"@typescript-eslint/types": "5.62.0",
"@typescript-eslint/typescript-estree": "5.62.0",
"eslint-scope": "^5.1.1",
"semver": "^7.3.7"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/@typescript-eslint/visitor-keys": {
"version": "5.62.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.62.0.tgz",
"integrity": "sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.62.0",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"dev": true,
"dependencies": {
"esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
},
"engines": {
"node": ">=8.0.0"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-scope/node_modules/estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true,
"engines": {
"node": ">=4.0"
}
},
"node_modules/eslint-plugin-strict-null-checks/node_modules/eslint-visitor-keys": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/eslint-scope": {
"version": "7.2.2",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
@ -6303,26 +6030,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/gopd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
@ -8916,12 +8623,6 @@
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true
},
"node_modules/natural-compare-lite": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz",
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
"dev": true
},
"node_modules/node-releases": {
"version": "2.0.18",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz",
@ -9331,15 +9032,6 @@
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
"dev": true
},
"node_modules/path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true,
"engines": {
"node": ">=8"
}
},
"node_modules/pathe": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz",
@ -10875,15 +10567,6 @@
"node": ">=0.10.0"
}
},
"node_modules/requireindex": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz",
"integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==",
"dev": true,
"engines": {
"node": ">=0.10.5"
}
},
"node_modules/reselect": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",
@ -12094,27 +11777,6 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
"integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA=="
},
"node_modules/tsutils": {
"version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dev": true,
"dependencies": {
"tslib": "^1.8.1"
},
"engines": {
"node": ">= 6"
},
"peerDependencies": {
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
}
},
"node_modules/tsutils/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",

View file

@ -32,6 +32,7 @@
"@tiptap/react": "^2.1.13",
"@tiptap/starter-kit": "^2.1.13",
"@tiptap/suggestion": "^2.1.13",
"@types/uuid": "^10.0.0",
"@types/vscode-webview": "^1.57.1",
"core": "file:../core",
"dompurify": "^3.0.6",
@ -78,6 +79,7 @@
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/dompurify": "^3.2.0",
"@types/lodash": "^4.17.6",
"@types/mustache": "^4.2.5",
"@types/node": "^20.5.6",
@ -93,7 +95,6 @@
"autoprefixer": "^10.4.13",
"eslint": "^8",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-strict-null-checks": "^0.1.3",
"jsdom": "^25.0.1",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.7",

BIN
gui/public/logos/novita.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View file

@ -1,4 +1,3 @@
import { useState } from "react";
import styled from "styled-components";
import { defaultBorderRadius, vscBackground, vscForeground } from ".";
import { CheckIcon } from "@heroicons/react/24/outline";

View file

@ -8,8 +8,8 @@ import FileIcon from "../FileIcon";
import { useAppSelector } from "../../redux/hooks";
export interface AddFileComboboxProps {
onSelect: (filepaths: string[]) => void;
onEscape: () => void;
onSelect: (filepaths: string[]) => void | Promise<void>;
onEscape: () => void | Promise<void>;
}
export default function AddFileCombobox({
@ -50,7 +50,7 @@ export default function AddFileCombobox({
value={selectedFiles}
onChange={(files) => {
setSelectedFiles(files);
onSelect(files.map((file) => file.id));
void onSelect(files.map((file) => file.id));
buttonRef.current?.click();
}}
>
@ -72,7 +72,7 @@ export default function AddFileCombobox({
placeholder="Type to search files..."
onKeyDown={(e) => {
if (e.key === "Escape" && !open) {
onEscape();
void onEscape();
}
}}
/>

View file

@ -2,7 +2,7 @@ import { useContext, useState } from "react";
import { useDispatch } from "react-redux";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import CodeToEditListItem from "./CodeToEditListItem";
import type { CodeToEdit, RangeInFileWithContents } from "core";
import type { CodeToEdit } from "core";
import AddFileButton from "./AddFileButton";
import AddFileCombobox from "./AddFileCombobox";
import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline";
@ -25,19 +25,19 @@ export default function CodeToEditCard() {
? "Code to edit (1 item)"
: `Code to edit (${codeToEdit.length} items)`;
function onDelete(rif: RangeInFileWithContents) {
function onDelete(rif: CodeToEdit) {
dispatch(removeCodeToEdit(rif));
}
function onClickFilename(code: CodeToEdit) {
async function onClickFilename(code: CodeToEdit) {
if ("range" in code) {
ideMessenger.ide.showLines(
await ideMessenger.ide.showLines(
code.filepath,
code.range.start.line,
code.range.end.line,
);
} else {
ideMessenger.ide.openFile(code.filepath);
await ideMessenger.ide.openFile(code.filepath);
}
}
@ -93,10 +93,10 @@ export default function CodeToEditCard() {
/>
</div>
<XMarkIcon
onClick={(e) => {
onClick={() => {
setShowAddFileCombobox(false);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground mb-2 h-3.5 w-3.5 cursor-pointer rounded-md rounded-sm p-0.5 hover:bg-opacity-20"
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground mb-2 h-3.5 w-3.5 cursor-pointer rounded-sm p-0.5 hover:bg-opacity-20"
/>
</div>
)}

View file

@ -16,8 +16,8 @@ import {
export interface CodeToEditListItemProps {
code: CodeToEdit;
onDelete: (codeToEdit: CodeToEdit) => void;
onClickFilename: (codeToEdit: CodeToEdit) => void;
onDelete: (codeToEdit: CodeToEdit) => void | Promise<void>;
onClickFilename: (codeToEdit: CodeToEdit) => void | Promise<void>;
}
const NoPaddingWrapper = styled.div`
@ -87,7 +87,7 @@ export default function CodeToEditListItem({
className="flex-shrink-0 text-xs hover:underline"
onClick={(e) => {
e.stopPropagation();
onClickFilename(code);
void onClickFilename(code);
}}
>
{title}
@ -122,7 +122,7 @@ export default function CodeToEditListItem({
<XMarkIcon
onClick={(e) => {
e.stopPropagation();
onDelete(code);
void onDelete(code);
}}
className="text-lightgray hover:bg-lightgray hover:text-vsc-foreground h-3.5 w-3.5 cursor-pointer rounded-sm p-0.5 hover:bg-opacity-20"
/>

View file

@ -1,3 +1,4 @@
// @ts-ignore
import DOMPurify from "dompurify";
import { useMemo } from "react";
import { themeIcons } from "seti-file-icons";

View file

@ -1,6 +1,6 @@
import { CubeIcon } from "@heroicons/react/24/outline";
import { DEFAULT_CHAT_MODEL_CONFIG } from "core/config/default";
import { useContext, useState } from "react";
import { FormEventHandler, useContext, useState } from "react";
import { useDispatch } from "react-redux";
import { Button, Input, InputSubtext, lightGray } from "../..";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
@ -33,7 +33,7 @@ function BestExperienceConfigForm({
const [autocompleteApiKey, setAutocompleteApiKey] = useState("");
const [chatApiKey, setChatApiKey] = useState("");
async function handleSubmit(e) {
const handleSubmit: FormEventHandler<HTMLFormElement> = async (e) => {
e.preventDefault();
const chatModelConfig = {
@ -74,7 +74,7 @@ function BestExperienceConfigForm({
}
onComplete();
}
};
return (
<form onSubmit={handleSubmit}>
@ -83,7 +83,7 @@ function BestExperienceConfigForm({
<div className="mb-1 flex flex-row justify-between gap-4 text-lg font-bold">
<label className="text-lg font-bold">Chat model</label>
<div
className="flex hidden items-center justify-end text-xs font-semibold sm:flex"
className="hidden items-center justify-end text-xs font-semibold sm:flex"
style={{ color: lightGray }}
>
<CubeIcon className="mr-1 h-4 w-4 flex-shrink-0" />

View file

@ -36,7 +36,7 @@ export default function EditActions({ index, item }: EditActionsProps) {
// const isCurCheckpoint = Math.floor(index / 2) === curCheckpointIndex;
const hasPendingApplies = pendingApplyStates.length > 0;
if (isStreaming) return;
if (isStreaming) return null;
return (
<div

View file

@ -12,9 +12,7 @@ export default function UndoAndRedoButtons() {
const dispatch = useDispatch();
const ideMessenger = useContext(IdeMessengerContext);
const checkpoints = useAppSelector(
(store) => store.session.history.at(-1).checkpoint,
);
const history = useAppSelector((store) => store.session.history);
const curCheckpointIndex = useAppSelector(
(store) => store.session.curCheckpointIndex,
@ -28,10 +26,13 @@ export default function UndoAndRedoButtons() {
type === "undo" ? curCheckpointIndex - 1 : curCheckpointIndex + 1,
);
const checkpoint = checkpoints[checkpointIndex];
const checkpoint = history[checkpointIndex]?.checkpoint ?? {};
for (const [filepath, prevFileContent] of Object.entries(checkpoint)) {
ideMessenger.post("overwriteFile", { filepath, prevFileContent });
for (const [filepath, cachedFileContent] of Object.entries(checkpoint)) {
ideMessenger.post("overwriteFile", {
filepath,
prevFileContent: cachedFileContent,
});
}
dispatch(setCurCheckpointIndex(checkpointIndex));

View file

@ -0,0 +1,20 @@
import { Node } from "@tiptap/core";
export const MockExtension = Node.create({
name: "mockExtension",
addOptions() {
return {
enabled: false,
};
},
addCommands() {
return {};
},
addKeyboardShortcuts() {
return {};
},
addProseMirrorPlugins() {
return [];
},
});

View file

@ -6,10 +6,8 @@ import {
import { WrenchScrewdriverIcon as WrenchScrewdriverIconSolid } from "@heroicons/react/24/solid";
import { useEffect, useRef, useState } from "react";
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { defaultBorderRadius, lightGray, vscForeground } from "../..";
import { lightGray, vscForeground } from "../..";
import { toggleUseTools } from "../../../redux/slices/uiSlice";
import { getFontSize } from "../../../util";
import InfoHover from "../../InfoHover";
import HoverItem from "./HoverItem";
import ToolDropdownItem from "./ToolDropdownItem";

View file

@ -66,11 +66,12 @@ const ICONS_FOR_DROPDOWN: { [key: string]: any } = {
"/cmd": CommandLineIcon,
};
export function getIconFromDropdownItem(id: string, type: ComboBoxItemType) {
return (
ICONS_FOR_DROPDOWN[id] ??
(type === "contextProvider" ? AtSymbolIcon : BoltIcon)
);
export function getIconFromDropdownItem(
id: string | undefined,
type: ComboBoxItemType,
) {
const typeIcon = type === "contextProvider" ? AtSymbolIcon : BoltIcon;
return id ? (ICONS_FOR_DROPDOWN[id] ?? typeIcon) : typeIcon;
}
function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
@ -238,7 +239,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
}
}, [querySubmenuItem]);
const selectItem = (index) => {
const selectItem = (index: number) => {
const item = allItems[index];
if (item.type === "action" && item.action) {
@ -251,7 +252,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
item.contextProvider?.type === "submenu"
) {
setSubMenuTitle(item.description);
props.enterSubmenu(props.editor, item.id);
if (item.id) {
props.enterSubmenu?.(props.editor, item.id);
}
return;
}
@ -308,7 +311,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
useEffect(() => setSelectedIndex(0), [allItems]);
useImperativeHandle(ref, () => ({
onKeyDown: ({ event }) => {
onKeyDown: ({ event }: { event: KeyboardEvent }) => {
if (event.key === "ArrowUp") {
upHandler();
return true;
@ -359,6 +362,9 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
ref={queryInputRef}
placeholder={querySubmenuItem.description}
onKeyDown={(e) => {
if (!queryInputRef.current) {
return;
}
if (e.key === "Enter") {
if (e.shiftKey) {
queryInputRef.current.innerText += "\n";

View file

@ -5,7 +5,13 @@ import Paragraph from "@tiptap/extension-paragraph";
import Placeholder from "@tiptap/extension-placeholder";
import Text from "@tiptap/extension-text";
import { Plugin } from "@tiptap/pm/state";
import { Editor, EditorContent, JSONContent, useEditor } from "@tiptap/react";
import {
AnyExtension,
Editor,
EditorContent,
JSONContent,
useEditor,
} from "@tiptap/react";
import { ContextProviderDescription, InputModifiers } from "core";
import { rifWithContentsToContextItem } from "core/commands/util";
import { modelSupportsImages } from "core/llm/autodetect";
@ -71,6 +77,7 @@ import {
handleVSCMetaKeyIssues,
} from "./handleMetaKeyIssues";
import { ComboBoxItem } from "./types";
import { MockExtension } from "./FillerExtension";
const InputBoxDiv = styled.div<{ border?: string }>`
resize: none;
@ -301,7 +308,7 @@ function TipTapEditor(props: TipTapEditorProps) {
const { prevRef, nextRef, addRef } = useInputHistory(props.historyKey);
const editor: Editor = useEditor({
const editor: Editor | null = useEditor({
extensions: [
Document,
History,
@ -392,6 +399,7 @@ function TipTapEditor(props: TipTapEditorProps) {
if (isStreamingRef.current) {
return true;
}
return false;
},
"Shift-Enter": () =>
this.editor.commands.first(({ commands }) => [
@ -417,6 +425,7 @@ function TipTapEditor(props: TipTapEditorProps) {
}, 0);
return true;
}
return false;
},
Escape: () => {
if (inDropdownRef.current || !isInEditModeRef.current) {
@ -449,6 +458,7 @@ function TipTapEditor(props: TipTapEditorProps) {
}, 0);
return true;
}
return false;
},
};
},
@ -530,7 +540,7 @@ function TipTapEditor(props: TipTapEditorProps) {
return props.node.attrs.label;
},
})
: undefined,
: MockExtension,
CodeBlockExtension,
],
editorProps: {
@ -562,6 +572,9 @@ function TipTapEditor(props: TipTapEditorProps) {
}
useEffect(() => {
if (!editor) {
return;
}
const placeholder = getPlaceholderText(
props.placeholder,
historyLengthRef.current,
@ -576,9 +589,9 @@ function TipTapEditor(props: TipTapEditorProps) {
useEffect(() => {
if (props.isMainInput) {
editor.commands.clearContent(true);
editor?.commands.clearContent(true);
}
}, [isInEditMode, props.isMainInput]);
}, [editor, isInEditMode, props.isMainInput]);
useEffect(() => {
if (editor) {
@ -615,6 +628,10 @@ function TipTapEditor(props: TipTapEditorProps) {
* with those key actions.
*/
const handleKeyDown = async (e: KeyboardEvent<HTMLDivElement>) => {
if (!editor) {
return;
}
setActiveKey(e.key);
if (!editorFocusedRef?.current || !isMetaEquivalentKeyPressed(e)) return;
@ -632,6 +649,9 @@ function TipTapEditor(props: TipTapEditorProps) {
const onEnterRef = useUpdatingRef(
(modifiers: InputModifiers) => {
if (!editor) {
return;
}
if (isStreaming || isEditModeAndNoCodeToEdit) {
return;
}
@ -659,7 +679,7 @@ function TipTapEditor(props: TipTapEditorProps) {
* commands are redundant, especially the ones inside
* useTimeout.
*/
editor.commands.focus();
editor?.commands.focus();
}
}, [props.isMainInput, editor]);
@ -679,7 +699,7 @@ function TipTapEditor(props: TipTapEditorProps) {
return;
}
queueMicrotask(() => {
editor.commands.setContent(mainInputContentTrigger);
editor?.commands.setContent(mainInputContentTrigger);
});
dispatch(setMainEditorContentTrigger(undefined));
}, [editor, props.isMainInput, mainInputContentTrigger]);
@ -852,7 +872,7 @@ function TipTapEditor(props: TipTapEditorProps) {
useWebviewListener(
"isContinueInputFocused",
async () => {
return props.isMainInput && editorFocusedRef.current;
return props.isMainInput && !!editorFocusedRef.current;
},
[editorFocusedRef, props.isMainInput],
!props.isMainInput,
@ -902,6 +922,9 @@ function TipTapEditor(props: TipTapEditorProps) {
const insertCharacterWithWhitespace = useCallback(
(char: string) => {
if (!editor) {
return;
}
const text = editor.getText();
if (!text.endsWith(char)) {
if (text.length > 0 && !text.endsWith(" ")) {
@ -921,7 +944,7 @@ function TipTapEditor(props: TipTapEditorProps) {
onKeyUp={handleKeyUp}
className="cursor-text"
onClick={() => {
editor && editor.commands.focus();
editor?.commands.focus();
}}
onDragOver={(event) => {
event.preventDefault();
@ -941,6 +964,7 @@ function TipTapEditor(props: TipTapEditorProps) {
}}
onDrop={(event) => {
if (
!defaultModel ||
!modelSupportsImages(
defaultModel.provider,
defaultModel.model,
@ -952,11 +976,17 @@ function TipTapEditor(props: TipTapEditorProps) {
}
setShowDragOverMsg(false);
let file = event.dataTransfer.files[0];
handleImageFile(file).then(([img, dataUrl]) => {
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
const tr = editor.state.tr.insert(0, node);
editor.view.dispatch(tr);
handleImageFile(file).then((result) => {
if (!editor) {
return;
}
if (result) {
const [_, dataUrl] = result;
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
const tr = editor.state.tr.insert(0, node);
editor.view.dispatch(tr);
}
});
event.preventDefault();
}}
@ -977,13 +1007,19 @@ function TipTapEditor(props: TipTapEditorProps) {
onAddSlashCommand={() => insertCharacterWithWhitespace("/")}
onEnter={onEnterRef.current}
onImageFileSelected={(file) => {
handleImageFile(file).then(([img, dataUrl]) => {
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
editor.commands.command(({ tr }) => {
tr.insert(0, node);
return true;
});
handleImageFile(file).then((result) => {
if (!editor) {
return;
}
if (result) {
const [_, dataUrl] = result;
const { schema } = editor.state;
const node = schema.nodes.image.create({ src: dataUrl });
editor.commands.command(({ tr }) => {
tr.insert(0, node);
return true;
});
}
});
}}
disabled={isStreaming}

View file

@ -17,8 +17,18 @@ export const handleJetBrainsOSRMetaKeyIssues = (
const handlers: Record<string, () => void> = {
Backspace: () => handleJetBrainsMetaBackspace(editor),
ArrowLeft: () => selection?.modify(alter, "backward", "lineboundary"),
ArrowRight: () => selection?.modify(alter, "forward", "lineboundary"),
ArrowLeft: () =>
selection?.modify(
alter,
"backward",
platform === "mac" ? "lineboundary" : "word",
),
ArrowRight: () =>
selection?.modify(
alter,
"forward",
platform === "mac" ? "lineboundary" : "word",
),
ArrowDown: () => selection?.modify(alter, "forward", "documentboundary"),
ArrowUp: () => {
selection?.modify(alter, "backward", "documentboundary");

View file

@ -122,8 +122,8 @@ async function resolveEditorContent({
let contextItems: ContextItemWithId[] = [];
for (const item of contextItemAttrs) {
const result = await ideMessenger.request("context/getContextItems", {
name: item.itemType === "contextProvider" ? item.id : item.itemType,
query: item.query,
name: item.itemType === "contextProvider" ? item.id : item.itemType!,
query: item.query ?? "",
fullInput: stripImages(parts),
selectedCode,
selectedModelTitle,
@ -211,22 +211,22 @@ function resolveParagraph(
p: JSONContent,
): [string, MentionAttrs[], string | undefined] {
let text = "";
const contextItems = [];
const contextItems: MentionAttrs[] = [];
let slashCommand: string | undefined = undefined;
for (const child of p.content || []) {
if (child.type === "text") {
text += text === "" ? child.text.trimStart() : child.text;
text += text === "" ? child.text?.trimStart() : child.text;
} else if (child.type === "mention") {
text +=
typeof child.attrs.renderInlineAs === "string"
typeof child.attrs?.renderInlineAs === "string"
? child.attrs.renderInlineAs
: child.attrs.label;
contextItems.push(child.attrs);
: child.attrs?.label;
contextItems.push(child.attrs as MentionAttrs);
} else if (child.type === "slashcommand") {
if (typeof slashCommand === "undefined") {
slashCommand = child.attrs.id;
slashCommand = child.attrs?.id;
} else {
text += child.attrs.label;
text += child.attrs?.label;
}
} else {
console.warn("Unexpected child type", child.type);

View file

@ -50,7 +50,7 @@ const InnerHoverDiv = styled.div<{ isBottomToolbarPosition: boolean }>`
`;
interface StepContainerPreActionButtonsProps {
language: string;
language: string | null;
codeBlockContent: string;
codeBlockIndex: number;
children: any;

View file

@ -44,7 +44,7 @@ const ToolbarDiv = styled.div<{ isExpanded: boolean }>`
export interface StepContainerPreToolbarProps {
codeBlockContent: string;
language: string;
language: string | null;
relativeFilepath: string;
isGeneratingCodeBlock: boolean;
codeBlockIndex: number; // To track which codeblock we are applying
@ -98,7 +98,6 @@ export default function StepContainerPreToolbar(
props.relativeFilepath,
ideMessenger.ide,
);
console.log("HERE", props.relativeFilepath, fileUri);
ideMessenger.post("applyToFile", {
streamId: streamIdRef.current,

View file

@ -1,4 +1,4 @@
import { useMemo } from "react";
import { ReactNode, useMemo } from "react";
import { Tooltip } from "react-tooltip";
import { lightGray, vscForeground } from "../..";
import styled from "styled-components";
@ -19,11 +19,18 @@ export const ToolbarButton = styled.button`
filter: brightness(1.25);
}
`;
interface ToolbarButtonWithTooltipProps {
onClick: () => void;
children: ReactNode;
tooltipContent: string;
}
export function ToolbarButtonWithTooltip({
onClick,
children,
tooltipContent,
}) {
}: ToolbarButtonWithTooltipProps) {
const tooltipId = useMemo(
() => `tooltip-${Math.random().toString(36).slice(2, 11)}`,
[],

View file

@ -28,6 +28,8 @@ import { fixDoubleDollarNewLineLatex } from "./utils/fixDoubleDollarLatex";
import { selectUIConfig } from "../../redux/slices/configSlice";
import { ToolTip } from "../gui/Tooltip";
import { v4 as uuidv4 } from "uuid";
import { ContextItemWithId, RangeInFileWithContents } from "core";
import { getContextItemsFromHistory } from "../../redux/thunks/updateFileSymbols";
const StyledMarkdown = styled.div<{
fontSize?: number;
@ -139,34 +141,34 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
// So they won't use the most up-to-date state values
// So in this case we just put them in refs
// Grab context items that are this one or further back
// The logic here is to get file names from
// 1. Context items found in past messages
// 2. Toolbar Codeblocks found in past messages
const history = useAppSelector((state) => state.session.history);
const previousFileContextItems = useMemo(() => {
const allSymbols = useAppSelector((state) => state.session.symbols);
const pastFileInfo = useMemo(() => {
const index = props.itemIndex;
if (index === undefined) {
return [];
return {
symbols: [],
rifs: [],
};
}
const previousItems = history.flatMap((item, i) =>
i <= index ? item.contextItems : [],
const pastContextItems = getContextItemsFromHistory(history, index);
const rifs = pastContextItems.map((item) =>
ctxItemToRifWithContents(item, true),
);
return previousItems.filter(
(item) => item.uri?.type === "file" && item?.uri?.value,
);
}, [props.itemIndex, history]);
const previousFileContextItemsRef = useUpdatingRef(previousFileContextItems);
// Extract global symbols for files matching previous context items
const allSymbols = useAppSelector((state) => state.session.symbols);
const previousFileContextItemSymbols = useMemo(() => {
const uniqueUris = new Set(
previousFileContextItems.map((item) => item.uri!.value!),
);
return Object.entries(allSymbols)
.filter((e) => uniqueUris.has(e[0]))
const symbols = Object.entries(allSymbols)
.filter((e) => pastContextItems.find((item) => item.uri!.value === e[0]))
.map((f) => f[1])
.flat();
}, [allSymbols, previousFileContextItems]);
const symbolsRef = useUpdatingRef(previousFileContextItemSymbols);
return {
symbols,
rifs,
};
}, [props.itemIndex, history, allSymbols]);
const pastFileInfoRef = useUpdatingRef(pastFileInfo);
const [reactContent, setMarkdownSource] = useRemark({
remarkPlugins: [
@ -228,7 +230,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
],
rehypeReactOptions: {
components: {
a: ({ node, ...aProps }) => {
a: ({ ...aProps }) => {
const tooltipId = uuidv4();
return (
@ -247,7 +249,7 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
</>
);
},
pre: ({ node, ...preProps }) => {
pre: ({ ...preProps }) => {
const codeBlockIndex = preProps["data-codeblockindex"];
const preChildProps = preProps?.children?.[0]?.props ?? {};
@ -293,29 +295,32 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview(
</StepContainerPreToolbar>
);
},
code: ({ node, ...codeProps }) => {
code: ({ ...codeProps }) => {
const content = getCodeChildrenContent(codeProps.children);
if (content && previousFileContextItemsRef.current) {
if (content) {
const { symbols, rifs } = pastFileInfoRef.current;
// Insert file links for matching previous context items
const ctxItem = previousFileContextItemsRef.current.find((item) =>
item.uri!.value!.includes(content),
);
if (ctxItem) {
const rif = ctxItemToRifWithContents(ctxItem);
return <FilenameLink rif={rif} />;
// With some reasonable limitations on what might be a filename
if (rifs.length && content.includes(".") && content.length > 2) {
const match = rifs.find(
(rif) => rif.filepath.split("/").pop() === content, // Exact match for last segment of URI
);
if (match) {
return <FilenameLink rif={match} />;
}
}
// Insert symbols for exact matches
const exactSymbol = symbolsRef.current.find(
(s) => s.name === content,
);
const exactSymbol = symbols.find((s) => s.name === content);
if (exactSymbol) {
return <SymbolLink content={content} symbol={exactSymbol} />;
}
// Partial matches - this is the case where the llm returns e.g. `subtract(number)` instead of `subtract`
const partialSymbol = symbolsRef.current.find((s) =>
const partialSymbol = symbols.find((s) =>
content.startsWith(s.name),
);
if (partialSymbol) {

View file

@ -26,18 +26,18 @@ export function getTerminalCommand(text: string): string {
}
export function isTerminalCodeBlock(
language: string | undefined,
language: string | undefined | null,
text: string,
) {
return (
terminalLanguages.includes(language) ||
(language && terminalLanguages.includes(language)) ||
((!language || language?.length === 0) &&
(text.trim().split("\n").length === 1 ||
commonTerminalCommands.some((c) => text.trim().startsWith(c))))
);
}
function childToText(child: any) {
function childToText(child: any): string {
if (typeof child === "string") {
return child;
} else if (child?.props) {

View file

@ -6,7 +6,7 @@ import {
PlusIcon,
TrashIcon,
} from "@heroicons/react/24/outline";
import { useContext, useEffect, useRef, useState } from "react";
import { MouseEvent, useContext, useEffect, useRef, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import styled from "styled-components";
import {
@ -144,7 +144,7 @@ function ModelOption({
const dispatch = useDispatch();
const [hovered, setHovered] = useState(false);
function onClickDelete(e) {
function onClickDelete(e: MouseEvent) {
e.stopPropagation();
e.preventDefault();
@ -164,7 +164,7 @@ function ModelOption({
);
}
function onClickGear(e) {
function onClickGear(e: MouseEvent) {
e.stopPropagation();
e.preventDefault();
@ -173,7 +173,7 @@ function ModelOption({
});
}
function handleOptionClick(e) {
function handleOptionClick(e: MouseEvent) {
if (showMissingApiKeyMsg) {
e.preventDefault();
e.stopPropagation();
@ -287,7 +287,7 @@ function ModelSelect() {
setShowAbove(spaceBelow < dropdownHeight && spaceAbove > spaceBelow);
}
function onClickAddModel(e) {
function onClickAddModel(e: MouseEvent) {
e.stopPropagation();
e.preventDefault();

View file

@ -17,7 +17,11 @@ import {
vscListActiveBackground,
vscListActiveForeground,
} from "..";
import { providers } from "../../pages/AddNewModel/configs/providers";
import {
DisplayInfo,
ModelPackage,
} from "../../pages/AddNewModel/configs/models";
import { ProviderInfo } from "../../pages/AddNewModel/configs/providers";
export const StyledListbox = styled(Listbox)`
background-color: ${vscBackground};
@ -98,14 +102,9 @@ export const StyledListboxOption = styled(Listbox.Option)<{
}
`;
interface DisplayInfo {
title: string;
icon?: string;
}
interface ModelSelectionListboxProps {
selectedProvider: DisplayInfo;
setSelectedProvider: Dispatch<SetStateAction<DisplayInfo>>;
setSelectedProvider: (val: DisplayInfo) => void;
topOptions?: DisplayInfo[];
otherOptions?: DisplayInfo[];
}

View file

@ -7,6 +7,10 @@ import { createContext } from "react";
import { v4 as uuidv4 } from "uuid";
import "vscode-webview";
import { isJetBrains } from "../util";
import {
AsyncGeneratorYieldType,
ProtocolGeneratorYield,
} from "core/protocol/core";
interface vscode {
postMessage(message: any): vscode;
@ -164,24 +168,28 @@ export class IdeMessenger implements IIdeMessenger {
messageType: T,
data: FromWebviewProtocol[T][0],
cancelToken?: AbortSignal,
): AsyncGenerator<unknown[]> {
// ): FromWebviewProtocol[T][1] {
): AsyncGenerator<AsyncGeneratorYieldType<FromWebviewProtocol[T][1]>[], any> {
type GenYield = AsyncGeneratorYieldType<FromWebviewProtocol[T][1]>;
// type GenReturn = AsyncGeneratorReturnType<FromWebviewProtocol[T][1]>;
const messageId = uuidv4();
this.post(messageType, data, messageId);
const buffer: any[] = [];
const buffer: GenYield[] = [];
let index = 0;
let done = false;
let returnVal = undefined;
const handler = (event: { data: Message }) => {
const handler = (event: {
data: Message<ProtocolGeneratorYield<GenYield>>;
}) => {
if (event.data.messageId === messageId) {
const responseData = event.data.data;
if (responseData.done) {
window.removeEventListener("message", handler);
done = true;
returnVal = responseData;
returnVal = responseData.content;
} else {
buffer.push(responseData.content);
}
@ -239,8 +247,8 @@ export class IdeMessenger implements IIdeMessenger {
next = await gen.next();
}
if (next.value.error) {
throw new Error(next.value.error);
if (!next.done) {
throw new Error();
}
return {

View file

@ -82,8 +82,6 @@ export const SubmenuContextProvidersProvider = ({
const [isLoading, setIsLoading] = useState(false);
const [autoLoadTriggered, setAutoLoadTriggered] = useState(false);
const config = useAppSelector((store) => store.config.config);
const ideMessenger = useContext(IdeMessengerContext);
const getOpenFilesItems = useCallback(async () => {
@ -102,7 +100,7 @@ export const SubmenuContextProvidersProvider = ({
}));
}, [ideMessenger]);
useWebviewListener("refreshSubmenuItems", async (data) => {
useWebviewListener("refreshSubmenuItems", async () => {
if (!isLoading) {
setInitialLoadComplete(false);
setAutoLoadTriggered((prev) => !prev); // Toggle to trigger effect
@ -146,7 +144,9 @@ export const SubmenuContextProvidersProvider = ({
[minisearches],
);
const lastOpenFilesRef = useRef([]);
const lastOpenFilesRef = useRef<
Awaited<ReturnType<typeof getOpenFilesItems>>
>([]);
useEffect(() => {
let isMounted = true;
const refreshOpenFiles = async () => {
@ -216,12 +216,14 @@ export const SubmenuContextProvidersProvider = ({
try {
const results = getSubmenuSearchResults(providerTitle, query);
if (results.length === 0) {
const fallbackItems = (fallbackResults[providerTitle] ?? [])
const fallbackItems = (
providerTitle ? (fallbackResults[providerTitle] ?? []) : []
)
.slice(0, limit)
.map((result) => {
return {
...result,
providerTitle,
providerTitle: providerTitle || "unknown",
};
});

View file

@ -58,7 +58,7 @@ function constructTheme(
): Record<string, string> {
const rules = tmTheme?.["rules"] || [];
const tokenToForeground = {};
const tokenToForeground: Record<string, string> = {};
rules.forEach(({ token, foreground }) => {
if (!foreground || !token) {
return;
@ -66,7 +66,7 @@ function constructTheme(
tokenToForeground[token] = foreground;
});
const theme = {};
const theme: Record<string, string> = {};
Object.keys(hljsToTextMate).forEach((className) => {
const tokens = hljsToTextMate[className];
for (const scope of tokens) {

View file

@ -14,6 +14,7 @@ import {
import { FREE_TRIAL_LIMIT_REQUESTS, hasPassedFTL } from "../util/freeTrial";
import { completionParamsInputs } from "../pages/AddNewModel/configs/completionParamsInputs";
import { setDefaultModel } from "../redux/slices/configSlice";
import { DisplayInfo } from "../pages/AddNewModel/configs/models";
interface QuickModelSetupProps {
onDone: () => void;
@ -52,7 +53,9 @@ function AddModelForm({
const allProviders = Object.entries(providers)
.filter(([key]) => !["freetrial", "openai-aiohttp"].includes(key))
.map(([, provider]) => provider);
.map(([, provider]) => provider)
.filter((provider) => !!provider)
.map((provider) => provider!); // for type checking
const popularProviders = allProviders
.filter((provider) => popularProviderTitles.includes(provider.title))
@ -77,13 +80,13 @@ function AddModelForm({
}
const required = selectedProvider.collectInputFor
.filter((input) => input.required)
?.filter((input) => input.required)
.map((input) => {
const value = formMethods.watch(input.key);
return value;
});
return !required.every((value) => value !== undefined && value.length > 0);
return !required?.every((value) => value !== undefined && value.length > 0);
}
useEffect(() => {
@ -93,8 +96,8 @@ function AddModelForm({
function onSubmit() {
const apiKey = formMethods.watch("apiKey");
const hasValidApiKey = apiKey !== undefined && apiKey !== "";
const reqInputFields = {};
for (let input of selectedProvider.collectInputFor) {
const reqInputFields: Record<string, any> = {};
for (let input of selectedProvider.collectInputFor ?? []) {
reqInputFields[input.key] = formMethods.watch(input.key);
}
@ -147,7 +150,14 @@ function AddModelForm({
<label className="block text-sm font-medium">Provider</label>
<ModelSelectionListbox
selectedProvider={selectedProvider}
setSelectedProvider={setSelectedProvider}
setSelectedProvider={(val: DisplayInfo) => {
const match = [...popularProviders, ...otherProviders].find(
(provider) => provider.title === val.title,
);
if (match) {
setSelectedProvider(match);
}
}}
topOptions={popularProviders}
otherOptions={otherProviders}
/>
@ -184,11 +194,24 @@ function AddModelForm({
<label className="block text-sm font-medium">Model</label>
<ModelSelectionListbox
selectedProvider={selectedModel}
setSelectedProvider={setSelectedModel}
setSelectedProvider={(val: DisplayInfo) => {
const options =
Object.entries(providers).find(
([, provider]) =>
provider?.title === selectedProvider.title,
)?.[1]?.packages ?? [];
const match = options.find(
(option) => option.title === val.title,
);
if (match) {
setSelectedModel(match);
}
}}
otherOptions={
Object.entries(providers).find(
([, provider]) => provider.title === selectedProvider.title,
)?.[1].packages
([, provider]) =>
provider?.title === selectedProvider.title,
)?.[1]?.packages
}
/>
</div>
@ -220,9 +243,14 @@ function AddModelForm({
<InputSubtext className="mb-0">
<a
className="cursor-pointer text-inherit underline hover:text-inherit"
onClick={() =>
ideMessenger.post("openUrl", selectedProviderApiKeyUrl)
}
onClick={() => {
if (selectedProviderApiKeyUrl) {
ideMessenger.post(
"openUrl",
selectedProviderApiKeyUrl,
);
}
}}
>
Click here
</a>{" "}

View file

@ -119,10 +119,12 @@ function useSetup() {
if (isJetBrains()) {
// Save theme colors to local storage for immediate loading in JetBrains
ideMessenger.request("jetbrains/getColors", undefined).then((result) => {
Object.keys(result).forEach((key) => {
document.body.style.setProperty(key, result[key]);
document.documentElement.style.setProperty(key, result[key]);
});
if (result.status === "success") {
Object.entries(result.content).forEach(([key, value]) => {
document.body.style.setProperty(key, value);
document.documentElement.style.setProperty(key, value);
});
}
});
// Tell JetBrains the webview is ready

View file

@ -13,10 +13,10 @@ export function useWebviewListener<T extends keyof ToWebviewProtocol>(
useEffect(
() => {
let listener;
let listener: (event: { data: Message<ToWebviewProtocol[T][0]>}) => Promise<void>;
if (!skip) {
listener = async (event: { data: Message }) => {
listener = async (event) => {
if (event.data.messageType === messageType) {
const result = await handler(event.data.data);
ideMessenger.respond(messageType, result, event.data.messageId);

View file

@ -122,22 +122,24 @@ function AddNewModel() {
</div>
<GridDiv>
{Object.entries(providers).map(([providerName, modelInfo], i) => (
<ModelCard
key={`${providerName}-${i}`}
title={modelInfo.title}
description={modelInfo.description}
tags={modelInfo.tags}
icon={modelInfo.icon}
refUrl={`https://docs.continue.dev/reference/Model%20Providers/${
modelInfo.refPage || modelInfo.provider.toLowerCase()
}`}
onClick={(e) => {
console.log(`/addModel/provider/${providerName}`);
navigate(`/addModel/provider/${providerName}`);
}}
/>
))}
{Object.entries(providers).map(([providerName, modelInfo], i) =>
modelInfo ? (
<ModelCard
key={`${providerName}-${i}`}
title={modelInfo.title}
description={modelInfo.description}
tags={modelInfo.tags}
icon={modelInfo.icon}
refUrl={`https://docs.continue.dev/reference/Model%20Providers/${
modelInfo.refPage || modelInfo.provider.toLowerCase()
}`}
onClick={(e) => {
console.log(`/addModel/provider/${providerName}`);
navigate(`/addModel/provider/${providerName}`);
}}
/>
) : null,
)}
</GridDiv>
</>
) : (
@ -176,6 +178,9 @@ function AddNewModel() {
dimensions={config.dimensions}
providerOptions={config.providerOptions}
onClick={(e, dimensionChoices, selectedProvider) => {
if (!selectedProvider) {
return;
}
const model = {
...config.params,
..._.merge(
@ -187,7 +192,7 @@ function AddNewModel() {
};
}) || []),
),
provider: providers[selectedProvider].provider,
provider: providers[selectedProvider]?.provider,
};
ideMessenger.post("config/addModel", { model });
dispatch(

View file

@ -9,6 +9,12 @@ export interface PackageDimension {
description: string;
options: { [key: string]: { [key: string]: any } };
}
export interface DisplayInfo {
title: string;
icon?: string;
}
export interface ModelPackage {
title: string;
icon?: string;
@ -31,6 +37,60 @@ export interface ModelPackage {
}
export const models: { [key: string]: ModelPackage } = {
llama318BChat: {
title: "Llama 3.1 8B",
description: "A model from Meta, fine-tuned for chat",
refUrl: "",
params: {
title: "Llama3.1-8b",
model: "meta-llama/llama-3.1-8b-instruct",
contextLength: 8192,
},
icon: "meta.png",
dimensions: [
{
name: "Parameter Count",
description: "The number of parameters in the model",
options: {
"8b": {
model: "meta-llama/llama-3.1-8b-instruct",
title: "Llama3.1-8b",
}
},
},
],
providerOptions: [
"novita"
],
isOpenSource: true,
},
mistralChat: {
title: "Mistral Chat",
description:
"A series of open-weight models created by Mistral AI, highly competent for code generation and other tasks",
params: {
title: "Mistral",
model: "mistralai/mistral-7b-instruct",
contextLength: 4096,
},
dimensions: [
{
name: "Parameter Count",
description: "The number of parameters in the model",
options: {
"7b": {
model: "mistralai/mistral-7b-instruct",
title: "Mistral-7b",
},
},
},
],
icon: "mistral.png",
providerOptions: [
"novita",
],
isOpenSource: true,
},
llama31Chat: {
title: "Llama3.1 Chat",
description: "A model from Meta, fine-tuned for chat",
@ -70,7 +130,7 @@ export const models: { [key: string]: ModelPackage } = {
"sambanova",
"cerebras",
"nebius",
"scaleway"
"scaleway",
],
isOpenSource: true,
},
@ -1085,8 +1145,7 @@ export const models: { [key: string]: ModelPackage } = {
},
asksagegpt35gov: {
title: "GPT-3.5-Turbo gov",
description:
"U.S. Government. Inexpensive and good ROI.",
description: "U.S. Government. Inexpensive and good ROI.",
params: {
model: "gpt-gov",
contextLength: 8096,
@ -1122,7 +1181,7 @@ export const models: { [key: string]: ModelPackage } = {
contextLength: 8_192,
title: "GPT-4",
},
providerOptions: ["openai",],
providerOptions: ["openai"],
icon: "openai.png",
isOpenSource: false,
},
@ -1135,7 +1194,7 @@ export const models: { [key: string]: ModelPackage } = {
contextLength: 32_768,
title: "GPT-4-32k",
},
providerOptions: ["openai",],
providerOptions: ["openai"],
icon: "openai.png",
isOpenSource: false,
},
@ -1148,7 +1207,7 @@ export const models: { [key: string]: ModelPackage } = {
contextLength: 128_000,
title: "GPT-o1",
systemMessage:
"You are an expert software developer. You give helpful and concise responses.",
"You are an expert software developer. You give helpful and concise responses.",
},
providerOptions: ["askSage"],
icon: "openai.png",
@ -1163,7 +1222,7 @@ export const models: { [key: string]: ModelPackage } = {
contextLength: 128_000,
title: "GPT-o1-mini",
systemMessage:
"You are an expert software developer. You give helpful and concise responses.",
"You are an expert software developer. You give helpful and concise responses.",
},
providerOptions: ["askSage"],
icon: "openai.png",
@ -1178,7 +1237,7 @@ export const models: { [key: string]: ModelPackage } = {
contextLength: 200_000,
title: "Claude 3.5 Sonnet gov",
systemMessage:
"You are an expert software developer. You give helpful and concise responses.",
"You are an expert software developer. You give helpful and concise responses.",
},
providerOptions: ["askSage"],
icon: "anthropic.png",
@ -1186,8 +1245,7 @@ export const models: { [key: string]: ModelPackage } = {
},
asksagegroqllama33: {
title: "Llama 3.3",
description:
"Llama-3.3 is a large language model customized by Groq.",
description: "Llama-3.3 is a large language model customized by Groq.",
params: {
title: "Llama 3.3",
model: "groq-llama33",
@ -1198,8 +1256,7 @@ export const models: { [key: string]: ModelPackage } = {
},
asksagegroq70b: {
title: "Groq-70B",
description:
"A large language model customized by Groq.",
description: "A large language model customized by Groq.",
params: {
title: "Groq-70B",
model: "groq-70b",
@ -1244,7 +1301,7 @@ export const models: { [key: string]: ModelPackage } = {
},
icon: "qwen.png",
providerOptions: ["scaleway"],
isOpenSource: true,
isOpenSource: true,
},
grokBeta: {
title: "Grok Beta",

View file

@ -165,7 +165,8 @@ export const providers: Partial<Record<string, ProviderInfo>> = {
title: "Scaleway",
provider: "scaleway",
refPage: "scaleway",
description: "Use the Scaleway Generative APIs to instantly access leading open models",
description:
"Use the Scaleway Generative APIs to instantly access leading open models",
longDescription: `Hosted in European data centers, ideal for developers requiring low latency, full data privacy, and compliance with EU AI Act. You can generate your API key in [Scaleway's console](https://console.scaleway.com/generative-api/models). Get started:\n1. Create an API key [here](https://console.scaleway.com/iam/api-keys/)\n2. Paste below\n3. Select a model preset`,
params: {
apiKey: "",
@ -404,6 +405,36 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
}),
apiKeyUrl: "https://api.together.xyz/settings/api-keys",
},
novita: {
title: "NovitaAI",
provider: "novita",
refPage: "novita",
description:
"Use Novita AI API for extremely fast streaming of open-source models",
icon: "novita.png",
longDescription: `[Novita AI](https://novita.ai?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link) offers an affordable, reliable, and simple inference platform with scalable [LLM APIs](https://novita.ai/docs/model-api/reference/introduction.html), empowering developers to build AI applications. To get started with Novita AI:\n1. Obtain an API key from [here](https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link)\n2. Paste below\n3. Select a model preset`,
tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource],
params: {
apiKey: "",
},
collectInputFor: [
{
inputType: "text",
key: "apiKey",
label: "API Key",
placeholder: "Enter your Novita AI API key",
required: true,
},
...completionParamsInputsConfigs,
],
packages: [
models.llama318BChat, models.mistralChat
].map((p) => {
p.params.contextLength = 4096;
return p;
}),
apiKeyUrl: "https://novita.ai/settings/key-management?utm_source=github_continuedev&utm_medium=github_readme&utm_campaign=github_link",
},
gemini: {
title: "Google Gemini API",
provider: "gemini",
@ -640,8 +671,8 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
provider: "free-trial",
refPage: "freetrial",
description:
"New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key",
longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, or Together using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`,
"New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together, or Novita AI using our API key",
longDescription: `New users can try out Continue for free using a proxy server that securely makes calls to OpenAI, Anthropic, Together or Novita AI using our API key. If you are ready to set up a model for long-term use or have used all ${FREE_TRIAL_LIMIT_REQUESTS} free uses, you can enter your API key or use a local model.`,
icon: "openai.png",
tags: [ModelProviderTags.Free],
packages: [

View file

@ -407,9 +407,8 @@ export function Chat() {
return (
<div key={i}>
<ToolCallDiv
reactKey={toolCall.id}
toolCallState={item.toolCallState}
toolCall={toolCall as any}
toolCallState={item.toolCallState!}
toolCall={toolCall}
/>
</div>
);

View file

@ -44,15 +44,18 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
let statusCode: undefined | number = undefined;
// Attempt to get error message and status code from error
if (error && (error instanceof Error || typeof error === "object")) {
if (error["message"]) {
message = error["message"];
const status = message?.split(" ")[0];
if (status) {
const code = Number(status);
if (!Number.isNaN(statusCode)) {
statusCode = code;
}
if (
error &&
(error instanceof Error || typeof error === "object") &&
"message" in error &&
typeof error["message"] === "string"
) {
message = error["message"];
const status = message?.split(" ")[0];
if (status) {
const code = Number(status);
if (!Number.isNaN(statusCode)) {
statusCode = code;
}
}
}

View file

@ -1,4 +1,4 @@
import { ToolCall, ToolCallState } from "core";
import { ToolCall, ToolCallDelta, ToolCallState } from "core";
import { CreateFile } from "./CreateFile";
import { RunTerminalCommand } from "./RunTerminalCommand";
@ -6,12 +6,12 @@ function FunctionSpecificToolCallDiv({
toolCall,
toolCallState,
}: {
toolCall: ToolCall;
toolCall: ToolCallDelta;
toolCallState: ToolCallState;
}) {
const args = toolCallState.parsedArgs;
switch (toolCall.function.name) {
switch (toolCall.function?.name) {
case "builtin_create_new_file":
return (
<CreateFile

View file

@ -1,4 +1,4 @@
import { Tool, ToolCall, ToolCallState } from "core";
import { Tool, ToolCallDelta, ToolCallState } from "core";
import Mustache from "mustache";
import styled from "styled-components";
import { useAppSelector } from "../../../redux/hooks";
@ -6,9 +6,8 @@ import { useAppSelector } from "../../../redux/hooks";
interface ThreadDivProps {
children: React.ReactNode;
icon: React.ReactNode;
toolCall: ToolCall;
toolCall: ToolCallDelta;
toolCallState: ToolCallState;
reactKey: string;
}
const Container = styled.div`
@ -48,7 +47,7 @@ export function ThreadDiv(props: ThreadDivProps) {
}
return (
<Container key={props.reactKey}>
<Container>
<HeaderDiv>
<div
style={{
@ -64,7 +63,7 @@ export function ThreadDiv(props: ThreadDivProps) {
Continue wants to{" "}
{renderWouldLikeToMessage(
availableTools.find(
(tool) => props.toolCall.function.name === tool.function.name,
(tool) => props.toolCall.function?.name === tool.function.name,
),
props.toolCallState,
)}

View file

@ -3,16 +3,15 @@ import {
CheckIcon,
XMarkIcon,
} from "@heroicons/react/24/outline";
import { ToolCall, ToolCallState, ToolStatus } from "core";
import { ToolCall, ToolCallDelta, ToolCallState, ToolStatus } from "core";
import { vscButtonBackground } from "../../../components";
import Spinner from "../../../components/gui/Spinner";
import FunctionSpecificToolCallDiv from "./FunctionSpecificToolCallDiv";
import { ThreadDiv } from "./ThreadDiv";
interface ToolCallDivProps {
toolCall: ToolCall;
toolCall: ToolCallDelta;
toolCallState: ToolCallState;
reactKey: string;
}
export function ToolCallDiv(props: ToolCallDivProps) {
@ -32,7 +31,6 @@ export function ToolCallDiv(props: ToolCallDivProps) {
return (
<ThreadDiv
reactKey={props.reactKey}
icon={getIcon(props.toolCallState.status)}
toolCall={props.toolCall}
toolCallState={props.toolCallState}

View file

@ -13,7 +13,6 @@ export const selectLastToolCall = createSelector(
break;
}
}
if (!lastToolCallHistoryItem) return null;
return lastToolCallHistoryItem.toolCallState;
return lastToolCallHistoryItem?.toolCallState ?? null;
},
);

View file

@ -116,7 +116,10 @@ export const sessionSlice = createSlice({
state.isStreaming = true;
},
setIsGatheringContext: (state, { payload }: PayloadAction<boolean>) => {
state.history.at(-1).isGatheringContext = payload;
const curMessage = state.history.at(-1);
if (curMessage) {
curMessage.isGatheringContext = payload;
}
},
clearLastEmptyResponse: (state) => {
if (state.history.length < 2) {
@ -278,14 +281,14 @@ export const sessionSlice = createSlice({
},
streamUpdate: (state, action: PayloadAction<ChatMessage[]>) => {
if (state.history.length) {
const lastItem = state.history[state.history.length - 1];
const lastMessage = lastItem.message;
for (const message of action.payload) {
const lastMessage = state.history[state.history.length - 1];
if (
message.role &&
(lastMessage.message.role !== message.role ||
(lastMessage.role !== message.role ||
// This is when a tool call comes after assistant text
(lastMessage.message.content !== "" &&
(lastMessage.content !== "" &&
message.role === "assistant" &&
message.toolCalls?.length))
) {
@ -297,51 +300,60 @@ export const sessionSlice = createSlice({
},
contextItems: [],
};
if (message.role === "assistant" && message.toolCalls) {
const [_, parsedArgs] = incrementalParseJson(
message.toolCalls[0].function.arguments,
);
historyItem.toolCallState = {
status: "generating",
toolCall: message.toolCalls[0] as ToolCall,
toolCallId: message.toolCalls[0].id,
parsedArgs,
};
if (message.role === "assistant" && message.toolCalls?.[0]) {
const toolCalls = message.toolCalls?.[0];
if (toolCalls) {
const [_, parsedArgs] = incrementalParseJson(
message.toolCalls[0].function?.arguments ?? "{}",
);
historyItem.toolCallState = {
status: "generating",
toolCall: message.toolCalls[0] as ToolCall,
toolCallId: message.toolCalls[0].id as ToolCall["id"],
parsedArgs,
};
}
}
state.history.push(historyItem);
} else {
// Add to the existing message
const msg = state.history[state.history.length - 1].message;
if (message.content) {
msg.content += renderChatMessage(message);
lastMessage.content += renderChatMessage(message);
} else if (
message.role === "assistant" &&
message.toolCalls &&
msg.role === "assistant"
lastMessage.role === "assistant"
) {
if (!msg.toolCalls) {
msg.toolCalls = [];
if (!lastMessage.toolCalls) {
lastMessage.toolCalls = [];
}
message.toolCalls.forEach((toolCall, i) => {
if (msg.toolCalls.length <= i) {
msg.toolCalls.push(toolCall);
if (lastMessage.toolCalls!.length <= i) {
lastMessage.toolCalls!.push(toolCall);
} else {
msg.toolCalls[i].function.arguments +=
toolCall.function.arguments;
if (
toolCall?.function?.arguments &&
lastMessage?.toolCalls?.[i]?.function?.arguments &&
lastItem.toolCallState
) {
lastMessage.toolCalls[i].function!.arguments +=
toolCall.function.arguments;
const [_, parsedArgs] = incrementalParseJson(
msg.toolCalls[i].function.arguments,
);
const [_, parsedArgs] = incrementalParseJson(
lastMessage.toolCalls[i].function!.arguments!,
);
state.history[
state.history.length - 1
].toolCallState.parsedArgs = parsedArgs;
state.history[
state.history.length - 1
].toolCallState.toolCall.function.arguments +=
toolCall.function.arguments;
lastItem.toolCallState.parsedArgs = parsedArgs;
lastItem.toolCallState.toolCall.function.arguments +=
toolCall.function.arguments;
} else {
console.error(
"Unexpected tool call format received - this message added during gui strict null checks",
message,
lastMessage,
);
}
}
});
}
@ -472,8 +484,10 @@ export const sessionSlice = createSlice({
state,
{ payload }: PayloadAction<{ filepath: string; content: string }>,
) => {
state.history[state.curCheckpointIndex].checkpoint[payload.filepath] =
payload.content;
const checkpoint = state.history[state.curCheckpointIndex].checkpoint;
if (checkpoint) {
checkpoint[payload.filepath] = payload.content;
}
},
updateApplyState: (state, { payload }: PayloadAction<ApplyState>) => {
const applyState = state.codeBlockApplyStates.states.find(

View file

@ -63,7 +63,10 @@ const persistConfig = {
migrate: createMigrate(migrations, { debug: false }),
};
const persistedReducer = persistReducer(persistConfig, rootReducer);
const persistedReducer = persistReducer<ReturnType<typeof rootReducer>>(
persistConfig,
rootReducer,
);
export function setupStore() {
return configureStore({

View file

@ -14,10 +14,10 @@ export const callTool = createAsyncThunk<void, undefined, ThunkApiType>(
const state = getState();
const toolCallState = selectCurrentToolCall(state);
console.log("calling tool", toolCallState.toolCall);
if (!toolCallState) {
return;
}
console.log("calling tool", toolCallState.toolCall);
if (toolCallState.status !== "generated") {
return;

View file

@ -6,14 +6,10 @@ import {
MessageContent,
RangeInFile,
} from "core";
import resolveEditorContent, {
hasSlashCommandOrContextProvider,
} from "../../components/mainInput/resolveInput";
import resolveEditorContent from "../../components/mainInput/resolveInput";
import { ThunkApiType } from "../store";
import { selectDefaultModel } from "../slices/configSlice";
import { setIsGatheringContext } from "../slices/sessionSlice";
import { findUriInDirs, getUriPathBasename } from "core/util/uri";
import { updateFileSymbolsFromNewContextItems } from "./updateFileSymbols";
export const gatherContext = createAsyncThunk<
{
@ -39,8 +35,10 @@ export const gatherContext = createAsyncThunk<
state.config.config.experimental?.defaultContext ?? [];
if (!state.config.defaultModelTitle) {
console.error("Failed to gather context, no model selected");
return;
console.error(
"gatherContext thunk: Cannot gather context, no model selected",
);
throw new Error("No chat model selected");
}
// Resolve context providers and construct new history
@ -95,8 +93,6 @@ export const gatherContext = createAsyncThunk<
}
}
dispatch(updateFileSymbolsFromNewContextItems(selectedContextItems));
if (promptPreamble) {
if (typeof content === "string") {
content = promptPreamble + content;

View file

@ -192,7 +192,7 @@ export const saveCurrentSession = createAsyncThunk<
}
// Fallbacks if above doesn't work out or getChatTitles = false
if (title === NEW_SESSION_TITLE) {
title = getChatTitleFromMessage(history[0].message);
title = getChatTitleFromMessage(state.session.history[0].message);
}
}
// More fallbacks in case of no title

View file

@ -32,18 +32,19 @@ export const streamNormalInput = createAsyncThunk<
defaultModel.title,
streamAborter.signal,
messages,
{
tools: useTools
? Object.keys(toolSettings)
useTools
? {
tools: Object.keys(toolSettings)
.filter((tool) => toolSettings[tool] !== "disabled")
.map((toolName) =>
state.config.config.tools.find(
(tool) => tool.function.name === toolName,
),
)
.filter(Boolean)
: undefined,
},
.filter((tool) => !!tool)
.map((tool) => tool!), // for type safety
}
: {},
);
// Stream response
@ -54,15 +55,14 @@ export const streamNormalInput = createAsyncThunk<
break;
}
const updates = next.value as ChatMessage[];
const updates = next.value;
dispatch(streamUpdate(updates));
next = await gen.next();
}
// Attach prompt log
let returnVal = next.value as PromptLog;
if (returnVal) {
dispatch(addPromptCompletionPair([returnVal]));
if (next.done) {
dispatch(addPromptCompletionPair([next.value]));
}
// If it's a tool call that is automatically accepted, we should call it

View file

@ -16,6 +16,7 @@ import { resetStateForNewMessage } from "./resetStateForNewMessage";
import { streamNormalInput } from "./streamNormalInput";
import { streamSlashCommand } from "./streamSlashCommand";
import { streamThunkWrapper } from "./streamThunkWrapper";
import { updateFileSymbolsFromFiles } from "./updateFileSymbols";
const getSlashCommandForInput = (
input: MessageContent,
@ -66,6 +67,10 @@ export const streamResponseThunk = createAsyncThunk<
const slashCommands = state.config.config.slashCommands || [];
const inputIndex = index ?? state.session.history.length;
if (!defaultModel) {
throw new Error("No chat model selected");
}
dispatch(submitEditorAndInitAtIndex({ index, editorState }));
resetStateForNewMessage();
@ -79,6 +84,15 @@ export const streamResponseThunk = createAsyncThunk<
const unwrapped = unwrapResult(result);
const { selectedContextItems, selectedCode, content } = unwrapped;
// symbols for both context items AND selected codeblocks
const filesForSymbols = [
...selectedContextItems
.filter((item) => item.uri?.type === "file" && item?.uri?.value)
.map((item) => item.uri!.value),
...selectedCode.map((rif) => rif.filepath),
];
dispatch(updateFileSymbolsFromFiles(filesForSymbols));
dispatch(
updateHistoryItemAtIndex({
index: inputIndex,
@ -115,7 +129,6 @@ export const streamResponseThunk = createAsyncThunk<
unwrapResult(await dispatch(streamNormalInput(messages)));
} else {
const [slashCommand, commandInput] = commandAndInput;
let updatedContextItems = [];
posthog.capture("step run", {
step_name: slashCommand.name,
params: {},
@ -132,7 +145,7 @@ export const streamResponseThunk = createAsyncThunk<
input: commandInput,
historyIndex: inputIndex,
selectedCode,
contextItems: updatedContextItems,
contextItems: [],
}),
);
}

View file

@ -30,6 +30,11 @@ export const streamResponseAfterToolCall = createAsyncThunk<
const initialHistory = state.session.history;
const defaultModel = selectDefaultModel(state);
if (!defaultModel) {
console.error("No default model found");
return;
}
resetStateForNewMessage();
await new Promise((resolve) => setTimeout(resolve, 0));

View file

@ -1,28 +1,53 @@
import { createAsyncThunk } from "@reduxjs/toolkit";
import { ThunkApiType } from "../store";
import { updateFileSymbols } from "../slices/sessionSlice";
import { ContextItemWithId } from "core";
import { ChatHistoryItem, ContextItemWithId } from "core";
export function getContextItemsFromHistory(
historyItems: ChatHistoryItem[],
priorToIndex?: number,
) {
const pastHistoryItems = historyItems.filter(
(_, i) => i <= (priorToIndex ?? historyItems.length - 1),
);
const pastNormalContextItems = pastHistoryItems.flatMap((item) => {
return (
item.contextItems?.filter(
(item) => item.uri?.type === "file" && item.uri?.value,
) ?? []
);
});
const pastToolbarContextItems: ContextItemWithId[] = pastHistoryItems
.filter(
(item) => item.editorState && Array.isArray(item.editorState.content),
)
.flatMap((item) => item.editorState.content)
.filter(
(content) =>
content?.type === "codeBlock" &&
content?.attrs?.item?.uri?.value &&
content.attrs.item.uri?.type === "file",
)
.map((content) => content.attrs!.item!);
return [...pastNormalContextItems, ...pastToolbarContextItems];
}
/*
Get file symbols for given context items
Overwrite symbols for existing file matches
*/
export const updateFileSymbolsFromNewContextItems = createAsyncThunk<
export const updateFileSymbolsFromFiles = createAsyncThunk<
void,
ContextItemWithId[],
string[],
ThunkApiType
>(
"symbols/updateFromContextItems",
async (contextItems, { dispatch, extra, getState }) => {
async (filepaths, { dispatch, extra, getState }) => {
try {
// Get unique file uris from context items
const uniqueUris = Array.from(
new Set(
contextItems
.filter((item) => item.uri?.type === "file" && item?.uri?.value)
.map((item) => item.uri!.value),
),
);
const uniqueUris = Array.from(new Set(filepaths));
// Update symbols for those files
if (uniqueUris.length > 0) {
@ -36,11 +61,7 @@ export const updateFileSymbolsFromNewContextItems = createAsyncThunk<
dispatch(updateFileSymbols(result.content));
}
} catch (e) {
console.error(
"Error updating file symbols from context items",
e,
contextItems,
);
console.error("Error updating file symbols from filepaths", e, filepaths);
}
},
);
@ -58,9 +79,8 @@ export const updateFileSymbolsFromHistory = createAsyncThunk<
const state = getState();
// Get unique context item file uris from all history
const contextItems = state.session.history.flatMap(
(item) => item.contextItems,
);
const contextItems = getContextItemsFromHistory(state.session.history);
const uniqueUris = new Set(
contextItems
.filter((item) => item.uri?.type === "file" && item?.uri?.value)

View file

@ -7,7 +7,7 @@
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
@ -18,7 +18,6 @@
"noEmitOnError": false,
"types": ["vitest/globals"]
// Disabled for now since it's causing too many errors
// "strictNullChecks": true
},
"include": ["src", "../src/util/messenger.ts"],
"references": [{ "path": "./tsconfig.node.json" }]

View file

@ -1,31 +0,0 @@
{
"compilerOptions": {
"strictNullChecks": true,
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"noEmitOnError": false,
"types": ["vitest/globals"]
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
"exclude": ["dist", "node_modules"],
}

View file

@ -59,6 +59,7 @@ They are concerned with:
- [ ] Silicon Flow
- [x] TextGen Web UI
- [x] Together
- [x] Novita AI
- [x] Vllm
- [ ] Vertex AI
- [x] Voyage AI

View file

@ -73,6 +73,8 @@ export function constructLlmApi(config: LLMConfig): BaseLlmApi | undefined {
return openAICompatible("https://api.fireworks.ai/inference/v1/", config);
case "together":
return openAICompatible("https://api.together.xyz/v1/", config);
case "novita":
return openAICompatible("https://api.novita.ai/v3/openai", config);
case "nebius":
return openAICompatible("https://api.studio.nebius.ai/v1/", config);
case "function-network":

View file

@ -39,6 +39,7 @@ export const OpenAIConfigSchema = BasePlusConfig.extend({
z.literal("nvidia"),
z.literal("fireworks"),
z.literal("together"),
z.literal("novita"),
z.literal("sambanova"),
z.literal("nebius"),
z.literal("function-network"),

View file

@ -267,6 +267,12 @@ const COMPLETION_TESTS: ({ chatOnly?: boolean } & LlmApiConfig)[] = [
apiKey: process.env.TOGETHER_API_KEY!,
chatOnly: true,
},
{
provider: "novita",
model: "meta-llama/llama-3.1-8b-instruct",
apiKey: process.env.NOVITA_API_KEY!,
chatOnly: true,
},
{
provider: "sambanova",
model: "Meta-Llama-3.1-8B-Instruct",