Merge branch 'dev' into slash-commit-staged-only
This commit is contained in:
commit
ed3bb88329
227 changed files with 5020 additions and 2012 deletions
7
.changes/extensions/intellij/0.0.72.md
Normal file
7
.changes/extensions/intellij/0.0.72.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
## 0.0.72 - 2024-10-04
|
||||
### Added
|
||||
* Listen for changes to Intellij settings without requiring window reload
|
||||
### Changed
|
||||
* Updated tutorial file
|
||||
### Fixed
|
||||
* Fix ability to load config.ts in JetBrains IDEs
|
||||
12
.changes/extensions/vscode/0.8.53.md
Normal file
12
.changes/extensions/vscode/0.8.53.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
## 0.8.53 - 2024-10-11
|
||||
### Added
|
||||
* Improved loading/accept/reject UI for apply
|
||||
* Polished chat sidebar, especially context dropdown
|
||||
* Further prompt caching with Anthropic
|
||||
### Changed
|
||||
* Updated tutorial file
|
||||
* Improved styling on "More" page
|
||||
### Fixed
|
||||
* Continue for teams auth bug fix
|
||||
* Fixed a number of apply bugs
|
||||
* Fixed autoscrolling behavior
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
## 0.9.210 - 2024-09-15
|
||||
|
||||
### Added
|
||||
|
||||
- NVIDIA NIMs embeddings provider
|
||||
- SambaNova LLM Provider
|
||||
- Support for OpenAI's new o1-preview and o1-mini models
|
||||
|
||||
### Changed
|
||||
|
||||
- Use Chromium only as a fallback after asking user
|
||||
|
||||
### Fixed
|
||||
|
||||
- Increased default maxTokens, and autodetect for common models
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/vscode
|
||||
kind: Added
|
||||
body: Improved loading/accept/reject UI for apply
|
||||
time: 2024-09-27T14:29:40.283176-07:00
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/vscode
|
||||
kind: Added
|
||||
body: Polished chat sidebar, especially context dropdown
|
||||
time: 2024-09-27T14:30:05.576347-07:00
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/intellij
|
||||
kind: Changed
|
||||
body: Updated tutorial file
|
||||
time: 2024-09-23T16:02:51.918152-07:00
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/vscode
|
||||
kind: Changed
|
||||
body: Updated tutorial file
|
||||
time: 2024-09-23T16:03:02.944462-07:00
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/vscode
|
||||
kind: Fixed
|
||||
body: Continue for teams auth bug fix
|
||||
time: 2024-09-19T21:11:12.997946-07:00
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
project: extensions/vscode
|
||||
kind: Fixed
|
||||
body: Fixed a number of apply bugs
|
||||
time: 2024-09-27T14:29:24.69568-07:00
|
||||
5
.changes/unreleased/Fixed-20241007-183820.yaml
Normal file
5
.changes/unreleased/Fixed-20241007-183820.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
project: extensions/intellij
|
||||
kind: Fixed
|
||||
body: Off-screen rendering to solve white flash on load and lack of changing cursor
|
||||
type
|
||||
time: 2024-10-07T18:38:20.733658-07:00
|
||||
18
.github/workflows/auto-assign.yaml
vendored
Normal file
18
.github/workflows/auto-assign.yaml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: Issue assignment
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
auto-assign:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
steps:
|
||||
- name: "Auto-assign issue"
|
||||
uses: pozil/auto-assign-issue@v2
|
||||
with:
|
||||
repo-token: ${{ secrets.CI_GITHUB_TOKEN }}
|
||||
assignees: sestinj,Patrick-Erichsen
|
||||
numOfAssignee: 1
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -169,4 +169,6 @@ Icon?
|
|||
.prompts/
|
||||
.aider*
|
||||
|
||||
notes.md
|
||||
notes.md
|
||||
|
||||
manual-testing-sandbox/Continue/.idea/vcs.xml
|
||||
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
|
|
@ -5,7 +5,6 @@
|
|||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/extensions/intellij" />
|
||||
<option name="gradleJvm" value="corretto-17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/extensions/intellij" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
extensions/vscode/continue_rc_schema.json
|
||||
**/.continueignore
|
||||
CHANGELOG.md
|
||||
**/continue_tutorial.py
|
||||
**/continue_tutorial.py
|
||||
|
|
|
|||
19
.prompts/test.prompt
Normal file
19
.prompts/test.prompt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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")
|
||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
|
|
@ -17,9 +17,9 @@
|
|||
"**/binary": true,
|
||||
"binary/": false,
|
||||
"**/core/vendor/**": true,
|
||||
"**/gui/dist": true
|
||||
"**/gui/dist": true,
|
||||
"**/extensions/vscode/gui/**": true,
|
||||
"**/extensions/vscode/out/**": true
|
||||
},
|
||||
"eslint.workingDirectories": [
|
||||
"./core"
|
||||
]
|
||||
"eslint.workingDirectories": ["./core"]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
## Getting Started
|
||||
|
||||
Learn about how to install and use Continue in the docs [here](https://continue.dev/docs/getting-started)
|
||||
Learn about how to install and use Continue in the docs [here](https://continue.dev/docs/getting-started/install)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
1
binary/package-lock.json
generated
1
binary/package-lock.json
generated
|
|
@ -74,6 +74,7 @@
|
|||
"jsdom": "^24.0.0",
|
||||
"launchdarkly-node-client-sdk": "^3.2.0",
|
||||
"llm-code-highlighter": "^0.0.14",
|
||||
"lru-cache": "^10.2.2",
|
||||
"mac-ca": "^3.1.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import Parser from "web-tree-sitter";
|
|||
import { RangeInFileWithContents } from "../commands/util.js";
|
||||
import { getParserForFile } from "../util/treeSitter.js";
|
||||
|
||||
export type AstPath = Parser.SyntaxNode[];
|
||||
|
||||
export async function getAst(
|
||||
filepath: string,
|
||||
fileContents: string,
|
||||
|
|
@ -23,7 +25,7 @@ export async function getAst(
|
|||
export async function getTreePathAtCursor(
|
||||
ast: Parser.Tree,
|
||||
cursorIndex: number,
|
||||
): Promise<Parser.SyntaxNode[] | undefined> {
|
||||
): Promise<AstPath> {
|
||||
const path = [ast.rootNode];
|
||||
while (path[path.length - 1].childCount > 0) {
|
||||
let foundChild = false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { stopAtStopTokens } from "./charStream";
|
||||
import { stopAtStopTokens } from "./streamTransforms/charStream";
|
||||
|
||||
describe("stopAtStopTokens", () => {
|
||||
async function* createMockStream(chunks: string[]): AsyncGenerator<string> {
|
||||
|
|
|
|||
|
|
@ -22,20 +22,18 @@ import {
|
|||
} from "../util/parameters.js";
|
||||
import { Telemetry } from "../util/posthog.js";
|
||||
import { getRangeInString } from "../util/ranges.js";
|
||||
import { ImportDefinitionsService } from "./ImportDefinitionsService.js";
|
||||
import { BracketMatchingService } from "./brackets.js";
|
||||
|
||||
import AutocompleteLruCache from "./cache.js";
|
||||
import {
|
||||
noFirstCharNewline,
|
||||
onlyWhitespaceAfterEndOfLine,
|
||||
stopAtStopTokens,
|
||||
} from "./charStream.js";
|
||||
import {
|
||||
constructAutocompletePrompt,
|
||||
languageForFilepath,
|
||||
} from "./constructPrompt.js";
|
||||
import { isOnlyPunctuationAndWhitespace } from "./filter.js";
|
||||
import { AutocompleteLanguageInfo } from "./languages.js";
|
||||
import { postprocessCompletion } from "./postprocessing.js";
|
||||
import { AutocompleteSnippet } from "./ranking.js";
|
||||
import { RecentlyEditedRange } from "./recentlyEdited.js";
|
||||
import { RootPathContextService } from "./services/RootPathContextService.js";
|
||||
import {
|
||||
avoidPathLineAndEmptyComments,
|
||||
noTopLevelKeywordsMidline,
|
||||
|
|
@ -44,15 +42,19 @@ import {
|
|||
stopAtRepeatingLines,
|
||||
stopAtSimilarLine,
|
||||
streamWithNewLines,
|
||||
} from "./lineStream.js";
|
||||
import { postprocessCompletion } from "./postprocessing.js";
|
||||
import { AutocompleteSnippet } from "./ranking.js";
|
||||
import { RecentlyEditedRange } from "./recentlyEdited.js";
|
||||
} from "./streamTransforms/lineStream.js";
|
||||
import { getTemplateForModel } from "./templates.js";
|
||||
import { GeneratorReuseManager } from "./util.js";
|
||||
// @prettier-ignore
|
||||
import Handlebars from "handlebars";
|
||||
import { getConfigJsonPath } from "../util/paths.js";
|
||||
import { BracketMatchingService } from "./services/BracketMatchingService.js";
|
||||
import { ImportDefinitionsService } from "./services/ImportDefinitionsService.js";
|
||||
import {
|
||||
noFirstCharNewline,
|
||||
onlyWhitespaceAfterEndOfLine,
|
||||
stopAtStopTokens,
|
||||
} from "./streamTransforms/charStream.js";
|
||||
|
||||
export interface AutocompleteInput {
|
||||
completionId: string;
|
||||
|
|
@ -158,9 +160,14 @@ export class CompletionProvider {
|
|||
this.onError.bind(this),
|
||||
);
|
||||
this.importDefinitionsService = new ImportDefinitionsService(this.ide);
|
||||
this.rootPathContextService = new RootPathContextService(
|
||||
this.importDefinitionsService,
|
||||
this.ide,
|
||||
);
|
||||
}
|
||||
|
||||
private importDefinitionsService: ImportDefinitionsService;
|
||||
private rootPathContextService: RootPathContextService;
|
||||
private generatorReuseManager: GeneratorReuseManager;
|
||||
private autocompleteCache = AutocompleteLruCache.get();
|
||||
public errorsShown: Set<string> = new Set();
|
||||
|
|
@ -542,6 +549,7 @@ export class CompletionProvider {
|
|||
llm.model,
|
||||
extrasSnippets,
|
||||
this.importDefinitionsService,
|
||||
this.rootPathContextService,
|
||||
);
|
||||
|
||||
// If prefix is manually passed
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import Parser from "web-tree-sitter";
|
||||
import { RangeInFileWithContents } from "../commands/util.js";
|
||||
import { TabAutocompleteOptions } from "../index.js";
|
||||
|
||||
|
|
@ -7,8 +6,7 @@ import {
|
|||
pruneLinesFromBottom,
|
||||
pruneLinesFromTop,
|
||||
} from "../llm/countTokens.js";
|
||||
import { ImportDefinitionsService } from "./ImportDefinitionsService.js";
|
||||
import { getAst, getTreePathAtCursor } from "./ast.js";
|
||||
import { AstPath, getAst, getTreePathAtCursor } from "./ast.js";
|
||||
import {
|
||||
AutocompleteLanguageInfo,
|
||||
LANGUAGES,
|
||||
|
|
@ -22,6 +20,8 @@ import {
|
|||
type AutocompleteSnippet,
|
||||
} from "./ranking.js";
|
||||
import { RecentlyEditedRange, findMatchingRange } from "./recentlyEdited.js";
|
||||
import { ImportDefinitionsService } from "./services/ImportDefinitionsService.js";
|
||||
import { RootPathContextService } from "./services/RootPathContextService.js";
|
||||
|
||||
export function languageForFilepath(
|
||||
filepath: string,
|
||||
|
|
@ -32,7 +32,7 @@ export function languageForFilepath(
|
|||
const BLOCK_TYPES = ["body", "statement_block"];
|
||||
|
||||
function shouldCompleteMultilineAst(
|
||||
treePath: Parser.SyntaxNode[],
|
||||
treePath: AstPath,
|
||||
cursorLine: number,
|
||||
): boolean {
|
||||
// If at the base of the file, do multiline
|
||||
|
|
@ -63,7 +63,7 @@ function isMidlineCompletion(prefix: string, suffix: string): boolean {
|
|||
}
|
||||
|
||||
async function shouldCompleteMultiline(
|
||||
filepath: string,
|
||||
treePath: AstPath | undefined,
|
||||
fullPrefix: string,
|
||||
fullSuffix: string,
|
||||
language: AutocompleteLanguageInfo,
|
||||
|
|
@ -94,18 +94,6 @@ async function shouldCompleteMultiline(
|
|||
}
|
||||
|
||||
// Use AST to determine whether to complete multiline
|
||||
let treePath: Parser.SyntaxNode[] | undefined;
|
||||
try {
|
||||
const ast = await getAst(filepath, fullPrefix + fullSuffix);
|
||||
if (!ast) {
|
||||
return true;
|
||||
}
|
||||
|
||||
treePath = await getTreePathAtCursor(ast, fullPrefix.length);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse AST", e);
|
||||
}
|
||||
|
||||
let completeMultiline = false;
|
||||
if (treePath) {
|
||||
const cursorLine = fullPrefix.split("\n").length - 1;
|
||||
|
|
@ -127,6 +115,7 @@ export async function constructAutocompletePrompt(
|
|||
modelName: string,
|
||||
extraSnippets: AutocompleteSnippet[],
|
||||
importDefinitionsService: ImportDefinitionsService,
|
||||
rootPathContextService: RootPathContextService,
|
||||
): Promise<{
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
|
|
@ -145,6 +134,17 @@ export async function constructAutocompletePrompt(
|
|||
);
|
||||
const suffix = pruneLinesFromBottom(fullSuffix, maxSuffixTokens, modelName);
|
||||
|
||||
// Calculate AST Path
|
||||
let treePath: AstPath | undefined;
|
||||
try {
|
||||
const ast = await getAst(filepath, fullPrefix + fullSuffix);
|
||||
if (ast) {
|
||||
treePath = await getTreePathAtCursor(ast, fullPrefix.length);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to parse AST", e);
|
||||
}
|
||||
|
||||
// Find external snippets
|
||||
let snippets: AutocompleteSnippet[] = [];
|
||||
|
||||
|
|
@ -215,6 +215,14 @@ export async function constructAutocompletePrompt(
|
|||
snippets.push(...importSnippets);
|
||||
}
|
||||
|
||||
if (options.useRootPathContext && treePath) {
|
||||
const ctx = await rootPathContextService.getContextForPath(
|
||||
filepath,
|
||||
treePath,
|
||||
);
|
||||
snippets.push(...ctx);
|
||||
}
|
||||
|
||||
// Filter out empty snippets and ones that are already in the prefix/suffix
|
||||
snippets = snippets
|
||||
.map((snippet) => ({ ...snippet }))
|
||||
|
|
@ -269,7 +277,7 @@ export async function constructAutocompletePrompt(
|
|||
suffix,
|
||||
useFim: true,
|
||||
completeMultiline: await shouldCompleteMultiline(
|
||||
filepath,
|
||||
treePath,
|
||||
fullPrefix,
|
||||
fullSuffix,
|
||||
language,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { LineFilter } from "./lineStream.js";
|
||||
import { LineFilter } from "./streamTransforms/lineStream";
|
||||
|
||||
export interface AutocompleteLanguageInfo {
|
||||
name: string;
|
||||
|
|
@ -26,7 +26,7 @@ export const Python = {
|
|||
name: "Python",
|
||||
// """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks.
|
||||
// This stops the model from trying to complete the start of a new markdown block
|
||||
topLevelKeywords: ["def", "class", "\"\"\"#"],
|
||||
topLevelKeywords: ["def", "class", '"""#'],
|
||||
singleLineComment: "#",
|
||||
endOfLine: [],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { jest } from "@jest/globals";
|
||||
import * as lineStream from "./lineStream";
|
||||
import * as lineStream from "./streamTransforms/lineStream";
|
||||
|
||||
describe("lineStream", () => {
|
||||
let mockFullStop: jest.Mock;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { ILLM } from "../index.js";
|
||||
import { longestCommonSubsequence } from "../util/lcs.js";
|
||||
import { lineIsRepeated } from "./lineStream.js";
|
||||
import { lineIsRepeated } from "./streamTransforms/lineStream.js";
|
||||
|
||||
function rewritesLineAbove(completion: string, prefix: string): boolean {
|
||||
const lineAbove = prefix
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export function deduplicateSnippets(
|
|||
function mergeSnippetsByRange(
|
||||
snippets: Required<AutocompleteSnippet>[],
|
||||
): Required<AutocompleteSnippet>[] {
|
||||
if (snippets.length === 0) {
|
||||
if (snippets.length <= 1) {
|
||||
return snippets;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { IDE } from "../index.js";
|
||||
import { RangeInFileWithContents } from "../commands/util.js";
|
||||
import { PrecalculatedLruCache } from "../util/LruCache.js";
|
||||
import { IDE } from "../..";
|
||||
import { RangeInFileWithContents } from "../../commands/util";
|
||||
import { PrecalculatedLruCache } from "../../util/LruCache";
|
||||
import {
|
||||
TSQueryType,
|
||||
getParserForFile,
|
||||
getQueryForFile,
|
||||
} from "../util/treeSitter.js";
|
||||
} from "../../util/treeSitter";
|
||||
|
||||
interface FileInfo {
|
||||
imports: { [key: string]: RangeInFileWithContents[] };
|
||||
45
core/autocomplete/services/NearbyDefinitionsService.ts
Normal file
45
core/autocomplete/services/NearbyDefinitionsService.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { IDE, Location } from "../..";
|
||||
import { LANGUAGES } from "../languages";
|
||||
import { getSymbolsForSnippet } from "../ranking";
|
||||
|
||||
interface FileInfo {
|
||||
filepath: string;
|
||||
}
|
||||
|
||||
export class NearbyDefinitionsService {
|
||||
static N = 10;
|
||||
|
||||
constructor(private readonly ide: IDE) {}
|
||||
|
||||
async getDefinitionsForLine(filepath: string, line: number) {
|
||||
const lineContent = await this.ide.readRangeInFile(filepath, {
|
||||
start: {
|
||||
line,
|
||||
character: 0,
|
||||
},
|
||||
end: {
|
||||
line: line + 1,
|
||||
character: 0,
|
||||
},
|
||||
});
|
||||
|
||||
// Remove keywords
|
||||
const lang = LANGUAGES[filepath.split(".").slice(-1)[0]];
|
||||
const symbols = Array.from(getSymbolsForSnippet(lineContent))
|
||||
.filter((s) => s.length > 0)
|
||||
.filter((s) => !(lang && lang?.stopWords?.includes(s)));
|
||||
|
||||
return Promise.all(
|
||||
symbols.map((s) => {
|
||||
const character = lineContent.indexOf(s);
|
||||
const pos: Location = {
|
||||
filepath,
|
||||
position: {
|
||||
line,
|
||||
character,
|
||||
},
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
129
core/autocomplete/services/RootPathContextService.ts
Normal file
129
core/autocomplete/services/RootPathContextService.ts
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
import { createHash } from "crypto";
|
||||
import { LRUCache } from "lru-cache";
|
||||
import Parser from "web-tree-sitter";
|
||||
import { IDE } from "../..";
|
||||
import { getQueryForFile, TSQueryType } from "../../util/treeSitter";
|
||||
import { AstPath } from "../ast";
|
||||
import { AutocompleteSnippet } from "../ranking";
|
||||
import { ImportDefinitionsService } from "./ImportDefinitionsService";
|
||||
|
||||
export class RootPathContextService {
|
||||
private cache = new LRUCache<string, AutocompleteSnippet[]>({
|
||||
max: 100,
|
||||
});
|
||||
|
||||
constructor(
|
||||
private readonly importDefinitionsService: ImportDefinitionsService,
|
||||
private readonly ide: IDE,
|
||||
) {}
|
||||
|
||||
private static getNodeId(node: Parser.SyntaxNode): string {
|
||||
return `${node.startIndex}`;
|
||||
}
|
||||
|
||||
private static TYPES_TO_USE = new Set([
|
||||
"program",
|
||||
"function_declaration",
|
||||
"method_definition",
|
||||
]);
|
||||
|
||||
/**
|
||||
* Key comes from hash of parent key and node type and node id.
|
||||
*/
|
||||
private static keyFromNode(
|
||||
parentKey: string,
|
||||
astNode: Parser.SyntaxNode,
|
||||
): string {
|
||||
return createHash("sha256")
|
||||
.update(parentKey)
|
||||
.update(astNode.type)
|
||||
.update(RootPathContextService.getNodeId(astNode))
|
||||
.digest("hex");
|
||||
}
|
||||
|
||||
private async getSnippetsForNode(
|
||||
filepath: string,
|
||||
node: Parser.SyntaxNode,
|
||||
): Promise<AutocompleteSnippet[]> {
|
||||
const snippets: AutocompleteSnippet[] = [];
|
||||
|
||||
let query: Parser.Query | undefined;
|
||||
switch (node.type) {
|
||||
case "program":
|
||||
this.importDefinitionsService.get(filepath);
|
||||
break;
|
||||
case "function_declaration":
|
||||
query = await getQueryForFile(
|
||||
filepath,
|
||||
TSQueryType.FunctionDeclaration,
|
||||
);
|
||||
break;
|
||||
case "method_definition":
|
||||
query = await getQueryForFile(filepath, TSQueryType.MethodDefinition);
|
||||
break;
|
||||
case "function_definition":
|
||||
query = await getQueryForFile(filepath, TSQueryType.FunctionDefinition);
|
||||
break;
|
||||
case "method_declaration":
|
||||
query = await getQueryForFile(filepath, TSQueryType.MethodDeclaration);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return snippets;
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
query.matches(node).map(async (match) => {
|
||||
const startPosition = match.captures[0].node.startPosition;
|
||||
const endPosition = match.captures[0].node.endPosition;
|
||||
const definitions = await this.ide.gotoDefinition({
|
||||
filepath,
|
||||
position: {
|
||||
line: endPosition.row,
|
||||
character: endPosition.column,
|
||||
},
|
||||
});
|
||||
const newSnippets = await Promise.all(
|
||||
definitions.map(async (def) => ({
|
||||
...def,
|
||||
contents: await this.ide.readRangeInFile(def.filepath, def.range),
|
||||
})),
|
||||
);
|
||||
snippets.push(...newSnippets);
|
||||
}),
|
||||
);
|
||||
|
||||
return snippets;
|
||||
}
|
||||
|
||||
async getContextForPath(
|
||||
filepath: string,
|
||||
astPath: AstPath,
|
||||
// cursorIndex: number,
|
||||
): Promise<AutocompleteSnippet[]> {
|
||||
const snippets: AutocompleteSnippet[] = [];
|
||||
|
||||
let parentKey = filepath;
|
||||
for (const astNode of astPath.filter((node) =>
|
||||
RootPathContextService.TYPES_TO_USE.has(node.type),
|
||||
)) {
|
||||
const key = RootPathContextService.keyFromNode(parentKey, astNode);
|
||||
|
||||
const foundInCache = this.cache.get(key);
|
||||
const newSnippets =
|
||||
foundInCache ?? (await this.getSnippetsForNode(filepath, astNode));
|
||||
snippets.push(...newSnippets);
|
||||
|
||||
if (!foundInCache) {
|
||||
this.cache.set(key, newSnippets);
|
||||
}
|
||||
|
||||
parentKey = key;
|
||||
}
|
||||
|
||||
return snippets;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { distance } from "fastest-levenshtein";
|
||||
import { DiffLine } from "../";
|
||||
import { LineStream } from "../diff/util";
|
||||
import { DiffLine } from "../..";
|
||||
import { LineStream } from "../../diff/util";
|
||||
|
||||
export type LineFilter = (args: {
|
||||
lines: LineStream;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { ContextItemWithId, ILLM, SlashCommand } from "../../";
|
||||
import {
|
||||
filterCodeBlockLines,
|
||||
filterEnglishLinesAtEnd,
|
||||
|
|
@ -5,9 +6,8 @@ import {
|
|||
fixCodeLlamaFirstLineIndentation,
|
||||
stopAtLines,
|
||||
streamWithNewLines,
|
||||
} from "../../autocomplete/lineStream";
|
||||
} from "../../autocomplete/streamTransforms/lineStream";
|
||||
import { streamLines } from "../../diff/util";
|
||||
import { ContextItemWithId, ILLM, SlashCommand } from "../../";
|
||||
import { stripImages } from "../../llm/images";
|
||||
import {
|
||||
dedentAndGetCommonWhitespace,
|
||||
|
|
@ -613,6 +613,7 @@ Please briefly explain the changes made to the code above. Give no more than 2-3
|
|||
yield update;
|
||||
}
|
||||
}
|
||||
yield `Edited ${contextItemToEdit.name}`;
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -600,15 +600,19 @@ async function loadFullConfigNode(
|
|||
try {
|
||||
module = await import(configJsPath);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log("Could not load config.ts as absolute path, retrying as file url ...");
|
||||
console.log(e);
|
||||
console.log(
|
||||
"Could not load config.ts as absolute path, retrying as file url ...",
|
||||
);
|
||||
try {
|
||||
module = await import(`file://${configJsPath}`);
|
||||
} catch (e) {
|
||||
throw new Error("Could not load config.ts as file url either", { cause: e });
|
||||
throw new Error("Could not load config.ts as file url either", {
|
||||
cause: e,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (typeof require !== "undefined") {
|
||||
delete require.cache[require.resolve(configJsPath)];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ declare global {
|
|||
| "gitlab-mr"
|
||||
| "os"
|
||||
| "currentFile"
|
||||
| "greptile;
|
||||
| "greptile";
|
||||
|
||||
type TemplateType =
|
||||
| "llama2"
|
||||
|
|
|
|||
139
core/context/providers/DiscordContextProvider.ts
Normal file
139
core/context/providers/DiscordContextProvider.ts
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import {
|
||||
ContextItem,
|
||||
ContextProviderDescription,
|
||||
ContextProviderExtras,
|
||||
ContextSubmenuItem,
|
||||
LoadSubmenuItemsArgs,
|
||||
FetchFunction,
|
||||
} from "../../index.js";
|
||||
import { BaseContextProvider } from "../index.js";
|
||||
|
||||
//Define helper interfaces for Discord responses
|
||||
export interface DiscordChannel {
|
||||
id: string;
|
||||
name?: string;
|
||||
icon?: string;
|
||||
topic?: string;
|
||||
type?: number;
|
||||
guild_id?: string;
|
||||
}
|
||||
|
||||
interface DiscordMessage {
|
||||
id: string;
|
||||
content: string;
|
||||
author: {
|
||||
id: string;
|
||||
username: string;
|
||||
};
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
class DiscordContextProvider extends BaseContextProvider {
|
||||
static description: ContextProviderDescription = {
|
||||
title: "discord",
|
||||
displayTitle: "Discord",
|
||||
description: "Reference Discord messages from a channel",
|
||||
type: "submenu",
|
||||
};
|
||||
|
||||
private baseUrl = "https://discord.com/api/v10";
|
||||
|
||||
// Helper function to get the full fetch URL
|
||||
private getUrl(path: string): string {
|
||||
return `${this.baseUrl}${path}`;
|
||||
}
|
||||
|
||||
async fetchMessages(
|
||||
channelId: string,
|
||||
fetch: FetchFunction,
|
||||
): Promise<Array<DiscordMessage>> {
|
||||
const url = this.getUrl(`/channels/${channelId}/messages`);
|
||||
// Fetch messages from the specified channel using the provided fetch function
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bot ${this.options.discordKey}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch messages: ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async fetchChannels(fetch: FetchFunction): Promise<Array<DiscordChannel>> {
|
||||
const url = this.getUrl(`/guilds/${this.options.guildId}/channels`);
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Authorization: `Bot ${this.options.discordKey}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch channels: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const channels = await response.json();
|
||||
// Filter channels to only include text channels (type 0)
|
||||
return channels.filter((channel: DiscordChannel) => channel.type === 0);
|
||||
}
|
||||
|
||||
async getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
const channels = await this.fetchChannels(extras.fetch);
|
||||
|
||||
let channelId: string;
|
||||
// Find the channel by ID or name in the query string. If not found, use the first channel
|
||||
const selectedChannel = channels.find(
|
||||
(channel) => channel.id === query || channel.name === query,
|
||||
);
|
||||
|
||||
channelId = selectedChannel ? selectedChannel.id : channels[0].id;
|
||||
|
||||
const parts = ["# Discord Channel Messages", `Channel ID: ${channelId}`];
|
||||
const messages = await this.fetchMessages(channelId, extras.fetch);
|
||||
|
||||
if (messages.length > 0) {
|
||||
parts.push("## Messages");
|
||||
// Format each message into a markdown string
|
||||
messages.forEach((message) => {
|
||||
parts.push(
|
||||
`### ${message.author?.username ?? "Unknown User"} on ${
|
||||
message.timestamp
|
||||
}\n\n${message.content}`,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
parts.push("No messages found.");
|
||||
}
|
||||
|
||||
const content = parts.join("\n\n");
|
||||
|
||||
return [
|
||||
{
|
||||
name: `Messages from Channel ${channelId}`,
|
||||
content,
|
||||
description: "Latest messages from the channel",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
const channels = await this.fetchChannels(args.fetch);
|
||||
|
||||
return channels.map((channel) => ({
|
||||
id: channel.id,
|
||||
title: channel.name || `Channel ${channel.id}`,
|
||||
description: channel.topic ?? "",
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export default DiscordContextProvider;
|
||||
|
|
@ -64,9 +64,7 @@ const getSubprocess = async (extras: ContextProviderExtras) => {
|
|||
const workingDir = await extras.ide.getWorkspaceDirs().then(trimFirstElement);
|
||||
|
||||
return (command: string) =>
|
||||
extras.ide
|
||||
.subprocess(`cd ${workingDir}; ${command}`)
|
||||
.then(trimFirstElement);
|
||||
extras.ide.subprocess(command, workingDir).then(trimFirstElement);
|
||||
};
|
||||
|
||||
class GitLabMergeRequestContextProvider extends BaseContextProvider {
|
||||
|
|
@ -269,7 +267,7 @@ class GitLabMergeRequestContextProvider extends BaseContextProvider {
|
|||
if (ex instanceof AxiosError) {
|
||||
if (ex.response) {
|
||||
const errorMessage = ex.response?.data
|
||||
? ex.response.data.message ?? JSON.stringify(ex.response?.data)
|
||||
? (ex.response.data.message ?? JSON.stringify(ex.response?.data))
|
||||
: `${ex.response.status}: ${ex.response.statusText}`;
|
||||
content += `GitLab Error: ${errorMessage}`;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class HttpContextProvider extends BaseContextProvider {
|
|||
displayTitle: "HTTP",
|
||||
description: "Retrieve a context item from a custom server",
|
||||
type: "normal",
|
||||
renderInlineAs: "",
|
||||
};
|
||||
|
||||
override get description(): ContextProviderDescription {
|
||||
|
|
@ -36,18 +37,29 @@ class HttpContextProvider extends BaseContextProvider {
|
|||
body: JSON.stringify({
|
||||
query: query || "",
|
||||
fullInput: extras.fullInput,
|
||||
options: this.options.options,
|
||||
}),
|
||||
});
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
const createContextItem = (item: any) => ({
|
||||
description: item.description ?? "HTTP Context Item",
|
||||
content: item.content ?? "",
|
||||
name: item.name ?? this.options.title ?? "HTTP",
|
||||
});
|
||||
try {
|
||||
const createContextItem = (item: any) => ({
|
||||
description: item.description ?? "HTTP Context Item",
|
||||
content: item.content ?? "",
|
||||
name: item.name ?? this.options.title ?? "HTTP",
|
||||
});
|
||||
|
||||
return Array.isArray(json) ? json.map(createContextItem) : [createContextItem(json)];
|
||||
return Array.isArray(json)
|
||||
? json.map(createContextItem)
|
||||
: [createContextItem(json)];
|
||||
} catch (e) {
|
||||
console.warn(
|
||||
`Failed to parse response from custom HTTP context provider.\nError:\n${e}\nResponse from server:\n`,
|
||||
json,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class TerminalContextProvider extends BaseContextProvider {
|
|||
static description: ContextProviderDescription = {
|
||||
title: "terminal",
|
||||
displayTitle: "Terminal",
|
||||
description: "Reference the contents of the terminal",
|
||||
description: "Reference the last terminal command",
|
||||
type: "normal",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import SearchContextProvider from "./SearchContextProvider";
|
|||
import TerminalContextProvider from "./TerminalContextProvider";
|
||||
import URLContextProvider from "./URLContextProvider";
|
||||
import RepoMapContextProvider from "./RepoMapContextProvider";
|
||||
import DiscordContextProvider from "./DiscordContextProvider";
|
||||
import GreptileContextProvider from "./GreptileContextProvider";
|
||||
|
||||
/**
|
||||
|
|
@ -54,6 +55,7 @@ export const Providers: (typeof BaseContextProvider)[] = [
|
|||
URLContextProvider,
|
||||
ContinueProxyContextProvider,
|
||||
RepoMapContextProvider,
|
||||
DiscordContextProvider,
|
||||
GreptileContextProvider,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -8,14 +8,20 @@ export class VoyageReranker implements Reranker {
|
|||
private readonly params: {
|
||||
apiKey: string;
|
||||
model?: string;
|
||||
apiBase?: string;
|
||||
},
|
||||
) {}
|
||||
|
||||
private get apiBase() {
|
||||
return this.params.apiBase ?? "https://api.voyageai.com/v1/";
|
||||
}
|
||||
|
||||
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
|
||||
if (!query || chunks.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const resp = await fetch("https://api.voyageai.com/v1/rerank", {
|
||||
const url = new URL("rerank", this.apiBase);
|
||||
const resp = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
|
@ -24,11 +30,20 @@ export class VoyageReranker implements Reranker {
|
|||
body: JSON.stringify({
|
||||
query,
|
||||
documents: chunks.map((chunk) => chunk.content),
|
||||
model: this.params.model ?? "rerank-lite-1",
|
||||
model: this.params.model ?? "rerank-2",
|
||||
}),
|
||||
});
|
||||
const data: any = await resp.json();
|
||||
const results = data.data.sort((a: any, b: any) => a.index - b.index);
|
||||
return results.map((result: any) => result.relevance_score);
|
||||
|
||||
if (resp.status !== 200) {
|
||||
throw new Error(
|
||||
`VoyageReranker API error ${resp.status}: ${await resp.text()}`,
|
||||
);
|
||||
}
|
||||
|
||||
const data = (await resp.json()) as {
|
||||
data: Array<{ index: number; relevance_score: number }>;
|
||||
};
|
||||
const results = data.data.sort((a, b) => a.index - b.index);
|
||||
return results.map((result) => result.relevance_score);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
throw new Error("No reranker provided");
|
||||
}
|
||||
|
||||
// remove empty chunks -- some APIs fail on that
|
||||
chunks = chunks.filter((chunk) => chunk.content);
|
||||
|
||||
let scores: number[] = await this.options.config.reranker.rerank(
|
||||
input,
|
||||
chunks,
|
||||
|
|
@ -62,8 +65,11 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
// (score) => score >= RETRIEVAL_PARAMS.rerankThreshold,
|
||||
// );
|
||||
|
||||
const chunkIndexMap = new Map<Chunk, number>();
|
||||
chunks.forEach((chunk, idx) => chunkIndexMap.set(chunk, idx));
|
||||
|
||||
results.sort(
|
||||
(a, b) => scores[results.indexOf(a)] - scores[results.indexOf(b)],
|
||||
(a, b) => scores[chunkIndexMap.get(a)!] - scores[chunkIndexMap.get(b)!],
|
||||
);
|
||||
results = results.slice(-this.options.nFinal);
|
||||
return results;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import path from "path";
|
||||
import { BranchAndDir, ContextItem, ContextProviderExtras } from "../../";
|
||||
import TransformersJsEmbeddingsProvider from "../../indexing/embeddings/TransformersJsEmbeddingsProvider";
|
||||
import { resolveRelativePathInWorkspace } from "../../util/ideUtils";
|
||||
import { getRelativePath } from "../../util/";
|
||||
import { INSTRUCTIONS_BASE_ITEM } from "../providers/utils";
|
||||
import { RetrievalPipelineOptions } from "./pipelines/BaseRetrievalPipeline";
|
||||
import NoRerankerRetrievalPipeline from "./pipelines/NoRerankerRetrievalPipeline";
|
||||
import RerankerRetrievalPipeline from "./pipelines/RerankerRetrievalPipeline";
|
||||
import path from "path";
|
||||
|
||||
const DEFAULT_N_FINAL = 25;
|
||||
|
||||
export async function retrieveContextItemsFromEmbeddings(
|
||||
extras: ContextProviderExtras,
|
||||
|
|
@ -43,7 +44,8 @@ export async function retrieveContextItemsFromEmbeddings(
|
|||
const contextLength = extras.llm.contextLength;
|
||||
const tokensPerSnippet = 512;
|
||||
const nFinal =
|
||||
options?.nFinal ?? Math.min(50, contextLength / tokensPerSnippet / 2);
|
||||
options?.nFinal ??
|
||||
Math.min(DEFAULT_N_FINAL, contextLength / tokensPerSnippet / 2);
|
||||
const useReranking = !!extras.reranker;
|
||||
const nRetrieve = useReranking ? options?.nRetrieve || 2 * nFinal : nFinal;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ export interface ControlPlaneModelDescription extends ModelDescription {}
|
|||
export const DEFAULT_CONTROL_PLANE_PROXY_URL =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
? "http://localhost:3001/"
|
||||
: "https://control-plane-proxy.continue.dev/";
|
||||
: "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/";
|
||||
// : "https://control-plane-proxy.continue.dev/";
|
||||
|
||||
export const CONTROL_PLANE_URL =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
|
|
|
|||
10
core/core.ts
10
core/core.ts
|
|
@ -28,6 +28,7 @@ import type { IMessenger, Message } from "./util/messenger";
|
|||
import { editConfigJson } from "./util/paths";
|
||||
import { Telemetry } from "./util/posthog";
|
||||
import { TTS } from "./util/tts";
|
||||
import { ChatDescriber } from "./util/chatDescriber";
|
||||
|
||||
export class Core {
|
||||
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
|
||||
|
|
@ -401,7 +402,6 @@ export class Core {
|
|||
if (config.experimental?.readResponseTTS && "completion" in next.value) {
|
||||
void TTS.read(next.value?.completion);
|
||||
}
|
||||
|
||||
return { done: true, content: next.value };
|
||||
}
|
||||
|
||||
|
|
@ -476,12 +476,18 @@ export class Core {
|
|||
}
|
||||
});
|
||||
|
||||
// Provide messenger to TTS so it can set GUI active / inactive state
|
||||
// Provide messenger to utils so they can interact with GUI + state
|
||||
TTS.messenger = this.messenger;
|
||||
ChatDescriber.messenger = this.messenger;
|
||||
|
||||
on("tts/kill", async () => {
|
||||
void TTS.kill();
|
||||
});
|
||||
|
||||
on("chatDescriber/describe", async (msg) => {
|
||||
const currentModel = await this.getSelectedModel();
|
||||
return await ChatDescriber.describe(currentModel, {}, msg.data);
|
||||
});
|
||||
|
||||
async function* runNodeJsSlashCommand(
|
||||
configHandler: ConfigHandler,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { LineStream, matchLine } from "./util.js";
|
|||
* - old + same = oldLinesCopy.length
|
||||
* ^ (above two guarantee that all lines get represented)
|
||||
* - Lines are always output in order, at least among old and new separately
|
||||
* - Old lines in a hunk are always output before the new lines
|
||||
*/
|
||||
export async function* streamDiff(
|
||||
oldLines: string[],
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { ILLM } from "../..";
|
|||
import {
|
||||
filterLeadingNewline,
|
||||
stopAtLines,
|
||||
} from "../../autocomplete/lineStream";
|
||||
} from "../../autocomplete/streamTransforms/lineStream";
|
||||
import { streamLines } from "../../diff/util";
|
||||
import { dedent } from "../../util";
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import {
|
|||
filterLeadingAndTrailingNewLineInsertion,
|
||||
filterLeadingNewline,
|
||||
stopAtLines,
|
||||
} from "../../autocomplete/lineStream.js";
|
||||
} from "../../autocomplete/streamTransforms/lineStream";
|
||||
import { streamDiff } from "../../diff/streamDiff.js";
|
||||
import { LineStream, streamLines } from "../../diff/util.js";
|
||||
import { DiffLine, ILLM } from "../../index.js";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
filterLeadingAndTrailingNewLineInsertion,
|
||||
skipLines,
|
||||
stopAtLines,
|
||||
} from "../autocomplete/lineStream.js";
|
||||
} from "../autocomplete/streamTransforms/lineStream.js";
|
||||
import { streamDiff } from "../diff/streamDiff.js";
|
||||
import { streamLines } from "../diff/util.js";
|
||||
import {
|
||||
|
|
|
|||
16
core/index.d.ts
vendored
16
core/index.d.ts
vendored
|
|
@ -500,7 +500,7 @@ export interface IDE {
|
|||
getCurrentFile(): Promise<string | undefined>;
|
||||
getPinnedFiles(): Promise<string[]>;
|
||||
getSearchResults(query: string): Promise<string>;
|
||||
subprocess(command: string): Promise<[string, string]>;
|
||||
subprocess(command: string, cwd?: string): Promise<[string, string]>;
|
||||
getProblems(filepath?: string | undefined): Promise<Problem[]>;
|
||||
getBranch(dir: string): Promise<string>;
|
||||
getTags(artifactId: string): Promise<IndexTag[]>;
|
||||
|
|
@ -644,7 +644,9 @@ type ModelProvider =
|
|||
| "sambanova"
|
||||
| "nvidia"
|
||||
| "vllm"
|
||||
| "mock";
|
||||
| "mock"
|
||||
| "cerebras";
|
||||
|
||||
|
||||
export type ModelName =
|
||||
| "AUTODETECT"
|
||||
|
|
@ -683,6 +685,9 @@ export type ModelName =
|
|||
// Llama 3
|
||||
| "llama3-8b"
|
||||
| "llama3-70b"
|
||||
// Llama 3.1
|
||||
| "llama3.1-8b"
|
||||
| "llama3.1-70b"
|
||||
// Other Open-source
|
||||
| "phi2"
|
||||
| "phind-codellama-34b"
|
||||
|
|
@ -801,6 +806,7 @@ export interface ModelDescription {
|
|||
}
|
||||
|
||||
export type EmbeddingsProviderName =
|
||||
| "sagemaker"
|
||||
| "bedrock"
|
||||
| "huggingface-tei"
|
||||
| "transformers.js"
|
||||
|
|
@ -882,6 +888,7 @@ export interface TabAutocompleteOptions {
|
|||
recentLinePrefixMatchMinLength: number;
|
||||
disableInFiles?: string[];
|
||||
useImports?: boolean;
|
||||
useRootPathContext?: boolean;
|
||||
}
|
||||
|
||||
export interface ContinueUIConfig {
|
||||
|
|
@ -951,6 +958,11 @@ interface ExperimentalConfig {
|
|||
*/
|
||||
readResponseTTS?: boolean;
|
||||
|
||||
/**
|
||||
* Prompt the user's LLM for a title given the current chat content
|
||||
*/
|
||||
getChatTitles?: boolean;
|
||||
|
||||
/**
|
||||
* If set to true, we will attempt to pull down and install an instance of Chromium
|
||||
* that is compatible with the current version of Puppeteer.
|
||||
|
|
|
|||
|
|
@ -261,7 +261,9 @@ class CheerioCrawler {
|
|||
console.error(error);
|
||||
return { html: "", links: [] };
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
return { html: "", links: [] };
|
||||
}
|
||||
const html = await response.text();
|
||||
let links: string[] = [];
|
||||
|
||||
|
|
@ -277,7 +279,7 @@ class CheerioCrawler {
|
|||
return;
|
||||
}
|
||||
|
||||
const parsedUrl = new URL(href, url);
|
||||
const parsedUrl = new URL(href, location);
|
||||
if (parsedUrl.hostname === baseUrl.hostname) {
|
||||
links.push(parsedUrl.pathname);
|
||||
}
|
||||
|
|
@ -289,14 +291,11 @@ class CheerioCrawler {
|
|||
!this.IGNORE_PATHS_ENDING_IN.some((ending) => link.endsWith(ending))
|
||||
);
|
||||
});
|
||||
|
||||
return { html, links };
|
||||
}
|
||||
|
||||
private splitUrl(url: URL) {
|
||||
const baseUrl = `${url.protocol}//${url.hostname}${
|
||||
url.port ? ":" + url.port : ""
|
||||
}`;
|
||||
const baseUrl = new URL('/', url).href;
|
||||
const basePath = url.pathname;
|
||||
return { baseUrl, basePath };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -534,8 +534,12 @@ export default class DocsService {
|
|||
await table.delete(`title = '${mockRowTitle}'`);
|
||||
}
|
||||
|
||||
private removeInvalidLanceTableNameChars(tableName: string) {
|
||||
return tableName.replace(/:/g, "");
|
||||
/**
|
||||
* From Lance: Table names can only contain alphanumeric characters,
|
||||
* underscores, hyphens, and periods
|
||||
*/
|
||||
private sanitizeLanceTableName(name: string) {
|
||||
return name.replace(/[^a-zA-Z0-9_.-]/g, "_");
|
||||
}
|
||||
|
||||
private async getLanceTableNameFromEmbeddingsProvider(
|
||||
|
|
@ -544,10 +548,10 @@ export default class DocsService {
|
|||
const embeddingsProvider = await this.getEmbeddingsProvider(
|
||||
isPreIndexedDoc,
|
||||
);
|
||||
const embeddingsProviderId = this.removeInvalidLanceTableNameChars(
|
||||
embeddingsProvider.id,
|
||||
|
||||
const tableName = this.sanitizeLanceTableName(
|
||||
`${DocsService.lanceTableName}${embeddingsProvider.id}`,
|
||||
);
|
||||
const tableName = `${DocsService.lanceTableName}${embeddingsProviderId}`;
|
||||
|
||||
return tableName;
|
||||
}
|
||||
|
|
|
|||
114
core/indexing/embeddings/SageMakerEmbeddingsProvider.ts
Normal file
114
core/indexing/embeddings/SageMakerEmbeddingsProvider.ts
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
import {
|
||||
InvokeEndpointCommand,
|
||||
SageMakerRuntimeClient,
|
||||
} from "@aws-sdk/client-sagemaker-runtime";
|
||||
import { fromIni } from "@aws-sdk/credential-providers";
|
||||
|
||||
import {
|
||||
EmbeddingsProviderName,
|
||||
EmbedOptions,
|
||||
FetchFunction,
|
||||
} from "../../index.js";
|
||||
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
|
||||
|
||||
|
||||
class SageMakerEmbeddingsProvider extends BaseEmbeddingsProvider {
|
||||
static providerName: EmbeddingsProviderName = "sagemaker";
|
||||
|
||||
static defaultOptions: Partial<EmbedOptions> | undefined = {
|
||||
region: "us-west-2",
|
||||
maxBatchSize: 1,
|
||||
};
|
||||
profile?: string | undefined;
|
||||
|
||||
constructor(options: EmbedOptions, fetch: FetchFunction) {
|
||||
super(options, fetch);
|
||||
if (!options.apiBase) {
|
||||
options.apiBase = `https://runtime.sagemaker.${options.region}.amazonaws.com`;
|
||||
}
|
||||
|
||||
if (options.profile) {
|
||||
this.profile = options.profile;
|
||||
} else {
|
||||
this.profile = "sagemaker";
|
||||
}
|
||||
}
|
||||
|
||||
async embed(chunks: string[]) {
|
||||
const credentials = await this._getCredentials();
|
||||
const client = new SageMakerRuntimeClient({
|
||||
region: this.options.region,
|
||||
credentials: {
|
||||
accessKeyId: credentials.accessKeyId,
|
||||
secretAccessKey: credentials.secretAccessKey,
|
||||
sessionToken: credentials.sessionToken || "",
|
||||
},
|
||||
});
|
||||
|
||||
const batchedChunks = this.getBatchedChunks(chunks);
|
||||
return (
|
||||
await Promise.all(
|
||||
batchedChunks.map(async (batch) => {
|
||||
const input = this._generateInvokeModelCommandInput(
|
||||
batch,
|
||||
this.options,
|
||||
);
|
||||
const command = new InvokeEndpointCommand(input);
|
||||
const response = await client.send(command);
|
||||
|
||||
if (response.Body) {
|
||||
const responseBody = JSON.parse(
|
||||
new TextDecoder().decode(response.Body),
|
||||
);
|
||||
// If the body contains a key called "embedding" or "embeddings", return the value, otherwise return the whole body
|
||||
if (responseBody.embedding) {
|
||||
return responseBody.embedding;
|
||||
} else if (responseBody.embeddings) {
|
||||
return responseBody.embeddings;
|
||||
} else {
|
||||
return responseBody;
|
||||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
).flat();
|
||||
}
|
||||
private _generateInvokeModelCommandInput(
|
||||
prompts: string | string[],
|
||||
options: EmbedOptions,
|
||||
): any {
|
||||
const payload = {
|
||||
inputs: prompts,
|
||||
normalize: true,
|
||||
// ...(options.requestOptions?.extraBodyProperties || {}),
|
||||
};
|
||||
|
||||
if (options.requestOptions?.extraBodyProperties) {
|
||||
Object.assign(payload, options.requestOptions.extraBodyProperties);
|
||||
}
|
||||
|
||||
return {
|
||||
EndpointName: this.options.model,
|
||||
Body: JSON.stringify(payload),
|
||||
ContentType: "application/json",
|
||||
CustomAttributes: "accept_eula=false",
|
||||
};
|
||||
}
|
||||
|
||||
private async _getCredentials() {
|
||||
try {
|
||||
return await fromIni({
|
||||
profile: this.profile,
|
||||
ignoreCache: true,
|
||||
})();
|
||||
} catch (e) {
|
||||
console.warn(
|
||||
`AWS profile with name ${this.profile} not found in ~/.aws/credentials, using default profile`,
|
||||
);
|
||||
return await fromIni()();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default SageMakerEmbeddingsProvider;
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { EmbeddingsProviderName } from "../../index.js";
|
||||
import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
|
||||
import SageMakerEmbeddingsProvider from "./SageMakerEmbeddingsProvider.js";
|
||||
import BedrockEmbeddingsProvider from "./BedrockEmbeddingsProvider.js";
|
||||
import CohereEmbeddingsProvider from "./CohereEmbeddingsProvider.js";
|
||||
import ContinueProxyEmbeddingsProvider from "./ContinueProxyEmbeddingsProvider.js";
|
||||
|
|
@ -22,6 +23,7 @@ export const allEmbeddingsProviders: Record<
|
|||
EmbeddingsProviderName,
|
||||
EmbeddingsProviderConstructor
|
||||
> = {
|
||||
sagemaker: SageMakerEmbeddingsProvider,
|
||||
bedrock: BedrockEmbeddingsProvider,
|
||||
ollama: OllamaEmbeddingsProvider,
|
||||
"transformers.js": TransformersJsEmbeddingsProvider,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ export const DEFAULT_IGNORE_FILETYPES = [
|
|||
"*.uasset",
|
||||
"*.pdb",
|
||||
"*.bin",
|
||||
"*.pag",
|
||||
"*.swp",
|
||||
// "*.prompt", // can be incredibly confusing for the LLM to have another set of instructions injected into the prompt
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { findLlmInfo } from "@continuedev/llm-info";
|
||||
import Handlebars from "handlebars";
|
||||
import {
|
||||
CacheBehavior,
|
||||
ChatMessage,
|
||||
ChatMessageRole,
|
||||
CompletionOptions,
|
||||
|
|
@ -14,7 +15,6 @@ import {
|
|||
PromptTemplate,
|
||||
RequestOptions,
|
||||
TemplateType,
|
||||
CacheBehavior
|
||||
} from "../index.js";
|
||||
import { logDevData } from "../util/devdata.js";
|
||||
import { DevDataSqliteDb } from "../util/devdataSqlite.js";
|
||||
|
|
|
|||
20
core/llm/llms/Cerebras.ts
Normal file
20
core/llm/llms/Cerebras.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { LLMOptions, ModelProvider } from "../../index.js";
|
||||
import OpenAI from "./OpenAI.js";
|
||||
|
||||
class Cerebras extends OpenAI {
|
||||
static providerName: ModelProvider = "cerebras";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "https://api.cerebras.ai/v1/",
|
||||
};
|
||||
maxStopWords: number | undefined = 4;
|
||||
|
||||
private static modelConversion: { [key: string]: string } = {
|
||||
"llama3.1-8b": "llama3.1-8b",
|
||||
"llama3.1-70b": "llama3.1-70b",
|
||||
};
|
||||
protected _convertModelName(model: string): string {
|
||||
return Cerebras.modelConversion[model] ?? model;
|
||||
}
|
||||
}
|
||||
|
||||
export default Cerebras;
|
||||
|
|
@ -3,6 +3,7 @@ import { BaseLLM } from "../index.js";
|
|||
import { streamSse } from "../stream.js";
|
||||
|
||||
class HuggingFaceTGI extends BaseLLM {
|
||||
private static MAX_STOP_TOKENS = 4;
|
||||
static providerName: ModelProvider = "huggingface-tgi";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: "http://localhost:8080/",
|
||||
|
|
@ -36,7 +37,10 @@ class HuggingFaceTGI extends BaseLLM {
|
|||
top_k: options.topK,
|
||||
presence_penalty: options.presencePenalty,
|
||||
frequency_penalty: options.frequencyPenalty,
|
||||
stop: options.stop,
|
||||
stop: options.stop?.slice(
|
||||
0,
|
||||
this.maxStopWords ?? HuggingFaceTGI.MAX_STOP_TOKENS,
|
||||
),
|
||||
};
|
||||
|
||||
return finalOptions;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class Ollama extends BaseLLM {
|
|||
model: "codellama-7b",
|
||||
};
|
||||
|
||||
private fimSupported: boolean = false;
|
||||
|
||||
constructor(options: LLMOptions) {
|
||||
super(options);
|
||||
|
||||
|
|
@ -31,7 +33,7 @@ class Ollama extends BaseLLM {
|
|||
body: JSON.stringify({ name: this._getModel() }),
|
||||
})
|
||||
.then(async (response) => {
|
||||
if (response.status !== 200) {
|
||||
if (response?.status !== 200) {
|
||||
// console.warn(
|
||||
// "Error calling Ollama /api/show endpoint: ",
|
||||
// await response.text(),
|
||||
|
|
@ -70,6 +72,13 @@ class Ollama extends BaseLLM {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no API to get the model's FIM capabilities, so we have to
|
||||
* make an educated guess. If a ".Suffix" variable appears in the template
|
||||
* it's a good indication the model supports FIM.
|
||||
*/
|
||||
this.fimSupported = !!body?.template?.includes(".Suffix");
|
||||
})
|
||||
.catch((e) => {
|
||||
// console.warn("Error calling the Ollama /api/show endpoint: ", e);
|
||||
|
|
@ -251,7 +260,7 @@ class Ollama extends BaseLLM {
|
|||
}
|
||||
|
||||
supportsFim(): boolean {
|
||||
return true;
|
||||
return this.fimSupported;
|
||||
}
|
||||
|
||||
protected async *_streamFim(
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import Anthropic from "./Anthropic";
|
|||
import Azure from "./Azure";
|
||||
import Bedrock from "./Bedrock";
|
||||
import BedrockImport from "./BedrockImport";
|
||||
import Cerebras from "./Cerebras";
|
||||
import Cloudflare from "./Cloudflare";
|
||||
import Cohere from "./Cohere";
|
||||
import DeepInfra from "./DeepInfra";
|
||||
|
|
@ -77,6 +78,7 @@ const LLMs = [
|
|||
Vllm,
|
||||
SambaNova,
|
||||
Mock,
|
||||
Cerebras,
|
||||
];
|
||||
|
||||
export async function llmFromDescription(
|
||||
|
|
|
|||
21
core/package-lock.json
generated
21
core/package-lock.json
generated
|
|
@ -39,6 +39,7 @@
|
|||
"jsdom": "^24.0.0",
|
||||
"launchdarkly-node-client-sdk": "^3.2.0",
|
||||
"llm-code-highlighter": "^0.0.14",
|
||||
"lru-cache": "^10.2.2",
|
||||
"mac-ca": "^3.1.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
|
|
@ -1342,6 +1343,15 @@
|
|||
"node": ">=6.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-compilation-targets/node_modules/lru-cache": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"yallist": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/helper-compilation-targets/node_modules/semver": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||
|
|
@ -10481,12 +10491,11 @@
|
|||
"integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q=="
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"yallist": "^3.0.2"
|
||||
"version": "10.2.2",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz",
|
||||
"integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==",
|
||||
"engines": {
|
||||
"node": "14 || >=16.14"
|
||||
}
|
||||
},
|
||||
"node_modules/mac-ca": {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@
|
|||
"jsdom": "^24.0.0",
|
||||
"launchdarkly-node-client-sdk": "^3.2.0",
|
||||
"llm-code-highlighter": "^0.0.14",
|
||||
"lru-cache": "^10.2.2",
|
||||
"mac-ca": "^3.1.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"node-html-markdown": "^1.3.0",
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
|
|||
},
|
||||
ProtocolGeneratorType<DiffLine>,
|
||||
];
|
||||
"chatDescriber/describe": [string, string | undefined];
|
||||
"stats/getTokensPerDay": [
|
||||
undefined,
|
||||
{ day: string; promptTokens: number; generatedTokens: number }[],
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
openFile: [{ path: string }, void];
|
||||
runCommand: [{ command: string }, void];
|
||||
getSearchResults: [{ query: string }, string];
|
||||
subprocess: [{ command: string }, [string, string]];
|
||||
subprocess: [{ command: string; cwd?: string }, [string, string]];
|
||||
saveFile: [{ filepath: string }, void];
|
||||
fileExists: [{ filepath: string }, boolean];
|
||||
readFile: [{ filepath: string }, string];
|
||||
|
|
@ -97,4 +97,5 @@ export type ToWebviewOrCoreFromIdeProtocol = {
|
|||
{ sessionInfo: ControlPlaneSessionInfo | undefined },
|
||||
void,
|
||||
];
|
||||
didChangeIdeSettings: [{ settings: IdeSettings }, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & {
|
|||
toggleDevTools: [undefined, void];
|
||||
reloadWindow: [undefined, void];
|
||||
focusEditor: [undefined, void];
|
||||
toggleFullScreen: [undefined, void];
|
||||
toggleFullScreen: [{ newWindow?: boolean } | undefined, void];
|
||||
insertAtCursor: [{ text: string }, void];
|
||||
copyText: [{ text: string }, void];
|
||||
"jetbrains/editorInsetHeight": [{ height: number }, void];
|
||||
|
|
@ -58,8 +58,13 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
},
|
||||
void,
|
||||
];
|
||||
navigateTo: [{ path: string; toggle?: boolean }, void];
|
||||
addModel: [undefined, void];
|
||||
|
||||
openSettings: [undefined, void];
|
||||
/**
|
||||
* @deprecated Use navigateTo with a path instead.
|
||||
*/
|
||||
viewHistory: [undefined, void];
|
||||
newSession: [undefined, void];
|
||||
setTheme: [{ theme: any }, void];
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
|
|||
"llm/streamChat",
|
||||
"llm/listModels",
|
||||
"streamDiffLines",
|
||||
"chatDescriber/describe",
|
||||
"stats/getTokensPerDay",
|
||||
"stats/getTokensPerModel",
|
||||
"index/setPaused",
|
||||
|
|
|
|||
76
core/test/util/dedentAndGetCommonWhitespace.test.ts
Normal file
76
core/test/util/dedentAndGetCommonWhitespace.test.ts
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
// File generated by Continue
|
||||
import { dedentAndGetCommonWhitespace } from "../../util";
|
||||
|
||||
describe("dedentAndGetCommonWhitespace", () => {
|
||||
let originalString: string;
|
||||
|
||||
beforeEach(() => {
|
||||
// Setup any global variables or states if needed
|
||||
originalString = " line1\n line2\n line3";
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Tear down any changes to global variables or states if needed
|
||||
originalString = "";
|
||||
});
|
||||
|
||||
test("should dedent and return common whitespace for a simple case", () => {
|
||||
const input = " line1\n line2\n line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["line1\nline2\nline3", " "]);
|
||||
});
|
||||
|
||||
test("should handle empty string", () => {
|
||||
const input = "";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["", ""]);
|
||||
});
|
||||
|
||||
test("should handle string with only whitespace", () => {
|
||||
const input = " ";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["", ""]);
|
||||
});
|
||||
|
||||
test("should handle string with mixed whitespace and content", () => {
|
||||
const input = " line1\n line2\n line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual([" line1\nline2\n line3", " "]);
|
||||
});
|
||||
|
||||
test("should handle string with no common leading whitespace", () => {
|
||||
const input = "line1\n line2\n line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual([input, ""]);
|
||||
});
|
||||
|
||||
test("should handle string with empty lines", () => {
|
||||
const input = " line1\n\n line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["line1\n\nline3", " "]);
|
||||
});
|
||||
|
||||
test("should handle string with only empty lines", () => {
|
||||
const input = "\n\n";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["\n\n", ""]);
|
||||
});
|
||||
|
||||
test("should handle string with tabs as whitespace", () => {
|
||||
const input = "\tline1\n\tline2\n\tline3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["line1\nline2\nline3", "\t"]);
|
||||
});
|
||||
|
||||
test("should handle string with mixed tabs and spaces", () => {
|
||||
const input = "\t line1\n\t line2\n\t line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual(["line1\nline2\nline3", "\t "]);
|
||||
});
|
||||
|
||||
test("should handle string with different leading whitespace lengths", () => {
|
||||
const input = " line1\n line2\n line3";
|
||||
const output = dedentAndGetCommonWhitespace(input);
|
||||
expect(output).toEqual([" line1\nline2\n line3", " "]);
|
||||
});
|
||||
});
|
||||
51
core/test/util/getLastNPathParts.test.ts
Normal file
51
core/test/util/getLastNPathParts.test.ts
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// File generated by Continue
|
||||
import { getLastNPathParts } from "../../util";
|
||||
|
||||
describe("getLastNPathParts", () => {
|
||||
const SEP_REGEX = /[\\/]+/;
|
||||
|
||||
beforeAll(() => {
|
||||
// Setup code if needed
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
// Teardown code if needed
|
||||
});
|
||||
|
||||
test("returns the last N parts of a filepath with forward slashes", () => {
|
||||
const filepath = "home/user/documents/project/file.txt";
|
||||
expect(getLastNPathParts(filepath, 2)).toBe("project/file.txt");
|
||||
});
|
||||
|
||||
test("returns the last N parts of a filepath with backward slashes", () => {
|
||||
const filepath = "C:\\home\\user\\documents\\project\\file.txt";
|
||||
expect(getLastNPathParts(filepath, 3)).toBe("documents/project/file.txt");
|
||||
});
|
||||
|
||||
test("returns the last part if N is 1", () => {
|
||||
const filepath = "/home/user/documents/project/file.txt";
|
||||
expect(getLastNPathParts(filepath, 1)).toBe("file.txt");
|
||||
});
|
||||
|
||||
test("returns the entire path if N is greater than the number of parts", () => {
|
||||
const filepath = "home/user/documents/project/file.txt";
|
||||
expect(getLastNPathParts(filepath, 10)).toBe(
|
||||
"home/user/documents/project/file.txt",
|
||||
);
|
||||
});
|
||||
|
||||
test("returns an empty string if N is 0", () => {
|
||||
const filepath = "home/user/documents/project/file.txt";
|
||||
expect(getLastNPathParts(filepath, 0)).toBe("");
|
||||
});
|
||||
|
||||
test("handles paths with mixed forward and backward slashes", () => {
|
||||
const filepath = "home\\user/documents\\project/file.txt";
|
||||
expect(getLastNPathParts(filepath, 3)).toBe("documents/project/file.txt");
|
||||
});
|
||||
|
||||
test("handles edge case with empty filepath", () => {
|
||||
const filepath = "";
|
||||
expect(getLastNPathParts(filepath, 2)).toBe("");
|
||||
});
|
||||
});
|
||||
40
core/test/util/lcs.test.ts
Normal file
40
core/test/util/lcs.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// This file is generated by Continue
|
||||
import { longestCommonSubsequence } from "../../util/lcs";
|
||||
|
||||
describe("longestCommonSubsequence", () => {
|
||||
beforeAll(() => {
|
||||
// Setup if needed
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
// Teardown if needed
|
||||
});
|
||||
|
||||
test("should return the longest common subsequence for non-empty strings", () => {
|
||||
expect(longestCommonSubsequence("abcde", "ace")).toBe("ace");
|
||||
expect(longestCommonSubsequence("abc", "abc")).toBe("abc");
|
||||
expect(longestCommonSubsequence("abc", "def")).toBe("");
|
||||
});
|
||||
|
||||
test("should handle cases where one or both strings are empty", () => {
|
||||
expect(longestCommonSubsequence("", "abc")).toBe("");
|
||||
expect(longestCommonSubsequence("abc", "")).toBe("");
|
||||
expect(longestCommonSubsequence("", "")).toBe("");
|
||||
});
|
||||
|
||||
test("should handle cases with no common subsequence", () => {
|
||||
expect(longestCommonSubsequence("abc", "def")).toBe("");
|
||||
expect(longestCommonSubsequence("xyz", "abc")).toBe("");
|
||||
});
|
||||
|
||||
test("should handle cases with special characters", () => {
|
||||
expect(longestCommonSubsequence("a!@#b$c", "!@#$")).toBe("!@#$");
|
||||
expect(longestCommonSubsequence("a!@#b$c", "xyz")).toBe("");
|
||||
});
|
||||
|
||||
test("should handle long strings efficiently", () => {
|
||||
const str1 = "a".repeat(1000) + "b".repeat(1000);
|
||||
const str2 = "a".repeat(1000) + "c".repeat(1000);
|
||||
expect(longestCommonSubsequence(str1, str2)).toBe("a".repeat(1000));
|
||||
});
|
||||
});
|
||||
100
core/test/util/merge.test.ts
Normal file
100
core/test/util/merge.test.ts
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
// File generated by Continue
|
||||
import { mergeJson } from "../../util/merge";
|
||||
|
||||
describe("mergeJson", () => {
|
||||
it("should merge two simple JSON objects", () => {
|
||||
const first = { a: 1, b: 2 };
|
||||
const second = { b: 3, c: 4 };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 1, b: 3, c: 4 });
|
||||
});
|
||||
|
||||
it('should overwrite values when mergeBehavior is "overwrite"', () => {
|
||||
const first = { a: 1, b: 2 };
|
||||
const second = { b: 3, c: 4 };
|
||||
const result = mergeJson(first, second, "overwrite");
|
||||
expect(result).toEqual({ a: 1, b: 3, c: 4 });
|
||||
});
|
||||
|
||||
it("should merge nested objects", () => {
|
||||
const first = { a: { b: 1 } };
|
||||
const second = { a: { c: 2 } };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: { b: 1, c: 2 } });
|
||||
});
|
||||
|
||||
it("should merge arrays without mergeKeys", () => {
|
||||
const first = { a: [1, 2] };
|
||||
const second = { a: [3, 4] };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: [1, 2, 3, 4] });
|
||||
});
|
||||
|
||||
it("should merge arrays with mergeKeys", () => {
|
||||
const first = {
|
||||
a: [
|
||||
{ id: 1, value: "first" },
|
||||
{ id: 2, value: "second" },
|
||||
],
|
||||
};
|
||||
const second = {
|
||||
a: [
|
||||
{ id: 2, value: "updated" },
|
||||
{ id: 3, value: "third" },
|
||||
],
|
||||
};
|
||||
const mergeKeys = {
|
||||
a: (item1: any, item2: any) => item1.id === item2.id,
|
||||
};
|
||||
const result = mergeJson(first, second, undefined, mergeKeys);
|
||||
expect(result).toEqual({
|
||||
a: [
|
||||
{ id: 1, value: "first" },
|
||||
{ id: 2, value: "updated" },
|
||||
{ id: 3, value: "third" },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("should handle non-object values correctly", () => {
|
||||
const first = { a: 1, b: "string", c: true };
|
||||
const second = { a: 2, b: "new string", c: false };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 2, b: "new string", c: false });
|
||||
});
|
||||
|
||||
it("should handle null and undefined values correctly", () => {
|
||||
const first = { a: 1, b: null };
|
||||
const second = { b: 2, c: undefined };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 1, b: 2, c: undefined });
|
||||
});
|
||||
|
||||
it("should handle empty objects", () => {
|
||||
const first = {};
|
||||
const second = { a: 1 };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 1 });
|
||||
});
|
||||
|
||||
it("should handle empty second object", () => {
|
||||
const first = { a: 1 };
|
||||
const second = {};
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 1 });
|
||||
});
|
||||
|
||||
it("should handle errors gracefully", () => {
|
||||
const first = { a: 1 };
|
||||
const second = { b: () => {} }; // Functions are not serializable in JSON
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: 1, b: expect.any(Function) });
|
||||
});
|
||||
|
||||
it("should merge deeply nested objects", () => {
|
||||
const first = { a: { b: { c: 1 } } };
|
||||
const second = { a: { b: { d: 2 } } };
|
||||
const result = mergeJson(first, second);
|
||||
expect(result).toEqual({ a: { b: { c: 1, d: 2 } } });
|
||||
});
|
||||
});
|
||||
105
core/test/util/ranges/getRangeInString.test.ts
Normal file
105
core/test/util/ranges/getRangeInString.test.ts
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// This file is generated by Continue
|
||||
|
||||
import { getRangeInString } from "../../../util/ranges";
|
||||
|
||||
describe.skip("getRangeInString", () => {
|
||||
let content: string;
|
||||
|
||||
beforeEach(() => {
|
||||
content = `Line 1
|
||||
Line 2
|
||||
Line 3
|
||||
Line 4
|
||||
Line 5`;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
content = "";
|
||||
});
|
||||
|
||||
test("should return substring within the same line", () => {
|
||||
const range = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 1, character: 4 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("Line");
|
||||
});
|
||||
|
||||
test("should return substring spanning multiple lines", () => {
|
||||
const range = {
|
||||
start: { line: 1, character: 2 },
|
||||
end: { line: 3, character: 3 },
|
||||
};
|
||||
const expected = `ne 2
|
||||
Line 3
|
||||
Line 4`;
|
||||
expect(getRangeInString(content, range)).toBe(expected);
|
||||
});
|
||||
|
||||
test("should handle range that starts and ends at the same character", () => {
|
||||
const range = {
|
||||
start: { line: 2, character: 0 },
|
||||
end: { line: 2, character: 0 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("L");
|
||||
});
|
||||
|
||||
test("should handle range that spans entire content", () => {
|
||||
const range = {
|
||||
start: { line: 0, character: 0 },
|
||||
end: { line: 4, character: 5 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe(content);
|
||||
});
|
||||
|
||||
test("should handle range that spans to the end of the last line", () => {
|
||||
const range = {
|
||||
start: { line: 3, character: 2 },
|
||||
end: { line: 4, character: 5 },
|
||||
};
|
||||
const expected = `ne 4
|
||||
Line 5`;
|
||||
expect(getRangeInString(content, range)).toBe(expected);
|
||||
});
|
||||
|
||||
test("should handle empty content", () => {
|
||||
content = "";
|
||||
const range = {
|
||||
start: { line: 0, character: 0 },
|
||||
end: { line: 0, character: 0 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("");
|
||||
});
|
||||
|
||||
test("should handle invalid range (start line > end line)", () => {
|
||||
const range = {
|
||||
start: { line: 3, character: 0 },
|
||||
end: { line: 2, character: 0 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("");
|
||||
});
|
||||
|
||||
test("should handle invalid range (start character > end character on same line)", () => {
|
||||
const range = {
|
||||
start: { line: 1, character: 5 },
|
||||
end: { line: 1, character: 2 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("");
|
||||
});
|
||||
|
||||
test("should handle range that starts and ends at the same line but different characters", () => {
|
||||
const range = {
|
||||
start: { line: 1, character: 2 },
|
||||
end: { line: 1, character: 6 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("ne 2");
|
||||
});
|
||||
|
||||
test("should handle range that starts and ends at the same line and same characters", () => {
|
||||
const range = {
|
||||
start: { line: 1, character: 2 },
|
||||
end: { line: 1, character: 2 },
|
||||
};
|
||||
expect(getRangeInString(content, range)).toBe("n");
|
||||
});
|
||||
});
|
||||
123
core/test/util/ranges/intersection.test.ts
Normal file
123
core/test/util/ranges/intersection.test.ts
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
// This file is generated by Continue
|
||||
|
||||
import { intersection } from "../../../util/ranges";
|
||||
|
||||
interface Position {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
interface Range {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
describe("intersection", () => {
|
||||
let rangeA: Range;
|
||||
let rangeB: Range;
|
||||
|
||||
beforeEach(() => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 3, character: 5 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 2, character: 2 },
|
||||
end: { line: 4, character: 0 },
|
||||
};
|
||||
});
|
||||
|
||||
test("returns correct intersection for overlapping ranges", () => {
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 2, character: 2 },
|
||||
end: { line: 3, character: 5 },
|
||||
});
|
||||
});
|
||||
|
||||
test("returns null for non-overlapping ranges", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 2, character: 0 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 3, character: 0 },
|
||||
end: { line: 4, character: 0 },
|
||||
};
|
||||
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
// TODO
|
||||
test.skip("returns correct intersection for single line overlap", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 1, character: 5 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 1, character: 3 },
|
||||
end: { line: 2, character: 0 },
|
||||
};
|
||||
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 1, character: 3 },
|
||||
end: { line: 1, character: 5 },
|
||||
});
|
||||
});
|
||||
|
||||
test("returns null for single line non-overlapping ranges", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 1, character: 2 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 1, character: 3 },
|
||||
end: { line: 1, character: 5 },
|
||||
};
|
||||
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
test("returns correct intersection when one range is fully within another", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 4, character: 5 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 2, character: 2 },
|
||||
end: { line: 3, character: 3 },
|
||||
};
|
||||
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 2, character: 2 },
|
||||
end: { line: 3, character: 3 },
|
||||
});
|
||||
});
|
||||
|
||||
test("returns correct intersection when ranges touch at the edge", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 2, character: 0 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 2, character: 0 },
|
||||
end: { line: 3, character: 0 },
|
||||
};
|
||||
|
||||
const result = intersection(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 2, character: 0 },
|
||||
end: { line: 2, character: 0 },
|
||||
});
|
||||
});
|
||||
});
|
||||
70
core/test/util/ranges/maxMinPosition.test.ts
Normal file
70
core/test/util/ranges/maxMinPosition.test.ts
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { maxPosition, minPosition } from "../../../util/ranges";
|
||||
|
||||
// This file is generated by Continue
|
||||
interface Position {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
describe("Position comparison functions", () => {
|
||||
let pos1: Position;
|
||||
let pos2: Position;
|
||||
let pos3: Position;
|
||||
let pos4: Position;
|
||||
|
||||
beforeAll(() => {
|
||||
// Setup: Initializing positions
|
||||
pos1 = { line: 1, character: 5 };
|
||||
pos2 = { line: 2, character: 3 };
|
||||
pos3 = { line: 1, character: 7 };
|
||||
pos4 = { line: 2, character: 3 }; // Same as pos2 to test equality
|
||||
});
|
||||
|
||||
describe("maxPosition", () => {
|
||||
it("should return the position with the greater line number", () => {
|
||||
expect(maxPosition(pos1, pos2)).toEqual(pos2);
|
||||
});
|
||||
|
||||
it("should return the position with the greater character number when lines are equal", () => {
|
||||
expect(maxPosition(pos1, pos3)).toEqual(pos3);
|
||||
});
|
||||
|
||||
it("should return the first position when both positions are equal", () => {
|
||||
expect(maxPosition(pos2, pos4)).toEqual(pos2);
|
||||
});
|
||||
|
||||
it("should handle positions with negative line numbers", () => {
|
||||
const posNegative = { line: -1, character: 0 };
|
||||
expect(maxPosition(posNegative, pos1)).toEqual(pos1);
|
||||
});
|
||||
|
||||
it("should handle positions with negative character numbers", () => {
|
||||
const posNegativeChar = { line: 1, character: -1 };
|
||||
expect(maxPosition(posNegativeChar, pos1)).toEqual(pos1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("minPosition", () => {
|
||||
it("should return the position with the lesser line number", () => {
|
||||
expect(minPosition(pos1, pos2)).toEqual(pos1);
|
||||
});
|
||||
|
||||
it("should return the position with the lesser character number when lines are equal", () => {
|
||||
expect(minPosition(pos1, pos3)).toEqual(pos1);
|
||||
});
|
||||
|
||||
it("should return the first position when both positions are equal", () => {
|
||||
expect(minPosition(pos2, pos4)).toEqual(pos2);
|
||||
});
|
||||
|
||||
it("should handle positions with negative line numbers", () => {
|
||||
const posNegative = { line: -1, character: 0 };
|
||||
expect(minPosition(posNegative, pos1)).toEqual(posNegative);
|
||||
});
|
||||
|
||||
it("should handle positions with negative character numbers", () => {
|
||||
const posNegativeChar = { line: 1, character: -1 };
|
||||
expect(minPosition(posNegativeChar, pos1)).toEqual(posNegativeChar);
|
||||
});
|
||||
});
|
||||
});
|
||||
92
core/test/util/ranges/union.test.ts
Normal file
92
core/test/util/ranges/union.test.ts
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
import { union } from "../../../util/ranges";
|
||||
|
||||
// This file is generated by Continue
|
||||
interface Position {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
interface Range {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
|
||||
describe("union", () => {
|
||||
let rangeA: Range;
|
||||
let rangeB: Range;
|
||||
|
||||
beforeEach(() => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 3, character: 5 },
|
||||
};
|
||||
|
||||
rangeB = {
|
||||
start: { line: 2, character: 3 },
|
||||
end: { line: 4, character: 2 },
|
||||
};
|
||||
});
|
||||
|
||||
test("should return the union of two overlapping ranges", () => {
|
||||
const result = union(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 4, character: 2 },
|
||||
});
|
||||
});
|
||||
|
||||
test("should return the union when ranges are identical", () => {
|
||||
const result = union(rangeA, rangeA);
|
||||
expect(result).toEqual(rangeA);
|
||||
});
|
||||
|
||||
test("should return the union when ranges do not overlap but are adjacent", () => {
|
||||
rangeB = {
|
||||
start: { line: 3, character: 5 },
|
||||
end: { line: 4, character: 2 },
|
||||
};
|
||||
const result = union(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 4, character: 2 },
|
||||
});
|
||||
});
|
||||
|
||||
test("should return the union when one range is completely within the other", () => {
|
||||
rangeB = {
|
||||
start: { line: 2, character: 1 },
|
||||
end: { line: 2, character: 4 },
|
||||
};
|
||||
const result = union(rangeA, rangeB);
|
||||
expect(result).toEqual(rangeA);
|
||||
});
|
||||
|
||||
test("should return the union when ranges do not overlap and are not adjacent", () => {
|
||||
rangeB = {
|
||||
start: { line: 4, character: 3 },
|
||||
end: { line: 5, character: 1 },
|
||||
};
|
||||
const result = union(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 5, character: 1 },
|
||||
});
|
||||
});
|
||||
|
||||
// TODO
|
||||
test.skip("should handle edge case where start and end lines are the same", () => {
|
||||
rangeA = {
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 1, character: 5 },
|
||||
};
|
||||
rangeB = {
|
||||
start: { line: 1, character: 3 },
|
||||
end: { line: 1, character: 7 },
|
||||
};
|
||||
const result = union(rangeA, rangeB);
|
||||
expect(result).toEqual({
|
||||
start: { line: 1, character: 0 },
|
||||
end: { line: 1, character: 7 },
|
||||
});
|
||||
});
|
||||
});
|
||||
66
core/util/chatDescriber.ts
Normal file
66
core/util/chatDescriber.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import type { IMessenger } from "./messenger";
|
||||
import type { FromCoreProtocol, ToCoreProtocol } from "../protocol";
|
||||
import { ILLM, LLMFullCompletionOptions } from "..";
|
||||
import { stripImages } from "../llm/images";
|
||||
import { removeQuotesAndEscapes } from ".";
|
||||
|
||||
/**
|
||||
* Removes code blocks from a message.
|
||||
*
|
||||
* Return modified message text.
|
||||
*/
|
||||
function removeCodeBlocksAndTrim(msgText: string): string {
|
||||
const codeBlockRegex = /```[\s\S]*?```/g;
|
||||
|
||||
// Remove code blocks from the message text
|
||||
const textWithoutCodeBlocks = msgText.replace(codeBlockRegex, "");
|
||||
|
||||
return textWithoutCodeBlocks.trim();
|
||||
}
|
||||
|
||||
export class ChatDescriber {
|
||||
static prompt: string | undefined =
|
||||
"Given the following... please reply with a short summary that is 4-12 words in length, you should summarize what the user is asking for OR what the user is trying to accomplish. You should only respond with the summary, no additional text or explanation, you don't need ending punctuation.\n\n";
|
||||
static messenger: IMessenger<ToCoreProtocol, FromCoreProtocol>;
|
||||
|
||||
static async describe(
|
||||
model: ILLM,
|
||||
completionOptions: LLMFullCompletionOptions,
|
||||
message: string,
|
||||
): Promise<string | undefined> {
|
||||
if (!ChatDescriber.prompt) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean up and distill the message we want to send to the LLM
|
||||
message = stripImages(message);
|
||||
message = removeCodeBlocksAndTrim(message);
|
||||
|
||||
if (!message) {
|
||||
return;
|
||||
}
|
||||
|
||||
completionOptions.maxTokens = 24;
|
||||
|
||||
// Prompt the user's current LLM for the title
|
||||
const titleResponse = await model.chat(
|
||||
[
|
||||
{
|
||||
role: "user",
|
||||
content: ChatDescriber.prompt + message,
|
||||
},
|
||||
],
|
||||
completionOptions,
|
||||
);
|
||||
|
||||
// Set the title
|
||||
return removeQuotesAndEscapes(titleResponse.content.toString());
|
||||
}
|
||||
|
||||
// // TODO: Allow the user to manually set specific/tailored prompts to generate their titles
|
||||
// static async setup() {
|
||||
// if(config?.prompt) {
|
||||
// ChatDescriber.prompt = config?.prompt;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ class FileSystemIde implements IDE {
|
|||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
async subprocess(command: string): Promise<[string, string]> {
|
||||
async subprocess(command: string, cwd?: string): Promise<[string, string]> {
|
||||
return ["", ""];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,8 +193,8 @@ export class MessageIde implements IDE {
|
|||
return this.request("getProblems", { filepath });
|
||||
}
|
||||
|
||||
subprocess(command: string): Promise<[string, string]> {
|
||||
return this.request("subprocess", { command });
|
||||
subprocess(command: string, cwd?: string): Promise<[string, string]> {
|
||||
return this.request("subprocess", { command, cwd });
|
||||
}
|
||||
|
||||
async getBranch(dir: string): Promise<string> {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
|
|||
recentLinePrefixMatchMinLength: 7,
|
||||
disableInFiles: undefined,
|
||||
useImports: true,
|
||||
useRootPathContext: false,
|
||||
};
|
||||
|
||||
export const COUNT_COMPLETION_REJECTED_AFTER = 10_000;
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ export class ReverseMessageIde {
|
|||
});
|
||||
|
||||
this.on("subprocess", (data) => {
|
||||
return this.ide.subprocess(data.command);
|
||||
return this.ide.subprocess(data.command, data.cwd);
|
||||
});
|
||||
|
||||
this.on("getBranch", (data) => {
|
||||
|
|
|
|||
|
|
@ -129,6 +129,11 @@ export async function getLanguageForFile(
|
|||
export enum TSQueryType {
|
||||
CodeSnippets = "code-snippet-queries",
|
||||
Imports = "import-queries",
|
||||
// Used in RootPathContextService.ts
|
||||
FunctionDeclaration = "root-path-context-queries/function_declaration",
|
||||
MethodDefinition = "root-path-context-queries/method_definition",
|
||||
FunctionDefinition = "root-path-context-queries/function_definition",
|
||||
MethodDeclaration = "root-path-context-queries/method_declaration",
|
||||
}
|
||||
|
||||
export async function getQueryForFile(
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ export class NoBadWordsLogitsProcessor extends LogitsProcessor {
|
|||
* @property {number} [eta_cutoff=0.0] Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between 0 and 1, a token is only considered if it is greater than either `eta_cutoff` or `sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits)))`. The latter term is intuitively the expected next token probability, scaled by `sqrt(eta_cutoff)`. In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://arxiv.org/abs/2210.15191) for more details.
|
||||
* @property {number} [diversity_penalty=0.0] This value is subtracted from a beam's score if it generates a token same as any beam from other group at a particular time. Note that `diversity_penalty` is only effective if `group beam search` is enabled.
|
||||
* @property {number} [repetition_penalty=1.0] The parameter for repetition penalty. 1.0 means no penalty. See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.
|
||||
* @property {number} [encoder_repetition_penalty=1.0] The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty.
|
||||
* @property {number} [encoder_repetition_penalty=1.0] The parameter for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty.
|
||||
* @property {number} [length_penalty=1.0] Exponential penalty to the length that is used with beam-based generation. It is applied as an exponent to the sequence length, which in turn is used to divide the score of the sequence. Since the score is the log likelihood of the sequence (i.e. negative), `length_penalty` > 0.0 promotes longer sequences, while `length_penalty` < 0.0 encourages shorter sequences.
|
||||
* @property {number} [no_repeat_ngram_size=0] If set to int > 0, all ngrams of that size can only occur once.
|
||||
* @property {number[][]} [bad_words_ids=null] List of token ids that are not allowed to be generated. In order to get the token ids of the words that should not appear in the generated text, use `(await tokenizer(bad_words, {add_prefix_space: true, add_special_tokens: false})).input_ids`.
|
||||
|
|
@ -488,7 +488,7 @@ export type GenerationConfigType = {
|
|||
*/
|
||||
repetition_penalty?: number;
|
||||
/**
|
||||
* The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty.
|
||||
* The parameter for encoder_repetition_penalty. An exponential penalty on sequences that are not in the original input. 1.0 means no penalty.
|
||||
*/
|
||||
encoder_repetition_penalty?: number;
|
||||
/**
|
||||
|
|
@ -590,4 +590,4 @@ export type GenerationConfigType = {
|
|||
};
|
||||
import { Tensor } from './tensor.js';
|
||||
export {};
|
||||
//# sourceMappingURL=generation.d.ts.map
|
||||
//# sourceMappingURL=generation.d.ts.map
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ keywords: [context, "@", provider, LLM]
|
|||
|
||||
Context Providers allow you to type '@' and see a dropdown of content that can all be fed to the LLM as context. Every context provider is a plugin, which means if you want to reference some source of information that you don't see here, you can request (or build!) a new context provider.
|
||||
|
||||
As an example, say you are working on solving a new GitHub Issue. You type '@Isse' and select the one you are working on. Continue can now see the issue title and contents. You also know that the issue is related to the files 'readme.md' and 'helloNested.py', so you type '@readme' and '@hello' to find and select them. Now these 3 "Context Items" are displayed inline with the rest of your input.
|
||||
As an example, say you are working on solving a new GitHub Issue. You type '@Issue' and select the one you are working on. Continue can now see the issue title and contents. You also know that the issue is related to the files 'readme.md' and 'helloNested.py', so you type '@readme' and '@hello' to find and select them. Now these 3 "Context Items" are displayed inline with the rest of your input.
|
||||
|
||||

|
||||
|
||||
|
|
@ -58,7 +58,7 @@ Reference all of the changes you've made to your current branch. This is useful
|
|||
|
||||
### `@Terminal`
|
||||
|
||||
Reference the contents of your IDE's terminal.
|
||||
Reference the last command you ran in your IDE's terminal and its output.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
|
|
@ -200,7 +200,7 @@ For example, type "@Google python tutorial" if you want to search and discuss wa
|
|||
|
||||
Note: You can get an API key for free at [serper.dev](https://serper.dev).
|
||||
|
||||
### `@Isse`
|
||||
### `@Issue`
|
||||
|
||||
Reference the conversation in a GitHub issue.
|
||||
|
||||
|
|
@ -315,6 +315,36 @@ assignee = currentUser() AND resolution = Unresolved order by updated DESC
|
|||
|
||||
You can override this query by setting the `issueQuery` parameter.
|
||||
|
||||
### `@Discord`
|
||||
|
||||
Reference the messages in a Discord channel.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "discord",
|
||||
"params": {
|
||||
"discordKey": "bot token",
|
||||
"guildId": "1234567890",
|
||||
"channels": [
|
||||
{
|
||||
"id": "123456",
|
||||
"name": "example-channel"
|
||||
},
|
||||
{
|
||||
"id": "678901",
|
||||
"name": "example-channel-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Make sure to include your own [Bot Token](https://discord.com/developers/applications), and join it to your related server . If you want more granular control over which channels are searched, you can specify a list of channel IDs to search in. If you don't want to specify any channels, just include the guild id(Server ID) and all channels will be included. The provider only reads text channels.
|
||||
|
||||
### `@Postgres`
|
||||
|
||||
Reference the schema of a table, and some sample rows
|
||||
|
|
@ -451,7 +481,7 @@ The HttpContextProvider makes a POST request to the url passed in the configurat
|
|||
{
|
||||
"name": "http",
|
||||
"params": {
|
||||
"url": "https://api.example.com/v1/users",
|
||||
"url": "https://api.example.com/v1/users"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -459,6 +489,7 @@ The HttpContextProvider makes a POST request to the url passed in the configurat
|
|||
```
|
||||
|
||||
The receiving URL should expect to receive the following parameters:
|
||||
|
||||
```json title="POST parameters"
|
||||
{
|
||||
query: string,
|
||||
|
|
@ -467,6 +498,7 @@ The receiving URL should expect to receive the following parameters:
|
|||
```
|
||||
|
||||
The response 200 OK should be a JSON object with the following structure:
|
||||
|
||||
```json title="Response"
|
||||
[
|
||||
{
|
||||
|
|
|
|||
|
|
@ -73,4 +73,4 @@ If you need to force a refresh of the index, reload the VS Code window with `cmd
|
|||
|
||||
## Repository map
|
||||
|
||||
Models in the Claude 3, Llama 3.1, Gemini 1.5, and GPT-4o families will automatically use a [repository map](../context-providers.md#repository-map) during codebsae retrieval, which allows the model to understand the structure of your codebase and use it to answer questions. Currently, the repository map only contains the filepaths in the codebase.
|
||||
Models in the Claude 3, Llama 3.1, Gemini 1.5, and GPT-4o families will automatically use a [repository map](../context-providers.md#repository-map) during codebase retrieval, which allows the model to understand the structure of your codebase and use it to answer questions. Currently, the repository map only contains the filepaths in the codebase.
|
||||
|
|
|
|||
20
docs/docs/customize/model-providers/more/cerebras.md
Normal file
20
docs/docs/customize/model-providers/more/cerebras.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Cerebras Inference
|
||||
|
||||
Cerebras Inference uses specialized silicon to provides fast inference for the Llama3.1 8B and Llama3.1 70B models.
|
||||
|
||||
1. Create an account in the portal [here](https://cloud.cerebras.ai/).
|
||||
2. Create and copy the API key for use in Continue.
|
||||
3. Update your Continue config file:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Cerebras Llama 3.1 70B",
|
||||
"provider": "cerebras",
|
||||
"model": "llama3.1-70b",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
# AWS SageMaker
|
||||
|
||||
SageMaker provider support SageMaker endpoint deployed with [LMI](https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html)
|
||||
SageMaker can be used for both chat and embedding models. Chat models are supported for endpoints deployed with [LMI](https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html), and embedding models are supported for endpoints deployed with [HuggingFace TEI](https://huggingface.co/blog/sagemaker-huggingface-embedding)
|
||||
|
||||
To setup SageMaker, add the following to your `config.json` file:
|
||||
To setup SageMaker as a chat model provider, add the following to your `config.json` file:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
|
|
@ -13,7 +13,11 @@ To setup SageMaker, add the following to your `config.json` file:
|
|||
"model": "lmi-model-deepseek-coder-xxxxxxx",
|
||||
"region": "us-west-2"
|
||||
}
|
||||
]
|
||||
],
|
||||
"embeddingsProvider": {
|
||||
"provider": "sagemaker",
|
||||
"model": "mxbai-embed-large-v1-endpoint"
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ We recommend configuring **GPT-4o** as your chat model.
|
|||
|
||||
## Autocomplete model
|
||||
|
||||
We recommend configuring **Codestral** as your autocomplete model.
|
||||
We recommend configuring **Codestral** as your autocomplete model. There are not currently any other models in Azure that are capable of autocomplete.
|
||||
|
||||
```json title="config.json"
|
||||
"tabAutocompleteModel": [{
|
||||
|
|
@ -42,7 +42,7 @@ We recommend configuring **Codestral** as your autocomplete model.
|
|||
We recommend configuring **text-embedding-3-large** as your embeddings model.
|
||||
|
||||
```json title="config.json"
|
||||
"embeddingsProvider": [{
|
||||
"embeddingsProvider": {
|
||||
"provider": "azure",
|
||||
"model": "text-embedding-3-large",
|
||||
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
|
||||
|
|
@ -50,7 +50,7 @@ We recommend configuring **text-embedding-3-large** as your embeddings model.
|
|||
"apiVersion": "<YOUR_API_VERSION>",
|
||||
"apiType": "azure",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## Reranking model
|
||||
|
|
|
|||
|
|
@ -38,13 +38,11 @@ We recommend configuring **text-embedding-004** as your embeddings model.
|
|||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": [
|
||||
{
|
||||
"provider": "gemini",
|
||||
"model": "models/text-embedding-004",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
"embeddingsProvider": {
|
||||
"provider": "gemini",
|
||||
"model": "models/text-embedding-004",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -46,14 +46,12 @@ We recommend configuring **Mistral Embed** as your embeddings model.
|
|||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": [
|
||||
{
|
||||
"provider": "mistral",
|
||||
"model": "mistral-embed",
|
||||
"apiKey": "[API_KEY]",
|
||||
"apiBase": "https://api.mistral.ai/v1"
|
||||
}
|
||||
]
|
||||
"embeddingsProvider": {
|
||||
"provider": "mistral",
|
||||
"model": "mistral-embed",
|
||||
"apiKey": "[API_KEY]",
|
||||
"apiBase": "https://api.mistral.ai/v1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,11 @@ We recommend configuring **text-embedding-3-large** as your embeddings model.
|
|||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": [
|
||||
{
|
||||
"provider": "openai",
|
||||
"model": "text-embedding-3-large",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
"embeddingsProvider": {
|
||||
"provider": "openai",
|
||||
"model": "text-embedding-3-large",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -11,18 +11,18 @@ In Continue, reranking is used by [@Codebase](../deep-dives/codebase.md) in orde
|
|||
|
||||
## Recommended reranking models
|
||||
|
||||
If you have the ability to use any model, we recommend `rerank-1` by Voyage AI, which is listed below along with the rest of the options for rerankers.
|
||||
If you have the ability to use any model, we recommend `rerank-2` by Voyage AI, which is listed below along with the rest of the options for rerankers.
|
||||
|
||||
### Voyage AI
|
||||
|
||||
Voyage AI offers the best reranking model for code with their `rerank-1` model. After obtaining an API key from [here](https://www.voyageai.com/), you can configure like this:
|
||||
Voyage AI offers the best reranking model for code with their `rerank-2` model. After obtaining an API key from [here](https://www.voyageai.com/), you can configure like this:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "voyage",
|
||||
"params": {
|
||||
"model": "rerank-1",
|
||||
"model": "rerank-2",
|
||||
"apiKey": "<VOYAGE_API_KEY>"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,12 +180,15 @@ If you'd like to write a context provider in a language other than TypeScript, y
|
|||
"url": "https://myserver.com/context-provider",
|
||||
"title": "http",
|
||||
"description": "Custom HTTP Context Provider",
|
||||
"displayTitle": "My Custom Context"
|
||||
"displayTitle": "My Custom Context",
|
||||
"options": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI. -->
|
||||
Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI.
|
||||
|
||||
The `"options"` property can be used to send additional parameters to your endpoint, which will be included in the request body.
|
||||
|
||||
## Extension API for VSCode
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ func = get_registry().get("openai").create(
|
|||
class CodeChunks(LanceModel):
|
||||
filename: str
|
||||
text: str = func.SourceField()
|
||||
vector: Vector(func.ndims()) = func.VectorField()
|
||||
# 1536 is the embedding dimension of the `voyage-code-2` model.
|
||||
vector: Vector(1536) = func.VectorField()
|
||||
|
||||
table = db.create_table("code_chunks", schema=CodeChunks, mode="overwrite")
|
||||
table.add([
|
||||
|
|
@ -145,4 +146,4 @@ If you wish to return 10 total results for each query for example, then you woul
|
|||
2. Send all of these 50 results to the reranker API along with the query in order to get relevancy scores for each
|
||||
3. Sort the results by relevancy score and return the top 10
|
||||
|
||||
We recommend using the `rerank-1` model from Voyage AI, which has examples of usage [here](https://docs.voyageai.com/docs/reranker).
|
||||
We recommend using the `rerank-2` model from Voyage AI, which has examples of usage [here](https://docs.voyageai.com/docs/reranker).
|
||||
|
|
|
|||
|
|
@ -111,3 +111,24 @@ SambaNova Cloud provides world record Llama3.1 70B/405B serving.
|
|||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Cerebras Inference
|
||||
|
||||
Cerebras Inference uses specialized silicon to provides fast inference for the Llama3.1 8B/70B.
|
||||
|
||||
1. Create an account in the portal [here](https://cloud.cerebras.ai/).
|
||||
2. Create and copy the API key for use in Continue.
|
||||
3. Update your Continue config file:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Cerebras Llama 3.1 70B",
|
||||
"provider": "cerebras",
|
||||
"model": "llama3.1-70b",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ keywords:
|
|||
**Continue is the leading open-source AI code assistant inside of [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension)**
|
||||
|
||||
- [Chat](chat/how-to-use-it.md) to understand and iterate on code in the sidebar
|
||||
- [Autocomplete](autocomplete/how-to-use-it.md) to recieve inline code suggestions as you type
|
||||
- [Autocomplete](autocomplete/how-to-use-it.md) to receive inline code suggestions as you type
|
||||
- [Edit](edit/how-to-use-it.md) to modify code without leaving your current file
|
||||
- [Actions](actions/how-to-use-it.md) to establish shortcuts for common use cases
|
||||
|
|
|
|||
|
|
@ -40,7 +40,9 @@ If you're getting a response from the LLM that doesn't seem to make sense, you c
|
|||
|
||||
### JetBrains
|
||||
|
||||
Open `~/.continue/logs/core.log`. The most recent logs are found at the bottom of the file.
|
||||
Open `~/.continue/logs/core.log` to view the logs for the Continue plugin. The most recent logs are found at the bottom of the file.
|
||||
|
||||
Some JetBrains-related logs may also be found by clicking "Help" > "Show Log in Explorer/Finder".
|
||||
|
||||
## Download the latest pre-release
|
||||
|
||||
|
|
@ -124,7 +126,7 @@ This can be accomplished using the following command: `Continue: Rebuild codebas
|
|||
|
||||
### Android Studio - "Nothing to show" in Chat
|
||||
|
||||
This can be fixed by selecting `Actions > Choose Boot runtime for the IDE` then selecting the latest version, and then restarting Android Studio. [See this thread](https://github.com/continuedev/continue/issues/2280#issuecomment-2365231567) for details.
|
||||
This can be fixed by selecting `Actions > Choose Boot runtime for the IDE` then selecting the latest version, and then restarting Android Studio. [See this thread](https://github.com/continuedev/continue/issues/596#issuecomment-1789327178) for details.
|
||||
|
||||
## Still having trouble?
|
||||
|
||||
|
|
|
|||
118
docs/static/schemas/config.json
vendored
118
docs/static/schemas/config.json
vendored
|
|
@ -194,7 +194,8 @@
|
|||
"openrouter",
|
||||
"sambanova",
|
||||
"nvidia",
|
||||
"vllm"
|
||||
"vllm",
|
||||
"cerebras"
|
||||
],
|
||||
"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)",
|
||||
|
|
@ -224,7 +225,8 @@
|
|||
"### IBM watsonx\nwatsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.",
|
||||
"### OpenRouter\nOpenRouter offers a single API to access almost any language model. To get started, obtain an API key from [their console](https://openrouter.ai/settings/keys).",
|
||||
"### 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."
|
||||
"### 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/)."
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -246,7 +248,25 @@
|
|||
"region": {
|
||||
"title": "Region",
|
||||
"description": "The region where the model is hosted",
|
||||
"type": "string"
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"us-east-1",
|
||||
"us-east-2",
|
||||
"us-west-1",
|
||||
"us-west-2",
|
||||
"eu-west-1",
|
||||
"eu-central-1",
|
||||
"ap-southeast-1",
|
||||
"ap-northeast-1",
|
||||
"ap-south-1"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"profile": {
|
||||
"title": "Profile",
|
||||
|
|
@ -1142,6 +1162,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": ["cerebras"]
|
||||
}
|
||||
},
|
||||
"required": ["provider"]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"enum": ["llama3.1-8b", "llama3.1-70b"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
|
|
@ -1389,7 +1426,6 @@
|
|||
"enum": [
|
||||
"issue",
|
||||
"share",
|
||||
"so",
|
||||
"cmd",
|
||||
"edit",
|
||||
"comment",
|
||||
|
|
@ -1401,7 +1437,6 @@
|
|||
"markdownEnumDescriptions": [
|
||||
"Generate a link to a drafted GitHub issue",
|
||||
"Export the current chat session to markdown",
|
||||
"Reference StackOverflow to answer the question",
|
||||
"Generate a terminal command and paste it into the terminal",
|
||||
"Edit the highlighted code with given instructions",
|
||||
"Add comments to the highlighted code",
|
||||
|
|
@ -1573,11 +1608,12 @@
|
|||
"url",
|
||||
"database",
|
||||
"os",
|
||||
"repo-map"
|
||||
"repo-map",
|
||||
"greptile"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
"Reference the contents of the current changes as given by `git diff`",
|
||||
"Reference the contents of the terminal",
|
||||
"Reference the last terminal command",
|
||||
"Reference the contents of the local variables with top n level (defaulting to 3) of call stack for that thread",
|
||||
"Reference the contents of all open or pinned files.",
|
||||
"Enter a search phrase and include the Google search results as context",
|
||||
|
|
@ -1597,7 +1633,8 @@
|
|||
"Reference the contents of a page at a URL",
|
||||
"Reference table schemas",
|
||||
"Operating system and CPU Information",
|
||||
"Map of files in the repository with important code highlights"
|
||||
"Map of files in the repository with important code highlights",
|
||||
"Query your greptile index of the current repo"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
@ -1874,6 +1911,11 @@
|
|||
"url": {
|
||||
"type": "string",
|
||||
"description": "The HTTP endpoint of your context provider server."
|
||||
},
|
||||
"options": {
|
||||
"title": "Custom Options",
|
||||
"description": "Additional options to pass to your custom HTTP server.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": ["url"]
|
||||
|
|
@ -1975,6 +2017,36 @@
|
|||
},
|
||||
"required": ["host", "port", "user", "password", "database"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"enum": ["greptile"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"params": {
|
||||
"properties": {
|
||||
"GithubToken": {
|
||||
"title": "GithubToken",
|
||||
"description": "Your github access token",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
},
|
||||
"GreptileToken": {
|
||||
"title": "GreptileToken",
|
||||
"description": "Your greptile access token",
|
||||
"default": "",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["GreptileToken", "GithubToken"]
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["name"]
|
||||
|
|
@ -2134,7 +2206,8 @@
|
|||
"gemini",
|
||||
"voyage",
|
||||
"nvidia",
|
||||
"bedrock"
|
||||
"bedrock",
|
||||
"sagemaker"
|
||||
]
|
||||
},
|
||||
"model": {
|
||||
|
|
@ -2168,7 +2241,7 @@
|
|||
"region": {
|
||||
"title": "Region",
|
||||
"description": "The region where the model is hosted",
|
||||
"type": "string"
|
||||
"$ref": "#/definitions/ModelDescription/properties/region"
|
||||
},
|
||||
"profile": {
|
||||
"title": "Profile",
|
||||
|
|
@ -2190,6 +2263,24 @@
|
|||
"then": {
|
||||
"required": ["apiKey"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": ["sagemaker"]
|
||||
}
|
||||
},
|
||||
"required": ["provider"]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"markdownDescription": "SageMaker endpoint name"
|
||||
}
|
||||
},
|
||||
"required": ["model"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -2288,7 +2379,12 @@
|
|||
"type": "string"
|
||||
},
|
||||
"model": {
|
||||
"enum": ["rerank-lite-1", "rerank-1"]
|
||||
"enum": [
|
||||
"rerank-lite-1",
|
||||
"rerank-1",
|
||||
"rerank-2",
|
||||
"rerank-2-lite"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["apiKey"]
|
||||
|
|
|
|||
|
|
@ -6,8 +6,16 @@ and is generated by [Changie](https://github.com/miniscruff/changie).
|
|||
|
||||
|
||||
Pre-release Changes
|
||||
### Fixed
|
||||
* Off-screen rendering to solve white flash on load and lack of changing cursor type
|
||||
|
||||
## 0.0.72 - 2024-10-04
|
||||
### Added
|
||||
* Listen for changes to Intellij settings without requiring window reload
|
||||
### Changed
|
||||
* Updated tutorial file
|
||||
### Fixed
|
||||
* Fix ability to load config.ts in JetBrains IDEs
|
||||
|
||||
## 0.0.69 - 2024-09-22
|
||||
### Added
|
||||
|
|
|
|||
3
extensions/intellij/CONTRIBUTING.md
Normal file
3
extensions/intellij/CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
### Commands
|
||||
|
||||
Verify plugin compatibility: `./gradlew verifyPlugin`
|
||||
|
|
@ -1,35 +1,26 @@
|
|||
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
|
||||
|
||||
pluginGroup = com.github.continuedev.continueintellijextension
|
||||
pluginName = continue-intellij-extension
|
||||
pluginRepositoryUrl = https://github.com/continuedev/continue
|
||||
pluginGroup=com.github.continuedev.continueintellijextension
|
||||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion = 0.0.70
|
||||
|
||||
pluginVersion=0.0.76
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild = 223
|
||||
pluginSinceBuild=223
|
||||
#pluginUntilBuild = 232.*
|
||||
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
platformType = IC
|
||||
platformVersion = 2022.3.3
|
||||
platformType=IC
|
||||
platformVersion=2023.2
|
||||
#platformVersion = LATEST-EAP-SNAPSHOT
|
||||
|
||||
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
|
||||
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
|
||||
platformPlugins = org.jetbrains.plugins.terminal
|
||||
|
||||
platformPlugins=org.jetbrains.plugins.terminal
|
||||
# Gradle Releases -> https://github.com/gradle/gradle/releases
|
||||
gradleVersion = 8.3
|
||||
|
||||
gradleVersion=8.3
|
||||
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
|
||||
kotlin.stdlib.default.dependency = false
|
||||
|
||||
kotlin.stdlib.default.dependency=false
|
||||
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
|
||||
org.gradle.configuration-cache = true
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
|
||||
org.gradle.caching = true
|
||||
|
||||
org.gradle.caching=true
|
||||
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
|
||||
systemProp.org.gradle.unsafe.kotlin.assignment = true
|
||||
systemProp.org.gradle.unsafe.kotlin.assignment=true
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ fun getPluginService(project: Project?): ContinuePluginService? {
|
|||
return null
|
||||
}
|
||||
return ServiceManager.getService(
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
project,
|
||||
ContinuePluginService::class.java
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,8 @@ class AcceptDiffAction : AnAction() {
|
|||
|
||||
private fun acceptVerticalDiff(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val editor = e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val editor =
|
||||
e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val diffStreamService = project.service<DiffStreamService>()
|
||||
diffStreamService.accept(editor)
|
||||
}
|
||||
|
|
@ -61,120 +62,14 @@ class RejectDiffAction : AnAction() {
|
|||
|
||||
private fun rejectVerticalDiff(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
val editor = e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val editor =
|
||||
e.getData(PlatformDataKeys.EDITOR) ?: FileEditorManager.getInstance(project).selectedTextEditor ?: return
|
||||
val diffStreamService = project.service<DiffStreamService>()
|
||||
diffStreamService.reject(editor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickInputDialogWrapper : DialogWrapper(true) {
|
||||
private var panel: JPanel? = null
|
||||
private var textArea: JTextArea? = null
|
||||
init {
|
||||
init()
|
||||
title = "Continue Quick Input"
|
||||
}
|
||||
|
||||
override fun getPreferredFocusedComponent(): JComponent? {
|
||||
return textArea
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent? {
|
||||
panel = JPanel(BorderLayout())
|
||||
textArea = JTextArea(3, 60)
|
||||
textArea?.lineWrap = true
|
||||
textArea?.wrapStyleWord = true
|
||||
|
||||
// Add a DocumentListener to the JTextArea
|
||||
textArea?.document?.addDocumentListener(object : DocumentListener {
|
||||
override fun insertUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun removeUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
override fun changedUpdate(e: DocumentEvent?) {
|
||||
updateSize()
|
||||
}
|
||||
|
||||
private fun updateSize() {
|
||||
val text = textArea?.text ?: ""
|
||||
val lines = text.count { it == '\n' } + 1
|
||||
val metrics = textArea?.getFontMetrics(textArea?.font)
|
||||
val lineHeight = metrics?.height ?: 0
|
||||
textArea?.preferredSize = Dimension(textArea?.width ?: 0, lines * lineHeight)
|
||||
|
||||
// Revalidate the JPanel to reflect the changes
|
||||
panel?.revalidate()
|
||||
}
|
||||
})
|
||||
|
||||
val scrollPane = JBScrollPane(textArea)
|
||||
scrollPane.verticalScrollBarPolicy = JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
|
||||
panel?.add(scrollPane, BorderLayout.CENTER)
|
||||
|
||||
return panel
|
||||
}
|
||||
|
||||
|
||||
fun showDialogAndGetText(): String? {
|
||||
show()
|
||||
return if (this.exitCode == OK_EXIT_CODE) {
|
||||
textArea!!.text
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class QuickTextEntryAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
continuePluginService.ideProtocolClient?.sendHighlightedCode()
|
||||
|
||||
// Create and show the dialog
|
||||
val dialog = QuickInputDialogWrapper()
|
||||
val text: String? = dialog.showDialogAndGetText()
|
||||
|
||||
// Show the text entered by the user
|
||||
if (text != null) {
|
||||
val service = getPluginService(e.project)
|
||||
service?.ideProtocolClient?.sendMainUserInput(text)
|
||||
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInput", null)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ViewLogsAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
Messages.showMessageDialog(
|
||||
"This action is not yet implemented",
|
||||
"Continue Action not Implemented",
|
||||
Messages.getInformationIcon()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun focusContinueInput(project: Project?) {
|
||||
fun getContinuePluginService(project: Project?): ContinuePluginService? {
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
|
@ -186,7 +81,11 @@ fun focusContinueInput(project: Project?) {
|
|||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(project) ?: return
|
||||
return getPluginService(project)
|
||||
}
|
||||
|
||||
fun focusContinueInput(project: Project?) {
|
||||
val continuePluginService = getContinuePluginService(project) ?: return
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInputWithoutClear", null)
|
||||
|
||||
|
|
@ -202,19 +101,7 @@ class FocusContinueInputWithoutClearAction : AnAction() {
|
|||
|
||||
class FocusContinueInputAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInput", null)
|
||||
|
|
@ -225,20 +112,7 @@ class FocusContinueInputAction : AnAction() {
|
|||
|
||||
class NewContinueSessionAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
|
||||
if (toolWindow != null) {
|
||||
if (!toolWindow.isVisible) {
|
||||
toolWindow.activate(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
continuePluginService.continuePluginWindow?.content?.components?.get(0)?.requestFocus()
|
||||
continuePluginService.sendToWebview("focusContinueInputWithNewSession", null)
|
||||
}
|
||||
|
|
@ -246,14 +120,7 @@ class NewContinueSessionAction : AnAction() {
|
|||
|
||||
class ViewHistoryAction : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (project != null) {
|
||||
val toolWindowManager = ToolWindowManager.getInstance(project)
|
||||
val toolWindow = toolWindowManager.getToolWindow("Continue")
|
||||
}
|
||||
|
||||
val continuePluginService = getPluginService(e.project) ?: return
|
||||
|
||||
val continuePluginService = getContinuePluginService(e.project) ?: return
|
||||
continuePluginService.sendToWebview("viewHistory", null)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue