merge dev
This commit is contained in:
commit
d725bc45f4
68 changed files with 4358 additions and 1458 deletions
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="17" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/extensions/intellij" />
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { Mutex } from "async-mutex";
|
||||
import { open } from "sqlite";
|
||||
import sqlite3 from "sqlite3";
|
||||
import { DatabaseConnection } from "../indexing/refreshIndex.js";
|
||||
import { DatabaseConnection, truncateSqliteLikePattern } from "../indexing/refreshIndex.js";
|
||||
import { getTabAutocompleteCacheSqlitePath } from "../util/paths.js";
|
||||
|
||||
export class AutocompleteLruCache {
|
||||
private static capacity = 1000;
|
||||
private mutex = new Mutex();
|
||||
|
||||
constructor(private db: DatabaseConnection) {}
|
||||
constructor(private db: DatabaseConnection) { }
|
||||
|
||||
static async get(): Promise<AutocompleteLruCache> {
|
||||
const db = await open({
|
||||
|
|
@ -37,7 +37,7 @@ export class AutocompleteLruCache {
|
|||
// Have to make sure we take the key with shortest length
|
||||
const result = await this.db.get(
|
||||
"SELECT key, value FROM cache WHERE ? LIKE key || '%' ORDER BY LENGTH(key) DESC LIMIT 1",
|
||||
prefix,
|
||||
truncateSqliteLikePattern(prefix),
|
||||
);
|
||||
|
||||
// Validate that the cached compeltion is a valid completion for the prefix
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import { RecentlyEditedRange } from "./recentlyEdited.js";
|
|||
import { RootPathContextService } from "./services/RootPathContextService.js";
|
||||
import {
|
||||
avoidPathLineAndEmptyComments,
|
||||
noTopLevelKeywordsMidline,
|
||||
skipPrefixes,
|
||||
stopAtLines,
|
||||
stopAtRepeatingLines,
|
||||
|
|
@ -50,11 +49,7 @@ 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";
|
||||
import { stopAtStopTokens } from "./streamTransforms/charStream.js";
|
||||
|
||||
export interface AutocompleteInput {
|
||||
completionId: string;
|
||||
|
|
@ -95,6 +90,7 @@ const autocompleteCache = AutocompleteLruCache.get();
|
|||
|
||||
const DOUBLE_NEWLINE = "\n\n";
|
||||
const WINDOWS_DOUBLE_NEWLINE = "\r\n\r\n";
|
||||
// TODO: Do we want to stop completions when reaching a `/src/` string?
|
||||
const SRC_DIRECTORY = "/src/";
|
||||
// Starcoder2 tends to output artifacts starting with the letter "t"
|
||||
const STARCODER2_T_ARTIFACTS = ["t.", "\nt", "<file_sep>"];
|
||||
|
|
@ -111,6 +107,14 @@ const ERRORS_TO_IGNORE = [
|
|||
"unexpected server status",
|
||||
];
|
||||
|
||||
const LOCAL_PROVIDERS: ModelProvider[] = [
|
||||
"ollama",
|
||||
"lmstudio",
|
||||
"llama.cpp",
|
||||
"llamafile",
|
||||
"text-gen-webui",
|
||||
];
|
||||
|
||||
function formatExternalSnippet(
|
||||
filepath: string,
|
||||
snippet: string,
|
||||
|
|
@ -329,14 +333,6 @@ export class CompletionProvider {
|
|||
llm.completionOptions.temperature = 0.01;
|
||||
}
|
||||
|
||||
// Set model-specific options
|
||||
const LOCAL_PROVIDERS: ModelProvider[] = [
|
||||
"ollama",
|
||||
"lmstudio",
|
||||
"llama.cpp",
|
||||
"llamafile",
|
||||
"text-gen-webui",
|
||||
];
|
||||
if (
|
||||
!config.tabAutocompleteOptions?.maxPromptTokens &&
|
||||
LOCAL_PROVIDERS.includes(llm.providerName)
|
||||
|
|
@ -355,7 +351,7 @@ export class CompletionProvider {
|
|||
* elsewhere in the code. That said, I'm not yet confident enough to
|
||||
* remove this.
|
||||
*/
|
||||
if (isOnlyWhitespace(outcome.completion)) {
|
||||
if (options.transform && isOnlyWhitespace(outcome.completion)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
@ -437,6 +433,33 @@ export class CompletionProvider {
|
|||
};
|
||||
}
|
||||
|
||||
private isMultiline({
|
||||
language,
|
||||
prefix,
|
||||
suffix,
|
||||
selectedCompletionInfo,
|
||||
multilineCompletions,
|
||||
completeMultiline,
|
||||
}: {
|
||||
language: AutocompleteLanguageInfo;
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
selectedCompletionInfo: AutocompleteInput["selectedCompletionInfo"];
|
||||
multilineCompletions: TabAutocompleteOptions["multilineCompletions"];
|
||||
completeMultiline: boolean;
|
||||
}) {
|
||||
let langMultilineDecision = language.useMultiline?.({ prefix, suffix });
|
||||
if (langMultilineDecision) {
|
||||
return langMultilineDecision;
|
||||
} else {
|
||||
return (
|
||||
!selectedCompletionInfo && // Only ever single-line if using intellisense selected value
|
||||
multilineCompletions !== "never" &&
|
||||
(multilineCompletions === "always" || completeMultiline)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async getTabCompletion(
|
||||
token: AbortSignal,
|
||||
options: TabAutocompleteOptions,
|
||||
|
|
@ -460,10 +483,13 @@ export class CompletionProvider {
|
|||
|
||||
// Filter
|
||||
const lang = languageForFilepath(filepath);
|
||||
const line = fileLines[pos.line] ?? "";
|
||||
for (const endOfLine of lang.endOfLine) {
|
||||
if (line.endsWith(endOfLine) && pos.character >= line.length) {
|
||||
return undefined;
|
||||
|
||||
if (options.transform) {
|
||||
const line = fileLines[pos.line] ?? "";
|
||||
for (const endOfLine of lang.endOfLine) {
|
||||
if (line.endsWith(endOfLine) && pos.character >= line.length) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -634,25 +660,25 @@ export class CompletionProvider {
|
|||
} else {
|
||||
const stop = [
|
||||
...(completionOptions?.stop || []),
|
||||
...multilineStops,
|
||||
// ...multilineStops,
|
||||
...commonStops,
|
||||
...(llm.model.toLowerCase().includes("starcoder2")
|
||||
? STARCODER2_T_ARTIFACTS
|
||||
: []),
|
||||
...(lang.stopWords ?? []),
|
||||
...lang.topLevelKeywords.map((word) => `\n${word}`),
|
||||
// ...lang.topLevelKeywords.map((word) => `\n${word}`),
|
||||
];
|
||||
|
||||
let langMultilineDecision = lang.useMultiline?.({ prefix, suffix });
|
||||
let multiline: boolean = false;
|
||||
if (langMultilineDecision) {
|
||||
multiline = langMultilineDecision;
|
||||
} else {
|
||||
multiline =
|
||||
!input.selectedCompletionInfo && // Only ever single-line if using intellisense selected value
|
||||
options.multilineCompletions !== "never" &&
|
||||
(options.multilineCompletions === "always" || completeMultiline);
|
||||
}
|
||||
const multiline =
|
||||
!options.transform ||
|
||||
this.isMultiline({
|
||||
multilineCompletions: options.multilineCompletions,
|
||||
language: lang,
|
||||
selectedCompletionInfo: input.selectedCompletionInfo,
|
||||
prefix,
|
||||
suffix,
|
||||
completeMultiline,
|
||||
});
|
||||
|
||||
// Try to reuse pending requests if what the user typed matches start of completion
|
||||
const generator = this.generatorReuseManager.getGenerator(
|
||||
|
|
@ -687,46 +713,52 @@ export class CompletionProvider {
|
|||
}
|
||||
};
|
||||
let charGenerator = generatorWithCancellation();
|
||||
charGenerator = noFirstCharNewline(charGenerator);
|
||||
charGenerator = onlyWhitespaceAfterEndOfLine(
|
||||
charGenerator,
|
||||
lang.endOfLine,
|
||||
fullStop,
|
||||
);
|
||||
charGenerator = stopAtStopTokens(charGenerator, stop);
|
||||
charGenerator = this.bracketMatchingService.stopOnUnmatchedClosingBracket(
|
||||
charGenerator,
|
||||
prefix,
|
||||
suffix,
|
||||
filepath,
|
||||
multiline,
|
||||
);
|
||||
|
||||
let lineGenerator = streamLines(charGenerator);
|
||||
lineGenerator = stopAtLines(lineGenerator, fullStop);
|
||||
lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop);
|
||||
lineGenerator = avoidPathLineAndEmptyComments(
|
||||
lineGenerator,
|
||||
lang.singleLineComment,
|
||||
);
|
||||
lineGenerator = skipPrefixes(lineGenerator);
|
||||
lineGenerator = noTopLevelKeywordsMidline(
|
||||
lineGenerator,
|
||||
lang.topLevelKeywords,
|
||||
fullStop,
|
||||
);
|
||||
|
||||
for (const lineFilter of lang.lineFilters ?? []) {
|
||||
lineGenerator = lineFilter({ lines: lineGenerator, fullStop });
|
||||
if (options.transform) {
|
||||
// charGenerator = noFirstCharNewline(charGenerator);
|
||||
// charGenerator = onlyWhitespaceAfterEndOfLine(
|
||||
// charGenerator,
|
||||
// lang.endOfLine,
|
||||
// fullStop,
|
||||
// );
|
||||
charGenerator = stopAtStopTokens(charGenerator, stop);
|
||||
charGenerator =
|
||||
this.bracketMatchingService.stopOnUnmatchedClosingBracket(
|
||||
charGenerator,
|
||||
prefix,
|
||||
suffix,
|
||||
filepath,
|
||||
multiline,
|
||||
);
|
||||
}
|
||||
|
||||
lineGenerator = streamWithNewLines(lineGenerator);
|
||||
let lineGenerator = streamLines(charGenerator);
|
||||
if (options.transform) {
|
||||
lineGenerator = stopAtLines(lineGenerator, fullStop);
|
||||
lineGenerator = stopAtRepeatingLines(lineGenerator, fullStop);
|
||||
lineGenerator = avoidPathLineAndEmptyComments(
|
||||
lineGenerator,
|
||||
lang.singleLineComment,
|
||||
);
|
||||
lineGenerator = skipPrefixes(lineGenerator);
|
||||
|
||||
const finalGenerator = stopAtSimilarLine(
|
||||
lineGenerator,
|
||||
lineBelowCursor,
|
||||
fullStop,
|
||||
);
|
||||
// lineGenerator = noTopLevelKeywordsMidline(
|
||||
// lineGenerator,
|
||||
// lang.topLevelKeywords,
|
||||
// fullStop,
|
||||
// );
|
||||
for (const lineFilter of lang.lineFilters ?? []) {
|
||||
lineGenerator = lineFilter({ lines: lineGenerator, fullStop });
|
||||
}
|
||||
|
||||
lineGenerator = stopAtSimilarLine(
|
||||
lineGenerator,
|
||||
lineBelowCursor,
|
||||
fullStop,
|
||||
);
|
||||
}
|
||||
|
||||
const finalGenerator = streamWithNewLines(lineGenerator);
|
||||
|
||||
try {
|
||||
for await (const update of finalGenerator) {
|
||||
|
|
@ -743,12 +775,14 @@ export class CompletionProvider {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
const processedCompletion = postprocessCompletion({
|
||||
completion,
|
||||
prefix,
|
||||
suffix,
|
||||
llm,
|
||||
});
|
||||
const processedCompletion = options.transform
|
||||
? postprocessCompletion({
|
||||
completion,
|
||||
prefix,
|
||||
suffix,
|
||||
llm,
|
||||
})
|
||||
: completion;
|
||||
|
||||
if (!processedCompletion) {
|
||||
return undefined;
|
||||
|
|
|
|||
|
|
@ -84,9 +84,13 @@ export class BracketMatchingService {
|
|||
// Add corresponding open brackets from suffix to stack
|
||||
// because we overwrite them and the diff is displayed, and this allows something to be edited after that
|
||||
for (let i = 0; i < suffix.length; i++) {
|
||||
if (suffix[i] === " ") {continue;}
|
||||
if (suffix[i] === " ") {
|
||||
continue;
|
||||
}
|
||||
const openBracket = BracketMatchingService.BRACKETS_REVERSE[suffix[i]];
|
||||
if (!openBracket) {break;}
|
||||
if (!openBracket) {
|
||||
break;
|
||||
}
|
||||
stack.unshift(openBracket);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,33 +3,6 @@ import { AutocompleteLanguageInfo } from "./languages";
|
|||
|
||||
const BLOCK_TYPES = ["body", "statement_block"];
|
||||
|
||||
function shouldCompleteMultilineAst(
|
||||
treePath: AstPath,
|
||||
cursorLine: number,
|
||||
): boolean {
|
||||
// If at the base of the file, do multiline
|
||||
if (treePath.length === 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If at the first line of an otherwise empty funtion body, do multiline
|
||||
for (let i = treePath.length - 1; i >= 0; i--) {
|
||||
const node = treePath[i];
|
||||
if (
|
||||
BLOCK_TYPES.includes(node.type) &&
|
||||
Math.abs(node.startPosition.row - cursorLine) <= 1
|
||||
) {
|
||||
let text = node.text;
|
||||
text = text.slice(text.indexOf("{") + 1);
|
||||
text = text.slice(0, text.lastIndexOf("}"));
|
||||
text = text.trim();
|
||||
return text.split("\n").length === 1;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isMidlineCompletion(prefix: string, suffix: string): boolean {
|
||||
return !suffix.startsWith("\n");
|
||||
}
|
||||
|
|
@ -56,20 +29,5 @@ export async function shouldCompleteMultiline(
|
|||
return false;
|
||||
}
|
||||
|
||||
// First, if the line before ends with an opening bracket, then assume multi-line
|
||||
if (
|
||||
["{", "(", "["].includes(
|
||||
fullPrefix.split("\n").slice(-2)[0]?.trim().slice(-1)[0],
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Use AST to determine whether to complete multiline
|
||||
let completeMultiline = false;
|
||||
if (treePath) {
|
||||
const cursorLine = fullPrefix.split("\n").length - 1;
|
||||
completeMultiline = shouldCompleteMultilineAst(treePath, cursorLine);
|
||||
}
|
||||
return completeMultiline;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
51
core/autocomplete/test/NEGATIVE_CASES_STARCODER.tsx
Normal file
51
core/autocomplete/test/NEGATIVE_CASES_STARCODER.tsx
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
##### Prompt #####
|
||||
class Calculator {
|
||||
constructor() {
|
||||
this.result = 0;
|
||||
}
|
||||
|
||||
add(number) {
|
||||
this.result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
subtract(number) {
|
||||
this.result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
multiply(number) {
|
||||
this.result *= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
divide(number) {
|
||||
if (number === 0) {
|
||||
throw new Error("Cannot divide by zero");
|
||||
}
|
||||
|
||||
<FIM>
|
||||
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.result = 0;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
==========================================================================
|
||||
==========================================================================
|
||||
Completion:
|
||||
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Calculator;
|
||||
30
core/autocomplete/test/filter.test.ts
Normal file
30
core/autocomplete/test/filter.test.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import {
|
||||
AutocompleteFileringTestInput,
|
||||
testAutocompleteFiltering,
|
||||
} from "./util";
|
||||
import { TEST_CASES } from "./testCases";
|
||||
|
||||
const filterTestCases = (tests: AutocompleteFileringTestInput[]) => {
|
||||
if (tests.some((test) => test.options?.only)) {
|
||||
return tests.filter((test) => test.options?.only);
|
||||
}
|
||||
|
||||
return tests;
|
||||
};
|
||||
|
||||
describe("llms/Mock", () => {
|
||||
describe("Autocomplete Filtering Tests", () => {
|
||||
beforeEach(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
});
|
||||
|
||||
describe("Should return unmodified LLM output", () => {
|
||||
it.each(filterTestCases(TEST_CASES))("$description", async (testCase) => {
|
||||
await testAutocompleteFiltering(testCase);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Add test cases where modifying LLM output is desirable
|
||||
describe.skip("Should return modified LLM output", () => {});
|
||||
});
|
||||
});
|
||||
2013
core/autocomplete/test/testCases.ts
Normal file
2013
core/autocomplete/test/testCases.ts
Normal file
File diff suppressed because it is too large
Load diff
74
core/autocomplete/test/util.ts
Normal file
74
core/autocomplete/test/util.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import Mock from "../../llm/llms/Mock";
|
||||
import { testConfigHandler, testIde } from "../../test/util/fixtures";
|
||||
import { AutocompleteInput, CompletionProvider } from "../completionProvider";
|
||||
|
||||
const FIM_DELIMITER = "<|fim|>";
|
||||
|
||||
function parseFimExample(text: string): { prefix: string; suffix: string } {
|
||||
const [prefix, suffix] = text.split(FIM_DELIMITER);
|
||||
return { prefix, suffix };
|
||||
}
|
||||
|
||||
export interface AutocompleteFileringTestInput {
|
||||
description: string;
|
||||
filename: string;
|
||||
input: string;
|
||||
llmOutput: string;
|
||||
expectedCompletion: string | null;
|
||||
options?: {
|
||||
only?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export async function testAutocompleteFiltering(
|
||||
test: AutocompleteFileringTestInput,
|
||||
) {
|
||||
const { prefix, suffix } = parseFimExample(test.input);
|
||||
|
||||
// Setup necessary objects
|
||||
const llm = new Mock({
|
||||
model: "mock",
|
||||
});
|
||||
llm.completion = test.llmOutput;
|
||||
const ide = testIde;
|
||||
const configHandler = testConfigHandler;
|
||||
|
||||
// Create a real file
|
||||
const [workspaceDir] = await ide.getWorkspaceDirs();
|
||||
const filepath = path.join(workspaceDir, test.filename);
|
||||
fs.writeFileSync(filepath, test.input.replace(FIM_DELIMITER, ""));
|
||||
|
||||
// Prepare completion input and provider
|
||||
const completionProvider = new CompletionProvider(
|
||||
configHandler,
|
||||
ide,
|
||||
async () => llm,
|
||||
() => {},
|
||||
async () => [],
|
||||
);
|
||||
|
||||
const line = prefix.split("\n").length - 1;
|
||||
const character = prefix.split("\n")[line].length;
|
||||
const autocompleteInput: AutocompleteInput = {
|
||||
clipboardText: "",
|
||||
completionId: "test-completion-id",
|
||||
filepath,
|
||||
pos: {
|
||||
line,
|
||||
character,
|
||||
},
|
||||
recentlyEditedFiles: [],
|
||||
recentlyEditedRanges: [],
|
||||
};
|
||||
|
||||
// Generate a completion
|
||||
const result = await completionProvider.provideInlineCompletionItems(
|
||||
autocompleteInput,
|
||||
undefined,
|
||||
);
|
||||
|
||||
// Ensure that we return the text that is wanted to be displayed
|
||||
expect(result?.completion).toEqual(test.expectedCompletion);
|
||||
}
|
||||
|
|
@ -110,6 +110,11 @@ export async function* streamLines(
|
|||
yield line;
|
||||
allLines.push(line);
|
||||
}
|
||||
|
||||
// if (buffer === "" && chunk.endsWith("\n")) {
|
||||
// yield "";
|
||||
// allLines.push("");
|
||||
// }
|
||||
}
|
||||
if (buffer.length > 0) {
|
||||
yield buffer;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export async function* streamLazyApply(
|
|||
let lazyCompletionLines = streamLines(lazyCompletion, true);
|
||||
// Process line output
|
||||
// lazyCompletionLines = filterEnglishLinesAtStart(lazyCompletionLines);
|
||||
lazyCompletionLines = stopAtLines(lazyCompletionLines, () => {}, ["```"]);
|
||||
lazyCompletionLines = stopAtLines(lazyCompletionLines, () => { }, ["```"]);
|
||||
lazyCompletionLines = filterLeadingNewline(lazyCompletionLines);
|
||||
|
||||
// Fill in unchanged code
|
||||
|
|
|
|||
8
core/index.d.ts
vendored
8
core/index.d.ts
vendored
|
|
@ -610,7 +610,6 @@ type ModelProvider =
|
|||
| "openai"
|
||||
| "free-trial"
|
||||
| "anthropic"
|
||||
| "anthropic-vertexai"
|
||||
| "cohere"
|
||||
| "together"
|
||||
| "ollama"
|
||||
|
|
@ -623,9 +622,7 @@ type ModelProvider =
|
|||
| "lmstudio"
|
||||
| "llamafile"
|
||||
| "gemini"
|
||||
| "gemini-vertexai"
|
||||
| "mistral"
|
||||
| "mistral-vertexai"
|
||||
| "bedrock"
|
||||
| "bedrockimport"
|
||||
| "sagemaker"
|
||||
|
|
@ -647,9 +644,9 @@ type ModelProvider =
|
|||
| "vllm"
|
||||
| "mock"
|
||||
| "cerebras"
|
||||
| "vertexai"
|
||||
| "askSage";
|
||||
|
||||
|
||||
export type ModelName =
|
||||
| "AUTODETECT"
|
||||
// OpenAI
|
||||
|
|
@ -830,7 +827,7 @@ export type EmbeddingsProviderName =
|
|||
| "nvidia"
|
||||
| "voyage"
|
||||
| "mistral"
|
||||
| "vertex"
|
||||
| "vertexai"
|
||||
| "watsonx";
|
||||
|
||||
export interface EmbedOptions {
|
||||
|
|
@ -890,6 +887,7 @@ export interface TabAutocompleteOptions {
|
|||
debounceDelay: number;
|
||||
maxSuffixPercentage: number;
|
||||
prefixPercentage: number;
|
||||
transform?: boolean;
|
||||
template?: string;
|
||||
multilineCompletions: "always" | "never" | "auto";
|
||||
slidingWindowPrefixPercentage: number;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
getParserForFile,
|
||||
getQueryForFile,
|
||||
} from "../util/treeSitter";
|
||||
import { DatabaseConnection, SqliteDb, tagToString } from "./refreshIndex";
|
||||
import { DatabaseConnection, SqliteDb, tagToString, truncateSqliteLikePattern } from "./refreshIndex";
|
||||
import {
|
||||
IndexResultType,
|
||||
MarkCompleteCallback,
|
||||
|
|
@ -28,7 +28,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
relativeExpectedTime: number = 1;
|
||||
artifactId = "codeSnippets";
|
||||
|
||||
constructor(private readonly ide: IDE) {}
|
||||
constructor(private readonly ide: IDE) { }
|
||||
|
||||
private static async _createTables(db: DatabaseConnection) {
|
||||
await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets (
|
||||
|
|
@ -383,7 +383,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
|
|||
const db = await SqliteDb.get();
|
||||
await CodeSnippetsCodebaseIndex._createTables(db);
|
||||
|
||||
const likePatterns = workspaceDirs.map((dir) => `${dir}%`);
|
||||
const likePatterns = workspaceDirs.map((dir) => truncateSqliteLikePattern(`${dir}%`));
|
||||
const placeholders = likePatterns.map(() => "?").join(" OR path LIKE ");
|
||||
|
||||
const query = `
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import BaseEmbeddingsProvider from "./BaseEmbeddingsProvider.js";
|
|||
* [View the Vertex Text Embedding docs.](https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-text-embeddings)
|
||||
*/
|
||||
class VertexEmbeddingsProvider extends BaseEmbeddingsProvider {
|
||||
static providerName: EmbeddingsProviderName = "vertex";
|
||||
static providerName: EmbeddingsProviderName = "vertexai";
|
||||
declare apiBase: string;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ export const allEmbeddingsProviders: Record<
|
|||
nvidia: NvidiaEmbeddingsProvider,
|
||||
voyage: VoyageEmbeddingsProvider,
|
||||
mistral: MistralEmbeddingsProvider,
|
||||
vertex: VertexEmbeddingsProvider,
|
||||
watsonx: WatsonxEmbeddingsProvider,
|
||||
vertexai: VertexEmbeddingsProvider,
|
||||
watsonx: WatsonxEmbeddingsProvider
|
||||
};
|
||||
|
|
|
|||
34
core/indexing/refreshIndex.test.ts
Normal file
34
core/indexing/refreshIndex.test.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { truncateToLastNBytes } from "./refreshIndex";
|
||||
|
||||
describe("truncateToLastNBytes", () => {
|
||||
it("should return full string if maxBytes greater than string byte length", () => {
|
||||
const input = "Hello World";
|
||||
const result = truncateToLastNBytes(input, 100);
|
||||
expect(result).toBe("Hello World");
|
||||
});
|
||||
|
||||
it("should truncate ASCII string correctly", () => {
|
||||
const input = "Hello World";
|
||||
const result = truncateToLastNBytes(input, 5);
|
||||
expect(result).toBe("World");
|
||||
});
|
||||
|
||||
it("should handle empty string", () => {
|
||||
const input = "";
|
||||
const result = truncateToLastNBytes(input, 5);
|
||||
expect(result).toBe("");
|
||||
});
|
||||
|
||||
it("should handle UTF-8 characters correctly", () => {
|
||||
const input = "👋 Hello";
|
||||
// 👋 is 4 bytes, space is 1 byte
|
||||
const result = truncateToLastNBytes(input, 5);
|
||||
expect(result).toBe("Hello");
|
||||
});
|
||||
|
||||
it("should handle maxBytes of 0", () => {
|
||||
const input = "Hello World";
|
||||
const result = truncateToLastNBytes(input, 0);
|
||||
expect(result).toBe("");
|
||||
});
|
||||
});
|
||||
|
|
@ -469,3 +469,24 @@ export class GlobalCacheCodeBaseIndex implements CodebaseIndex {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
const SQLITE_MAX_LIKE_PATTERN_LENGTH = 50000;
|
||||
|
||||
export function truncateToLastNBytes(input: string, maxBytes: number): string {
|
||||
let bytes = 0;
|
||||
let startIndex = 0;
|
||||
|
||||
for (let i = input.length - 1; i >= 0; i--) {
|
||||
bytes += new TextEncoder().encode(input[i]).length;
|
||||
if (bytes > maxBytes) {
|
||||
startIndex = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return input.substring(startIndex, input.length);
|
||||
}
|
||||
|
||||
export function truncateSqliteLikePattern(input: string) {
|
||||
return truncateToLastNBytes(input, SQLITE_MAX_LIKE_PATTERN_LENGTH);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,29 +42,27 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [
|
|||
"together",
|
||||
"msty",
|
||||
"anthropic",
|
||||
"anthropic-vertexai",
|
||||
"bedrock",
|
||||
"sagemaker",
|
||||
"continue-proxy",
|
||||
"mistral",
|
||||
"mistral-vertexai",
|
||||
"sambanova",
|
||||
"watsonx",
|
||||
"vertexai",
|
||||
"watsonx"
|
||||
];
|
||||
|
||||
const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [
|
||||
"openai",
|
||||
"ollama",
|
||||
"gemini",
|
||||
"gemini-vertexai",
|
||||
"free-trial",
|
||||
"msty",
|
||||
"anthropic",
|
||||
"anthropic-vertexai",
|
||||
"bedrock",
|
||||
"sagemaker",
|
||||
"continue-proxy",
|
||||
"openrouter",
|
||||
"vertexai"
|
||||
];
|
||||
|
||||
const MODEL_SUPPORTS_IMAGES: string[] = [
|
||||
|
|
@ -110,20 +108,18 @@ function modelSupportsImages(
|
|||
}
|
||||
const PARALLEL_PROVIDERS: ModelProvider[] = [
|
||||
"anthropic",
|
||||
"anthropic-vertexai",
|
||||
"bedrock",
|
||||
"sagemaker",
|
||||
"deepinfra",
|
||||
"gemini",
|
||||
"gemini-vertexai",
|
||||
"huggingface-inference-api",
|
||||
"huggingface-tgi",
|
||||
"mistral",
|
||||
"mistral-vertexai",
|
||||
"free-trial",
|
||||
"replicate",
|
||||
"together",
|
||||
"sambanova",
|
||||
"vertexai"
|
||||
];
|
||||
|
||||
function llmCanGenerateInParallel(
|
||||
|
|
@ -224,7 +220,7 @@ function autodetectTemplateType(model: string): TemplateType | undefined {
|
|||
}
|
||||
|
||||
if (lower.includes("granite")) {
|
||||
return "granite";
|
||||
return "granite";
|
||||
}
|
||||
|
||||
return "chatml";
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class Anthropic extends BaseLLM {
|
|||
apiBase: "https://api.anthropic.com/v1/",
|
||||
};
|
||||
|
||||
private _convertArgs(options: CompletionOptions) {
|
||||
public convertArgs(options: CompletionOptions) { // should be public for use within VertexAI
|
||||
const finalOptions = {
|
||||
top_k: options.topK,
|
||||
top_p: options.topP,
|
||||
|
|
@ -34,7 +34,7 @@ class Anthropic extends BaseLLM {
|
|||
return finalOptions;
|
||||
}
|
||||
|
||||
private _convertMessages(msgs: ChatMessage[]): any[] {
|
||||
public convertMessages(msgs: ChatMessage[]): any[] { // should be public for use within VertexAI
|
||||
const filteredmessages = msgs.filter((m) => m.role !== "system")
|
||||
const lastTwoUserMsgIndices = filteredmessages
|
||||
.map((msg, index) => (msg.role === "user" ? index : -1))
|
||||
|
|
@ -115,8 +115,8 @@ class Anthropic extends BaseLLM {
|
|||
: {}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...this._convertArgs(options),
|
||||
messages: this._convertMessages(messages),
|
||||
...this.convertArgs(options),
|
||||
messages: this.convertMessages(messages),
|
||||
system: shouldCacheSystemMessage
|
||||
? [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,142 +0,0 @@
|
|||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider,
|
||||
} from "../../index.js";
|
||||
import { stripImages } from "../images.js";
|
||||
import { streamSse } from "../stream.js";
|
||||
import VertexAI from "./VertexAI.js";
|
||||
|
||||
class AnthropicVertexAI extends VertexAI {
|
||||
static providerName: ModelProvider = "anthropic-vertexai";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
region: "us-east5",
|
||||
model: "claude-3-5-sonnet",
|
||||
};
|
||||
|
||||
private _convertArgs(options: CompletionOptions) {
|
||||
const finalOptions = {
|
||||
anthropic_version: "vertex-2023-10-16",
|
||||
top_k: options.topK,
|
||||
top_p: options.topP,
|
||||
temperature: options.temperature,
|
||||
max_tokens: options.maxTokens ?? 2048,
|
||||
stop_sequences: options.stop?.filter((x) => x.trim() !== ""),
|
||||
stream: options.stream ?? true,
|
||||
};
|
||||
|
||||
return finalOptions;
|
||||
}
|
||||
|
||||
private _convertMessages(msgs: ChatMessage[]): any[] {
|
||||
const filteredmessages = msgs.filter((m) => m.role !== "system")
|
||||
const lastTwoUserMsgIndices = filteredmessages
|
||||
.map((msg, index) => (msg.role === "user" ? index : -1))
|
||||
.filter((index) => index !== -1).slice(-2);
|
||||
|
||||
const messages = filteredmessages.map((message, filteredMsgIdx) => {
|
||||
// Add cache_control parameter to the last two user messages
|
||||
// The second-to-last because it retrieves potentially already cached contents,
|
||||
// The last one because we want it cached for later retrieval.
|
||||
// See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
||||
const addCaching = this.cacheBehavior?.cacheConversation && lastTwoUserMsgIndices.includes(filteredMsgIdx);
|
||||
|
||||
if (typeof message.content === "string") {
|
||||
var chatMessage = {
|
||||
...message,
|
||||
content: [{
|
||||
type: "text",
|
||||
text: message.content,
|
||||
...(addCaching? { cache_control: { type: "ephemeral" } } : {})
|
||||
}]
|
||||
};
|
||||
return chatMessage;
|
||||
}
|
||||
|
||||
return {
|
||||
...message,
|
||||
content: message.content.map((part, contentIdx) => {
|
||||
if (part.type === "text") {
|
||||
const newpart = {
|
||||
...part,
|
||||
// If multiple text parts, only add cache_control to the last one
|
||||
...((addCaching && contentIdx == message.content.length - 1) ? { cache_control: { type: "ephemeral" } } : {})
|
||||
};
|
||||
return newpart;
|
||||
}
|
||||
return {
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
data: part.imageUrl?.url.split(",")[1],
|
||||
},
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
return messages;
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const messages = [{ role: "user" as const, content: prompt }];
|
||||
for await (const update of this._streamChat(messages, options)) {
|
||||
yield stripImages(update.content);
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
|
||||
const systemMessage: string = stripImages(
|
||||
messages.filter((m) => m.role === "system")[0]?.content,
|
||||
);
|
||||
const apiURL = new URL(
|
||||
`publishers/anthropic/models/${options.model}:streamRawPredict`,
|
||||
this.apiBase
|
||||
);
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
...(shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation
|
||||
? { "anthropic-beta": "prompt-caching-2024-07-31" }
|
||||
: {}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...this._convertArgs(options),
|
||||
messages: this._convertMessages(messages),
|
||||
system: shouldCacheSystemMessage
|
||||
? [
|
||||
{
|
||||
type: "text",
|
||||
text: this.systemMessage,
|
||||
cache_control: { type: "ephemeral" },
|
||||
},
|
||||
]
|
||||
: systemMessage,
|
||||
}),
|
||||
});
|
||||
|
||||
if (options.stream === false) {
|
||||
const data = await response.json();
|
||||
yield { role: "assistant", content: data.content[0].text };
|
||||
return;
|
||||
}
|
||||
|
||||
for await (const value of streamSse(response)) {
|
||||
if (value.type == "message_start") console.log(value);
|
||||
if (value.delta?.text) {
|
||||
yield { role: "assistant", content: value.delta.text };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default AnthropicVertexAI;
|
||||
|
|
@ -19,7 +19,7 @@ class Gemini extends BaseLLM {
|
|||
};
|
||||
|
||||
// Function to convert completion options to Gemini format
|
||||
private _convertArgs(options: CompletionOptions) {
|
||||
public convertArgs(options: CompletionOptions) { // should be public for use within VertexAI
|
||||
const finalOptions: any = {}; // Initialize an empty object
|
||||
|
||||
// Map known options
|
||||
|
|
@ -56,7 +56,7 @@ class Gemini extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
private removeSystemMessage(messages: ChatMessage[]) {
|
||||
public removeSystemMessage(messages: ChatMessage[]) { // should be public for use within VertexAI
|
||||
const msgs = [...messages];
|
||||
|
||||
if (msgs[0]?.role === "system") {
|
||||
|
|
@ -103,7 +103,7 @@ class Gemini extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
private _continuePartToGeminiPart(part: MessagePart) {
|
||||
continuePartToGeminiPart(part: MessagePart) {
|
||||
return part.type === "text"
|
||||
? {
|
||||
text: part.text,
|
||||
|
|
@ -142,13 +142,13 @@ class Gemini extends BaseLLM {
|
|||
parts:
|
||||
typeof msg.content === "string"
|
||||
? [{ text: msg.content }]
|
||||
: msg.content.map(this._continuePartToGeminiPart),
|
||||
: msg.content.map(this.continuePartToGeminiPart),
|
||||
};
|
||||
})
|
||||
.filter((c) => c !== null);
|
||||
|
||||
const body = {
|
||||
...this._convertArgs(options),
|
||||
...this.convertArgs(options),
|
||||
contents,
|
||||
// if this.systemMessage is defined, reformat it for Gemini API
|
||||
...(this.systemMessage &&
|
||||
|
|
|
|||
|
|
@ -1,232 +0,0 @@
|
|||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
MessagePart,
|
||||
ModelProvider,
|
||||
} from "../../index.js";
|
||||
import { stripImages } from "../images.js";
|
||||
import { streamResponse } from "../stream.js";
|
||||
import VertexAI from "./VertexAI.js";
|
||||
|
||||
class GeminiVertexAI extends VertexAI {
|
||||
static providerName: ModelProvider = "gemini-vertexai";
|
||||
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
model: "gemini-pro",
|
||||
region: "us-central1",
|
||||
};
|
||||
|
||||
// Function to convert completion options to Gemini format
|
||||
private _convertArgs(options: CompletionOptions) {
|
||||
const finalOptions: any = {}; // Initialize an empty object
|
||||
|
||||
// Map known options
|
||||
if (options.topK) {
|
||||
finalOptions.topK = options.topK;
|
||||
}
|
||||
if (options.topP) {
|
||||
finalOptions.topP = options.topP;
|
||||
}
|
||||
if (options.temperature !== undefined && options.temperature !== null) {
|
||||
finalOptions.temperature = options.temperature;
|
||||
}
|
||||
if (options.maxTokens) {
|
||||
finalOptions.maxOutputTokens = options.maxTokens;
|
||||
}
|
||||
if (options.stop) {
|
||||
finalOptions.stopSequences = options.stop.filter((x) => x.trim() !== "");
|
||||
}
|
||||
|
||||
return { generationConfig: finalOptions }; // Wrap options under 'generationConfig'
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
for await (const message of this._streamChat(
|
||||
[{ content: prompt, role: "user" }],
|
||||
options,
|
||||
)) {
|
||||
yield stripImages(message.content);
|
||||
}
|
||||
}
|
||||
|
||||
private removeSystemMessage(messages: ChatMessage[]) {
|
||||
const msgs = [...messages];
|
||||
|
||||
if (msgs[0]?.role === "system") {
|
||||
const sysMsg = msgs.shift()?.content;
|
||||
// @ts-ignore
|
||||
if (msgs[0]?.role === "user") {
|
||||
msgs[0].content = `System message - follow these instructions in every response: ${sysMsg}\n\n---\n\n${msgs[0].content}`;
|
||||
}
|
||||
}
|
||||
|
||||
return msgs;
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const isV1API = this.apiBase.includes("/v1/");
|
||||
|
||||
// Conditionally apply removeSystemMessage
|
||||
const convertedMsgs = isV1API
|
||||
? this.removeSystemMessage(messages)
|
||||
: messages;
|
||||
|
||||
if (options.model.includes("gemini")) {
|
||||
yield* this.streamChatGemini(convertedMsgs, options);
|
||||
} else {
|
||||
yield* this.streamChatBison(convertedMsgs, options);
|
||||
}
|
||||
}
|
||||
|
||||
private _continuePartToGeminiPart(part: MessagePart) {
|
||||
return part.type === "text"
|
||||
? {
|
||||
text: part.text,
|
||||
}
|
||||
: {
|
||||
inlineData: {
|
||||
mimeType: "image/jpeg",
|
||||
data: part.imageUrl?.url.split(",")[1],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private async *streamChatGemini(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const apiURL = new URL(
|
||||
`publishers/google/models/${options.model}:streamGenerateContent`,
|
||||
this.apiBase,
|
||||
);
|
||||
// This feels hacky to repeat code from above function but was the quickest
|
||||
// way to ensure system message re-formatting isn't done if user has specified v1
|
||||
const isV1API = this.apiBase.includes("/v1/");
|
||||
|
||||
const contents = messages
|
||||
.map((msg) => {
|
||||
if (msg.role === "system" && !isV1API) {
|
||||
return null; // Don't include system message in contents
|
||||
}
|
||||
return {
|
||||
role: msg.role === "assistant" ? "model" : "user",
|
||||
parts:
|
||||
typeof msg.content === "string"
|
||||
? [{ text: msg.content }]
|
||||
: msg.content.map(this._continuePartToGeminiPart),
|
||||
};
|
||||
})
|
||||
.filter((c) => c !== null);
|
||||
|
||||
const body = {
|
||||
...this._convertArgs(options),
|
||||
contents,
|
||||
// if this.systemMessage is defined, reformat it for Gemini API
|
||||
...(this.systemMessage &&
|
||||
!isV1API && {
|
||||
systemInstruction: { parts: [{ text: this.systemMessage }] },
|
||||
}),
|
||||
};
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
let buffer = "";
|
||||
for await (const chunk of streamResponse(response)) {
|
||||
buffer += chunk;
|
||||
if (buffer.startsWith("[")) {
|
||||
buffer = buffer.slice(1);
|
||||
}
|
||||
if (buffer.endsWith("]")) {
|
||||
buffer = buffer.slice(0, -1);
|
||||
}
|
||||
if (buffer.startsWith(",")) {
|
||||
buffer = buffer.slice(1);
|
||||
}
|
||||
|
||||
const parts = buffer.split("\n,");
|
||||
|
||||
let foundIncomplete = false;
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i];
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(part);
|
||||
} catch (e) {
|
||||
foundIncomplete = true;
|
||||
continue; // yo!
|
||||
}
|
||||
if (data.error) {
|
||||
throw new Error(data.error.message);
|
||||
}
|
||||
// Check for existence of each level before accessing the final 'text' property
|
||||
if (data?.candidates?.[0]?.content?.parts?.[0]?.text) {
|
||||
// Incrementally stream the content to make it smoother
|
||||
const content = data.candidates[0].content.parts[0].text;
|
||||
const words = content.split(/(\s+)/);
|
||||
const delaySeconds = Math.min(4.0 / (words.length + 1), 0.1);
|
||||
while (words.length > 0) {
|
||||
const wordsToYield = Math.min(3, words.length);
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: words.splice(0, wordsToYield).join(""),
|
||||
};
|
||||
await delay(delaySeconds);
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the expected data structure is not found
|
||||
console.warn("Unexpected response format:", data);
|
||||
}
|
||||
}
|
||||
if (foundIncomplete) {
|
||||
buffer = parts[parts.length - 1];
|
||||
} else {
|
||||
buffer = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async *streamChatBison(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const instances = messages.map((message) => ({ prompt: message.content }));
|
||||
|
||||
const apiURL = new URL(
|
||||
`publishers/google/models/${options.model}:predict`,
|
||||
this.apiBase,
|
||||
);
|
||||
const body = {
|
||||
instances,
|
||||
parameters: {
|
||||
temperature: options.temperature,
|
||||
maxOutputTokens: options.maxTokens,
|
||||
topP: options.topP,
|
||||
topK: options.topK,
|
||||
stopSequences: options.stop,
|
||||
presencePenalty: options.presencePenalty,
|
||||
frequencyPenalty: options.frequencyPenalty,
|
||||
},
|
||||
};
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
const data = await response.json();
|
||||
yield { role: "assistant", content: data.predictions[0].content };
|
||||
}
|
||||
}
|
||||
|
||||
async function delay(seconds: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
|
||||
export default GeminiVertexAI;
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
ModelProvider
|
||||
} from "../../index.js";
|
||||
import { stripImages } from "../images.js";
|
||||
import { streamSse } from "../stream.js";
|
||||
import { gptEditPrompt } from "../templates/edit.js";
|
||||
import VertexAI from "./VertexAI.js";
|
||||
|
||||
class MistralVertexAI extends VertexAI {
|
||||
static providerName: ModelProvider = "mistral-vertexai";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
region: "us-central1",
|
||||
model: "codestral-latest",
|
||||
promptTemplates: {
|
||||
edit: gptEditPrompt,
|
||||
},
|
||||
};
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
for await (const chunk of this._streamChat(
|
||||
[{ role: "user", content: prompt }],
|
||||
options,
|
||||
)) {
|
||||
yield stripImages(chunk.content);
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const apiBase = this.apiBase!;
|
||||
const apiURL = new URL(
|
||||
`publishers/mistralai/models/${options.model}:streamRawPredict`,
|
||||
apiBase,
|
||||
);
|
||||
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
if (lastMessage?.role === "assistant") {
|
||||
(lastMessage as any).prefix = true;
|
||||
}
|
||||
|
||||
const body = {
|
||||
model: options.model,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
max_tokens: options.maxTokens,
|
||||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
messages,
|
||||
};
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
for await (const chunk of streamSse(response)) {
|
||||
yield chunk.choices[0].delta;
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamFim(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const apiBase = this.apiBase!;
|
||||
const apiURL = new URL(
|
||||
`publishers/mistralai/models/${options.model}:streamRawPredict`,
|
||||
apiBase,
|
||||
);
|
||||
|
||||
const body = {
|
||||
model: options.model,
|
||||
max_tokens: options.maxTokens,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
prompt: prefix,
|
||||
suffix,
|
||||
};
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
for await (const chunk of streamSse(response)) {
|
||||
yield chunk.choices[0].delta.content;
|
||||
}
|
||||
}
|
||||
|
||||
supportsFim(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export default MistralVertexAI;
|
||||
|
|
@ -2,24 +2,26 @@ import { ChatMessage, CompletionOptions, ModelProvider } from "../../index.js";
|
|||
import { BaseLLM } from "../index.js";
|
||||
|
||||
class Mock extends BaseLLM {
|
||||
static Completion = "Test Completion";
|
||||
public completion: string = "Test Completion";
|
||||
static providerName: ModelProvider = "mock";
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
yield Mock.Completion;
|
||||
yield this.completion;
|
||||
}
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: Mock.Completion,
|
||||
};
|
||||
for (const char of this.completion) {
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: char,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,24 @@
|
|||
import { GoogleAuth } from "google-auth-library";
|
||||
import { LLMOptions } from "../../index.js";
|
||||
import { BaseLLM } from "../index.js";
|
||||
import { stripImages } from "../images.js";
|
||||
import { streamSse } from "../stream.js";
|
||||
import {
|
||||
ChatMessage,
|
||||
CompletionOptions,
|
||||
LLMOptions,
|
||||
MessagePart,
|
||||
ModelProvider,
|
||||
} from "../../index.js";
|
||||
import { streamResponse } from "../stream.js";
|
||||
import Anthropic from "./Anthropic.js";
|
||||
import Gemini from "./Gemini.js";
|
||||
|
||||
abstract class VertexAI extends BaseLLM {
|
||||
class VertexAI extends BaseLLM {
|
||||
static providerName: ModelProvider = "vertexai";
|
||||
declare apiBase: string;
|
||||
declare vertexProvider: string;
|
||||
declare anthropicInstance: Anthropic;
|
||||
declare geminiInstance: Gemini;
|
||||
|
||||
private clientPromise = new GoogleAuth({
|
||||
scopes: "https://www.googleapis.com/auth/cloud-platform",
|
||||
|
|
@ -22,6 +37,17 @@ abstract class VertexAI extends BaseLLM {
|
|||
constructor(_options: LLMOptions) {
|
||||
super(_options);
|
||||
this.apiBase ??= VertexAI.getDefaultApiBaseFrom(_options);
|
||||
this.vertexProvider =
|
||||
_options.model.includes("mistral") || _options.model.includes("codestral") || _options.model.includes("mixtral")
|
||||
? "mistral"
|
||||
: _options.model.includes("claude")
|
||||
? "anthropic"
|
||||
: _options.model.includes("gemini")
|
||||
? "gemini" :
|
||||
"unknown";
|
||||
this.anthropicInstance = new Anthropic(_options);
|
||||
this.geminiInstance = new Gemini(_options)
|
||||
|
||||
}
|
||||
|
||||
async fetch(url: RequestInfo | URL, init?: RequestInit) {
|
||||
|
|
@ -41,6 +67,373 @@ abstract class VertexAI extends BaseLLM {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Anthropic functions
|
||||
private _anthropicConvertArgs(options: CompletionOptions) {
|
||||
const convertedArgs = this.anthropicInstance.convertArgs(options);
|
||||
|
||||
// Remove the `model` property and add `anthropic_version`
|
||||
const { model, ...finalOptions } = convertedArgs;
|
||||
return {
|
||||
...finalOptions,
|
||||
anthropic_version: "vertex-2023-10-16",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
protected async *StreamChatAnthropic(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
|
||||
const systemMessage: string = stripImages(
|
||||
messages.filter((m) => m.role === "system")[0]?.content,
|
||||
);
|
||||
const apiURL = new URL(
|
||||
`publishers/anthropic/models/${options.model}:streamRawPredict`,
|
||||
this.apiBase
|
||||
);
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
...(shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation
|
||||
? { "anthropic-beta": "prompt-caching-2024-07-31" }
|
||||
: {}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
...this._anthropicConvertArgs(options),
|
||||
messages: this.anthropicInstance.convertMessages(messages),
|
||||
system: shouldCacheSystemMessage
|
||||
? [
|
||||
{
|
||||
type: "text",
|
||||
text: this.systemMessage,
|
||||
cache_control: { type: "ephemeral" },
|
||||
},
|
||||
]
|
||||
: systemMessage,
|
||||
}),
|
||||
});
|
||||
|
||||
if (options.stream === false) {
|
||||
const data = await response.json();
|
||||
yield { role: "assistant", content: data.content[0].text };
|
||||
return;
|
||||
}
|
||||
|
||||
for await (const value of streamSse(response)) {
|
||||
if (value.type == "message_start") console.log(value);
|
||||
if (value.delta?.text) {
|
||||
yield { role: "assistant", content: value.delta.text };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Gemini
|
||||
|
||||
private async *streamChatGemini(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const apiURL = new URL(
|
||||
`publishers/google/models/${options.model}:streamGenerateContent`,
|
||||
this.apiBase,
|
||||
);
|
||||
// This feels hacky to repeat code from above function but was the quickest
|
||||
// way to ensure system message re-formatting isn't done if user has specified v1
|
||||
const isV1API = this.apiBase.includes("/v1/");
|
||||
|
||||
const contents = messages
|
||||
.map((msg) => {
|
||||
if (msg.role === "system" && !isV1API) {
|
||||
return null; // Don't include system message in contents
|
||||
}
|
||||
return {
|
||||
role: msg.role === "assistant" ? "model" : "user",
|
||||
parts:
|
||||
typeof msg.content === "string"
|
||||
? [{ text: msg.content }]
|
||||
: msg.content.map(this.geminiInstance.continuePartToGeminiPart),
|
||||
};
|
||||
})
|
||||
.filter((c) => c !== null);
|
||||
|
||||
const body = {
|
||||
...this.geminiInstance.convertArgs(options),
|
||||
contents,
|
||||
// if this.systemMessage is defined, reformat it for Gemini API
|
||||
...(this.systemMessage &&
|
||||
!isV1API && {
|
||||
systemInstruction: { parts: [{ text: this.systemMessage }] },
|
||||
}),
|
||||
};
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
let buffer = "";
|
||||
for await (const chunk of streamResponse(response)) {
|
||||
buffer += chunk;
|
||||
if (buffer.startsWith("[")) {
|
||||
buffer = buffer.slice(1);
|
||||
}
|
||||
if (buffer.endsWith("]")) {
|
||||
buffer = buffer.slice(0, -1);
|
||||
}
|
||||
if (buffer.startsWith(",")) {
|
||||
buffer = buffer.slice(1);
|
||||
}
|
||||
|
||||
const parts = buffer.split("\n,");
|
||||
|
||||
let foundIncomplete = false;
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
const part = parts[i];
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(part);
|
||||
} catch (e) {
|
||||
foundIncomplete = true;
|
||||
continue; // yo!
|
||||
}
|
||||
if (data.error) {
|
||||
throw new Error(data.error.message);
|
||||
}
|
||||
// Check for existence of each level before accessing the final 'text' property
|
||||
if (data?.candidates?.[0]?.content?.parts?.[0]?.text) {
|
||||
// Incrementally stream the content to make it smoother
|
||||
const content = data.candidates[0].content.parts[0].text;
|
||||
const words = content.split(/(\s+)/);
|
||||
const delaySeconds = Math.min(4.0 / (words.length + 1), 0.1);
|
||||
while (words.length > 0) {
|
||||
const wordsToYield = Math.min(3, words.length);
|
||||
yield {
|
||||
role: "assistant",
|
||||
content: words.splice(0, wordsToYield).join(""),
|
||||
};
|
||||
await delay(delaySeconds);
|
||||
}
|
||||
} else {
|
||||
// Handle the case where the expected data structure is not found
|
||||
if (data?.candidates?.[0]?.finishReason !== "STOP") {
|
||||
console.warn("Unexpected response format:", data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (foundIncomplete) {
|
||||
buffer = parts[parts.length - 1];
|
||||
} else {
|
||||
buffer = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async *streamChatBison(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const instances = messages.map((message) => ({ prompt: message.content }));
|
||||
|
||||
const apiURL = new URL(
|
||||
`publishers/google/models/${options.model}:predict`,
|
||||
this.apiBase,
|
||||
);
|
||||
const body = {
|
||||
instances,
|
||||
parameters: {
|
||||
temperature: options.temperature,
|
||||
maxOutputTokens: options.maxTokens,
|
||||
topP: options.topP,
|
||||
topK: options.topK,
|
||||
stopSequences: options.stop,
|
||||
presencePenalty: options.presencePenalty,
|
||||
frequencyPenalty: options.frequencyPenalty,
|
||||
},
|
||||
};
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
const data = await response.json();
|
||||
yield { role: "assistant", content: data.predictions[0].content };
|
||||
}
|
||||
|
||||
//Mistral
|
||||
|
||||
|
||||
protected async *StreamChatMistral(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const apiBase = this.apiBase!;
|
||||
const apiURL = new URL(
|
||||
`publishers/mistralai/models/${options.model}:streamRawPredict`,
|
||||
apiBase,
|
||||
);
|
||||
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
if (lastMessage?.role === "assistant") {
|
||||
(lastMessage as any).prefix = true;
|
||||
}
|
||||
|
||||
const body = {
|
||||
model: options.model,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
max_tokens: options.maxTokens,
|
||||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
messages,
|
||||
};
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
for await (const chunk of streamSse(response)) {
|
||||
if (chunk.choices?.[0]) {
|
||||
// At the end vertexai will return a empty chunk.
|
||||
yield chunk.choices[0].delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async *StreamFimMistral(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const apiBase = this.apiBase!;
|
||||
const apiURL = new URL(
|
||||
`publishers/mistralai/models/${options.model}:streamRawPredict`,
|
||||
apiBase,
|
||||
);
|
||||
|
||||
const body = {
|
||||
model: options.model,
|
||||
max_tokens: options.maxTokens,
|
||||
temperature: options.temperature,
|
||||
top_p: options.topP,
|
||||
stream: options.stream ?? true,
|
||||
stop: options.stop,
|
||||
prompt: prefix,
|
||||
suffix,
|
||||
};
|
||||
|
||||
const response = await this.fetch(apiURL, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
for await (const chunk of streamSse(response)) {
|
||||
yield chunk.choices[0].delta.content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//gecko
|
||||
protected async *streamFimGecko(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
const endpoint = new URL("publishers/google/models/code-gecko:predict", this.apiBase);
|
||||
const resp = await this.fetch(endpoint, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
instances: [
|
||||
{
|
||||
prefix: prefix,
|
||||
suffix: suffix
|
||||
}
|
||||
],
|
||||
parameters: {
|
||||
temperature: options.temperature,
|
||||
maxOutputTokens: Math.min(options.maxTokens ?? 64, 64),
|
||||
stopSequences: options.stop?.splice(0, 5),
|
||||
frequencyPenalty: options.frequencyPenalty,
|
||||
presencePenalty: options.frequencyPenalty,
|
||||
}
|
||||
|
||||
}),
|
||||
});
|
||||
// Streaming is not supported by code-gecko
|
||||
// TODO: convert to non-streaming fim method when one exist in continue.
|
||||
yield (await resp.json()).predictions[0].content;
|
||||
}
|
||||
|
||||
//Manager functions
|
||||
|
||||
protected async *_streamChat(
|
||||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const isV1API = this.apiBase.includes("/v1/");
|
||||
|
||||
// Conditionally apply removeSystemMessage
|
||||
const convertedMsgs = isV1API
|
||||
? this.geminiInstance.removeSystemMessage(messages)
|
||||
: messages;
|
||||
if (this.vertexProvider == "gemini") {
|
||||
yield* this.streamChatGemini(convertedMsgs, options);
|
||||
} else if (this.vertexProvider == "mistral") {
|
||||
yield* this.StreamChatMistral(messages, options);
|
||||
} else if (this.vertexProvider == "anthropic") {
|
||||
yield* this.StreamChatAnthropic(messages, options)
|
||||
} else {
|
||||
if (options.model.includes("bison")) {
|
||||
yield* this.streamChatBison(convertedMsgs, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamComplete(
|
||||
prompt: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
for await (const message of this._streamChat(
|
||||
[{ content: prompt, role: "user" }],
|
||||
options,
|
||||
)) {
|
||||
yield stripImages(message.content);
|
||||
}
|
||||
}
|
||||
|
||||
protected async *_streamFim(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<string> {
|
||||
|
||||
|
||||
|
||||
if (this.model === "code-gecko") {
|
||||
yield* this.streamFimGecko(prefix, suffix, options);
|
||||
} else if (this.model.includes("codestral")) {
|
||||
yield* this.StreamFimMistral(prefix, suffix, options);
|
||||
} else {
|
||||
throw new Error(`Unsupported model: ${this.model}`);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
supportsFim(): boolean {
|
||||
return ["code-gecko", "codestral-latest"].includes(this.model);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function delay(seconds: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default VertexAI;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import {
|
|||
import { renderTemplatedString } from "../../promptFiles/renderTemplatedString";
|
||||
import { BaseLLM } from "../index";
|
||||
import Anthropic from "./Anthropic";
|
||||
import AnthropicVertexAI from "./AnthropicVertexAI";
|
||||
import Azure from "./Azure";
|
||||
import Bedrock from "./Bedrock";
|
||||
import BedrockImport from "./BedrockImport";
|
||||
|
|
@ -21,7 +20,6 @@ import Fireworks from "./Fireworks";
|
|||
import Flowise from "./Flowise";
|
||||
import FreeTrial from "./FreeTrial";
|
||||
import Gemini from "./Gemini";
|
||||
import GeminiVertexAI from "./GeminiVertexAI";
|
||||
import Groq from "./Groq";
|
||||
import HuggingFaceInferenceAPI from "./HuggingFaceInferenceAPI";
|
||||
import HuggingFaceTGI from "./HuggingFaceTGI";
|
||||
|
|
@ -30,7 +28,6 @@ import LMStudio from "./LMStudio";
|
|||
import LlamaCpp from "./LlamaCpp";
|
||||
import Llamafile from "./Llamafile";
|
||||
import Mistral from "./Mistral";
|
||||
import MistralVertexAI from "./MistralVertexAI";
|
||||
import Mock from "./Mock";
|
||||
import Msty from "./Msty";
|
||||
import Nvidia from "./Nvidia";
|
||||
|
|
@ -45,15 +42,14 @@ import Together from "./Together";
|
|||
import Vllm from "./Vllm";
|
||||
import WatsonX from "./WatsonX";
|
||||
import ContinueProxy from "./stubs/ContinueProxy";
|
||||
import VertexAI from "./VertexAI";
|
||||
import Asksage from "./Asksage";
|
||||
|
||||
const LLMs = [
|
||||
Anthropic,
|
||||
AnthropicVertexAI,
|
||||
Cohere,
|
||||
FreeTrial,
|
||||
Gemini,
|
||||
GeminiVertexAI,
|
||||
Llamafile,
|
||||
Ollama,
|
||||
Replicate,
|
||||
|
|
@ -66,7 +62,6 @@ const LLMs = [
|
|||
OpenAI,
|
||||
LMStudio,
|
||||
Mistral,
|
||||
MistralVertexAI,
|
||||
Bedrock,
|
||||
BedrockImport,
|
||||
SageMaker,
|
||||
|
|
@ -87,6 +82,7 @@ const LLMs = [
|
|||
Mock,
|
||||
Cerebras,
|
||||
Asksage,
|
||||
VertexAI
|
||||
];
|
||||
|
||||
export async function llmFromDescription(
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class FileSystemIde implements IDE {
|
|||
throw new Error("Method not implemented.");
|
||||
}
|
||||
onDidChangeActiveTextEditor(callback: (filepath: string) => void): void {
|
||||
throw new Error("Method not implemented.");
|
||||
return;
|
||||
}
|
||||
|
||||
async getIdeSettings(): Promise<IdeSettings> {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
|
|||
disableInFiles: undefined,
|
||||
useImports: true,
|
||||
useRootPathContext: true,
|
||||
transform: true,
|
||||
};
|
||||
|
||||
export const COUNT_COMPLETION_REJECTED_AFTER = 10_000;
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
---
|
||||
title: Anthropic Vertex AI
|
||||
slug: ../anthropic-vertexai
|
||||
---
|
||||
|
||||
:::info
|
||||
|
||||
You need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).
|
||||
|
||||
:::
|
||||
|
||||
## Chat model
|
||||
|
||||
We recommend configuring **Claude 3.5 Sonnet** as your chat model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "anthropic-vertexai",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-east5"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Autocomplete model
|
||||
|
||||
Anthropic Vertex AI currently does not offer any autocomplete models.
|
||||
|
||||
[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers.
|
||||
|
||||
## Embeddings model
|
||||
|
||||
We recommend configuring **text-embedding-004** as your embeddings model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "vertex",
|
||||
"model": "text-embedding-004",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Reranking model
|
||||
|
||||
Anthropic Vertex AI currently does not offer any reranking models.
|
||||
|
||||
[Click here](../../model-types/reranking.md) to see a list of reranking model providers.
|
||||
|
||||
## Prompt caching
|
||||
|
||||
Anthropic Vertex AI supports [prompt caching with Claude](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching).
|
||||
|
||||
To enable caching of the system message and the turn-by-turn conversation, update your your model configuration as following:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
// Enable prompt caching
|
||||
"cacheBehavior": {
|
||||
"cacheSystemMessage": true,
|
||||
"cacheConversation": true
|
||||
},
|
||||
"title": "Anthropic",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
---
|
||||
title: Gemini Vertex AI
|
||||
slug: ../gemini-vertexai
|
||||
---
|
||||
|
||||
:::info
|
||||
|
||||
You need to enable the [Vertex AI API](https://console.cloud.google.com/marketplace/product/google/aiplatform.googleapis.com) and set up the [Google Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc).
|
||||
|
||||
:::
|
||||
|
||||
## Chat model
|
||||
|
||||
We recommend configuring **Gemini 1.5 Pro** as your chat model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Gemini 1.5 Pro (Vertex AI)",
|
||||
"provider": "gemini-vertexai",
|
||||
"model": "gemini-1.5-pro",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Autocomplete model
|
||||
|
||||
Gemini Vertex AI currently does not offer any autocomplete models.
|
||||
|
||||
[Click here](../../model-types/autocomplete.md) to see a list of autocomplete model providers.
|
||||
|
||||
## Embeddings model
|
||||
|
||||
We recommend configuring **text-embedding-004** as your embeddings model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "vertex",
|
||||
"model": "text-embedding-004",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Reranking model
|
||||
|
||||
Gemini Vertex AI currently does not offer any reranking models.
|
||||
|
||||
[Click here](../../model-types/reranking.md) to see a list of reranking model providers.
|
||||
|
|
@ -63,6 +63,7 @@ OpenAI compatible servers
|
|||
- [llama-cpp-python](https://github.com/abetlen/llama-cpp-python#web-server)
|
||||
- [TensorRT-LLM](https://github.com/NVIDIA/trt-llm-as-openai-windows?tab=readme-ov-file#examples)
|
||||
- [vLLM](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html)
|
||||
- [BerriAI/litellm](https://github.com/BerriAI/litellm)
|
||||
|
||||
OpenAI compatible APIs
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: Mistral Vertex AI
|
||||
slug: ../mistral-vertexai
|
||||
title: Vertex AI
|
||||
slug: ../vertexai
|
||||
---
|
||||
|
||||
:::info
|
||||
|
|
@ -11,38 +11,38 @@ You need to enable the [Vertex AI API](https://console.cloud.google.com/marketpl
|
|||
|
||||
## Chat model
|
||||
|
||||
We recommend configuring **Mistral Large** as your chat model.
|
||||
We recommend configuring **Claude 3.5 Sonnet** as your chat model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Mistral Large (Vertex AI)",
|
||||
"provider": "mistral-vertexai",
|
||||
"model": "mistral-large",
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "vertexai",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
"region": "us-east5"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Autocomplete model
|
||||
|
||||
We recommend configuring **Codestral** as your autocomplete model.
|
||||
We recommend configuring **Codestral** or **code-gecko** as your autocomplete model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Codestral (Vertex AI)",
|
||||
"provider": "mistral-vertexai",
|
||||
"provider": "vertexai",
|
||||
"model": "codestral",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Embeddings model
|
||||
|
||||
We recommend configuring **text-embedding-004** as your embeddings model.
|
||||
|
|
@ -50,7 +50,7 @@ We recommend configuring **text-embedding-004** as your embeddings model.
|
|||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "vertex",
|
||||
"provider": "vertexai",
|
||||
"model": "text-embedding-004",
|
||||
"projectId": "[PROJECT_ID]",
|
||||
"region": "us-central1"
|
||||
|
|
@ -60,6 +60,6 @@ We recommend configuring **text-embedding-004** as your embeddings model.
|
|||
|
||||
## Reranking model
|
||||
|
||||
Mistral Vertex AI currently does not offer any reranking models.
|
||||
Vertex AI currently does not offer any reranking models.
|
||||
|
||||
[Click here](../../model-types/reranking.md) to see a list of reranking model providers.
|
||||
|
|
@ -11,6 +11,6 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco
|
|||
|
||||
## Recommended Autocomplete models
|
||||
|
||||
If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Mistral Vertex AI](../model-providers/more/mistral-vertexai.md#autocomplete-model).
|
||||
If you have the ability to use any model, we recommend `Codestral` with [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) or [Vertex AI](../model-providers/top-level/vertexai.md#autocomplete-model).
|
||||
|
||||
If you want to run a model locally, we recommend `Starcoder2-3B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model).
|
||||
|
|
|
|||
|
|
@ -76,8 +76,4 @@ See [here](../model-providers/top-level/gemini.md#embeddings-model) for instruct
|
|||
|
||||
### Vertex
|
||||
|
||||
See the following for instructions on how to use Vertex for embeddings:
|
||||
|
||||
- [Gemini with Vertex](../model-providers/more/gemini-vertexai.md)
|
||||
- [Anthropic with Vertex](../model-providers/more/anthropic-vertexai.md)
|
||||
- [Mistral with Vertex](../model-providers/more/mistral-vertexai.md)
|
||||
See [here](../model-providers/top-level/vertexai.md#embeddings-model) for instructions on how to use Vertex for embeddings.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run Continue" type="CompoundRunConfigurationType">
|
||||
<toRun name="Run Extension" type="GradleRunConfiguration" />
|
||||
<toRun name="Start Core Dev Server" type="NodeJSConfigurationType" />
|
||||
<toRun name="Prompt Logs" type="ShConfigurationType" />
|
||||
<toRun name="Start Core Dev Server" type="Unknown" />
|
||||
<toRun name="Start GUI Dev Server" type="ShConfigurationType" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=0.0.78
|
||||
pluginVersion=0.0.79
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.auth
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.credentialStore.Credentials
|
||||
|
|
@ -37,7 +38,10 @@ class ContinueAuthService {
|
|||
}
|
||||
|
||||
init {
|
||||
setupRefreshTokenInterval()
|
||||
val settings = service<ContinueExtensionSettings>()
|
||||
if (settings.continueState.enableContinueTeamsBeta) {
|
||||
setupRefreshTokenInterval()
|
||||
}
|
||||
}
|
||||
|
||||
fun startAuthFlow(project: Project) {
|
||||
|
|
|
|||
|
|
@ -582,7 +582,9 @@ class IdeProtocolClient(
|
|||
val folders = mutableListOf<String>()
|
||||
fun findNestedFolders(dirPath: String) {
|
||||
val dir = File(dirPath)
|
||||
val nestedFolders = dir.listFiles { file -> file.isDirectory }?.map { file -> file.absolutePath } ?: emptyList()
|
||||
val nestedFolders =
|
||||
dir.listFiles { file -> file.isDirectory }?.map { file -> file.absolutePath }
|
||||
?: emptyList()
|
||||
folders.addAll(nestedFolders);
|
||||
nestedFolders.forEach { folder -> findNestedFolders(folder) }
|
||||
}
|
||||
|
|
@ -635,6 +637,22 @@ class IdeProtocolClient(
|
|||
val text = msg["text"] as String
|
||||
val curSelectedModelTitle = msg["curSelectedModelTitle"] as String
|
||||
|
||||
val editor = FileEditorManager.getInstance(project).selectedTextEditor
|
||||
|
||||
if (editor == null) {
|
||||
showToast("error", "No active editor to apply edits to")
|
||||
respond(null)
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (editor.document.text.trim().isEmpty()) {
|
||||
WriteCommandAction.runWriteCommandAction(project) {
|
||||
editor.document.insertString(0, text)
|
||||
}
|
||||
respond(null)
|
||||
return@launch
|
||||
}
|
||||
|
||||
val config = readConfigJson()
|
||||
var llm = getModelByRole(config, "applyCodeBlock")
|
||||
|
||||
|
|
@ -654,14 +672,6 @@ class IdeProtocolClient(
|
|||
val prompt =
|
||||
"The following code was suggested as an edit:\n```\n${text}\n```\nPlease apply it to the previous code."
|
||||
|
||||
val editor = FileEditorManager.getInstance(project).selectedTextEditor
|
||||
|
||||
if (editor == null) {
|
||||
showToast("error", "No active editor to apply edits to")
|
||||
respond(null)
|
||||
return@launch
|
||||
}
|
||||
|
||||
val rif = getHighlightedCode()
|
||||
|
||||
val (prefix, highlighted, suffix) = if (rif == null) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ fun makeTextArea(): JTextArea {
|
|||
isOpaque = false
|
||||
background = GetTheme().getSecondaryDark()
|
||||
maximumSize = Dimension(400, Short.MAX_VALUE.toInt())
|
||||
margin = JBUI.insets(6, 4, 6, 4)
|
||||
margin = JBUI.insets(6, 8, 6, 4)
|
||||
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE)
|
||||
preferredSize = Dimension(400, 75)
|
||||
}
|
||||
|
|
@ -398,13 +398,32 @@ class CustomPanel(
|
|||
isEditable = true
|
||||
background = defaultBackground
|
||||
foreground = Color(128, 128, 128, 200)
|
||||
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 11)
|
||||
border = EmptyBorder(2, 4, 2, 4)
|
||||
font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, 12)
|
||||
border = EmptyBorder(8, 8, 8, 8)
|
||||
isOpaque = false
|
||||
isEditable = false
|
||||
cursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)
|
||||
renderer =
|
||||
DefaultListCellRenderer().apply { horizontalAlignment = SwingConstants.LEFT }
|
||||
preferredSize = Dimension(200, 30)
|
||||
|
||||
renderer = object : DefaultListCellRenderer() {
|
||||
override fun getListCellRendererComponent(
|
||||
list: JList<*>?,
|
||||
value: Any?,
|
||||
index: Int,
|
||||
isSelected: Boolean,
|
||||
cellHasFocus: Boolean
|
||||
): Component {
|
||||
val component =
|
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus)
|
||||
if (component is JLabel) {
|
||||
component.border = EmptyBorder(4, 6, 4, 6)
|
||||
}
|
||||
return component
|
||||
}
|
||||
}.apply {
|
||||
horizontalAlignment = SwingConstants.LEFT
|
||||
}
|
||||
|
||||
selectedIndex =
|
||||
continueSettingsService.continueState.lastSelectedInlineEditModel?.let {
|
||||
if (modelTitles.isEmpty()) -1
|
||||
|
|
@ -430,19 +449,16 @@ class CustomPanel(
|
|||
border = EmptyBorder(2, 6, 2, 6)
|
||||
}
|
||||
|
||||
val rightPanel =
|
||||
JPanel(MigLayout("insets 0, fillx")).apply {
|
||||
isOpaque = false
|
||||
border = EmptyBorder(0, 0, 0, 0)
|
||||
add(dropdown, "align right")
|
||||
add(rightButton, "align right")
|
||||
}
|
||||
val rightPanel = JPanel(MigLayout("insets 0, fillx")).apply {
|
||||
isOpaque = false
|
||||
add(rightButton, "align right")
|
||||
}
|
||||
|
||||
border = EmptyBorder(0, 0, 16, 12)
|
||||
isOpaque = false
|
||||
|
||||
add(dropdown, "align left")
|
||||
add(rightPanel, "align right, split 2")
|
||||
isOpaque = false
|
||||
add(rightPanel, "align right")
|
||||
|
||||
cursor = Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)
|
||||
}
|
||||
|
|
@ -620,18 +636,7 @@ class CustomButton(text: String, onClick: () -> Unit) : JLabel(text, CENTER) {
|
|||
cornerRadius.toFloat(),
|
||||
cornerRadius.toFloat()
|
||||
)
|
||||
if (isHovered) {
|
||||
val brightenFactor = 1.1f
|
||||
val brighterColor =
|
||||
Color(
|
||||
(background.red * brightenFactor).coerceIn(0f, 255f).toInt(),
|
||||
(background.green * brightenFactor).coerceIn(0f, 255f).toInt(),
|
||||
(background.blue * brightenFactor).coerceIn(0f, 255f).toInt()
|
||||
)
|
||||
g2.color = brighterColor
|
||||
} else {
|
||||
g2.color = background
|
||||
}
|
||||
g2.color = background
|
||||
g2.fill(roundRect)
|
||||
g2.color = foreground
|
||||
g2.drawString(
|
||||
|
|
@ -653,7 +658,7 @@ class CustomTextArea(rows: Int, columns: Int) : JXTextArea("") {
|
|||
if (text.isEmpty()) {
|
||||
g.color = Color(128, 128, 128, 255)
|
||||
g.font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE)
|
||||
g.drawString("Enter instructions...", 3, 20)
|
||||
g.drawString("Enter instructions...", 8, 20)
|
||||
}
|
||||
|
||||
super.paintComponent(g)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class VerticalDiffBlock(
|
|||
)
|
||||
|
||||
acceptButton.setBounds(
|
||||
x + rejectButton.width + 5,
|
||||
x + rejectButton.width + 2,
|
||||
y,
|
||||
acceptButton.preferredSize.width,
|
||||
acceptButton.preferredSize.height
|
||||
|
|
@ -134,7 +134,7 @@ class VerticalDiffBlock(
|
|||
|
||||
private fun createButtons(): Pair<JButton, JButton> {
|
||||
val rejectBtn =
|
||||
createButton("${getAltKeyLabel()}⇧N", JBColor(0x99FF0000.toInt(), 0x99FF0000.toInt())).apply {
|
||||
createButton("${getAltKeyLabel()}↑N", JBColor(0x99FF0000.toInt(), 0x99FF0000.toInt())).apply {
|
||||
addActionListener {
|
||||
handleReject();
|
||||
onAcceptReject(this@VerticalDiffBlock, false)
|
||||
|
|
@ -143,7 +143,7 @@ class VerticalDiffBlock(
|
|||
}
|
||||
|
||||
val acceptBtn =
|
||||
createButton("${getAltKeyLabel()}⇧Y", JBColor(0x9900FF00.toInt(), 0x9900FF00.toInt())).apply {
|
||||
createButton("${getAltKeyLabel()}↑Y", JBColor(0x9900FF00.toInt(), 0x9900FF00.toInt())).apply {
|
||||
addActionListener {
|
||||
handleAccept();
|
||||
onAcceptReject(this@VerticalDiffBlock, true)
|
||||
|
|
@ -215,18 +215,17 @@ class VerticalDiffBlock(
|
|||
val g2 = g.create() as Graphics2D
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
g2.color = backgroundColor
|
||||
g2.fillRoundRect(0, 0, width - 1, height - 1, 8, 8)
|
||||
g2.fillRoundRect(0, 0, width - 1, height - 1, 4, 4)
|
||||
super.paintComponent(g2)
|
||||
g2.dispose()
|
||||
}
|
||||
}.apply {
|
||||
// This isn't working currently, font color is transparent
|
||||
foreground = JBColor.WHITE
|
||||
foreground = Color(240, 240, 240)
|
||||
font = Font("Arial", Font.BOLD, 9)
|
||||
isContentAreaFilled = false
|
||||
isOpaque = false
|
||||
border = null
|
||||
preferredSize = Dimension(preferredSize.width, 16)
|
||||
border = BorderFactory.createEmptyBorder(4, 2, 4, 2)
|
||||
preferredSize = Dimension(preferredSize.width - 30, 14)
|
||||
cursor = Cursor(Cursor.HAND_CURSOR)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.cef.CefApp
|
|||
import org.cef.browser.CefBrowser
|
||||
import org.cef.handler.CefLoadHandlerAdapter
|
||||
import com.intellij.openapi.application.ApplicationInfo
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
|
||||
class ContinueBrowser(val project: Project, url: String) {
|
||||
private val coroutineScope = CoroutineScope(
|
||||
|
|
@ -292,6 +293,12 @@ class ContinueBrowser(val project: Project, url: String) {
|
|||
* it's a simple integer without dot notation, making it easier to compare.
|
||||
*/
|
||||
private fun shouldRenderOffScreen(): Boolean {
|
||||
// With the 0.0.77 release, non-Mac users have been reporting issues with paste functionality
|
||||
// in the browser. Disabling OSR for all non-Mac users for now.
|
||||
if (!SystemInfo.isMac) {
|
||||
return false
|
||||
}
|
||||
|
||||
val minBuildNumber = 233
|
||||
val applicationInfo = ApplicationInfo.getInstance()
|
||||
val currentBuildNumber = applicationInfo.build.baselineVersion
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
19
extensions/intellij/src/main/resources/webview/index.html
Normal file
19
extensions/intellij/src/main/resources/webview/index.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
@@ -1,18 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/play_button.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Continue</title>
|
||||
<script type="module" crossorigin src="/assets/index.js"></script>
|
||||
<link rel="stylesheet" href="/assets/index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
<script>
|
||||
localStorage.setItem("ide", '"jetbrains"');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -172,7 +172,6 @@
|
|||
"openai",
|
||||
"free-trial",
|
||||
"anthropic",
|
||||
"anthropic-vertexai",
|
||||
"cohere",
|
||||
"bedrock",
|
||||
"bedrockimport",
|
||||
|
|
@ -184,11 +183,9 @@
|
|||
"llama.cpp",
|
||||
"replicate",
|
||||
"gemini",
|
||||
"gemini-vertexai",
|
||||
"lmstudio",
|
||||
"llamafile",
|
||||
"mistral",
|
||||
"mistral-vertexai",
|
||||
"deepinfra",
|
||||
"groq",
|
||||
"fireworks",
|
||||
|
|
@ -202,6 +199,7 @@
|
|||
"nvidia",
|
||||
"vllm",
|
||||
"cerebras",
|
||||
"vertexai",
|
||||
"askSage"
|
||||
],
|
||||
"markdownEnumDescriptions": [
|
||||
|
|
@ -849,53 +847,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": [
|
||||
"anthropic-vertexai"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"provider"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"cacheBehavior": {
|
||||
"title": "Caching Behavior",
|
||||
"description": "Options for the prompt caching",
|
||||
"properties": {
|
||||
"cacheSystemMessage": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"cacheConversation": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"model": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"claude-3-5-opus",
|
||||
"claude-3-5-sonnet",
|
||||
"claude-3-5-haiku",
|
||||
"claude-3-opus",
|
||||
"claude-3-sonnet",
|
||||
"claude-3-haiku"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
|
|
@ -1010,44 +961,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"provider": {
|
||||
"enum": [
|
||||
"gemini-vertexai"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"provider"
|
||||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"gemini-pro",
|
||||
"gemini-1.5-pro-latest",
|
||||
"gemini-1.5-pro",
|
||||
"gemini-1.5-flash-latest",
|
||||
"gemini-1.5-flash"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"projectId",
|
||||
"region"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
|
|
@ -1268,7 +1181,7 @@
|
|||
"properties": {
|
||||
"provider": {
|
||||
"enum": [
|
||||
"mistral-vertexai"
|
||||
"vertexai"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
@ -1277,22 +1190,6 @@
|
|||
]
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"model": {
|
||||
"anyOf": [
|
||||
{
|
||||
"enum": [
|
||||
"codestral",
|
||||
"mistral-nemo",
|
||||
"mistral-large"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"projectId",
|
||||
"region"
|
||||
|
|
@ -2784,7 +2681,7 @@
|
|||
"nvidia",
|
||||
"bedrock",
|
||||
"sagemaker",
|
||||
"vertex"
|
||||
"vertexai"
|
||||
]
|
||||
},
|
||||
"model": {
|
||||
|
|
@ -2881,7 +2778,7 @@
|
|||
"properties": {
|
||||
"provider": {
|
||||
"enum": [
|
||||
"vertex"
|
||||
"vertexai"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
@ -3152,6 +3049,10 @@
|
|||
"type": "number",
|
||||
"description": "The percentage of the input that should be dedicated to the prefix."
|
||||
},
|
||||
"transform": {
|
||||
"type": "boolean",
|
||||
"description": "Whether LLM output should be transformed to correct common model pitfalls."
|
||||
},
|
||||
"template": {
|
||||
"type": "string",
|
||||
"description": "An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables."
|
||||
|
|
|
|||
|
|
@ -158,6 +158,16 @@ export class VsCodeMessenger {
|
|||
return;
|
||||
}
|
||||
|
||||
// If document is empty, insert at 0,0 and finish
|
||||
if (!editor.document.getText().trim()) {
|
||||
editor.edit(builder => builder.insert(new vscode.Position(0, 0), data.text));
|
||||
await webviewProtocol.request("updateApplyState", {
|
||||
streamId: data.streamId,
|
||||
status: "done",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Get LLM from config
|
||||
const configHandler = await configHandlerPromise;
|
||||
const config = await configHandler.loadConfig();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
"exclude": [
|
||||
"../../core/dist/**/*",
|
||||
"../../core/**/*.test.ts",
|
||||
"../../core/**/test/**/*",
|
||||
"../../core/**/*.skip.ts"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
BIN
gui/public/logos/vertexai.png
Normal file
BIN
gui/public/logos/vertexai.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
|
|
@ -908,6 +908,47 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
providerOptions: ["watsonx"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
VertexGemini15Pro: {
|
||||
title: "Gemini 1.5 Pro",
|
||||
description: "A newer Gemini model with 1M token context length",
|
||||
params: {
|
||||
title: "Gemini 1.5 Pro",
|
||||
model: "gemini-1.5-pro-002",
|
||||
contextLength: 2_097_152,
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["vertexai"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
VertexGemini15Flash: {
|
||||
title: "Gemini 1.5 Flash",
|
||||
description:
|
||||
"Fast and versatile multimodal model for scaling across diverse tasks",
|
||||
params: {
|
||||
title: "Gemini 1.5 Flash",
|
||||
model: "gemini-1.5-flash-002",
|
||||
contextLength: 1_048_576,
|
||||
},
|
||||
icon: "gemini.png",
|
||||
providerOptions: ["vertexai"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
vertexMistralLarge: {
|
||||
title: "Mistral Large",
|
||||
description:
|
||||
"Mistral's flagship model that's ideal for complex tasks that require large reasoning capabilities or are highly specialized (Synthetic Text Generation, Code Generation, RAG, or Agents).",
|
||||
params: {
|
||||
title: "Mistral Large",
|
||||
model: "mistral-large",
|
||||
contextLength: 32000,
|
||||
},
|
||||
icon: "mistral.png",
|
||||
providerOptions: ["vertexai"],
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
||||
|
||||
|
||||
gpt4gov: {
|
||||
title: "GPT-4 gov",
|
||||
description:
|
||||
|
|
@ -919,7 +960,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.", // Need to set this on the Ask Sage side or just configure it in here to be discussed
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
@ -934,7 +975,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.", // Need to set this on the Ask Sage side or just configure it in here to be discussed
|
||||
},
|
||||
providerOptions: ["askSage"],
|
||||
providerOptions: ["askSage"],
|
||||
icon: "openai.png",
|
||||
isOpenSource: false,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
...completionParamsInputsConfigs,
|
||||
],
|
||||
packages: [models.commandR, models.commandRPlus],
|
||||
apiKeyUrl: "https://docs.cohere.com/v2/docs/rate-limits",
|
||||
},
|
||||
groq: {
|
||||
title: "Groq",
|
||||
|
|
@ -328,6 +329,7 @@ Select the \`GPT-4o\` model below to complete your provider configuration, but n
|
|||
p.params.contextLength = 4096;
|
||||
return p;
|
||||
}),
|
||||
apiKeyUrl: "https://api.together.xyz/settings/api-keys",
|
||||
},
|
||||
gemini: {
|
||||
title: "Google Gemini API",
|
||||
|
|
@ -622,6 +624,39 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo
|
|||
],
|
||||
apiKeyUrl: "https://cloud.cerebras.ai/",
|
||||
},
|
||||
vertexai: {
|
||||
title: "VertexAI",
|
||||
provider: "vertexai",
|
||||
description: "Use supported Vertex AI models",
|
||||
longDescription:
|
||||
"Use the supported Vertex AI models - see [here](https://cloud.google.com/docs/authentication/provide-credentials-adc) to authenticate",
|
||||
icon: "vertexai.png",
|
||||
packages: [
|
||||
models.VertexGemini15Pro,
|
||||
models.VertexGemini15Flash,
|
||||
models.mistralLarge
|
||||
|
||||
],
|
||||
collectInputFor: [
|
||||
{
|
||||
inputType: "project",
|
||||
key: "projectId",
|
||||
label: "Project Id",
|
||||
placeholder: "Enter your Vertex AI project Id",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
inputType: "region",
|
||||
key: "region",
|
||||
label: "Region",
|
||||
placeholder: "Enter your Vertex AI region",
|
||||
required: true,
|
||||
},
|
||||
|
||||
...completionParamsInputsConfigs,
|
||||
],
|
||||
},
|
||||
|
||||
askSage: {
|
||||
title: "Ask Sage",
|
||||
provider: "askSage",
|
||||
|
|
|
|||
|
|
@ -26,14 +26,15 @@ function MorePage() {
|
|||
return (
|
||||
<div className="overflow-y-scroll">
|
||||
<div
|
||||
onClick={() => navigate("/")}
|
||||
className="sticky top-0 m-0 flex cursor-pointer items-center border-0 border-b border-solid border-b-zinc-700 bg-inherit p-0"
|
||||
className="sticky top-0 m-0 flex items-center border-0 border-b border-solid border-b-zinc-700 bg-inherit p-0"
|
||||
style={{
|
||||
backgroundColor: vscBackground,
|
||||
}}
|
||||
>
|
||||
<ArrowLeftIcon className="ml-3 inline-block h-3 w-3 cursor-pointer" />
|
||||
<span className="m-2 inline-block text-base font-bold">Chat</span>
|
||||
<div className="cursor-pointer hover:text-zinc-100 transition-colors duration-200" onClick={() => navigate("/")}>
|
||||
<ArrowLeftIcon className="ml-3 inline-block h-3 w-3" />
|
||||
<span className="m-2 inline-block text-base font-bold">Chat</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="gap-2 divide-x-0 divide-y-2 divide-solid divide-zinc-700 px-4">
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ import { History } from "../../components/History";
|
|||
|
||||
export default function GUI() {
|
||||
return (
|
||||
<div className="flex overflow-scroll">
|
||||
<aside className="4xl:block border-vsc-input-border hidden w-96 overflow-y-auto border-0 border-r border-solid">
|
||||
<div className="flex overflow-hidden">
|
||||
<aside className="4xl:block border-vsc-input-border scrollbar-hide hidden w-96 overflow-y-auto border-0 border-r border-solid">
|
||||
<History />
|
||||
</aside>
|
||||
|
||||
<main className="flex flex-1 flex-col overflow-y-auto">
|
||||
<main className="scrollbar-hide flex flex-1 flex-col overflow-y-auto">
|
||||
<Chat />
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@ export const HistoryHeader = () => {
|
|||
borderBottom: `0.5px solid ${lightGray}`,
|
||||
}}
|
||||
>
|
||||
<ArrowLeftIcon
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
onClick={() => navigate("/")}
|
||||
className="ml-4 inline-block cursor-pointer"
|
||||
/>
|
||||
<span className="m-2 inline-block text-base font-bold">Chat</span>
|
||||
<div className="flex items-center cursor-pointer hover:text-zinc-100 transition-colors duration-200" onClick={() => navigate("/")}>
|
||||
<ArrowLeftIcon
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
className="ml-4 inline-block"
|
||||
/>
|
||||
<span className="m-2 inline-block text-base font-bold">Chat</span>
|
||||
</div>
|
||||
</div>
|
||||
{/* {workspacePaths && workspacePaths.length > 0 && (
|
||||
<CheckDiv
|
||||
|
|
|
|||
18
manual-testing-sandbox/Dockerfile
Normal file
18
manual-testing-sandbox/Dockerfile
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Use a base image
|
||||
FROM python:3.9-slim
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy requirements file and install dependencies
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Set environment variables
|
||||
ENV PORT=8080
|
||||
|
||||
# Start the application
|
||||
CMD ["python", "app.py"]
|
||||
14
manual-testing-sandbox/config.yaml
Normal file
14
manual-testing-sandbox/config.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
AWSTemplateFormatVersion: "2010-09-09"
|
||||
Description: Sample CloudFormation template
|
||||
|
||||
Resources:
|
||||
S3Bucket:
|
||||
Type: "AWS::S3::Bucket"
|
||||
Properties:
|
||||
BucketName: my-sample-bucket
|
||||
|
||||
EC2Instance:
|
||||
Type: "AWS::EC2::Instance"
|
||||
Properties:
|
||||
InstanceType: "t2.micro"
|
||||
ImageId: "ami-0abcdef12345abcdef"
|
||||
8
manual-testing-sandbox/data.json
Normal file
8
manual-testing-sandbox/data.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"employees": [
|
||||
{ "name": "John Doe", "age": 30, "position": "Developer" },
|
||||
{ "name": "Jane Smith", "age": 25, "position": "Designer" },
|
||||
{ "name": "Emily Johnson", "age": 35, "position": "Manager" }
|
||||
],
|
||||
"active": true
|
||||
}
|
||||
34
manual-testing-sandbox/program.cs
Normal file
34
manual-testing-sandbox/program.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
Calculator calc = new Calculator();
|
||||
calc.Add(5).Subtract(3);
|
||||
Console.WriteLine("Result: " + calc.GetResult());
|
||||
}
|
||||
|
||||
public class Calculator
|
||||
{
|
||||
private double result;
|
||||
|
||||
public Calculator Add(double number)
|
||||
{
|
||||
result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Calculator Subtract(double number)
|
||||
{
|
||||
result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double GetResult()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
manual-testing-sandbox/query.sql
Normal file
9
manual-testing-sandbox/query.sql
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE employees (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
age INT NOT NULL,
|
||||
position VARCHAR(100)
|
||||
);
|
||||
|
||||
INSERT INTO employees (name, age, position) VALUES ('John Doe', 30, 'Developer');
|
||||
SELECT * FROM employees WHERE age > 25;
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
The sole purpose of this folder is to open it when debugging the extension.
|
||||
The sole purpose of this folder is to open it when debugging the extension.
|
||||
It is not used by the extension itself.
|
||||
You can add more files that can be useful when manually testing the extension.
|
||||
You can add more files that can be useful when manually testing the extension.
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ a {
|
|||
|
||||
.button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
25
manual-testing-sandbox/test.html
Normal file
25
manual-testing-sandbox/test.html
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Sample Page</title>
|
||||
<link rel="stylesheet" href="test.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h1>Welcome to the Sample Page</h1>
|
||||
<nav>
|
||||
<a href="#home">Home</a>
|
||||
<a href="#about">About</a>
|
||||
<a href="#contact">Contact</a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<p>This is a sample paragraph.</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
28
manual-testing-sandbox/test.java
Normal file
28
manual-testing-sandbox/test.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
public class Calculator {
|
||||
private double result;
|
||||
|
||||
public Calculator add(double number) {
|
||||
result += number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Calculator subtract(double number) {
|
||||
result -= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Calculator reset() {
|
||||
result = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Calculator calc = new Calculator();
|
||||
calc.add(10).subtract(5);
|
||||
System.out.println("Result: " + calc.getResult());
|
||||
}
|
||||
}
|
||||
44
manual-testing-sandbox/test.php
Normal file
44
manual-testing-sandbox/test.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
class Calculator {
|
||||
private $result = 0.0;
|
||||
|
||||
public function add($number) {
|
||||
$this->result += $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function subtract($number) {
|
||||
$this->result -= $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function multiply($number) {
|
||||
$this->result *= $number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function divide($number) {
|
||||
if ($number != 0) {
|
||||
$this->result /= $number;
|
||||
} else {
|
||||
echo "Division by zero error.";
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getResult() {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function reset() {
|
||||
$this->result = 0.0;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
$calc = new Calculator();
|
||||
$calc->add(10)->subtract(5);
|
||||
echo "Result: " . $calc->getResult() . "\n";
|
||||
|
||||
?>
|
||||
18
manual-testing-sandbox/test.py
Normal file
18
manual-testing-sandbox/test.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
class Calculator:
|
||||
def __init__(self):
|
||||
self.result = 0
|
||||
|
||||
def add(self, number):
|
||||
self.result += number
|
||||
return self
|
||||
|
||||
def subtract(self, number):
|
||||
self.result -= number
|
||||
return self
|
||||
|
||||
def reset(self):
|
||||
self.result = 0
|
||||
return self
|
||||
|
||||
def get_result(self):
|
||||
return self.result
|
||||
30
manual-testing-sandbox/test.rb
Normal file
30
manual-testing-sandbox/test.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
class Calculator
|
||||
attr_accessor :result
|
||||
|
||||
def initialize
|
||||
@result = 0
|
||||
end
|
||||
|
||||
def add(number)
|
||||
@result += number
|
||||
self
|
||||
end
|
||||
|
||||
def subtract(number)
|
||||
@result -= number
|
||||
self
|
||||
end
|
||||
|
||||
def get_result
|
||||
@result
|
||||
end
|
||||
|
||||
def reset
|
||||
@result = 0
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
calc = Calculator.new
|
||||
calc.add(5).subtract(3)
|
||||
puts "Result: #{calc.get_result}"
|
||||
21
manual-testing-sandbox/test.sh
Normal file
21
manual-testing-sandbox/test.sh
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
function calculate {
|
||||
local a=$1
|
||||
local b=$2
|
||||
local op=$3
|
||||
local result
|
||||
|
||||
case $op in
|
||||
"+") result=$((a + b)) ;;
|
||||
"-") result=$((a - b)) ;;
|
||||
"*") result=$((a * b)) ;;
|
||||
"/") result=$((a / b)) ;;
|
||||
*) echo "Invalid operator"; exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "Result: $result"
|
||||
}
|
||||
|
||||
calculate 10 5 "+"
|
||||
calculate 10 3 "-"
|
||||
|
|
@ -133,6 +133,7 @@ export const tabAutocompleteOptionsSchema = z.object({
|
|||
debounceDelay: z.number(),
|
||||
maxSuffixPercentage: z.number(),
|
||||
prefixPercentage: z.number(),
|
||||
transform: z.boolean().optional(),
|
||||
template: z.string().optional(),
|
||||
multilineCompletions: z.enum(["always", "never", "auto"]),
|
||||
slidingWindowPrefixPercentage: z.number(),
|
||||
|
|
|
|||
38
packages/llm-info/src/providers/vertexai.ts
Normal file
38
packages/llm-info/src/providers/vertexai.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { AllMediaTypes, ModelProvider } from "../types.js";
|
||||
|
||||
export const Gemini: ModelProvider = {
|
||||
models: [
|
||||
{
|
||||
model: "gemini-1.5-flash",
|
||||
displayName: "Gemini 1.5 Flash",
|
||||
contextLength: 1048576,
|
||||
maxCompletionTokens: 8192,
|
||||
mediaTypes: AllMediaTypes,
|
||||
regex: /gemini-1\.5-flash/i,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
{
|
||||
model: "gemini-1.5-pro",
|
||||
displayName: "Gemini 1.5 Pro",
|
||||
contextLength: 2097152,
|
||||
maxCompletionTokens: 8192,
|
||||
regex: /gemini-1\.5-pro/i,
|
||||
recommendedFor: ["chat"],
|
||||
},
|
||||
// embed
|
||||
{
|
||||
model: "text-embedding-004",
|
||||
displayName: "Vertex Text Embedding",
|
||||
recommendedFor: ["embed"],
|
||||
},
|
||||
//autocomplete
|
||||
{
|
||||
model: "code-gecko",
|
||||
displayName: "VertexAI Code Gecko",
|
||||
recommendedFor: ["autocomplete"],
|
||||
maxCompletionTokens: 64,
|
||||
}
|
||||
],
|
||||
id: "gemini",
|
||||
displayName: "Gemini",
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue