Merge branch 'dev' into nate/prompt-file-v2

This commit is contained in:
Nate 2024-11-05 22:52:14 -08:00
commit 66c97159ae
68 changed files with 678 additions and 3836 deletions

View file

@ -16,8 +16,9 @@ jobs:
repo-token: ${{ secrets.CI_GITHUB_TOKEN }}
assignees: sestinj,Patrick-Erichsen
numOfAssignee: 1
- name: Add default labels
- name: "Add default labels"
uses: actions-ecosystem/action-add-labels@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: "needs-triage"
labels: |
"needs-triage"

View file

@ -2,5 +2,8 @@
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all",
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"plugins": ["prettier-plugin-tailwindcss"]
}

View file

@ -1,19 +0,0 @@
temperature: 0.5
maxTokens: 4096
name: jest
description: Write Jest unit tests
---
<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")

25
.vscode/settings.json vendored
View file

@ -14,11 +14,26 @@
}
},
"search.exclude": {
"**/core/vendor/**": true,
"**/gui/dist": true,
"**/extensions/vscode/gui/**": true,
"**/extensions/vscode/out/**": true,
"**/extensions/intellij/build/**": true
"**/package-lock.json": true,
"binary/bin/**": true,
"binary/build/**": true,
"binary/out/**": true,
"binary/tmp/**": true,
"core/llm/llamaTokenizer.js": true,
"core/llm/llamaTokenizer.mjs": true,
"core/vendor/**": true,
"docs/.docusaurus/**": true,
"extensions/intellij/build/**": true,
"extensions/vscode/bin/**": true,
"extensions/vscode/build/**": true,
"extensions/vscode/gui/**": true,
"extensions/vscode/models/all-MiniLM-L6-v2/**": true,
"extensions/vscode/out/**": true,
"extensions/vscode/tag-qry/**": true,
"extensions/vscode/textmate-syntaxes/**": true,
"extensions/vscode/tree-sitter/**": true,
"gui/dist/**": true
// "sync/**": true
},
"eslint.workingDirectories": ["./core"]
}

2
.vscode/tasks.json vendored
View file

@ -41,7 +41,7 @@
"background": {
"activeOnStart": true,
"beginsPattern": ">",
"endsPattern": "node scripts/esbuild.js --sourcemap --watch"
"endsPattern": "VS Code Extension esbuild complete"
}
}
]

View file

@ -6,7 +6,7 @@ import {
} from "../";
export const DEFAULT_CHAT_MODEL_CONFIG: ModelDescription = {
model: "claude-3-5-sonnet-20240620",
model: "claude-3-5-sonnet-latest",
provider: "anthropic",
apiKey: "",
title: "Claude 3.5 Sonnet",
@ -23,7 +23,7 @@ export const FREE_TRIAL_MODELS: ModelDescription[] = [
{
title: "Claude 3.5 Sonnet (Free Trial)",
provider: "free-trial",
model: "claude-3-5-sonnet-20240620",
model: "claude-3-5-sonnet-latest",
systemMessage:
"You are an expert software developer. You give helpful and concise responses.",
},

View file

@ -648,6 +648,7 @@ declare global {
| "gemma-7b-it"
| "gemma2-9b-it"
// Anthropic
| "claude-3-5-sonnet-latest"
| "claude-3-5-sonnet-20240620"
| "claude-3-opus-20240229"
| "claude-3-sonnet-20240229"

View file

@ -17,7 +17,7 @@ class DiffContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const diff = await extras.ide.getDiff(false);
const diff = await extras.ide.getDiff(this.options.includeUnstaged ?? true);
return [
{
description: "The current git diff",

View file

@ -15,6 +15,7 @@ export class HuggingFaceTEIReranker implements Reranker {
apiBase?: string;
truncate?: boolean;
truncation_direction?: string;
apiKey?: string;
},
) {}
@ -24,9 +25,17 @@ export class HuggingFaceTEIReranker implements Reranker {
apiBase += "/";
}
const headers: Record<string, string> = {
"Content-Type": "application/json",
};
if (this.params.apiKey) {
headers["Authorization"] = `Bearer ${this.params.apiKey}`;
}
const resp = await fetch(new URL("rerank", apiBase), {
method: "POST",
headers: { "Content-Type": "application/json" },
headers,
body: JSON.stringify({
query: query,
return_text: false,

18
core/index.d.ts vendored
View file

@ -48,9 +48,9 @@ export interface IndexingProgressUpdate {
export type PromptTemplate =
| string
| ((
history: ChatMessage[],
otherData: Record<string, string>,
) => string | ChatMessage[]);
history: ChatMessage[],
otherData: Record<string, string>,
) => string | ChatMessage[]);
export interface ILLM extends LLMOptions {
get providerName(): ModelProvider;
@ -646,7 +646,8 @@ type ModelProvider =
| "cerebras"
| "askSage"
| "vertexai"
| "nebius";
| "nebius"
| "xAI";
export type ModelName =
| "AUTODETECT"
@ -696,6 +697,8 @@ export type ModelName =
| "llama3.2-3b"
| "llama3.2-11b"
| "llama3.2-90b"
// xAI
| "grok-beta"
// Other Open-source
| "phi2"
| "phind-codellama-34b"
@ -710,6 +713,7 @@ export type ModelName =
| "gemma-7b-it"
| "gemma2-9b-it"
// Anthropic
| "claude-3-5-sonnet-latest"
| "claude-3-5-sonnet-20240620"
| "claude-3-opus-20240229"
| "claude-3-sonnet-20240229"
@ -1053,9 +1057,9 @@ export interface Config {
embeddingsProvider?: EmbeddingsProviderDescription | EmbeddingsProvider;
/** The model that Continue will use for tab autocompletions. */
tabAutocompleteModel?:
| CustomLLM
| ModelDescription
| (CustomLLM | ModelDescription)[];
| CustomLLM
| ModelDescription
| (CustomLLM | ModelDescription)[];
/** Options for tab autocomplete */
tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
/** UI styles customization */

View file

@ -35,15 +35,18 @@ class DocsCrawler {
async *crawl(
startUrl: URL,
maxRequestsPerCrawl: number = this.MAX_REQUESTS_PER_CRAWL,
): AsyncGenerator<PageData> {
): AsyncGenerator<PageData, undefined, undefined> {
if (startUrl.host === this.GITHUB_HOST) {
yield* new GitHubCrawler(startUrl).crawl();
return;
}
try {
yield* new DefaultCrawler(startUrl).crawl();
return;
const pageData = await new DefaultCrawler(startUrl).crawl();
if (pageData.length > 0) {
yield* pageData;
return;
}
} catch (e) {
console.error("Default crawler failed, trying backup: ", e);
}

View file

@ -404,12 +404,15 @@ export default class DocsService {
async getFavicon(startUrl: string) {
const db = await this.getOrCreateSqliteDb();
const { favicon } = await db.get(
const result = await db.get(
`SELECT favicon FROM ${DocsService.sqlitebTableName} WHERE startUrl = ?`,
startUrl,
);
return favicon;
if (!result) {
return;
}
return result.favicon;
}
private async init(configHandler: ConfigHandler) {

View file

@ -6,7 +6,7 @@ import { PageData } from "../DocsCrawler";
export class DefaultCrawler {
constructor(private readonly startUrl: URL) {}
async *crawl(): AsyncGenerator<PageData> {
async crawl(): Promise<PageData[]> {
const resp = await fetch(new URL("crawl", TRIAL_PROXY_URL).toString(), {
method: "POST",
headers: {
@ -20,8 +20,6 @@ export class DefaultCrawler {
throw new Error(`Failed to crawl site: ${text}`);
}
const json = (await resp.json()) as PageData[];
for (const pageData of json) {
yield pageData;
}
return json;
}
}

View file

@ -299,30 +299,32 @@ const preIndexedDocs: Record<
rootUrl: "https://docs.godotengine.org/en/latest/",
faviconUrl: "https://godotengine.org/favicon.ico",
},
"https://docs.amplify.aws/react/": {
"https://docs.amplify.aws/react/start/": {
title: "AWS Amplify (Gen 2)",
startUrl: "https://docs.amplify.aws/react/start/",
rootUrl: "https://docs.amplify.aws/react/",
faviconUrl: "https://docs.amplify.aws/favicon.ico"
faviconUrl: "https://docs.amplify.aws/favicon.ico",
},
"https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/": {
title: "AWS SDK for JavaScript v3",
startUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/",
rootUrl: "https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/",
faviconUrl: "https://docs.aws.amazon.com/favicon.ico"
faviconUrl: "https://docs.aws.amazon.com/favicon.ico",
},
"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html": {
title: "AWS CDK v2",
startUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html",
startUrl:
"https://docs.aws.amazon.com/cdk/api/v2/docs/aws-construct-library.html",
rootUrl: "https://docs.aws.amazon.com/cdk/api/v2/docs/",
faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png"
faviconUrl: "https://docs.aws.amazon.com/cdk/api/v2/img/favicon-32x32.png",
},
"https://awscli.amazonaws.com/v2/documentation/api/latest/index.html": {
title: "AWS CLI commands",
startUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/index.html",
startUrl:
"https://awscli.amazonaws.com/v2/documentation/api/latest/index.html",
rootUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/",
faviconUrl: "https://docs.aws.amazon.com/favicon.ico"
}
faviconUrl: "https://docs.aws.amazon.com/favicon.ico",
},
};
export default preIndexedDocs;

View file

@ -146,7 +146,8 @@ function autodetectTemplateType(model: string): TemplateType | undefined {
lower.includes("command") ||
lower.includes("chat-bison") ||
lower.includes("pplx") ||
lower.includes("gemini")
lower.includes("gemini") ||
lower.includes("grok")
) {
return undefined;
}

View file

@ -11,16 +11,17 @@ import { streamSse } from "../stream.js";
class Anthropic extends BaseLLM {
static providerName: ModelProvider = "anthropic";
static defaultOptions: Partial<LLMOptions> = {
model: "claude-3-5-sonnet-20240620",
model: "claude-3-5-sonnet-latest",
contextLength: 200_000,
completionOptions: {
model: "claude-3-5-sonnet-20240620",
model: "claude-3-5-sonnet-latest",
maxTokens: 4096,
},
apiBase: "https://api.anthropic.com/v1/",
};
public convertArgs(options: CompletionOptions) { // should be public for use within VertexAI
public convertArgs(options: CompletionOptions) {
// should be public for use within VertexAI
const finalOptions = {
top_k: options.topK,
top_p: options.topP,
@ -34,53 +35,61 @@ class Anthropic extends BaseLLM {
return finalOptions;
}
public convertMessages(msgs: ChatMessage[]): any[] { // should be public for use within VertexAI
const filteredmessages = msgs.filter((m) => m.role !== "system")
const lastTwoUserMsgIndices = filteredmessages
public convertMessages(msgs: ChatMessage[]): any[] {
// should be public for use within VertexAI
const filteredmessages = msgs.filter((m) => m.role !== "system");
const lastTwoUserMsgIndices = filteredmessages
.map((msg, index) => (msg.role === "user" ? index : -1))
.filter((index) => index !== -1).slice(-2);
.filter((index) => index !== -1)
.slice(-2);
const messages = filteredmessages.map((message, filteredMsgIdx) => {
// Add cache_control parameter to the last two user messages
// The second-to-last because it retrieves potentially already cached contents,
// The last one because we want it cached for later retrieval.
// See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
const addCaching = this.cacheBehavior?.cacheConversation && lastTwoUserMsgIndices.includes(filteredMsgIdx);
// Add cache_control parameter to the last two user messages
// The second-to-last because it retrieves potentially already cached contents,
// The last one because we want it cached for later retrieval.
// See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
const addCaching =
this.cacheBehavior?.cacheConversation &&
lastTwoUserMsgIndices.includes(filteredMsgIdx);
if (typeof message.content === "string") {
var chatMessage = {
...message,
content: [{
type: "text",
text: message.content,
...(addCaching? { cache_control: { type: "ephemeral" } } : {})
}]
};
return chatMessage;
}
return {
if (typeof message.content === "string") {
var chatMessage = {
...message,
content: message.content.map((part, contentIdx) => {
if (part.type === "text") {
const newpart = {
...part,
// If multiple text parts, only add cache_control to the last one
...((addCaching && contentIdx == message.content.length - 1) ? { cache_control: { type: "ephemeral" } } : {})
};
return newpart;
}
return {
type: "image",
source: {
type: "base64",
media_type: "image/jpeg",
data: part.imageUrl?.url.split(",")[1],
},
};
}),
content: [
{
type: "text",
text: message.content,
...(addCaching ? { cache_control: { type: "ephemeral" } } : {}),
},
],
};
});
return chatMessage;
}
return {
...message,
content: message.content.map((part, contentIdx) => {
if (part.type === "text") {
const newpart = {
...part,
// If multiple text parts, only add cache_control to the last one
...(addCaching && contentIdx == message.content.length - 1
? { cache_control: { type: "ephemeral" } }
: {}),
};
return newpart;
}
return {
type: "image",
source: {
type: "base64",
media_type: "image/jpeg",
data: part.imageUrl?.url.split(",")[1],
},
};
}),
};
});
return messages;
}
@ -98,7 +107,8 @@ class Anthropic extends BaseLLM {
messages: ChatMessage[],
options: CompletionOptions,
): AsyncGenerator<ChatMessage> {
const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
const shouldCacheSystemMessage =
!!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
const systemMessage: string = stripImages(
messages.filter((m) => m.role === "system")[0]?.content,
);

View file

@ -164,7 +164,7 @@ class FreeTrial extends BaseLLM {
async listModels(): Promise<string[]> {
return [
"codestral-latest",
"claude-3-5-sonnet-20240620",
"claude-3-5-sonnet-latest",
"llama3.1-405b",
"llama3.1-70b",
"gpt-4o",

View file

@ -45,6 +45,7 @@ import VertexAI from "./VertexAI";
import Vllm from "./Vllm";
import WatsonX from "./WatsonX";
import ContinueProxy from "./stubs/ContinueProxy";
import xAI from "./xAI";
const LLMs = [
Anthropic,
@ -85,6 +86,7 @@ const LLMs = [
Asksage,
Nebius,
VertexAI,
xAI,
];
export async function llmFromDescription(

20
core/llm/llms/xAI.ts Normal file
View file

@ -0,0 +1,20 @@
import { LLMOptions, ModelProvider } from "../../index.js";
import OpenAI from "./OpenAI.js";
class xAI extends OpenAI {
static providerName: ModelProvider = "xAI";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.x.ai/v1/",
};
private static MODEL_IDS: { [name: string]: string } = {
"grok-beta": "grok-beta", // Future names might not line up
};
protected _convertModelName(model: string) {
return xAI.MODEL_IDS[model] || this.model;
}
}
export default xAI;

View file

@ -25,7 +25,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz
{
"title": "Claude 3.5 Sonnet",
"provider": "anthropic",
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"apiKey": "[ANTHROPIC_API_KEY]"
}
]

View file

@ -19,7 +19,7 @@ We recommend configuring **Claude 3.5 Sonnet** as your chat model.
{
"title": "Claude 3.5 Sonnet",
"provider": "anthropic",
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"apiKey": "[API_KEY]"
}
]
@ -61,7 +61,7 @@ To enable caching of the system message and the turn-by-turn conversation, updat
},
"title": "Anthropic",
"provider": "anthropic",
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"apiKey": "[API_KEY]"
}
]

View file

@ -0,0 +1,53 @@
---
title: xAI
slug: ../xai
---
:::info
You can get an API key from the [xAI console](https://console.x.ai/)
:::
## Chat model
We recommend configuring **grok-beta** as your chat model.
```json title="config.json"
{
"models": [
{
"title": "Grok Beta",
"provider": "xAI",
"model": "grok-beta",
"apiKey": "[API_KEY]"
}
]
}
```
## Autocomplete model
xAI currently does not offer any autocomplete models.
[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers.
## Embeddings model
xAI currently does not offer any embeddings models.
[Click here](../../model-types/embeddings.md) to see a list of embeddings model providers.
## Reranking model
xAI currently does not offer any reranking models.
[Click here](../../model-types/reranking.md) to see a list of reranking model providers.
## Legacy Completions
To force usage of `chat/completions` instead of `completions` endpoint you can set
```json
"useLegacyCompletionsEndpoint": false
```

View file

@ -72,6 +72,7 @@ The `"modelTitle"` field must match one of the models in your "models" array in
"name": "huggingface-tei",
"params": {
"apiBase": "http://localhost:8080",
"apiKey": "<TEI_API_KEY>",
"truncate": true,
"truncation_direction": "Right"
}

View file

@ -421,7 +421,7 @@ Several experimental config parameters are available, as described below:
- `fix`: Prompt for fixing code.
- `optimize`: Prompt for optimizing code.
- `fixGrammar`: Prompt for fixing grammar or spelling.
- `useChromiumForDocsCrawling`: Use chromium to crawl docs instead of default lighter-weight tool that can't render sites. Downloads and installs Chromium to `~/.continue/.utils`.
- `useChromiumForDocsCrawling`: Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`..
Example

View file

@ -1,4 +1,5 @@
src/main/resources/webview
!src/main/resources/webview/index.html
src/main/resources/bin
src/main/resources/config_schema.json
src/main/resources/continue_rc_schema.json

View file

@ -14,7 +14,7 @@ const val DEFAULT_CONFIG =
{
"models": [
{
"model": "claude-3-5-sonnet-20240620",
"model": "claude-3-5-sonnet-latest",
"provider": "anthropic",
"apiKey": "",
"title": "Claude 3.5 Sonnet"

View file

@ -22,7 +22,7 @@ class ConfigJsonSchemaProviderFactory : JsonSchemaProviderFactory {
class ConfigJsonSchemaFileProvider : JsonSchemaFileProvider {
override fun isAvailable(file: VirtualFile): Boolean {
return path.endsWith("/.continue/config.json")
return file.path.endsWith("/.continue/config.json")
}
override fun getName(): String {

View file

@ -2,10 +2,12 @@ package com.github.continuedev.continueintellijextension.services
import com.github.continuedev.continueintellijextension.constants.getConfigJsPath
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.SystemInfo
import com.intellij.util.concurrency.AppExecutorUtil
import com.intellij.util.messages.Topic
import kotlinx.serialization.Serializable
@ -28,6 +30,7 @@ class ContinueSettingsComponent : DumbAware {
val userToken: JTextField = JTextField()
val enableTabAutocomplete: JCheckBox = JCheckBox("Enable Tab Autocomplete")
val enableContinueTeamsBeta: JCheckBox = JCheckBox("Enable Continue for Teams Beta")
val enableOSR: JCheckBox = JCheckBox("Enable Off-Screen Rendering")
val displayEditorTooltip: JCheckBox = JCheckBox("Display Editor Tooltip")
init {
@ -56,6 +59,8 @@ class ContinueSettingsComponent : DumbAware {
constraints.gridy++
panel.add(enableContinueTeamsBeta, constraints)
constraints.gridy++
panel.add(enableOSR, constraints)
constraints.gridy++
panel.add(displayEditorTooltip, constraints)
constraints.gridy++
@ -87,6 +92,7 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
var enableTabAutocomplete: Boolean = true
var ghAuthToken: String? = null
var enableContinueTeamsBeta: Boolean = false
var enableOSR: Boolean = shouldRenderOffScreen()
var displayEditorTooltip: Boolean = true
}
@ -107,6 +113,7 @@ open class ContinueExtensionSettings : PersistentStateComponent<ContinueExtensio
get() = ServiceManager.getService(ContinueExtensionSettings::class.java)
}
// Sync remote config from server
private fun syncRemoteConfig() {
val state = instance.continueState
@ -198,6 +205,7 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.userToken?.text != settings.continueState.userToken ||
mySettingsComponent?.enableTabAutocomplete?.isSelected != settings.continueState.enableTabAutocomplete ||
mySettingsComponent?.enableContinueTeamsBeta?.isSelected != settings.continueState.enableContinueTeamsBeta ||
mySettingsComponent?.enableOSR?.isSelected != settings.continueState.enableOSR ||
mySettingsComponent?.displayEditorTooltip?.isSelected != settings.continueState.displayEditorTooltip
return modified
}
@ -210,6 +218,7 @@ class ContinueExtensionConfigurable : Configurable {
settings.continueState.enableTabAutocomplete = mySettingsComponent?.enableTabAutocomplete?.isSelected ?: false
settings.continueState.enableContinueTeamsBeta =
mySettingsComponent?.enableContinueTeamsBeta?.isSelected ?: false
settings.continueState.enableOSR = mySettingsComponent?.enableOSR?.isSelected ?: true
settings.continueState.displayEditorTooltip = mySettingsComponent?.displayEditorTooltip?.isSelected ?: true
ApplicationManager.getApplication().messageBus.syncPublisher(SettingsListener.TOPIC)
@ -224,6 +233,7 @@ class ContinueExtensionConfigurable : Configurable {
mySettingsComponent?.userToken?.text = settings.continueState.userToken
mySettingsComponent?.enableTabAutocomplete?.isSelected = settings.continueState.enableTabAutocomplete
mySettingsComponent?.enableContinueTeamsBeta?.isSelected = settings.continueState.enableContinueTeamsBeta
mySettingsComponent?.enableOSR?.isSelected = settings.continueState.enableOSR
mySettingsComponent?.displayEditorTooltip?.isSelected = settings.continueState.displayEditorTooltip
ContinueExtensionSettings.instance.addRemoteSyncJob()
@ -237,3 +247,38 @@ class ContinueExtensionConfigurable : Configurable {
return "Continue Extension Settings"
}
}
/**
* This function checks if off-screen rendering (OSR) should be used.
*
* If ui.useOSR is set in config.json, that value is used.
*
* Otherwise, we check if the pluginSinceBuild is greater than or equal to 233, which corresponds
* to IntelliJ platform version 2023.3 and later.
*
* Setting `setOffScreenRendering` to `false` causes a number of issues such as a white screen flash when loading
* the GUI and the inability to set `cursor: pointer`. However, setting `setOffScreenRendering` to `true` on
* platform versions prior to 2023.3.4 causes larger issues such as an inability to type input for certain languages,
* e.g. Korean.
*
* References:
* 1. https://youtrack.jetbrains.com/issue/IDEA-347828/JCEF-white-flash-when-tool-window-show#focus=Comments-27-9334070.0-0
* This issue mentions that white screen flash problems were resolved in platformVersion 2023.3.4.
* 2. https://www.jetbrains.com/idea/download/other.html
* This documentation shows mappings from platformVersion to branchNumber.
*
* We use the branchNumber (e.g., 233) instead of the full version number (e.g., 2023.3.4) because
* it's a simple integer without dot notation, making it easier to compare.
*/
private fun shouldRenderOffScreen(): Boolean {
// With the 0.0.77 release, non-Mac users have been reporting issues with paste functionality
// in the browser. Disabling OSR for all non-Mac users for now.
if (!SystemInfo.isMac) {
return false
}
val minBuildNumber = 233
val applicationInfo = ApplicationInfo.getInstance()
val currentBuildNumber = applicationInfo.build.baselineVersion
return currentBuildNumber >= minBuildNumber
}

View file

@ -5,6 +5,7 @@ import com.github.continuedev.continueintellijextension.constants.MessageTypes
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
import com.github.continuedev.continueintellijextension.`continue`.*
import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
import com.google.gson.Gson
import com.google.gson.JsonObject
@ -78,7 +79,8 @@ class ContinueBrowser(val project: Project, url: String) {
val browser: JBCefBrowser
init {
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(shouldRenderOffScreen()).build()
val enableOSR = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR
this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(enableOSR).build()
browser.jbCefClient.setProperty(
@ -274,34 +276,4 @@ class ContinueBrowser(val project: Project, url: String) {
return """window.postMessage($jsonData, "*");"""
}
/**
* This function checks if the pluginSinceBuild is greater than or equal to 233, which corresponds
* to IntelliJ platform version 2023.3 and later.
*
* Setting `setOffScreenRendering` to `false` causes a number of issues such as a white screen flash when loading
* the GUI and the inability to set `cursor: pointer`. However, setting `setOffScreenRendering` to `true` on
* platform versions prior to 2023.3.4 causes larger issues such as an inability to type input for certain langauges,
* e.g. Korean.
*
* References:
* 1. https://youtrack.jetbrains.com/issue/IDEA-347828/JCEF-white-flash-when-tool-window-show#focus=Comments-27-9334070.0-0
* This issue mentions that white screen flash problems were resolved in platformVersion 2023.3.4.
* 2. https://www.jetbrains.com/idea/download/other.html
* This documentation shows mappings from platformVersion to branchNumber.
*
* We use the branchNumber (e.g., 233) instead of the full version number (e.g., 2023.3.4) because
* it's a simple integer without dot notation, making it easier to compare.
*/
private fun shouldRenderOffScreen(): Boolean {
// With the 0.0.77 release, non-Mac users have been reporting issues with paste functionality
// in the browser. Disabling OSR for all non-Mac users for now.
if (!SystemInfo.isMac) {
return false
}
val minBuildNumber = 233
val applicationInfo = ApplicationInfo.getInstance()
val currentBuildNumber = applicationInfo.build.baselineVersion
return currentBuildNumber >= minBuildNumber
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.4742 1.6668L9.77141 2.88516L11.5477 5.95951C11.5607 5.98283 11.5685 6.01135 11.5685 6.03728C11.5685 6.0632 11.5607 6.09172 11.5477 6.11505L9.77141 9.19199L10.4742 10.4104L13 6.03728L10.4742 1.66421V1.6668ZM9.4991 2.72702L10.2019 1.50867H8.79634L8.09357 2.72702H9.5017H9.4991ZM8.09097 3.0433L9.73249 5.88173H11.138L9.4991 3.0433H8.09097ZM9.4991 9.03645L11.138 6.19542H9.73249L8.09097 9.03645H9.4991ZM8.09097 9.35273L8.79374 10.5659H10.1993L9.4965 9.35273H8.08837H8.09097ZM3.32716 10.8666C3.29864 10.8666 3.27271 10.8588 3.24939 10.8458C3.22599 10.8329 3.20527 10.8122 3.19227 10.7889L1.41332 7.71183H0.00777705L2.53362 12.0824H7.58267L6.87991 10.8666H3.32976H3.32716ZM7.15222 10.7085L7.85498 11.9242L8.55775 10.7059L7.85498 9.48755L7.15222 10.7059V10.7085ZM7.58267 9.33201H4.30484L3.60207 10.5503H6.87991L7.58267 9.33201ZM4.02992 9.17647L2.38841 6.33536L1.68562 7.55376L3.32716 10.3948L4.02992 9.17647ZM0.00518489 7.39562H1.41073L2.1135 6.17729H0.71055L0.00518489 7.39562ZM3.18454 1.29611C3.19746 1.27278 3.21826 1.25205 3.24159 1.23908C3.26491 1.22612 3.29344 1.21834 3.31936 1.21834H6.87471L7.57747 0H2.52582L0 4.37305H1.40555L3.17934 1.29871L3.18454 1.29611ZM2.1135 5.90506L1.41073 4.68673H0.00518489L0.707957 5.90506H2.1135ZM3.32196 1.69013L1.68303 4.52859L2.38581 5.74699L4.02472 2.90848L3.32196 1.69013ZM6.87731 1.532H3.59427L4.29704 2.75034H7.58007L6.87731 1.532ZM7.85498 2.5922L8.55515 1.37647L7.85498 0.158126L7.15222 1.37388L7.85498 2.5922Z" fill="#6C707E"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1,3 +0,0 @@
{
"customCommands": []
}

View file

@ -10,7 +10,7 @@ exe
bin
assets
gui/*
gui/**
!gui/onigasm.wasm
.devcontainer

View file

@ -1,28 +0,0 @@
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

@ -1,17 +0,0 @@
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

@ -201,7 +201,8 @@
"cerebras",
"askSage",
"nebius",
"vertexai"
"vertexai",
"xAI"
],
"markdownEnumDescriptions": [
"### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)",
@ -236,7 +237,8 @@
"### NVIDIA NIMs\nNVIDIA offers a single API to access almost any language model. To find out more, visit the [LLM APIs Documentation](https://docs.api.nvidia.com/nim/reference/llm-apis).\nFor information specific to getting a key, please check out the [docs here](https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html#option-1-from-api-catalog)",
"### vLLM\nvLLM is a highly performant way of hosting LLMs for a team. To get started, follow their [quickstart](https://docs.vllm.ai/en/latest/getting_started/quickstart.html) to set up your server.",
"### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/).",
"### Ask Sage\nAsk Sage is an agnostic hosted service that provides language models. To get started with Ask Sage:\n1. Obtain an API key from your account. For more information, visit [Ask Sage](https://docs.asksage.ai/).\n2. Paste the API key below.\n3. Select a model preset.\n> [Reference](https://docs.asksage.ai/)"
"### Ask Sage\nAsk Sage is an agnostic hosted service that provides language models. To get started with Ask Sage:\n1. Obtain an API key from your account. For more information, visit [Ask Sage](https://docs.asksage.ai/).\n2. Paste the API key below.\n3. Select a model preset.\n> [Reference](https://docs.asksage.ai/)",
"### xAI offers a world class developer tool set to build scalable applications powered by Grok. To get started, obtain an API key from [the x Console](https://console.x.ai/), and see the [docs](https://docs.x.ai/docs/)"
],
"type": "string"
},
@ -471,7 +473,8 @@
"together",
"cloudflare",
"sambanova",
"nebius"
"nebius",
"xAI"
]
}
},
@ -655,6 +658,37 @@
}
}
},
{
"if": {
"properties": {
"provider": {
"enum": [
"xAI"
]
}
},
"required": [
"provider"
]
},
"then": {
"properties": {
"model": {
"anyOf": [
{
"enum": [
"grok-beta",
"AUTODETECT"
]
},
{
"type": "string"
}
]
}
}
}
},
{
"if": {
"properties": {
@ -719,7 +753,7 @@
"llama3.1-405b",
"gpt-3.5-turbo",
"gemini-pro",
"claude-3-5-sonnet-20240620",
"claude-3-5-sonnet-latest",
"claude-3-haiku-20240307",
"AUTODETECT"
]
@ -834,7 +868,7 @@
"enum": [
"claude-2",
"claude-instant-1",
"claude-3-5-sonnet-20240620",
"claude-3-5-sonnet-latest",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"claude-3-haiku-20240307",
@ -1301,7 +1335,10 @@
]
},
"then": {
"required": ["deployment", "apiBase"]
"required": [
"deployment",
"apiBase"
]
}
},
{
@ -1491,6 +1528,7 @@
"deepseek-33b",
"claude-2",
"claude-instant-1",
"claude-3-5-sonnet-latest",
"claude-3-5-sonnet-20240620",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
@ -2962,6 +3000,9 @@
"type": "string",
"default": "http://localhost:8080"
},
"apiKey": {
"type": "string"
},
"truncate": {
"type": "boolean",
"description": "Whether to truncate long sequences to the maximum allowed context length.",
@ -3279,6 +3320,11 @@
"default": "If there are any grammar or spelling mistakes in this writing, fix them. Do not make other large changes to the writing."
}
}
},
"useChromiumForDocsCrawling": {
"type": "boolean",
"description": "Use Chromium to crawl docs locally. Useful if the default Cheerio crawler fails on sites that require JavaScript rendering. Downloads and installs Chromium to `~/.continue/.utils`.",
"default": false
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/play_button.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Continue</title>
<script type="module" crossorigin src="/assets/index.js"></script>
<link rel="stylesheet" href="/assets/index.css">
</head>
<body>
<div id="root"></div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1,017 B

View file

@ -2,7 +2,7 @@
"name": "continue",
"icon": "media/icon.png",
"author": "Continue Dev, Inc",
"version": "0.9.225",
"version": "0.9.226",
"repository": {
"type": "git",
"url": "https://github.com/continuedev/continue"

View file

@ -30,4 +30,5 @@ const esbuildConfig = {
} else {
await esbuild.build(esbuildConfig);
}
})();
console.log("VS Code Extension esbuild complete"); // Used in task endpattern to signal completion
})();

View file

@ -18,8 +18,8 @@ function copyConfigSchema() {
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.",
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.",
"x-intellij-html-description": "<p>If set to <code>merge</code>, <code>.continuerc.json</code> will be applied on top of <code>config.json</code> (arrays and objects are merged). If set to <code>overwrite</code>, then every top-level property of <code>.continuerc.json</code> will overwrite that property from <code>config.json</code>.</p>"
};
fs.writeFileSync("continue_rc_schema.json", JSON.stringify(schema, null, 2));

2
gui/package-lock.json generated
View file

@ -37,7 +37,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.47.0",
"react-intersection-observer": "^9.10.3",
"react-intersection-observer": "^9.13.1",
"react-markdown": "^9.0.1",
"react-redux": "^8.0.5",
"react-remark": "^2.1.0",

View file

@ -45,7 +45,7 @@
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.47.0",
"react-intersection-observer": "^9.10.3",
"react-intersection-observer": "^9.13.1",
"react-markdown": "^9.0.1",
"react-redux": "^8.0.5",
"react-remark": "^2.1.0",

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -1,5 +1,4 @@
import {
ArrowPathIcon,
BarsArrowDownIcon,
HandThumbDownIcon,
HandThumbUpIcon,
@ -14,7 +13,7 @@ import { vscBackground, vscInputBackground } from "..";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import useUIConfig from "../../hooks/useUIConfig";
import { RootState } from "../../redux/store";
import { getFontSize } from "../../util";
import { getFontSize, getMetaKeyLabel } from "../../util";
import ButtonWithTooltip from "../ButtonWithTooltip";
import { CopyButton } from "../markdown/CopyButton";
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
@ -50,7 +49,7 @@ function StepContainer(props: StepContainerProps) {
const isUserInput = props.item.message.role === "user";
const uiConfig = useUIConfig();
const shouldRenderActions = !props.isLast || (props.isLast && !active);
const shouldRenderActions = !active || !props.isLast;
useEffect(() => {
if (!active) {
@ -84,7 +83,11 @@ function StepContainer(props: StepContainerProps) {
};
return (
<div className="relative">
<div className="relative"
style={{
minHeight: props.isLast ? "50vh" : 0
}}
>
<ContentDiv
hidden={!props.open}
isUserInput={isUserInput}
@ -104,52 +107,55 @@ function StepContainer(props: StepContainerProps) {
/>
)}
</ContentDiv>
{shouldRenderActions && (
<div className="flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 p-2 pb-0 cursor-default">
{truncatedEarly && (
<ButtonWithTooltip
tabIndex={-1}
text="Continue generation"
onClick={props.onContinueGeneration}
>
<BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
{props.index !== 1 && (
<ButtonWithTooltip
text="Delete"
tabIndex={-1}
onClick={props.onDelete}
>
<TrashIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
clipboardIconClassName="h-3.5 w-3.5 text-gray-500"
/>
<div className="h-7 mb-2 mx-2 flex items-center justify-end gap-0.5 xs:flex text-xs text-gray-400 pb-0 cursor-default"
style={{
opacity: shouldRenderActions ? 1 : 0,
pointerEvents: shouldRenderActions ? "auto" : "none"
}}
>
{truncatedEarly && (
<ButtonWithTooltip
text="Helpful"
tabIndex={-1}
onClick={() => sendFeedback(true)}
text="Continue generation"
onClick={props.onContinueGeneration}
>
<HandThumbUpIcon className="h-3.5 w-3.5 text-gray-500 mx-0.5" />
<BarsArrowDownIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
)}
{props.index !== 1 && (
<ButtonWithTooltip
text="Unhelpful"
text="Delete"
tabIndex={-1}
onClick={() => sendFeedback(false)}
onClick={props.onDelete}
>
<HandThumbDownIcon className="h-3.5 w-3.5 text-gray-500" />
<TrashIcon className="h-3.5 w-3.5 text-gray-500" />
</ButtonWithTooltip>
</div>
)}
)}
<CopyButton
tabIndex={-1}
text={stripImages(props.item.message.content)}
clipboardIconClassName="h-3.5 w-3.5 text-gray-500"
checkIconClassName="h-3.5 w-3.5 text-green-400"
/>
<ButtonWithTooltip
text="Helpful"
tabIndex={-1}
onClick={() => sendFeedback(true)}
>
<HandThumbUpIcon className={`h-3.5 w-3.5 mx-0.5 ${feedback === true ? 'text-green-400' : 'text-gray-500'}`} />
</ButtonWithTooltip>
<ButtonWithTooltip
text="Unhelpful"
tabIndex={-1}
onClick={() => sendFeedback(false)}
>
<HandThumbDownIcon className={`h-3.5 w-3.5 ${feedback === false ? 'text-red-400' : 'text-gray-500'}`} />
</ButtonWithTooltip>
</div>
</div>
);
}

View file

@ -109,7 +109,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
}, [isGatheringContextStore]);
return (
<div className={`mb-1 mt-3 ${props.hidden ? "hidden" : ""}`}>
<div className={`mb-1 ${props.hidden ? "hidden" : ""}`}>
<div className={`relative flex px-2`}>
<GradientBorder
loading={active && props.isLastUserInput ? 1 : 0}

View file

@ -50,9 +50,11 @@ import {
getFontSize,
isJetBrains,
isMetaEquivalentKeyPressed,
isWebEnvironment,
} from "../../util";
import { handleMetaKeyPressJetBrains } from "../../util/handleMetaKeyPressJetBrains";
import {
handleJetBrainsMetaKeyPress,
handleMetaKeyPress,
} from "./handleMetaKeyPress";
import { CodeBlockExtension } from "./CodeBlockExtension";
import { SlashCommand } from "./CommandsExtension";
import InputToolbar, { ToolbarOptions } from "./InputToolbar";
@ -78,6 +80,7 @@ const InputBoxDiv = styled.div<{ border?: string }>`
props.border ? props.border : `0.5px solid ${vscInputBorder}`};
outline: none;
font-size: ${getFontSize()}px;
&:focus {
outline: none;
@ -561,86 +564,36 @@ function TipTapEditor(props: TipTapEditorProps) {
/**
* This handles various issues with meta key actions
* - In JetBrains, when using "off screen rendering", there is a bug where using the meta key to
* - In JetBrains, when using OSR in JCEF, there is a bug where using the meta key to
* highlight code using arrow keys is not working
* - In VS Code, while working with .ipynb files there is a problem where copy/paste/cut will affect
* the actual notebook cells, even when performing them in our GUI
*
* Currently keydown events for a number of keys are not registering if the
* meta/shift key is pressed, for example "x", "c", "v", "z", etc.
* Until this is resolved we can't turn on OSR for non-Mac users due to issues
* with those key actions.
*/
const handleKeyDown = async (e: KeyboardEvent<HTMLDivElement>) => {
if (!editor || !editorFocusedRef.current) return;
setActiveKey(e.key);
if (isMetaEquivalentKeyPressed(e)) {
const { key, code } = e;
const isWebEnv = isWebEnvironment();
const text = editor.state.doc.textBetween(
editor.state.selection.from,
editor.state.selection.to,
);
if (isJetBrains()) {
if (code === "KeyJ") {
e.stopPropagation();
e.preventDefault();
setIgnoreHighlightedCode(true);
setTimeout(() => {
setIgnoreHighlightedCode(false);
}, 100);
}
if (isMetaEquivalentKeyPressed(e)) {
e.stopPropagation();
e.preventDefault();
handleMetaKeyPressJetBrains(e, text, editor.commands.setContent);
}
} else {
if (code === "KeyL") {
e.stopPropagation();
e.preventDefault();
setIgnoreHighlightedCode(true);
setTimeout(() => {
setIgnoreHighlightedCode(false);
}, 100);
return;
}
switch (key) {
case "x":
e.stopPropagation();
e.preventDefault();
if (isWebEnv) {
await navigator.clipboard.writeText(text);
editor.commands.deleteSelection();
} else {
document.execCommand("cut");
}
break;
case "c":
e.stopPropagation();
e.preventDefault();
if (isWebEnv) {
await navigator.clipboard.writeText(text);
} else {
document.execCommand("copy");
}
break;
case "v":
e.stopPropagation();
e.preventDefault();
if (isWebEnv) {
const clipboardText = await navigator.clipboard.readText();
editor.commands.insertContent(clipboardText);
} else {
document.execCommand("paste");
}
break;
}
}
} else if (e.key === "Escape") {
// Allow users to use the escape key to jump back to the editor
if (e.key === "Escape") {
e.stopPropagation();
e.preventDefault();
ideMessenger.post("focusEditor", undefined);
return;
}
// Handle meta key issues
if (isMetaEquivalentKeyPressed(e)) {
if (isJetBrains()) {
handleJetBrainsMetaKeyPress(e, editor);
}
await handleMetaKeyPress(e, editor);
}
};
@ -671,9 +624,6 @@ function TipTapEditor(props: TipTapEditorProps) {
[props.onEnter, editor, props.isMainInput],
);
// This is a mechanism for overriding the IDE keyboard shortcut when inside of the webview
const [ignoreHighlightedCode, setIgnoreHighlightedCode] = useState(false);
// Re-focus main input after done generating
useEffect(() => {
if (editor && !active && props.isMainInput && document.hasFocus()) {
@ -748,71 +698,68 @@ function TipTapEditor(props: TipTapEditorProps) {
if (!props.isMainInput || !editor) {
return;
}
if (!ignoreHighlightedCode) {
const rif: RangeInFile & { contents: string } =
data.rangeInFileWithContents;
const basename = getBasename(rif.filepath);
const relativePath = getRelativePath(
rif.filepath,
await ideMessenger.ide.getWorkspaceDirs(),
);
const rangeStr = `(${rif.range.start.line + 1}-${
rif.range.end.line + 1
})`;
const item: ContextItemWithId = {
content: rif.contents,
name: `${basename} ${rangeStr}`,
// Description is passed on to the LLM to give more context on file path
description: `${relativePath} ${rangeStr}`,
id: {
providerTitle: "code",
itemId: v4(),
},
uri: {
type: "file",
value: rif.filepath,
},
};
let index = 0;
for (const el of editor.getJSON().content) {
if (el.type === "codeBlock") {
index += 2;
} else {
break;
}
const rif: RangeInFile & { contents: string } =
data.rangeInFileWithContents;
const basename = getBasename(rif.filepath);
const relativePath = getRelativePath(
rif.filepath,
await ideMessenger.ide.getWorkspaceDirs(),
);
const rangeStr = `(${rif.range.start.line + 1}-${
rif.range.end.line + 1
})`;
const item: ContextItemWithId = {
content: rif.contents,
name: `${basename} ${rangeStr}`,
// Description is passed on to the LLM to give more context on file path
description: `${relativePath} ${rangeStr}`,
id: {
providerTitle: "code",
itemId: v4(),
},
uri: {
type: "file",
value: rif.filepath,
},
};
let index = 0;
for (const el of editor.getJSON().content) {
if (el.type === "codeBlock") {
index += 2;
} else {
break;
}
editor
.chain()
.insertContentAt(index, {
type: "codeBlock",
attrs: {
item,
},
})
.run();
if (data.prompt) {
editor.commands.focus("end");
editor.commands.insertContent(data.prompt);
}
if (data.shouldRun) {
onEnterRef.current({ useCodebase: false, noContext: true });
}
setTimeout(() => {
editor.commands.blur();
editor.commands.focus("end");
}, 20);
}
setIgnoreHighlightedCode(false);
editor
.chain()
.insertContentAt(index, {
type: "codeBlock",
attrs: {
item,
},
})
.run();
if (data.prompt) {
editor.commands.focus("end");
editor.commands.insertContent(data.prompt);
}
if (data.shouldRun) {
onEnterRef.current({ useCodebase: false, noContext: true });
}
setTimeout(() => {
editor.commands.blur();
editor.commands.focus("end");
}, 20);
},
[
editor,
props.isMainInput,
historyLength,
ignoreHighlightedCode,
props.isMainInput,
onEnterRef.current,
],

View file

@ -0,0 +1,107 @@
import { KeyboardEvent } from "react";
import { isWebEnvironment } from "../../util";
import { Editor } from "@tiptap/react";
const isWebEnv = isWebEnvironment();
export const handleJetBrainsMetaKeyPress = (
e: KeyboardEvent,
editor: Editor,
) => {
const selection = window.getSelection();
const handlers: Record<string, () => void> = {
Backspace: () => handleJetBrainsMetaBackspace(editor),
ArrowLeft: () =>
selection.modify(
e.shiftKey ? "extend" : "move",
"backward",
"lineboundary",
),
ArrowRight: () =>
selection.modify(
e.shiftKey ? "extend" : "move",
"forward",
"lineboundary",
),
ArrowDown: () =>
selection.modify(
e.shiftKey ? "extend" : "move",
"forward",
"documentboundary",
),
ArrowUp: () => {
selection.modify(
e.shiftKey ? "extend" : "move",
"backward",
"documentboundary",
);
},
};
if (e.key in handlers) {
e.stopPropagation();
e.preventDefault();
handlers[e.key]();
}
};
export const handleMetaKeyPress = async (e: KeyboardEvent, editor: Editor) => {
const text = editor.state.doc.textBetween(
editor.state.selection.from,
editor.state.selection.to,
);
const handlers: Record<string, () => Promise<void>> = {
x: () => handleCutOperation(text, editor),
c: () => handleCopyOperation(text),
v: () => handlePasteOperation(editor),
};
if (e.key in handlers) {
e.stopPropagation();
e.preventDefault();
await handlers[e.key]();
}
};
export const handleJetBrainsMetaBackspace = (editor: Editor) => {
const { doc } = editor.state;
for (let i = doc.content.childCount - 1; i >= 0; i--) {
const node = doc.content.child(i);
if (node.type.name !== "codeBlock") {
editor.commands.deleteNode(node.type.name);
}
}
// Add an empty string so the user can keep typing
editor.commands.createParagraphNear();
};
export const handleCutOperation = async (text: string, editor: Editor) => {
if (isWebEnv) {
await navigator.clipboard.writeText(text);
editor.commands.deleteSelection();
} else {
document.execCommand("cut");
}
};
export const handleCopyOperation = async (text: string) => {
if (isWebEnv) {
await navigator.clipboard.writeText(text);
} else {
document.execCommand("copy");
}
};
export const handlePasteOperation = async (editor: Editor) => {
if (isWebEnv) {
const clipboardText = await navigator.clipboard.readText();
editor.commands.insertContent(clipboardText);
} else {
document.execCommand("paste");
}
};

View file

@ -1,6 +1,6 @@
import { ILLM, ModelProvider } from "core";
import { InputDescriptor } from "./providers";
import { ModelProviderTags } from "../../../components/modelSelection/utils";
import { InputDescriptor } from "./providers";
// A dimension is like parameter count - 7b, 13b, 34b, etc.
// You would set options to the field that should be changed for that option in the params field of ModelPackage
@ -752,7 +752,7 @@ export const models: { [key: string]: ModelPackage } = {
description:
"Anthropic's most intelligent model, but much less expensive than Claude 3 Opus",
params: {
model: "claude-3-5-sonnet-20240620",
model: "claude-3-5-sonnet-latest",
contextLength: 200_000,
title: "Claude 3.5 Sonnet",
apiKey: "",
@ -870,27 +870,29 @@ export const models: { [key: string]: ModelPackage } = {
},
granite3Instruct8b: {
title: "Granite 3.0 8b Instruct",
description: "The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
description:
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
params: {
model: "ibm/granite-3-8b-instruct",
contextLength: 8_000,
title: "Granite 3.0 8b Instruct"
title: "Granite 3.0 8b Instruct",
},
providerOptions: ["watsonx"],
icon: "WatsonX.png",
isOpenSource: false
isOpenSource: false,
},
granite3Instruct2b: {
title: "Granite 3.0 2b Instruct",
description: "The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
description:
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
params: {
model: "ibm/granite-3-2b-instruct",
contextLength: 2_000,
title: "Granite 3.0 2b Instruct"
title: "Granite 3.0 2b Instruct",
},
providerOptions: ["watsonx"],
icon: "WatsonX.png",
isOpenSource: false
isOpenSource: false,
},
MistralLarge: {
title: "Mistral Large",
@ -973,8 +975,6 @@ export const models: { [key: string]: ModelPackage } = {
isOpenSource: false,
},
gpt4gov: {
title: "GPT-4 gov",
description:
@ -1059,6 +1059,19 @@ export const models: { [key: string]: ModelPackage } = {
providerOptions: ["nebius"],
isOpenSource: true,
},
grokBeta: {
title: "Grok Beta",
description: "Generative artificial intelligence chatbot developed by xAI.",
refUrl: "",
params: {
title: "Grok Beta",
model: "grok-beta",
contextLength: 128_000,
},
icon: "xAI.png",
providerOptions: ["xAI"],
isOpenSource: false,
},
AUTODETECT: {
title: "Autodetect",
description:

View file

@ -352,6 +352,27 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
packages: [models.gemini15Pro, models.geminiPro, models.gemini15Flash],
apiKeyUrl: "https://aistudio.google.com/app/apikey",
},
xAI: {
title: "xAI",
provider: "xAI",
icon: "xAI.png",
description: "xAI is a company working on building artificial intelligence to accelerate human scientific discovery",
longDescription: "To get started with xAI, obtain an API key from their [console](https://console.x.ai/).",
tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource],
collectInputFor: [
{
inputType: "text",
key: "apiKey",
label: "API Key",
placeholder: "Enter your xAI API key",
required: true,
},
],
packages: [
models.grokBeta,
],
apiKeyUrl: "https://console.x.ai/",
},
lmstudio: {
title: "LM Studio",
provider: "lmstudio",

View file

@ -66,7 +66,6 @@ const TopGuiDiv = styled.div<{
showScrollbar?: boolean;
}>`
overflow-y: auto;
height: 100%;
scrollbar-width: ${(props) => (props.showScrollbar ? "thin" : "none")};
&::-webkit-scrollbar {
@ -75,6 +74,7 @@ const TopGuiDiv = styled.div<{
`;
const StopButton = styled.div`
background-color: ${vscBackground};
width: fit-content;
margin-right: auto;
margin-left: auto;
@ -97,6 +97,7 @@ const StopButton = styled.div`
`;
const StepsDiv = styled.div`
margin-top: 8px;
position: relative;
background-color: transparent;
@ -147,16 +148,17 @@ export function Chat() {
const { saveSession, getLastSessionId, loadLastSession } =
useHistory(dispatch);
useEffect(() => {
if (!active || !topGuiDivRef.current) return;
const scrollAreaElement = topGuiDivRef.current;
scrollAreaElement.scrollTop =
scrollAreaElement.scrollHeight - scrollAreaElement.clientHeight;
const scrollToBottom = useCallback(() => {
if (!topGuiDivRef.current) return;
const elem = topGuiDivRef.current;
elem.scrollTop = elem.scrollHeight - elem.clientHeight;
setIsAtBottom(true);
}, [active]);
}, [topGuiDivRef, setIsAtBottom]);
useEffect(() => {
if (active) scrollToBottom();
}, [active, scrollToBottom]);
useEffect(() => {
// Cmd + Backspace to delete current step
@ -311,6 +313,7 @@ export function Chat() {
return (
<>
<TopGuiDiv
className={`${state.history.length > 0 ? "h-full" : ""}`}
ref={topGuiDivRef}
onScroll={handleScroll}
showScrollbar={state.config.ui?.showChatScrollbar || false}
@ -415,22 +418,56 @@ export function Chat() {
</Fragment>
))}
</StepsDiv>
</div>
<ChatScrollAnchor
scrollAreaRef={topGuiDivRef}
isAtBottom={isAtBottom}
trackVisibility={active}
/>
</TopGuiDiv>
<ContinueInputBox
isMainInput
isLastUserInput={false}
hidden={active}
onEnter={(editorContent, modifiers) => {
sendInput(editorContent, modifiers);
}}
/>
{active ? (
<>
<br />
<br />
</>
) : state.history.length > 0 ? (
<div className={`relative`}>
<div className="absolute -top-8 right-2 z-30">
{ttsActive && (
<StopButton
className=""
onClick={() => {
ideMessenger.post("tts/kill", undefined);
}}
>
■ Stop TTS
</StopButton>
)}
{active && (
<StopButton
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
)}
</div>
<ContinueInputBox
isMainInput
isLastUserInput={false}
onEnter={(editorContent, modifiers) => {
sendInput(editorContent, modifiers);
}}
/>
<div
style={{
// opacity: active ? 0 : 1,
pointerEvents: active ? "none" : "auto",
}}
>
{state.history.length > 0 ? (
<div className="xs:inline mt-2 hidden">
<NewSessionButton
onClick={() => {
@ -475,40 +512,7 @@ export function Chat() {
</>
)}
</div>
<ChatScrollAnchor
scrollAreaRef={topGuiDivRef}
isAtBottom={isAtBottom}
trackVisibility={active}
/>
</TopGuiDiv>
{ttsActive && (
<StopButton
className="mb-4 mt-2"
onClick={() => {
ideMessenger.post("tts/kill", undefined);
}}
>
■ Stop TTS
</StopButton>
)}
{active && (
<StopButton
className="mb-4 mt-auto"
onClick={() => {
dispatch(setInactive());
if (
state.history[state.history.length - 1]?.message.content
.length === 0
) {
dispatch(clearLastResponse());
}
}}
>
{getMetaKeyLabel()} ⌫ Cancel
</StopButton>
)}
</div>
</>
);
}

View file

@ -1,77 +0,0 @@
import { KeyboardEvent } from "react";
import { getPlatform } from ".";
export const handleMetaKeyPressJetBrains = (
e: KeyboardEvent,
text: string,
setText: (text: string) => void,
) => {
const { selectionStart, selectionEnd } = e.target as HTMLTextAreaElement;
if (e.key === "Backspace") {
handleMetaBackspace(e, text, setText, selectionStart, selectionEnd);
}
if (getPlatform() === "mac") {
if (e.key === "ArrowLeft") {
handleMacArrowLeftKey(e);
} else if (e.key === "ArrowRight") {
handleMacArrowRightKey(e);
}
}
};
const handleMetaBackspace = (
e: KeyboardEvent,
text: string,
setText: (text: string) => void,
start: number,
end: number,
) => {
const target = e.target as HTMLTextAreaElement;
let newStart = start;
if (start !== end) {
setText(text.slice(0, start) + text.slice(end));
} else {
newStart =
getPlatform() === "mac"
? text.lastIndexOf("\n", start - 1) + 1
: text.slice(0, start).trimEnd().lastIndexOf(" ") + 1;
setText(text.slice(0, newStart) + text.slice(start));
}
target.setSelectionRange(newStart, newStart);
};
const handleMacArrowLeftKey = (e: KeyboardEvent) => {
const target = e.target as HTMLDivElement;
const selection = window.getSelection();
const range = document.createRange();
if (e.shiftKey) {
selection.modify("extend", "backward", "character");
} else {
range.setStart(target.firstChild, 0);
range.setEnd(target.firstChild, 0);
selection.removeAllRanges();
selection.addRange(range);
}
};
const handleMacArrowRightKey = (e: KeyboardEvent) => {
const selection = window.getSelection();
const range = document.createRange();
const target = e.target as HTMLDivElement;
if (e.shiftKey) {
selection.modify("extend", "forward", "character");
} else {
range.selectNodeContents(target);
range.collapse(false);
selection.removeAllRanges();
selection.addRange(range);
}
};

View file

@ -8,6 +8,7 @@ import { Ollama } from "./providers/ollama.js";
import { OpenAi } from "./providers/openai.js";
import { Vllm } from "./providers/vllm.js";
import { Voyage } from "./providers/voyage.js";
import { xAI } from "./providers/xAI.js";
import { LlmInfo, ModelProvider, UseCase } from "./types.js";
export const allModelProviders: ModelProvider[] = [
@ -21,6 +22,7 @@ export const allModelProviders: ModelProvider[] = [
Vllm,
Bedrock,
Cohere,
xAI
];
export const allLlms: LlmInfo[] = allModelProviders.flatMap((provider) =>

View file

@ -0,0 +1,14 @@
import { ModelProvider } from "../types.js";
export const xAI: ModelProvider = {
models: [
{
model: "grok-beta",
displayName: "Grok Beta",
contextLength: 128000,
recommendedFor: ["chat"],
},
],
id: "xAI",
displayName: "xAI",
};