🎨 Merge Preview (#1333)

* Tidy regex to capture filename

* Ensure adjacent codeblocks separated by newline

* Aesthetic tweaks to output format

* ✨ disableInFiles option for autocomplete

* feat(httpContextProvider): load AC on fetch client (#1150)

Co-authored-by: Bertrand Pinel <bertrand.pinel@pole-emploi.fr>

* ✨ global filewatcher for config.json/ts changes

* 🐛 retry webview requests so that first cmd+L works

* ✨ Improved onboarding experience (#1155)

* 🚸 onboarding improvements

* 🧑‍💻 keyboard shortcuts to toggle autocomplete and open config.json

* ⚡️ improve detection of terminal code blocks

* 🚧 onboarding improvements

* 🚧 more onboarding improvements

* 💄 last session button

* 🚸 show more fallback options in dropdown

* 💄 add sectioning to models page

* 💄 clean up delete model button

* 💄 make tooltip look nicer

* 🚸 download Ollama button

* 💄 local LLM onboarding

* 🐛 select correct terminal on "runCommand" message

* 💄 polish onboarding

* 💚 fix gui build errors

* 📝 add /v1 to OpenAI examples in docs

* 🚑 hotfix for not iterable error

* ✨ add Cohere as Embeddings Provider

* 💄 add llama3 to UI

* 🔥 remove disable indexing

* 🍱 update continue logo

* 🐛 fix language undefined bug

* 🐛 fix merge mistake

* 📝 rename googlepalmapi.md to googlegeminiapi.md

* 📝 update mistral models

* Rename to geminiapi & change filename this time

* ✨ global request options (#1153)

* ✨ global request options

* 🐛 fix jira context provider by injecting fetch

* ✨ request options for embeddings providers

* ✨ add Cohere as Reranker (#1159)

* ♻️ use custom requestOptions with CohereEmbeddingsProvider

* Update preIndexedDocs.ts (#1154)

Add WordPress and WooCommerce as preIndexedDocs.

* 🩹 remove example "outputDir" from default config

* Fix slash command params loading (#1084)

Existing slash commands expect an object named
"params" so mapping to "options" here caused
params to be undefined within the run scope. I
renamed from 'm' to 's' just to avoid potential
confusion with the model property mapping above.

* 🐛 don't index if no open workspace folders

* 💄 improve onboarding language

* 🚸 improve onboarding

* 🐛 stop loading when error

* 💄 replace text in input box

* Respect Retry-After header when available from 429 responses (#1182)

* 🩹 remove dead code for exponential backoff

This has been replaced by the withExponentialBackoff helper

* 🩹 respect Retry-After header when available

* 🚸 update inline tips language

* ✨ input box history

* 📌 update package-locks

* 🔊 log errors in prepackage

* 🐛 err to string

* 📌 pin llama-tokenizer-js

* 📌 update lockfile

* 🚚 change /docs to docs.

* 📦 package win-ca dependencies in binary

* 🔥 remove unpopular models from UI

* 🍱 new logo in jetbrains

* 🎨 use node-fetch everywhere

* 🚸 immediately select newly added models

* 🚸 spell out Alt instead of using symbol

* 🔥 remove config shortcut

* 🐛 fix changing model bug

* 🩹 de-duplicate before adding models

* 🔧 add embeddingsProvider specific request options

* 🎨 refactor to always use node-fetch from LLM

* 🔥 remove duplicate tokens generated

* 🔊 add timestamp to JetBrains logs

* 🎨 maxStopWords for Groq

* 🐛 fix groq provider calling /completions

* 🐛 correctly adhere to LanceDB table name spec

* 🐛 fix sqlite NOT NULL constraint failed error with custom model

* Fix issue where Accept/Reject All only accepts/rejects a single diff hunk. (#1197)

* Fix issues parsing Ollama /api/show endpoint payloads. (#1199)

* ✨ model role for inlineEdit

* 🩹 various small updates

* 🐛 fix openai image support

* 🔖 update gradle version

* 🍱 update jetbrains icon

* 🐛 fix autocomplete in notebook cells

* 🔥 remove unused media

* 🔥 remove unused files

* Fix schema to allow 'AUTODETECT' sentinel for model when provider is 'groq'. (#1203)

* 🐛 small improvements

* Fix issue with @codebase provider when n becomes odd due to a divide by 2 during the full text search portion of the query. (#1204)

* 🐛 add skipLines

* ✨ URLContextProvider

* 🥅 improved error handling for codebase indexing

* 🏷️ use official Git extension types

* ➕ declare vscode.git extension dependency

* ⚡️ use reranker for docs context provider

* 🚸 Use templating in default customCommand

* 🎨 use U+23CE

* 🚸 disable autocomplete in commit message box

* 🩹 add gems to default ignored paths

* ⚡️ format markdown blocks as comments in .ipynb completions

* 🐛 don't strip port in URL

* 🐛 fix "gemini" provider spacing issues

* 📦 update posthog version

* CON-1067: Failed state seems to be toggling as intended

* 🏷️ update types.ts

* 🐛 fix copy/paste/cut behavior in VS Code notebooks

* ✨ llama3 prompt template

* Rework for proper initialization on start up

* CON-1067 Clean-up

* CON-1067 more clean-up

* Add indexingNotLoaded state

* CON-1067 communicate progress to frontend

* 🐛 fix undefined prefix, suffix and language for `/edit` (#1216)

* 🐛 add .bind to fix templating in systemMessage

* CON-1067 clean up

* 🐛 small improvements to autocomplete

* Update DocsContextProvider.ts (#1217)

I fixed a bug where you were sending the query variable (which holds the base URL of the doc) to the rerank method, and it made no sense to rerank the chunks based on a URL. So I changed it to extras.fullInput because it should rerank based on the user input, which should provide better results.

* 📝 select-provider.md update

* 🐛 fix merge errors

* Nate/autocomplete-metrics (#1230)

* ⚡️ use context.selectedCompletionInfo, deduplicate logs

* ⚡️ don't reject if user keeps typing same as completion

* ⚡️ vscode autocomplete edge cases

* 🚧 WIP on vscode autocomplete

* ⚡️ better bracket handlng

* ⚡️ improved multi-line detection

* Active file default context (#1231)

* 🚸 include currently active file by default

* 🚸 warn if non-autocomplete model being used

* ✨ try hole filling template for gpt

* 💄 ui for no context

* ⚡️ leave out bottom of excessively large files

* 🚧 experimenting with perplexity style streaming

* 🐛 fix #1237

* 💚 fix type error

* ⚡️ improve LSP usage in autocomplete

* 🐛 fix content parsing regression in /edit

* add PySide6 docs to preindexed docs (#1236)

* CON-232 bring custom docs to top, alphabetize doc results, make scrol… (#1239)

* CON-232 bring custom docs to top, alphabetize doc results, make scrollable

* CON-232 cleanup

---------

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* CON-1067 condense some things

* 🚚 [Auxiliary -> Continue] Sidebar

* 🔊 log completion options in ~/.continue/sessions

* CON-1067 wrong ret val fix

* CON-1067: fixes from testing

* ⚡️ filter out completions that are only punctuation/space

* ⚡️ inject intellisense docs, no multi-line on comments

* ⚡️ crawl type definitions for autocomplete

* ⚡️ truncate function text

* ⚡️ cache LSP calls

* ⚡️ find recently edited ranges with perfect prefix match

* 🐛 fix gif paths

* ⚡️ bring back double new line stop words

* 📌 add yarn lock files

* 🐛 allow language keywords to be generated

* 💄 toggle on help button

* 🎨 defaultContext option

* 🐛 fix lancedb bug by upgrading

* 🐛 fix groq stop tokens

* 🐛 preventDefault to avoid double paste

* 🚸 don't repeatedly override cmd+J

* 🧑‍💻 fix npm run test in core

* 📝 change description

* 🐛 silence Ollama invalid server state warning

* ⚡️ more accurate getTerminalContents

* ⚡️ make getTerminalContents more accurate

* 🧑‍💻 use yarn instead of npm

* 👷 fix yarn add --no-save in prepackge

* 🐛 correctly read entire notebook file contents

* ➕ import handlebars

* 🔥 remove unnecessary migrations

* ⚡️ improve /comment prompt

* Add debug terminal context menu (#1261)

* Add --no-dependencies to vsce package (#1255)

This is not needed because we bundle first with esbuild, and
vsce pack has issues with modern package managers.

see: microsoft/vscode-vsce#421 (comment)

* ui: change line decoration color to use vscode theme (#1253)

* ui: change line decoration color to use vscode theme

to give user a more consistent experience by letting the decoration color to user the color defined in the theme.

* fix: incorrect color item

should be line background not text background
because the decoration is for the whole line

* 🎨 refactor indexing state into a single object

* CON-223 Correct diff streaming abort (#1263)

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* 📦 switch to pnpm (#1265)

* 🎨 use pnpm instead of yarn

* ➕ make dependencies explicit for pnpm

* 🐛 add powershell to extension mapping, and default to ext

* Add stream support for Bedrock Anthropic

* 🎨 make llamatokenizer commonjs compatible

* ➕ add esbuild optional deps

* 🚚 rename vendor/node_modules -> modules

* 🔖 update core version

* 🐛 fixes for transformers.js compatibility

* 🔖 update core version

* 🎨 set modelPath in constructor

* 🎨 fix transformers.js import

* 🎨 eslint enforce import extensions

* 🎨 require -> import

* 🚸 notify user if not diff in /commit

* 💄 Improve colors of the IntelliJ tool window icon (#1273)

Without this fix, the continue icon sticks out from the other toolwindow icons,
resulting in an inconsistent appearance of the whole IDE and creates a feeling
that the continue plugin "doesn't fit, something must be broken".

According to
https://plugins.jetbrains.com/docs/intellij/icons.html#new-ui-icon-colors
specific colors are needed to work nicely with dark and light modes. Bonus is
that the active tool window icon color then changes automatically to white.

Co-authored-by: Lukas Baron <LukasBaron@gmail.com>

* ✨ send Bearer token to Ollama if apiKey set

* 🐛 fix slash command bug

* 🧑‍💻 add onnxruntime (--save-dev) for types

* 🐛 don't apply to file when running code block in terminal

* 🐛 avoid double paste

* ✨ gpt-4o

* 🎨 pass uniqueId to constructor

* 🚸 focus without scrolling into vie

* 🎨 refactoring for continue-proxy LLM (#1277)

* 🐛 continue server client fixes

* 🎨 refactor OpenAI _getHeaders

* 🎨 pass ideSettings to llmFromDescription

* ⚡️ improve add docstring command

* 💚 ci updates

* 🐛 fix repeated paste bug

* 🐛 fix build script

* 🩹 various small improvements

* 📌 pin esbuild 0.17.19

* 🧑‍💻 pnpm i gui in prepackage

* 🐛 show all diff changes in vscode

* 🩹 getMetaKeyName

* 🐛 fix reading of unopened ipynb files

* ⚡️ gpt-4o system prompt

* 💄 make font size configurable in config.json ui.fontSize

* 🩹 properly dispose of diff handler

* 🐛 fix indexing status display

* ⚡️ context pruning

* 🎨 update free trial models

* fix: remove some backup files generated by pkg if present (#1287)

* adjust toCopy (#1305)

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* Nate/prompt-file (#1308)

* ✨ .prompt files

* 🧑‍💻 back to npm  : (

* 🎨 nicer dropdown icon

* 🎨 full switch back to npm

* 🧑‍💻 uninstall script for fresh start

* 🎨 updated package-locks

* 🔥 remove hello from continuerc.json

* 🔥 remove example files

* 🎨 update test prompt

* 🎨 update prompt

* 🎨 update test prompt

* 👷 create out/node_modules in prepackage.js

* Log prompt-tokens to devdb and show in 'My Usage' view (#1309)

* Also log the number of prompt tokens to the dev-db

* Show prompt tokens in 'My Usage' view

* 🔥 remove console logs

* add lm studio tab-autocomplete walkthrough (#1298)

* 📝 update autocomplete LM Studio docs

* 💚 fix prepackage.js

* ⬆️ upgrade lancedb version

* 🚸 make it easier to continue past trial

* 🚸 improve model setup process

* 📌 update package-lock.jsons

* 🐛 fix prompt file loading bug

* docs: add setup guide for OpenRouter (#1284)

* Update preIndexedDocs.ts (#1292)

Add Bootstrap and Alpine.js as pre indexed docs.

* add toString (#1324)

* add toString

* Fix indentation

---------

Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>

* don't overwrite all models in onboarding

* 🔧 override headers with custom headers

* ✨ allow overwriting slash command description

* feature flag (#1327)

* ➕ feature flags dependency

* 🎨 make getHeaders awaitable

* 🔒️ token count for abuse monitoring

* 👷 remove win32-arm64 target

* Update build.js (#1330)

Fix error: EBUSY: resource busy or locked, rmdir '...\continue\binary\tmp\continue-node_modules-lancedb'

* 📌 pin onnxruntime version to match transformers.js

* 🎨 transformers cleanup, extensionVersion header

---------

Co-authored-by: Peter Zaback <pzaback@gmail.com>
Co-authored-by: Bertrand P <49525332+Berber31@users.noreply.github.com>
Co-authored-by: Bertrand Pinel <bertrand.pinel@pole-emploi.fr>
Co-authored-by: Maxime Brunet <max@brnt.mx>
Co-authored-by: Jose Vega <bloguea.y.gana@gmail.com>
Co-authored-by: Nejc Habjan <hab.nejc@gmail.com>
Co-authored-by: Chad Yates <cyates@dynfxdigital.com>
Co-authored-by: Justin Milner <jmilner@jmilner-lt2.deka.local>
Co-authored-by: 小颚虫 <123357481+5eqn@users.noreply.github.com>
Co-authored-by: 5eqn <491100866@qq.com>
Co-authored-by: Pixel <54180211+pixelsortr@users.noreply.github.com>
Co-authored-by: Justin Milner <42585006+justinmilner1@users.noreply.github.com>
Co-authored-by: Devin Gould <djgould0628@gmail.com>
Co-authored-by: Dipta Mahardhika <146386738+d-mahard@users.noreply.github.com>
Co-authored-by: Ruben Kostandyan <kostard@amazon.com>
Co-authored-by: tnglemongrass <113173292+tnglemongrass@users.noreply.github.com>
Co-authored-by: Lukas Baron <LukasBaron@gmail.com>
Co-authored-by: Fernando <fernando.sanchez.jr@gmail.com>
Co-authored-by: Tijs Zwinkels <tijs@tinkertank.eu>
Co-authored-by: DJ Johnson <mr.demarcus.johnson@gmail.com>
Co-authored-by: sam <1211977+sambarnes@users.noreply.github.com>
This commit is contained in:
Nate Sesti 2024-05-21 09:44:28 -07:00 • committed by GitHub
parent 678a40de2e
commit c23a3cec11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 59839 additions and 17231 deletions

View file

@ -58,15 +58,14 @@ Continue is continuously improving, but a feature isn't complete until it is ref
#### Pre-requisites
- You should have Node.js version 20.11.0 (LTS) or higher installed. You can get it on [nodejs.org](https://nodejs.org/en/download) or, if you are using NVM (Node Version Manager), you can set the correct version of Node.js for this project by running the following command in the root of the project:
- Continue uses `pnpm` to manage node_modules. You can install `pnpm` globally with `npm install -g pnpm`, or another method described in [their docs](https://pnpm.io/installation#using-npm).
#### VS Code
You should have Node.js version 20.11.0 (LTS) or higher installed. You can get it on [nodejs.org](https://nodejs.org/en/download) or, if you are using NVM (Node Version Manager), you can set the correct version of Node.js for this project by running the following command in the root of the project:
```bash
nvm use
```
#### VS Code
1. Clone and open in VS Code the Continue repo `https://github.com/continuedev/continue`
2. Open the VS Code command pallet (`cmd/ctrl+shift+p`) and select `Tasks: Run Task` and then select `install-all-dependencies`
@ -80,7 +79,7 @@ nvm use
1. The new VS Code window with the extension is referred to as the _Host VS Code_
2. The window you started debugging from is referred to as the _Main VS Code_
4. To package the extension, run `pnpm package` in the `extensions/vscode` directory. This will generate `extensions/vscode/build/continue-patch.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
4. To package the extension, run `npm package` in the `extensions/vscode` directory. This will generate `extensions/vscode/build/continue-patch.vsix`, which you can install by right-clicking and selecting "Install Extension VSIX".
> Note: Breakpoints can be used in both the `core` and `extensions/vscode` folders while debugging, but are not currently supported inside of `gui` code. Hot-reloading is enabled with Vite, so if you make any changes to the `gui`, they should be automatically reflected without rebuilding. Similarly, any changes to `core` or `extensions/vscode` will be automatically included by just reloading the _Host VS Code_ window with cmd/ctrl+shift+p "Reload Window".

View file

@ -15,14 +15,17 @@ function execCmdSync(cmd) {
}
const esbuildOutputFile = "out/index.js";
const platforms = ["darwin", "linux", "win32"];
const architectures = ["x64", "arm64"];
let targets = platforms.flatMap((platform) =>
architectures.map((arch) => `${platform}-${arch}`),
);
const targets = [
"darwin-x64",
"darwin-arm64",
"linux-x64",
"linux-arm64",
"win32-x64",
];
const assetBackups = [
"node_modules/win-ca/lib/crypt32-ia32.node.bak",
"node_modules/win-ca/lib/crypt32-x64.node.bak"
"node_modules/win-ca/lib/crypt32-x64.node.bak",
];
let esbuildOnly = false;
@ -47,10 +50,11 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
console.log(`Copying ${package} to ${toCopy}`);
// This is a way to install only one package without npm trying to install all the dependencies
// Create a temporary directory for installing the package
const adjustedName = toCopy.replace(/^@/, "").replace("/", "-");
const tempDir = path.join(
__dirname,
"tmp",
`continue-node_modules-${toCopy}`,
`continue-node_modules-${adjustedName}`,
);
const currentDir = process.cwd();
@ -90,7 +94,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
});
} finally {
// Clean up the temporary directory
rimrafSync(tempDir);
// rimrafSync(tempDir);
// Return to the original directory
process.chdir(currentDir);
@ -160,7 +164,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(package, toCopy) {
// delete asset backups generated by previous pkg invocations, if present
for (const assetPath of assetBackups) {
fs.rmSync(assetPath, {force: true});
fs.rmSync(assetPath, { force: true });
}
console.log("[info] Building with esbuild...");

11933
binary/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@
"posthog-node": "^3.6.3",
"system-ca": "^1.0.2",
"uuid": "^9.0.1",
"vectordb": "^0.4.10",
"vectordb": "^0.4.20",
"win-ca": "^3.5.1"
}
}

View file

@ -12,6 +12,30 @@ ollama run starcoder:3b
Once it has been downloaded, you should begin to see completions in VS Code.
## Setting up with LM Studio
You can also set up tab-autocomplete with a local LM Studio instance by following these steps:
1. Download the latest version of LM Studio from [here](https://lmstudio.ai/)
2. Download a model (e.g. search for `second-state/StarCoder2-3B-GGUF` and choose one of the options there)
3. Go to the server section (button is on the left), select your model from the dropdown at the top, and click "Start Server"
4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf`); this will be used as the "model" attribute in Continue
5. Go to Continue and modify the configurations for a [custom model](#setting-up-a-custom-model)
6. Set the "provider" to `lmstudio` and the "model" to the path copied earlier
Example:
```json title=~/.continue/config.json
{
"tabAutocompleteModel": {
"title": "Starcoder2 3b",
"model": "second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf",
"provider": "lmstudio",
},
...
}
```
## Setting up a custom model
All of the configuration options available for chat models are available to use for tab-autocomplete. For example, if you wanted to use a remote vLLM instance you would edit your `config.json` like this (note that it is not inside the models array), filling in the correct model name and vLLM endpoint:

View file

@ -1,65 +1,83 @@
import { CustomCommand, SlashCommand, SlashCommandDescription } from "../index.js";
import {
CustomCommand,
SlashCommand,
SlashCommandDescription,
} from "../index.js";
import { stripImages } from "../llm/countTokens.js";
import { renderTemplatedString } from "../llm/llms/index.js";
import SlashCommands from "./slash/index.js";
export function slashFromCustomCommand(
customCommand: CustomCommand,
customCommand: CustomCommand,
): SlashCommand {
return {
name: customCommand.name,
description: customCommand.description,
run: async function* ({ input, llm, history, ide }) {
// Remove slash command prefix from input
let userInput = input;
if (userInput.startsWith(`/${customCommand.name}`)) {
userInput = userInput
.slice(customCommand.name.length + 1, userInput.length)
.trimStart();
}
return {
name: customCommand.name,
description: customCommand.description,
run: async function* ({ input, llm, history, ide }) {
// Remove slash command prefix from input
let userInput = input;
if (userInput.startsWith(`/${customCommand.name}`)) {
userInput = userInput
.slice(customCommand.name.length + 1, userInput.length)
.trimStart();
}
// Render prompt template
const promptUserInput = await renderTemplatedString(
customCommand.prompt,
ide.readFile.bind(ide),
{ input: userInput },
);
// Render prompt template
const promptUserInput = await renderTemplatedString(
customCommand.prompt,
ide.readFile.bind(ide),
{ input: userInput },
);
const messages = [...history];
// Find the last chat message with this slash command and replace it with the user input
for (let i = messages.length - 1; i >= 0; i--) {
const {role, content} = messages[i];
if (role !== "user") {
continue;
}
const messages = [...history];
// Find the last chat message with this slash command and replace it with the user input
for (let i = messages.length - 1; i >= 0; i--) {
const { role, content } = messages[i];
if (role !== "user") {
continue;
}
if (Array.isArray(content) && content.some((part) => part.text?.startsWith(`/${customCommand.name}`))) {
messages[i] = { ...messages[i], content: content.map((part) => {
return part.text?.startsWith(`/${customCommand.name}`) ? {...part, text: promptUserInput } : part;
}) };
break;
} else if (typeof content === "string" && content.startsWith(`/${customCommand.name}`)) {
messages[i] = { ...messages[i], content: promptUserInput };
break;
}
}
if (
Array.isArray(content) &&
content.some((part) =>
part.text?.startsWith(`/${customCommand.name}`),
)
) {
messages[i] = {
...messages[i],
content: content.map((part) => {
return part.text?.startsWith(`/${customCommand.name}`)
? { ...part, text: promptUserInput }
: part;
}),
};
break;
} else if (
typeof content === "string" &&
content.startsWith(`/${customCommand.name}`)
) {
messages[i] = { ...messages[i], content: promptUserInput };
break;
}
}
for await (const chunk of llm.streamChat(messages)) {
yield stripImages(chunk.content);
}
},
};
for await (const chunk of llm.streamChat(messages)) {
yield stripImages(chunk.content);
}
},
};
}
export function slashCommandFromDescription(
desc: SlashCommandDescription,
desc: SlashCommandDescription,
): SlashCommand | undefined {
const cmd = SlashCommands.find((cmd) => cmd.name === desc.name);
if (!cmd) {
return undefined;
}
return {
...cmd,
params: desc.params,
};
const cmd = SlashCommands.find((cmd) => cmd.name === desc.name);
if (!cmd) {
return undefined;
}
return {
...cmd,
params: desc.params,
description: desc.description ?? cmd.description,
};
}

View file

@ -64,7 +64,7 @@ export class ConfigHandler {
const uniqueId = await this.ide.getUniqueId();
this.savedConfig = await loadFullConfigNode(
this.ide.readFile.bind(this.ide),
this.ide,
workspaceConfigs,
this.ideSettings,
ideInfo.ideType,

View file

@ -19,6 +19,7 @@ import {
CustomLLM,
EmbeddingsProviderDescription,
IContextProvider,
IDE,
IdeType,
ModelDescription,
Reranker,
@ -49,6 +50,7 @@ import {
defaultSlashCommandsJetBrains,
defaultSlashCommandsVscode,
} from "./default.js";
import { getPromptFiles, slashCommandFromPromptFile } from "./promptFile.js";
const { execSync } = require("child_process");
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
@ -130,9 +132,10 @@ function loadSerializedConfig(
return config;
}
function serializedToIntermediateConfig(
async function serializedToIntermediateConfig(
initial: SerializedContinueConfig,
): Config {
ide: IDE,
): Promise<Config> {
const slashCommands: SlashCommand[] = [];
for (const command of initial.slashCommands || []) {
const newCommand = slashCommandFromDescription(command);
@ -144,6 +147,20 @@ function serializedToIntermediateConfig(
slashCommands.push(slashFromCustomCommand(command));
}
const workspaceDirs = await ide.getWorkspaceDirs();
const promptFiles = (
await Promise.all(
workspaceDirs.map((dir) =>
getPromptFiles(ide, path.join(dir, ".prompts")),
),
)
)
.flat()
.filter(({ path }) => path.endsWith(".prompt"));
for (const file of promptFiles) {
slashCommands.push(slashCommandFromPromptFile(file.path, file.content));
}
const config: Config = {
...initial,
slashCommands,
@ -168,7 +185,7 @@ function isContextProviderWithParams(
/** Only difference between intermediate and final configs is the `models` array */
async function intermediateToFinalConfig(
config: Config,
readFile: (filepath: string) => Promise<string>,
ide: IDE,
ideSettings: IdeSettings,
uniqueId: string,
writeLog: (log: string) => Promise<void>,
@ -179,7 +196,7 @@ async function intermediateToFinalConfig(
if (isModelDescription(desc)) {
const llm = await llmFromDescription(
desc,
readFile,
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
@ -201,7 +218,7 @@ async function intermediateToFinalConfig(
model: modelName,
title: llm.title + " - " + modelName,
},
readFile,
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
@ -261,7 +278,7 @@ async function intermediateToFinalConfig(
if (isModelDescription(config.tabAutocompleteModel)) {
autocompleteLlm = await llmFromDescription(
config.tabAutocompleteModel,
readFile,
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
@ -451,7 +468,7 @@ async function buildConfigTs() {
}
async function loadFullConfigNode(
readFile: (filepath: string) => Promise<string>,
ide: IDE,
workspaceConfigs: ContinueRcJson[],
ideSettings: IdeSettings,
ideType: IdeType,
@ -459,7 +476,7 @@ async function loadFullConfigNode(
writeLog: (log: string) => Promise<void>,
): Promise<ContinueConfig> {
let serialized = loadSerializedConfig(workspaceConfigs, ideSettings, ideType);
let intermediate = serializedToIntermediateConfig(serialized);
let intermediate = await serializedToIntermediateConfig(serialized, ide);
const configJsContents = await buildConfigTs();
if (configJsContents) {
@ -496,7 +513,7 @@ async function loadFullConfigNode(
const finalConfig = await intermediateToFinalConfig(
intermediate,
readFile,
ide,
ideSettings,
uniqueId,
writeLog,

View file

@ -82,6 +82,7 @@ export function setupLocalMode(
provider: "ollama",
model: "AUTODETECT",
},
...config.models.filter((model) => model.provider !== "free-trial"),
],
tabAutocompleteModel: {
title: "Starcoder 3b",
@ -94,3 +95,24 @@ export function setupLocalMode(
reranker: undefined,
};
}
export function setupLocalAfterFreeTrial(
config: SerializedContinueConfig,
): SerializedContinueConfig {
return {
...config,
models: [
{
title: "Llama 3",
provider: "ollama",
model: "llama3",
},
{
title: "Ollama",
provider: "ollama",
model: "AUTODETECT",
},
...config.models.filter((model) => model.provider !== "free-trial"),
],
};
}

108
core/config/promptFile.ts Normal file
View file

@ -0,0 +1,108 @@
import * as YAML from "yaml";
import { IDE, SlashCommand } from "..";
import { stripImages } from "../llm/countTokens";
import { renderTemplatedString } from "../llm/llms";
import { getBasename } from "../util";
export async function getPromptFiles(
ide: IDE,
dir: string,
): Promise<{ path: string; content: string }[]> {
try {
const paths = await ide.listWorkspaceContents(dir);
const results = paths.map(async (path) => {
const content = await ide.readFile(path);
return { path, content };
});
return Promise.all(results);
} catch (e) {
console.error(e);
return [];
}
}
export function slashCommandFromPromptFile(
path: string,
content: string,
): SlashCommand {
let [preambleRaw, prompt] = content.split("\n---\n");
if (prompt === undefined) {
prompt = preambleRaw;
preambleRaw = "";
}
const preamble = YAML.parse(preambleRaw) ?? {};
const name = preamble.name ?? getBasename(path).split(".prompt")[0];
const description = preamble.description ?? name;
let systemMessage: string | undefined = undefined;
if (prompt.includes("<system>")) {
systemMessage = prompt.split("<system>")[1].split("</system>")[0].trim();
prompt = prompt.split("</system>")[1].trim();
}
return {
name,
description,
run: async function* ({ input, llm, history, ide }) {
// Remove slash command prefix from input
let userInput = input;
if (userInput.startsWith(`/${name}`)) {
userInput = userInput
.slice(name.length + 1, userInput.length)
.trimStart();
}
// Render prompt template
const diff = await ide.getDiff();
const promptUserInput = await renderTemplatedString(
prompt,
ide.readFile.bind(ide),
{ input: userInput, diff },
);
const messages = [...history];
// Find the last chat message with this slash command and replace it with the user input
for (let i = messages.length - 1; i >= 0; i--) {
const { role, content } = messages[i];
if (role !== "user") {
continue;
}
if (
Array.isArray(content) &&
content.some((part) => part.text?.startsWith(`/${name}`))
) {
messages[i] = {
...messages[i],
content: content.map((part) => {
return part.text?.startsWith(`/${name}`)
? { ...part, text: promptUserInput }
: part;
}),
};
break;
} else if (
typeof content === "string" &&
content.startsWith(`/${name}`)
) {
messages[i] = { ...messages[i], content: promptUserInput };
break;
}
}
// System message
if (systemMessage) {
if (messages[0]?.role === "system") {
messages[0].content = systemMessage;
} else {
messages.unshift({ role: "system", content: systemMessage });
}
}
for await (const chunk of llm.streamChat(messages)) {
yield stripImages(chunk.content);
}
},
};
}

View file

@ -32,13 +32,18 @@ export function addModel(model: ModelDescription) {
export function addOpenAIKey(key: string) {
editConfigJson((config) => {
config.models = config.models.map((m: ModelDescription) => {
if (m.provider === "free-trial") {
m.apiKey = key;
m.provider = "openai";
}
return m;
});
config.models = config.models
.filter(
(model) =>
model.provider !== "free-trial" || model.model.startsWith("gpt"),
)
.map((m: ModelDescription) => {
if (m.provider === "free-trial") {
m.apiKey = key;
m.provider = "openai";
}
return m;
});
return config;
});
}

View file

@ -114,7 +114,7 @@ class DocsContextProvider extends BaseContextProvider {
return 1;
} else {
// Secondary criterion: Alphabetical order when both items are in the same category
return a.title.localeCompare(b.title);
return a.title.toString().localeCompare(b.title.toString());
}
});

View file

@ -1,6 +1,6 @@
import fetch from "node-fetch";
import { Chunk, Reranker } from "../../index.js";
import { getHeaders } from "../../continueServer/stubs/headers.js";
import { Chunk, Reranker } from "../../index.js";
import { SERVER_URL } from "../../util/parameters.js";
export class FreeTrialReranker implements Reranker {
@ -11,7 +11,7 @@ export class FreeTrialReranker implements Reranker {
method: "POST",
headers: {
"Content-Type": "application/json",
...getHeaders(),
...(await getHeaders()),
},
body: JSON.stringify({
query,

View file

@ -1,3 +1,3 @@
export function getHeaders() {
export async function getHeaders() {
return {};
}

View file

@ -321,6 +321,7 @@ export class LanceDbIndex implements CodebaseIndex {
const tableName = this.tableNameForTag(tag);
const tableNames = await db.tableNames();
if (!tableNames.includes(tableName)) {
console.warn("Table not found in LanceDB", tableName);
return [];
}

View file

@ -231,6 +231,16 @@ const configs: SiteIndexingConfig[] = [
startUrl: "https://doc.qt.io/qtforpython-6/quickstart.html",
rootUrl: "https://doc.qt.io/qtforpython-6/api.html",
},
{
title: "Bootstrap",
startUrl: "https://getbootstrap.com/docs/5.3/getting-started/introduction/",
rootUrl: "https://getbootstrap.com/docs/5.3/",
},
{
title: "Alpine.js",
startUrl: "https://alpinejs.dev/start-here",
rootUrl: "https://alpinejs.dev/",
},
];
export default configs;

View file

@ -1,6 +1,6 @@
import { Response } from "node-fetch";
import { EmbedOptions } from "../../index.js";
import { getHeaders } from "../../continueServer/stubs/headers.js";
import { EmbedOptions } from "../../index.js";
import { SERVER_URL } from "../../util/parameters.js";
import { withExponentialBackoff } from "../../util/withExponentialBackoff.js";
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
@ -30,7 +30,7 @@ class FreeTrialEmbeddingsProvider extends BaseEmbeddingsProvider {
await Promise.all(
batchedChunks.map(async (batch) => {
const fetchWithBackoff = () =>
withExponentialBackoff<Response>(() =>
withExponentialBackoff<Response>(async () =>
this.fetch(new URL("embeddings", SERVER_URL), {
method: "POST",
body: JSON.stringify({
@ -39,7 +39,7 @@ class FreeTrialEmbeddingsProvider extends BaseEmbeddingsProvider {
}),
headers: {
"Content-Type": "application/json",
...getHeaders(),
...(await getHeaders()),
},
}),
);

View file

@ -1,3 +1,4 @@
// prettier-ignore
// @ts-ignore
import { PipelineType, env, pipeline } from "../../vendor/modules/@xenova/transformers/src/transformers.js";
@ -6,10 +7,7 @@ import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
env.allowLocalModels = true;
env.allowRemoteModels = false;
if (typeof window === "undefined") {
// The embeddings provider should just never be called in the browser
env.localModelPath = path.join(__dirname, "..", "models");
}
env.localModelPath = path.join(__dirname, "..", "models");
class EmbeddingsPipeline {
static task: PipelineType = "feature-extraction";
@ -31,7 +29,7 @@ export class TransformersJsEmbeddingsProvider extends BaseEmbeddingsProvider {
constructor(modelPath?: string) {
super({ model: "all-MiniLM-L2-v6" }, () => Promise.resolve(null));
if (modelPath) {
env.localModelPath = modelPath;
// env.localModelPath = modelPath;
}
}

View file

@ -57,7 +57,7 @@ function countTokens(
: encoding.encode(part.text ?? "", "all", []).length;
}, 0);
} else {
return encoding.encode(content, "all", []).length;
return encoding.encode(content ?? "", "all", []).length;
}
}

View file

@ -217,14 +217,16 @@ ${settings}
${prompt}`;
}
private _logTokensGenerated(model: string, completion: string) {
let tokens = this.countTokens(completion);
private _logTokensGenerated(model: string, prompt: string, completion: string) {
let promptTokens = this.countTokens(prompt);
let generatedTokens = this.countTokens(completion);
Telemetry.capture("tokens_generated", {
model: model,
provider: this.providerName,
tokens: tokens,
promptTokens: promptTokens,
generatedTokens: generatedTokens,
});
DevDataSqliteDb.logTokensGenerated(model, this.providerName, tokens);
DevDataSqliteDb.logTokensGenerated(model, this.providerName, promptTokens, generatedTokens);
}
fetch(url: RequestInfo | URL, init?: RequestInit): Promise<Response> {
@ -335,7 +337,7 @@ ${prompt}`;
yield chunk;
}
this._logTokensGenerated(completionOptions.model, completion);
this._logTokensGenerated(completionOptions.model, prompt, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
@ -370,7 +372,7 @@ ${prompt}`;
const completion = await this._complete(prompt, completionOptions);
this._logTokensGenerated(completionOptions.model, completion);
this._logTokensGenerated(completionOptions.model, prompt, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
@ -432,7 +434,7 @@ ${prompt}`;
throw error;
}
this._logTokensGenerated(completionOptions.model, completion);
this._logTokensGenerated(completionOptions.model, prompt, completion);
if (log && this.writeLog) {
await this.writeLog(`Completion:\n\n${completion}\n\n`);
}
@ -531,3 +533,4 @@ ${prompt}`;
}
}
}

View file

@ -1,8 +1,11 @@
import {
BedrockRuntimeClient,
InvokeModelWithResponseStreamCommand,
} from "@aws-sdk/client-bedrock-runtime";
import * as fs from "fs";
import os from "os";
import { join as joinPath } from "path";
import { promisify } from "util";
import { BaseLLM } from "../index.js";
import {
ChatMessage,
CompletionOptions,
@ -10,13 +13,14 @@ import {
ModelProvider,
} from "../../index.js";
import { stripImages } from "../countTokens.js";
import { BaseLLM } from "../index.js";
const aws4 = require("aws4");
const readFile = promisify(fs.readFile);
namespace BedrockCommon {
export enum Method {
Chat = "invoke",
Chat = "invoke-with-response-stream",
Completion = "invoke-with-response-stream",
}
export const Service: string = "bedrock";
@ -126,10 +130,7 @@ class Bedrock extends BaseLLM {
const path = `/model/${model}/${apiMethod}`;
const opts = {
headers: {
accept:
apiMethod === BedrockCommon.Method.Chat
? "application/json"
: "application/vnd.amazon.eventstream",
accept: "application/vnd.amazon.eventstream",
"content-type": "application/json",
"x-amzn-bedrock-accept": "*/*",
},
@ -147,10 +148,11 @@ class Bedrock extends BaseLLM {
joinPath(process.env.HOME ?? os.homedir(), ".aws", "credentials"),
"utf8",
);
const credentials = this._parseCredentialsFile(data);
accessKeyId = credentials.bedrock.accessKeyId;
secretAccessKey = credentials.bedrock.secretAccessKey;
sessionToken = credentials.bedrock.sessionToken || "";
const credentialsFile = this._parseCredentialsFile(data);
const credentials = credentialsFile.bedrock ?? credentialsFile.default;
accessKeyId = credentials.accessKeyId;
secretAccessKey = credentials.secretAccessKey;
sessionToken = credentials.sessionToken || "";
} catch (err) {
console.error("Error reading AWS credentials", err);
return new Response("403");
@ -172,39 +174,56 @@ class Bedrock extends BaseLLM {
for await (const update of this._streamChat(messages, options)) {
yield stripImages(update.content);
}
// TODO: Couldn't seem to get this stream API working yet. Deferring to _streamChat.
// import { streamSse } from "../stream";
// const response = await this._fetchWithAwsAuthSigV4(BedrockCommon.Method.Completion, JSON.stringify({
// ...this._convertArgs(options),
// max_tokens: undefined, // Delete this key in favor of the correct one for the Completions API.
// max_tokens_to_sample: options.maxTokens,
// prompt: `\n\nHuman: ${prompt}\n\nAssistant:`,
// })
// );
// for await (const value of streamSse(response)) {
// if (value.completion) {
// yield value.completion
// }
// }
}
protected async *_streamChat(
messages: ChatMessage[],
options: CompletionOptions,
): AsyncGenerator<ChatMessage> {
const response = await this._fetchWithAwsAuthSigV4(
BedrockCommon.Method.Chat,
JSON.stringify({
...this._convertArgs(options),
messages: this._convertMessages(messages),
anthropic_version: "bedrock-2023-05-31", // Fixed, required parameter for Chat API.
}),
this._convertModelName(options.model),
const data = await readFile(
joinPath(process.env.HOME ?? os.homedir(), ".aws", "credentials"),
"utf8",
);
yield {
role: "assistant",
content: (await response.json()).content[0].text,
};
const credentialsFile = this._parseCredentialsFile(data);
const credentials = credentialsFile.bedrock ?? credentialsFile.default;
const accessKeyId = credentials.accessKeyId;
const secretAccessKey = credentials.secretAccessKey;
const sessionToken = credentials.sessionToken || "";
const client = new BedrockRuntimeClient({
region: this.region,
credentials: {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
sessionToken: sessionToken,
},
});
const command = new InvokeModelWithResponseStreamCommand({
body: new TextEncoder().encode(
JSON.stringify({
anthropic_version: "bedrock-2023-05-31",
max_tokens: options.maxTokens,
system: this.systemMessage,
messages: this._convertMessages(messages),
temperature: options.temperature,
top_p: options.topP,
top_k: options.topK,
stop_sequences: options.stop,
}),
),
contentType: "application/json",
modelId: options.model,
});
const response = await client.send(command);
if (response.body) {
for await (const value of response.body) {
const binaryChunk = value.chunk?.bytes;
const textChunk = new TextDecoder().decode(binaryChunk);
const chunk = JSON.parse(textChunk).delta?.text;
if (chunk) {
yield { role: "assistant", content: chunk };
}
}
}
}
}

View file

@ -1,20 +1,38 @@
import { getHeaders } from "../../continueServer/stubs/headers.js";
import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js";
import { SERVER_URL } from "../../util/parameters.js";
import { Telemetry } from "../../util/posthog.js";
import { BaseLLM } from "../index.js";
import { streamResponse } from "../stream.js";
class FreeTrial extends BaseLLM {
static providerName: ModelProvider = "free-trial";
private _getHeaders() {
private async _getHeaders() {
return {
uniqueId: this.uniqueId || "None",
extensionVersion: Telemetry.extensionVersion ?? "Unknown",
os: Telemetry.os ?? "Unknown",
"Content-Type": "application/json",
...getHeaders(),
...(await getHeaders()),
};
}
private async _countTokens(prompt: string, model: string, isPrompt: boolean) {
if (!Telemetry.client) {
throw new Error(
'In order to use the free trial, telemetry must be enabled so that we can monitor abuse. To enable telemetry, set "allowAnonymousTelemetry": true in config.json and make sure the box is checked in IDE settings. If you use your own model (local or API key), telemetry will never be required.',
);
}
const event = isPrompt
? "free_trial_prompt_tokens"
: "free_trial_completion_tokens";
Telemetry.capture(event, {
tokens: this.countTokens(prompt),
model,
});
}
private _convertArgs(options: CompletionOptions): any {
return {
model: options.model,
@ -36,18 +54,23 @@ class FreeTrial extends BaseLLM {
): AsyncGenerator<string> {
const args = this._convertArgs(this.collectArgs(options));
await this._countTokens(prompt, args.model, true);
const response = await this.fetch(`${SERVER_URL}/stream_complete`, {
method: "POST",
headers: this._getHeaders(),
headers: await this._getHeaders(),
body: JSON.stringify({
prompt,
...args,
}),
});
let completion = "";
for await (const value of streamResponse(response)) {
yield value;
completion += value;
}
this._countTokens(completion, args.model, false);
}
protected _convertMessage(message: ChatMessage) {
@ -74,21 +97,30 @@ class FreeTrial extends BaseLLM {
): AsyncGenerator<ChatMessage> {
const args = this._convertArgs(this.collectArgs(options));
await this._countTokens(
messages.map((m) => m.content).join("\n"),
args.model,
true,
);
const response = await this.fetch(`${SERVER_URL}/stream_chat`, {
method: "POST",
headers: this._getHeaders(),
headers: await this._getHeaders(),
body: JSON.stringify({
messages: messages.map(this._convertMessage),
...args,
}),
});
let completion = "";
for await (const chunk of streamResponse(response)) {
yield {
role: "assistant",
content: chunk,
};
completion += chunk;
}
this._countTokens(completion, args.model, false);
}
async listModels(): Promise<string[]> {

11459
core/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -22,11 +22,12 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-require-extensions": "^0.1.3",
"jest": "^29.7.0",
"onnxruntime-common": "^1.17.3",
"onnxruntime-web": "^1.17.3",
"onnxruntime-common": "1.14.0",
"onnxruntime-web": "1.14.0",
"ts-jest": "^29.1.1"
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.574.0",
"@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.0.2",
"@types/jsdom": "^21.1.6",
@ -34,7 +35,8 @@
"@types/node-fetch": "^2.6.11",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@xenova/transformers": "^2.14.0",
"@xenova/transformers": "2.14.0",
"onnxruntime-node": "1.14.0",
"adf-to-md": "^1.1.0",
"axios": "^1.6.7",
"cheerio": "^1.0.0-rc.12",
@ -49,11 +51,11 @@
"ignore": "^5.3.1",
"js-tiktoken": "^1.0.8",
"jsdom": "^24.0.0",
"launchdarkly-node-client-sdk": "^3.2.0",
"llm-code-highlighter": "^0.0.14",
"node-fetch": "^3.3.2",
"node-html-markdown": "^1.3.0",
"ollama": "^0.4.6",
"onnxruntime-node": "1.17.3-rev.1",
"openai": "^4.20.1",
"pg": "^8.11.3",
"posthog-node": "^3.6.3",
@ -64,8 +66,9 @@
"sqlite3": "^5.1.7",
"tree-sitter-wasms": "^0.1.11",
"uuid": "^9.0.1",
"vectordb": "^0.4.12",
"web-tree-sitter": "^0.21.0"
"vectordb": "^0.4.20",
"web-tree-sitter": "^0.21.0",
"yaml": "^2.4.2"
},
"puppeteer": {
"chromium_revision": "119.0.6045.105"

View file

@ -12,41 +12,54 @@ export class DevDataSqliteDb {
model TEXT NOT NULL,
provider TEXT NOT NULL,
tokens_generated INTEGER NOT NULL,
tokens_prompt INTEGER NOT NULL DEFAULT 0,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
)`,
);
// Add tokens_prompt column if it doesn't exist
const columnCheckResult = await db.all(
`PRAGMA table_info(tokens_generated);`,
);
const columnExists = columnCheckResult.some(
(col: any) => col.name === "tokens_prompt",
);
if (!columnExists) {
await db.exec(
`ALTER TABLE tokens_generated ADD COLUMN tokens_prompt INTEGER NOT NULL DEFAULT 0;`,
);
}
}
public static async logTokensGenerated(
model: string,
provider: string,
tokens: number,
promptTokens: number,
generatedTokens: number,
) {
const db = await DevDataSqliteDb.get();
await db?.run(
"INSERT INTO tokens_generated (model, provider, tokens_generated) VALUES (?, ?, ?)",
[model, provider, tokens],
`INSERT INTO tokens_generated (model, provider, tokens_prompt, tokens_generated) VALUES (?, ?, ?, ?)`,
[model, provider, promptTokens, generatedTokens],
);
}
public static async getTokensPerDay() {
const db = await DevDataSqliteDb.get();
// Return a sum of tokens_generated column aggregated by day
const result = await db?.all(
`SELECT date(timestamp) as day, sum(tokens_generated) as tokens
// Return a sum of tokens_generated and tokens_prompt columns aggregated by day
`SELECT date(timestamp) as day, sum(tokens_prompt) as promptTokens, sum(tokens_generated) as generatedTokens
FROM tokens_generated
GROUP BY date(timestamp)`,
// WHERE model = ? AND provider = ?
// [model, provider],
);
return result ?? [];
}
public static async getTokensPerModel() {
const db = await DevDataSqliteDb.get();
// Return a sum of tokens_generated column aggregated by model
const result = await db?.all(
`SELECT model, sum(tokens_generated) as tokens
// Return a sum of tokens_generated and tokens_prompt columns aggregated by model
`SELECT model, sum(tokens_prompt) as promptTokens, sum(tokens_generated) as generatedTokens
FROM tokens_generated
GROUP BY model`,
);

View file

@ -59,10 +59,14 @@ export function fetchwithRequestOptions(
: new HttpProxyAgent(proxy, agentOptions)
: new protocol.Agent(agentOptions);
const headers: { [key: string]: string } = requestOptions?.headers || {};
let headers: { [key: string]: string } = {};
for (const [key, value] of Object.entries(init?.headers || {})) {
headers[key] = value as string;
}
headers = {
...headers,
...requestOptions?.headers,
};
// Replace localhost with 127.0.0.1
if (url.hostname === "localhost") {

View file

@ -1,3 +1,4 @@
import { RangeInFileWithContents } from "../commands/util.js";
import {
ContextItemWithId,
ContextSubmenuItem,
@ -9,7 +10,6 @@ import {
Range,
Thread,
} from "../index.js";
import { RangeInFileWithContents } from "../commands/util.js";
import { Protocol } from "../protocol.js";
@ -86,8 +86,14 @@ export type WebviewProtocol = Protocol &
reloadWindow: [undefined, void];
focusEditor: [undefined, void];
toggleFullScreen: [undefined, void];
"stats/getTokensPerDay": [undefined, { day: string; tokens: number }[]];
"stats/getTokensPerModel": [undefined, { model: string; tokens: number }[]];
"stats/getTokensPerDay": [
undefined,
{ day: string; promptTokens: number; generatedTokens: number }[],
];
"stats/getTokensPerModel": [
undefined,
{ model: string; promptTokens: number; generatedTokens: number }[],
];
insertAtCursor: [{ text: string }, void];
copyText: [{ text: string }, void];
"jetbrains/editorInsetHeight": [{ height: number }, void];
@ -98,7 +104,8 @@ export type WebviewProtocol = Protocol &
| "optimized"
| "custom"
| "localExistingUser"
| "optimizedExistingUser";
| "optimizedExistingUser"
| "localAfterFreeTrial";
},
void,
];
@ -135,4 +142,6 @@ export type ReverseWebviewProtocol = {
setTheme: [{ theme: any }, void];
setColors: [{ [key: string]: string }, void];
"jetbrains/editorInsetRefresh": [undefined, void];
addApiKey: [undefined, void];
setupLocalModel: [undefined, void];
};

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
# OpenRouter
OpenRouter is a unified interface for commercial and open-source models, giving you access to the best models at the best prices. You can sign up [here](https://openrouter.ai/signup), create your API key on the [keys page](https://openrouter.ai/keys), and then choose a model from the [list of supported models](https://openrouter.ai/models).
Change `~/.continue/config.json` to look like the following. Since OpenRouter is fully API compatible with OpenAI, it is recommended to stick with `"provider": "openai"`, even if they aren't necessarily the upstream provider.
```json title="~/.continue/config.json"
{
"models": [
{
"title": "OpenRouter LLaMA 70 8B",
"provider": "openai",
"model": "meta-llama/llama-3-70b-instruct",
"apiBase": "https://openrouter.ai/api/v1",
"apiKey": "..."
}
]
}
```
To utilize features such as provider preferences or model routing configuration, include these parameters inside the `models[].requestsOptions.extraBodyProperties` field of your plugin config.
For example, to prevent extra long prompts from being compressed, you can explicitly turn off the feature like so:
```json title="~/.continue/config.json"
{
"models": [
{
...
"requestOptions": {
"extraBodyProperties": {
"transforms": []
}
}
}
]
}
```
Learn more about available settings [here](https://openrouter.ai/docs).

View file

@ -38,6 +38,9 @@ You can deploy a model in your [AWS](https://github.com/continuedev/deploy-os-co
## SaaS
You can access both open-source and commercial LLMs via:
* [OpenRouter](../reference/Model%20Providers/openrouter.md)
### Open-source models
You can deploy open-source LLMs on a service using:

View file

@ -1,9 +1,3 @@
{
"customCommands": [
{
"name": "hello",
"prompt": "{{{ input }}}\n\nWrite a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
"description": "This is an example custom command. Use /config to edit it and create more"
}
]
"customCommands": []
}

View file

@ -0,0 +1,28 @@
temperature: 0.0
---
{{{ diff }}}
Give me feedback on the above changes. For each file, you should output a markdown section including the following:
- If you found any problems, an h3 like "❌ <filename>"
- If you didn't find any problems, an h3 like "✅ <filename>"
- If you found any problems, add below a bullet point description of what you found, including a minimal code snippet explaining how to fix it
- If you didn't find any problems, you don't need to add anything else
Here is an example. The example is surrounded in backticks, but your response should not be:
```
### ✅ <Filename1>
### ❌ <Filename2>
<Description>
```
You should look primarily for the following types of issues, and only mention other problems if they are highly pressing.
- console.logs that have been left after debugging
- repeated code
- algorithmic errors that could fail under edge cases
- something that could be refactored
Make sure to review ALL files that were changed, do not skip any.

View file

@ -0,0 +1,17 @@
temperature: 0.5
maxTokens: 4096
---
<system>
You are an expert programmer
</system>
{{{ input }}}
Write unit tests for the above selected code, following each of these instructions:
- Use `jest`
- Properly set up and tear down
- Include important edge cases
- The tests should be complete and sophisticated
- Give the tests just as chat output, don't edit any file
- Don't explain how to set up `jest`
- Write a single code block, making sure to label with the language being used (e.g. "```typscript")

View file

@ -267,7 +267,10 @@
"apiType": {
"title": "Api Type",
"markdownDescription": "OpenAI API type, either `openai` or `azure`",
"enum": ["openai", "azure"]
"enum": [
"openai",
"azure"
]
},
"apiVersion": {
"title": "Api Version",
@ -280,7 +283,11 @@
"type": "string"
}
},
"required": ["title", "provider", "model"],
"required": [
"title",
"provider",
"model"
],
"allOf": [
{
"if": {
@ -290,7 +297,9 @@
}
},
"not": {
"required": ["provider"]
"required": [
"provider"
]
}
},
"then": {
@ -316,33 +325,48 @@
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"required": ["apiKey"]
"required": [
"apiKey"
]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["huggingface-tgi", "huggingface-inference-api"]
"enum": [
"huggingface-tgi",
"huggingface-inference-api"
]
}
}
},
"then": {
"required": ["apiBase"]
"required": [
"apiBase"
]
},
"required": ["provider"]
"required": [
"provider"
]
},
{
"if": {
"properties": {
"provider": {
"enum": ["openai"]
"enum": [
"openai"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -362,10 +386,14 @@
"if": {
"properties": {
"provider": {
"enum": ["openai"]
"enum": [
"openai"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -396,10 +424,14 @@
"if": {
"properties": {
"provider": {
"enum": ["replicate"]
"enum": [
"replicate"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -429,10 +461,14 @@
"if": {
"properties": {
"provider": {
"enum": ["free-trial"]
"enum": [
"free-trial"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -459,7 +495,9 @@
"if": {
"properties": {
"provider": {
"enum": ["openai"]
"enum": [
"openai"
]
},
"apiType": {
"not": {
@ -467,7 +505,9 @@
}
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -525,10 +565,14 @@
"if": {
"properties": {
"provider": {
"enum": ["anthropic"]
"enum": [
"anthropic"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -556,15 +600,22 @@
"if": {
"properties": {
"provider": {
"enum": ["cohere"]
"enum": [
"cohere"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
"model": {
"enum": ["command-r", "command-r-plus"]
"enum": [
"command-r",
"command-r-plus"
]
}
}
}
@ -573,10 +624,14 @@
"if": {
"properties": {
"provider": {
"enum": ["bedrock"]
"enum": [
"bedrock"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -601,10 +656,14 @@
"if": {
"properties": {
"provider": {
"enum": ["gemini"]
"enum": [
"gemini"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -622,10 +681,14 @@
"if": {
"properties": {
"provider": {
"enum": ["together"]
"enum": [
"together"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -659,10 +722,14 @@
"if": {
"properties": {
"provider": {
"enum": ["deepinfra"]
"enum": [
"deepinfra"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -685,7 +752,9 @@
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -731,10 +800,14 @@
"if": {
"properties": {
"provider": {
"enum": ["ollama"]
"enum": [
"ollama"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -782,10 +855,14 @@
"if": {
"properties": {
"provider": {
"enum": ["mistral"]
"enum": [
"mistral"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -806,10 +883,14 @@
"if": {
"properties": {
"provider": {
"enum": ["groq"]
"enum": [
"groq"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -833,20 +914,30 @@
"const": "azure"
}
},
"required": ["apiType"]
"required": [
"apiType"
]
},
"then": {
"required": ["engine", "apiVersion", "apiBase"]
"required": [
"engine",
"apiVersion",
"apiBase"
]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["openai"]
"enum": [
"openai"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -863,7 +954,9 @@
"const": "llamafile"
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -877,10 +970,14 @@
"if": {
"properties": {
"provider": {
"enum": ["text-gen-webui"]
"enum": [
"text-gen-webui"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -894,10 +991,14 @@
"if": {
"properties": {
"provider": {
"enum": ["flowise"]
"enum": [
"flowise"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"properties": {
@ -924,7 +1025,10 @@
"type": "string"
}
},
"required": ["key", "value"]
"required": [
"key",
"value"
]
}
},
"additionalFlowiseConfiguration": {
@ -943,7 +1047,10 @@
"description": "Configuration Property value"
}
},
"required": ["key", "value"]
"required": [
"key",
"value"
]
}
},
"model": {
@ -1032,7 +1139,9 @@
"type": "string"
}
},
"required": ["default"]
"required": [
"default"
]
},
"SlashCommand": {
"title": "SlashCommand",
@ -1091,7 +1200,9 @@
"if": {
"properties": {
"name": {
"enum": ["issue"]
"enum": [
"issue"
]
}
}
},
@ -1104,17 +1215,23 @@
"description": "Enter the URL of the GitHub repository for which you want to generate the issue."
}
},
"required": ["repositoryUrl"]
"required": [
"repositoryUrl"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["edit"]
"enum": [
"edit"
]
}
}
},
@ -1139,7 +1256,9 @@
"if": {
"properties": {
"name": {
"enum": ["share"]
"enum": [
"share"
]
}
}
},
@ -1157,7 +1276,10 @@
}
}
],
"required": ["name", "description"]
"required": [
"name",
"description"
]
},
"CustomCommand": {
"title": "CustomCommand",
@ -1176,7 +1298,11 @@
"type": "string"
}
},
"required": ["name", "prompt", "description"]
"required": [
"name",
"prompt",
"description"
]
},
"ContextProviderWithParams": {
"title": "ContextProviderWithParams",
@ -1249,7 +1375,9 @@
"if": {
"properties": {
"name": {
"enum": ["google"]
"enum": [
"google"
]
}
}
},
@ -1262,17 +1390,23 @@
"description": "Your API key for https://serper.dev in order to get Google search results"
}
},
"required": ["serperApiKey"]
"required": [
"serperApiKey"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["open"]
"enum": [
"open"
]
}
}
},
@ -1294,7 +1428,9 @@
"if": {
"properties": {
"name": {
"enum": ["issue"]
"enum": [
"issue"
]
}
}
},
@ -1323,24 +1459,37 @@
"type": {
"type": "string",
"description": "The type of issues to search for",
"enum": ["open", "closed", "all"]
"enum": [
"open",
"closed",
"all"
]
}
},
"required": ["owner", "repo"]
"required": [
"owner",
"repo"
]
}
}
},
"required": ["repos"]
"required": [
"repos"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["database"]
"enum": [
"database"
]
}
}
},
@ -1358,7 +1507,11 @@
"connection_type": {
"type": "string",
"description": "The type of database (e.g., 'postgres', 'mysql')",
"enum": ["postgres", "mysql", "sqlite"]
"enum": [
"postgres",
"mysql",
"sqlite"
]
},
"connection": {
"type": "object",
@ -1391,17 +1544,25 @@
"required": []
}
},
"required": ["name", "type", "connection"]
"required": [
"name",
"type",
"connection"
]
}
},
"required": ["connections"]
"required": [
"connections"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["gitlab-mr"]
"enum": [
"gitlab-mr"
]
}
}
},
@ -1422,17 +1583,23 @@
"description": "If you have code selected, filters out comments that aren't related to the selection."
}
},
"required": ["token"]
"required": [
"token"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["jira"]
"enum": [
"jira"
]
}
}
},
@ -1478,17 +1645,24 @@
]
}
},
"required": ["domain", "token"]
"required": [
"domain",
"token"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["http"]
"enum": [
"http"
]
}
}
},
@ -1501,17 +1675,24 @@
"description": "The HTTP endpoint of your context provider server."
}
},
"required": ["url"]
"required": [
"url"
]
}
},
"required": ["params"]
"required": [
"params"
]
}
},
{
"if": {
"properties": {
"name": {
"enum": ["codebase", "folder"]
"enum": [
"codebase",
"folder"
]
}
}
},
@ -1546,7 +1727,9 @@
"if": {
"properties": {
"name": {
"enum": ["postgres"]
"enum": [
"postgres"
]
}
}
},
@ -1598,11 +1781,19 @@
}
}
},
"required": ["host", "port", "user", "password", "database"]
"required": [
"host",
"port",
"user",
"password",
"database"
]
}
}
],
"required": ["name"]
"required": [
"name"
]
},
"SerializedContinueConfig": {
"title": "config.json",
@ -1753,32 +1944,46 @@
"$ref": "#/definitions/RequestOptions"
}
},
"required": ["provider"],
"required": [
"provider"
],
"allOf": [
{
"if": {
"properties": {
"provider": {
"enum": ["ollama"]
"enum": [
"ollama"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"required": ["model"]
"required": [
"model"
]
}
},
{
"if": {
"properties": {
"provider": {
"enum": ["cohere"]
"enum": [
"cohere"
]
}
},
"required": ["provider"]
"required": [
"provider"
]
},
"then": {
"required": ["apiKey"]
"required": [
"apiKey"
]
}
}
]
@ -1789,22 +1994,33 @@
"type": "object",
"properties": {
"name": {
"enum": ["cohere", "voyage", "llm", "free-trial"]
"enum": [
"cohere",
"voyage",
"llm",
"free-trial"
]
},
"params": {
"type": "object"
}
},
"required": ["name"],
"required": [
"name"
],
"allOf": [
{
"if": {
"properties": {
"name": {
"enum": ["cohere"]
"enum": [
"cohere"
]
}
},
"required": ["name"]
"required": [
"name"
]
},
"then": {
"properties": {
@ -1826,7 +2042,9 @@
"type": "string"
}
},
"required": ["apiKey"]
"required": [
"apiKey"
]
}
}
}
@ -1835,10 +2053,14 @@
"if": {
"properties": {
"name": {
"enum": ["llm"]
"enum": [
"llm"
]
}
},
"required": ["name"]
"required": [
"name"
]
},
"then": {
"properties": {
@ -1849,7 +2071,9 @@
"type": "string"
}
},
"required": ["modelTitle"]
"required": [
"modelTitle"
]
}
}
}
@ -1858,10 +2082,14 @@
"if": {
"properties": {
"name": {
"enum": ["voyage"]
"enum": [
"voyage"
]
}
},
"required": ["name"]
"required": [
"name"
]
},
"then": {
"properties": {
@ -1872,10 +2100,14 @@
"type": "string"
},
"model": {
"enum": ["rerank-lite-1"]
"enum": [
"rerank-lite-1"
]
}
},
"required": ["apiKey"]
"required": [
"apiKey"
]
}
}
}
@ -1931,7 +2163,11 @@
"description": "An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables."
},
"multilineCompletions": {
"enum": ["always", "never", "auto"],
"enum": [
"always",
"never",
"auto"
],
"description": "If set to true, Continue will only complete a single line at a time."
},
"useCache": {
@ -1960,7 +2196,10 @@
"type": "object",
"properties": {
"codeBlockToolbarPosition": {
"enum": ["top", "bottom"],
"enum": [
"top",
"bottom"
],
"default": "top",
"description": "Whether to show the copy and apply code buttons at the top or bottom of code blocks in the sidebar."
},
@ -1977,7 +2216,9 @@
"defaultContext": {
"type": "array",
"items": {
"enum": ["activeFile"]
"enum": [
"activeFile"
]
}
},
"modelRoles": {
@ -2017,7 +2258,10 @@
},
"mergeBehavior": {
"type": "string",
"enum": ["merge", "overwrite"],
"enum": [
"merge",
"overwrite"
],
"default": "merge",
"title": "Merge behavior",
"markdownDescription": "If set to 'merge', .continuerc.json will be applied on top of config.json (arrays and objects are merged). If set to 'overwrite', then every top-level property of .continuerc.json will overwrite that property from config.json."
@ -2025,4 +2269,4 @@
}
}
}
}
}

View file

@ -1,12 +0,0 @@
import { factorial, repeat } from "./factorial";
function fib(n) {
if (n <= 1) return n;
return fib(n - 2) + fib(n - 1);
}
let d = repeat(5, "a");
console.log(d);
let e = factorial(3);
console.log(e);

View file

@ -1,8 +0,0 @@
export function factorial(n) {
if (n <= 1) return 1;
return n * factorial(n - 1);
}
export function repeat(n: number, a: string) {
return a.repeat(n);
}

14877
extensions/vscode/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,9 @@ function execCmdSync(cmd) {
// Clear folders that will be packaged to ensure clean slate
rimrafSync(path.join(__dirname, "..", "bin"));
rimrafSync(path.join(__dirname, "..", "out"));
fs.mkdirSync(path.join(__dirname, "..", "out", "node_modules"), {
recursive: true,
});
// Get the target to package for
let target = undefined;
@ -102,13 +105,14 @@ const exe = os === "win32" ? ".exe" : "";
}
// Install node_modules //
// execCmdSync("pnpm install");
// console.log("[info] pnpm install in extensions/vscode completed");
execCmdSync("npm install");
console.log("[info] npm install in extensions/vscode completed");
console.log("Contents of node_modules: ", fs.readdirSync("./node_modules"));
process.chdir("../../gui");
execCmdSync("pnpm install");
console.log("[info] pnpm install in gui completed");
execCmdSync("npm install");
console.log("[info] npm install in gui completed");
if (ghAction()) {
execCmdSync("pnpm run build");
@ -309,7 +313,9 @@ const exe = os === "win32" ? ".exe" : "";
console.log(`Copying ${package} to ${toCopy}`);
// This is a way to install only one package without npm trying to install all the dependencies
// Create a temporary directory for installing the package
const tempDir = `/tmp/continue-node_modules-${toCopy}`;
const adjustedName = toCopy.replace(/^@/, "").replace("/", "-");
const tempDir = `/tmp/continue-node_modules-${adjustedName}`;
const currentDir = process.cwd();
// Remove the dir we will be copying to
@ -482,7 +488,7 @@ function validateFilesPresent() {
os === "darwin"
? "libonnxruntime.1.17.3.dylib"
: os === "linux"
? "libonnxruntime.so.1.17.3"
? "libonnxruntime.so.1.14.0"
: "onnxruntime.dll"
}`,
"builtin-themes/dark_modern.json",

View file

@ -214,7 +214,10 @@ export class VsCodeExtension {
// Listen for file changes in the workspace
const filepath = event.uri.fsPath;
if (filepath.endsWith(".continuerc.json")) {
if (
filepath.endsWith(".continuerc.json") ||
filepath.endsWith(".prompt")
) {
this.configHandler.reloadConfig();
this.tabAutocompleteModel.clearLlm();
} else if (

View file

@ -1,6 +1,7 @@
import { ContextItemId, IDE } from "core";
import { ConfigHandler } from "core/config/handler";
import {
setupLocalAfterFreeTrial,
setupLocalMode,
setupOptimizedExistingUserMode,
setupOptimizedMode,
@ -125,19 +126,45 @@ export class VsCodeWebviewProtocol {
}
}
vscode.window
.showErrorMessage(message, "Show Logs", "Troubleshooting")
.then((selection) => {
if (selection === "Show Logs") {
vscode.commands.executeCommand(
"workbench.action.toggleDevTools",
);
} else if (selection === "Troubleshooting") {
vscode.env.openExternal(
vscode.Uri.parse("https://docs.continue.dev/troubleshooting"),
);
}
});
if (message.includes("https://proxy-server")) {
message = message.split("\n").slice(1).join("\n").trim();
try {
message = JSON.parse(message).message;
} catch {}
if (message.includes("exceeded")) {
message +=
" To keep using Continue, you can set up a local model or use your own API key.";
} else {
message +=
" To avoid rate limiting, you can set up a local model or use your own API key.";
}
vscode.window
.showInformationMessage(message, "Add API Key", "Use Local Model")
.then((selection) => {
if (selection === "Add API Key") {
this.request("addApiKey", undefined);
} else if (selection === "Use Local Model") {
this.request("setupLocalModel", undefined);
}
});
} else {
vscode.window
.showErrorMessage(message, "Show Logs", "Troubleshooting")
.then((selection) => {
if (selection === "Show Logs") {
vscode.commands.executeCommand(
"workbench.action.toggleDevTools",
);
} else if (selection === "Troubleshooting") {
vscode.env.openExternal(
vscode.Uri.parse(
"https://docs.continue.dev/troubleshooting",
),
);
}
});
}
}
}
});
@ -621,9 +648,11 @@ export class VsCodeWebviewProtocol {
editConfigJson(
mode === "local"
? setupLocalMode
: mode === "optimized"
? setupOptimizedMode
: setupOptimizedExistingUserMode,
: mode === "localAfterFreeTrial"
? setupLocalAfterFreeTrial
: mode === "optimized"
? setupOptimizedMode
: setupOptimizedExistingUserMode,
);
this.configHandler.reloadConfig();
});

File diff suppressed because it is too large Load diff

14778
gui/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

8119
gui/pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -167,6 +167,25 @@ const Layout = () => {
setIndexingState(data);
});
useWebviewListener(
"addApiKey",
async () => {
navigate("/modelconfig/openai");
},
[navigate],
);
useWebviewListener(
"setupLocalModel",
async () => {
postToIde("completeOnboarding", {
mode: "localAfterFreeTrial",
});
navigate("/localOnboarding");
},
[navigate],
);
useEffect(() => {
if (isJetBrains()) {
return;
@ -250,7 +269,7 @@ const Layout = () => {
{indexingState.status !== "indexing" && // Would take up too much space together with indexing progress
defaultModel?.provider === "free-trial" &&
(location.pathname === "/settings" ||
parseInt(localStorage.getItem("ftc") || "0") >= 50) && (
parseInt(localStorage.getItem("ftc") || "0") >= 10) && (
<ProgressBar
completed={parseInt(localStorage.getItem("ftc") || "0")}
total={100}

View file

@ -23,18 +23,16 @@ function FTCDialog() {
<div className="p-4">
<h3>Free Trial Limit Reached</h3>
<p>
You've reached the free trial limit of 250 free inputs with Continue's
OpenAI API key. To keep using Continue, you can either use your own API
key, or use a local LLM. To read more about the options, see our{" "}
You've reached the free trial limit of 100 free inputs. To keep using
Continue, you can either use your own API key, or use a local LLM. To
read more about the options, see our{" "}
<a
href="https://docs.continue.dev/customization/models"
target="_blank"
>
documentation
</a>
. If you're just looking for fastest way to keep going, type '/config'
to open your Continue config file and paste your API key into the
OpenAIFreeTrial object.
.
</p>
<Input

View file

@ -0,0 +1,85 @@
import React from "react";
import { useDispatch } from "react-redux";
import { useNavigate } from "react-router-dom";
import styled from "styled-components";
import { Button, Input } from "..";
import { setDefaultModel } from "../../redux/slices/stateSlice";
import { setShowDialog } from "../../redux/slices/uiStateSlice";
import { ideRequest, postToIde } from "../../util/ide";
const GridDiv = styled.div`
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 8px;
align-items: center;
`;
function SetupLocalOrKeyDialog() {
const navigate = useNavigate();
const [apiKey, setApiKey] = React.useState("");
const dispatch = useDispatch();
return (
<div className="p-4">
<h3>Set up your own model</h3>
<p>
To keep using Continue after your free inputs, you can either use your
own API key, or use a local LLM. To read more about the options, see our{" "}
<a
className="cursor-pointer"
onClick={() =>
ideRequest(
"openUrl",
"https://docs.continue.dev/reference/Model%20Providers/freetrial",
)
}
>
documentation
</a>
.
</p>
<Input
type="text"
placeholder="Enter your OpenAI API key"
value={apiKey}
onChange={(e) => setApiKey(e.target.value)}
/>
<Button
className="w-full"
disabled={!apiKey}
onClick={() => {
postToIde("config/addOpenAiKey", apiKey);
dispatch(setShowDialog(false));
dispatch(setDefaultModel({ title: "GPT-4" }));
}}
>
Use my OpenAI API key
</Button>
<div className="text-center">— OR —</div>
<GridDiv>
<Button
onClick={() => {
dispatch(setShowDialog(false));
postToIde("completeOnboarding", {
mode: "localAfterFreeTrial",
});
navigate("/localOnboarding");
}}
>
Use local model
</Button>
<Button
onClick={() => {
dispatch(setShowDialog(false));
navigate("/models");
}}
>
View all options
</Button>
</GridDiv>
</div>
);
}
export default SetupLocalOrKeyDialog;

View file

@ -1,6 +1,13 @@
import ReactDOM from "react-dom";
import { useDispatch } from "react-redux";
import styled from "styled-components";
import { StyledTooltip, lightGray, vscForeground } from "..";
import {
setDialogMessage,
setShowDialog,
} from "../../redux/slices/uiStateSlice";
import { getFontSize } from "../../util";
import SetupLocalOrKeyDialog from "../dialogs/SetupLocalOrKey";
const ProgressBarWrapper = styled.div`
width: 100px;
@ -23,6 +30,7 @@ const GridDiv = styled.div`
grid-template-rows: 1fr auto;
align-items: center;
justify-items: center;
cursor: pointer;
`;
const P = styled.p`
@ -42,37 +50,46 @@ interface ProgressBarProps {
}
const ProgressBar = ({ completed, total }: ProgressBarProps) => {
const dispatch = useDispatch();
const fillPercentage = Math.min(100, Math.max(0, (completed / total) * 100));
const tooltipPortalDiv = document.getElementById("tooltip-portal-div");
return (
<>
<a
href="https://docs.continue.dev/reference/Model%20Providers/freetrial"
className="no-underline ml-2"
<GridDiv
data-tooltip-id="usage_progress_bar"
onClick={() => {
dispatch(setShowDialog(true));
dispatch(setDialogMessage(<SetupLocalOrKeyDialog />));
}}
>
<GridDiv data-tooltip-id="usage_progress_bar">
<ProgressBarWrapper>
<ProgressBarFill
completed={fillPercentage}
color={
completed / total > 0.75
? completed / total > 0.95
? "#f00"
: "#fc0"
: undefined
}
/>
</ProgressBarWrapper>
<P>
Free Uses: {completed} / {total}
</P>
</GridDiv>
</a>
<StyledTooltip id="usage_progress_bar" place="bottom">
{
"Continue allows you to use our OpenAI API key for up to 250 inputs. After this, you can either use your own API key, or use a local LLM. Click the progress bar to go to the docs and learn more."
}
</StyledTooltip>
<ProgressBarWrapper>
<ProgressBarFill
completed={fillPercentage}
color={
completed / total > 0.75
? completed / total > 0.9
? "#f00"
: "#fc0"
: undefined
}
/>
</ProgressBarWrapper>
<P>
Free Uses: {completed} / {total}
</P>
</GridDiv>
{tooltipPortalDiv &&
ReactDOM.createPortal(
<StyledTooltip id="usage_progress_bar" place="top">
{
"Click to use your own API key or local LLM (required after 100 inputs)"
}
</StyledTooltip>,
tooltipPortalDiv,
)}
</>
);
};

View file

@ -4,10 +4,10 @@ import {
AtSymbolIcon,
BeakerIcon,
BookOpenIcon,
ChevronDoubleRightIcon,
CodeBracketIcon,
Cog6ToothIcon,
CommandLineIcon,
CubeIcon,
ExclamationCircleIcon,
ExclamationTriangleIcon,
FolderIcon,
@ -82,8 +82,8 @@ function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
props.item.type === "contextProvider"
? props.item.id
: props.item.type === "slashCommand"
? props.item.id
: props.item.type;
? props.item.id
: props.item.type;
const Icon = ICONS_FOR_DROPDOWN[provider];
const iconClass = `${props.className} flex-shrink-0`;
@ -91,11 +91,7 @@ function DropdownIcon(props: { className?: string; item: ComboBoxItem }) {
return props.item.type === "contextProvider" ? (
<AtSymbolIcon className={iconClass} height="1.2em" width="1.2em" />
) : (
<ChevronDoubleRightIcon
className={iconClass}
height="1.2em"
width="1.2em"
/>
<CubeIcon className={iconClass} height="1.2em" width="1.2em" />
);
}
return <Icon className={iconClass} height="1.2em" width="1.2em" />;

View file

@ -37,7 +37,12 @@ function Stats() {
useNavigationListener();
const navigate = useNavigate();
const [days, setDays] = useState<{ day: string; tokens: number }[]>([]);
const [days, setDays] = useState<
{ day: string; promptTokens: number; generatedTokens: number }[]
>([]);
const [models, setModels] = useState<
{ model: string; promptTokens: number; generatedTokens: number }[]
>([]);
useEffect(() => {
ideRequest("stats/getTokensPerDay", undefined).then((days) => {
@ -45,8 +50,6 @@ function Stats() {
});
}, []);
const [models, setModels] = useState<{ model: string; tokens: number }[]>([]);
useEffect(() => {
ideRequest("stats/getTokensPerModel", undefined).then((models) => {
setModels(models);
@ -75,8 +78,12 @@ function Stats() {
<h2 className="ml-2">Tokens per Day</h2>
<CopyButton
text={generateTable(
([["Day", "Tokens"]] as any).concat(
days.map((day) => [day.day, day.tokens]),
([["Day", "Generated Tokens", "Prompt Tokens"]] as any).concat(
days.map((day) => [
day.day,
day.generatedTokens,
day.promptTokens,
]),
),
)}
/>
@ -85,14 +92,16 @@ function Stats() {
<thead>
<Tr>
<Th>Day</Th>
<Th>Tokens</Th>
<Th>Generated Tokens</Th>
<Th>Prompt Tokens</Th>
</Tr>
</thead>
<tbody>
{days.map((day) => (
<Tr key={day.day} className="">
<Td>{day.day}</Td>
<Td>{day.tokens}</Td>
<Td>{day.generatedTokens}</Td>
<Td>{day.promptTokens}</Td>
</Tr>
))}
</tbody>
@ -102,8 +111,12 @@ function Stats() {
<h2 className="ml-2">Tokens per Model</h2>
<CopyButton
text={generateTable(
([["Model", "Tokens"]] as any).concat(
models.map((model) => [model.model, model.tokens]),
([["Model", "Generated Tokens", "Prompt Tokens"]] as any).concat(
models.map((model) => [
model.model,
model.generatedTokens,
model.promptTokens,
]),
),
)}
/>
@ -112,14 +125,16 @@ function Stats() {
<thead>
<Tr>
<Th>Model</Th>
<Th>Tokens</Th>
<Th>Generated Tokens</Th>
<Th>Prompt Tokens</Th>
</Tr>
</thead>
<tbody>
{models.map((model) => (
<Tr key={model.model} className="">
<Td>{model.model}</Td>
<Td>{model.tokens}</Td>
<Td>{model.generatedTokens}</Td>
<Td>{model.promptTokens}</Td>
</Tr>
))}
</tbody>

View file

@ -1,15 +1,30 @@
const fs = require("fs");
const path = require("path");
const directories = ["./gui", "./core", "./extensions/vscode", "./binary"];
const directories = [
// gui
"./gui/node_modules",
"./gui/out",
"./gui/dist",
// core
"./core/node_modules",
"./core/dist",
// extensions/vscode
"./extensions/vscode/node_modules",
"./extensions/vscode/bin",
"./extensions/vscode/build",
"./extensions/vscode/out",
// binary
"./binary/node_modules",
"./binary/bin",
"./binary/dist",
"./binary/out",
];
directories.forEach((dir) => {
const nodeModulesPath = path.join(dir, "node_modules");
if (fs.existsSync(nodeModulesPath)) {
fs.rmdirSync(nodeModulesPath, { recursive: true });
console.log(`Removed ${nodeModulesPath}`);
if (fs.existsSync(dir)) {
fs.rmdirSync(dir, { recursive: true });
console.log(`Removed ${dir}`);
} else {
console.log(`No node_modules found in ${dir}`);
console.log(`${dir} not found`);
}
});