Merge branch 'main' into nate/sys-prompt-file
This commit is contained in:
commit
689f3f0cfd
138 changed files with 5756 additions and 394 deletions
|
|
@ -261,13 +261,10 @@ export class CompletionProvider {
|
|||
|
||||
//////////
|
||||
|
||||
// Do some stuff later so as not to block return. Latency matters
|
||||
const completionToCache = outcome.completion;
|
||||
setTimeout(async () => {
|
||||
if (!outcome.cacheHit) {
|
||||
(await this.autocompleteCache).put(outcome.prefix, completionToCache);
|
||||
}
|
||||
}, 100);
|
||||
// Save to cache
|
||||
if (!outcome.cacheHit) {
|
||||
(await this.autocompleteCache).put(outcome.prefix, outcome.completion);
|
||||
}
|
||||
|
||||
// When using the JetBrains extension, Mark as displayed
|
||||
const ideType = (await this.ide.getIdeInfo()).ideType;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Continue now provides support for tab autocomplete in [VS Code](https://marketpl
|
|||
We recommend setting up tab-autocomplete with a local Ollama instance. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model:
|
||||
|
||||
```bash
|
||||
ollama run starcoder:3b
|
||||
ollama run qwen2.5-coder:1.5b
|
||||
```
|
||||
|
||||
Once it has been downloaded, you should begin to see completions in VS Code.
|
||||
|
|
@ -17,9 +17,9 @@ Once it has been downloaded, you should begin to see completions in VS Code.
|
|||
You can also set up tab-autocomplete with a local LM Studio instance by following these steps:
|
||||
|
||||
1. Download the latest version of LM Studio from [here](https://lmstudio.ai/)
|
||||
2. Download a model (e.g. search for `second-state/StarCoder2-3B-GGUF` and choose one of the options there)
|
||||
2. Download a model (e.g. search for `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF` and choose one of the options there)
|
||||
3. Go to the server section (button is on the left), select your model from the dropdown at the top, and click "Start Server"
|
||||
4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf`); this will be used as the "model" attribute in Continue
|
||||
4. Go to the "My Models" section (button is on the left), find your selected model, and copy the name the path (example: `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/qwen2.5-coder-1.5b-instruct-q4_k_m.gguf`); this will be used as the "model" attribute in Continue
|
||||
5. Go to Continue and modify the configurations for a [custom model](#setting-up-a-custom-model)
|
||||
6. Set the "provider" to `lmstudio` and the "model" to the path copied earlier
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ Example:
|
|||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Starcoder2 3b",
|
||||
"model": "second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf",
|
||||
"title": "Qwen2.5-Coder 1.5b",
|
||||
"model": "Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF",
|
||||
"provider": "lmstudio",
|
||||
},
|
||||
...
|
||||
|
|
@ -69,11 +69,9 @@ If you aren't yet familiar with the available options, you can learn more in our
|
|||
|
||||
### What model should I use?
|
||||
|
||||
If you are running the model locally, we recommend `starcoder:3b`.
|
||||
If you are running the model locally, we recommend `qwen2.5-coder:1.5b`.
|
||||
|
||||
If you find it to be too slow, you should try `deepseek-coder:1.3b-base`.
|
||||
|
||||
If you have a bit more compute, or are running a model in the cloud, you can upgrade to `deepseek-coder:6.7b-base`.
|
||||
If you have a bit more compute, or are running a model in the cloud, you can upgrade to `qwen2.5-coder:7b`.
|
||||
|
||||
Regardless of what you are willing to spend, we do not recommend using GPT or Claude for autocomplete. Learn why [below](#i-want-better-completions-should-i-use-gpt-4).
|
||||
|
||||
|
|
@ -83,7 +81,7 @@ The following can be configured in `config.json`:
|
|||
|
||||
### `tabAutocompleteModel`
|
||||
|
||||
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `starcoder-1b`, or `starcoder-3b`.
|
||||
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `qwen2.5-coder:1.5b`, or `starcoder-3b`.
|
||||
|
||||
### `tabAutocompleteOptions`
|
||||
|
||||
|
|
@ -105,7 +103,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa
|
|||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder:3b",
|
||||
"model": "qwen2.5-coder:1.5b",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
"tabAutocompleteOptions": {
|
||||
|
|
@ -128,7 +126,7 @@ Follow these steps to ensure that everything is set up correctly:
|
|||
|
||||
1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar).
|
||||
2. Make sure you have downloaded Ollama.
|
||||
3. Run `ollama run starcoder:3b` to verify that the model is downloaded.
|
||||
3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded.
|
||||
4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere.
|
||||
5. Make sure that you aren't also using another Ollama model for chat. This will cause Ollama to constantly load and unload the models from memory, resulting in slow responses (or none at all) for both.
|
||||
6. Check the output of the logs to find any potential errors (cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains).
|
||||
|
|
|
|||
|
|
@ -9,6 +9,21 @@ import { AstPath } from "../../util/ast";
|
|||
import { ImportDefinitionsService } from "../ImportDefinitionsService";
|
||||
import { AutocompleteSnippet } from "../ranking";
|
||||
|
||||
function getSyntaxTreeString(
|
||||
node: Parser.SyntaxNode,
|
||||
indent: string = "",
|
||||
): string {
|
||||
let result = "";
|
||||
const nodeInfo = `${node.type} [${node.startPosition.row}:${node.startPosition.column} - ${node.endPosition.row}:${node.endPosition.column}]`;
|
||||
result += `${indent}${nodeInfo}\n`;
|
||||
|
||||
for (const child of node.children) {
|
||||
result += getSyntaxTreeString(child, indent + " ");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export class RootPathContextService {
|
||||
private cache = new LRUCache<string, AutocompleteSnippet[]>({
|
||||
max: 100,
|
||||
|
|
@ -26,8 +41,11 @@ export class RootPathContextService {
|
|||
private static TYPES_TO_USE = new Set([
|
||||
"program",
|
||||
"function_declaration",
|
||||
"function_definition",
|
||||
"method_definition",
|
||||
"method_declaration",
|
||||
"class_declaration",
|
||||
"class_definition",
|
||||
]);
|
||||
|
||||
/**
|
||||
|
|
@ -56,12 +74,17 @@ export class RootPathContextService {
|
|||
this.importDefinitionsService.get(filepath);
|
||||
break;
|
||||
default:
|
||||
// const type = node.type;
|
||||
// debugger;
|
||||
// console.log(getSyntaxTreeString(node));
|
||||
|
||||
query = await getQueryForFile(
|
||||
filepath,
|
||||
`root-path-context-queries/${node.type}`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
const type = node.type;
|
||||
|
||||
if (!query) {
|
||||
return snippets;
|
||||
|
|
@ -97,6 +120,7 @@ export class RootPathContextService {
|
|||
contents: await this.ide.readRangeInFile(def.filepath, def.range),
|
||||
})),
|
||||
);
|
||||
|
||||
return newSnippets;
|
||||
}
|
||||
|
||||
|
|
@ -112,6 +136,8 @@ export class RootPathContextService {
|
|||
RootPathContextService.TYPES_TO_USE.has(node.type),
|
||||
)) {
|
||||
const key = RootPathContextService.keyFromNode(parentKey, astNode);
|
||||
// const type = astNode.type;
|
||||
// debugger;
|
||||
|
||||
const foundInCache = this.cache.get(key);
|
||||
const newSnippets =
|
||||
|
|
|
|||
|
|
@ -2,25 +2,21 @@ import { testRootPathContext } from "./testUtils";
|
|||
|
||||
const TEST_CASES = [
|
||||
{
|
||||
description: "function",
|
||||
nodeType: "function_declaration",
|
||||
fileName: "file1.ts",
|
||||
range: {
|
||||
start: { line: 10, character: 2 },
|
||||
end: { line: 10, character: 24 },
|
||||
},
|
||||
positions: [
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 10, character: 24 },
|
||||
definitionPositions: [
|
||||
{ row: 9, column: 34 }, // Person
|
||||
{ row: 9, column: 44 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
description: "class method",
|
||||
nodeType: "method_declaration",
|
||||
fileName: "file1.ts",
|
||||
range: {
|
||||
start: { line: 22, character: 4 },
|
||||
end: { line: 22, character: 30 },
|
||||
},
|
||||
positions: [
|
||||
language: "TypeScript",
|
||||
cursorPosition: { line: 22, character: 30 },
|
||||
definitionPositions: [
|
||||
{ row: 13, column: 29 }, // BaseClass
|
||||
{ row: 13, column: 55 }, // FirstInterface
|
||||
{ row: 13, column: 72 }, // SecondInterface
|
||||
|
|
@ -28,15 +24,63 @@ const TEST_CASES = [
|
|||
{ row: 21, column: 43 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition",
|
||||
fileName: "file1.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 4, character: 25 },
|
||||
definitionPositions: [
|
||||
{ row: 3, column: 30 }, // Person
|
||||
{ row: 3, column: 42 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition (inside a class)",
|
||||
fileName: "file1.py",
|
||||
language: "Python",
|
||||
cursorPosition: { line: 12, character: 33 },
|
||||
definitionPositions: [
|
||||
{ row: 6, column: 21 }, // BaseClass
|
||||
{ row: 6, column: 33 }, // Collection
|
||||
{ row: 11, column: 47 }, // Person
|
||||
{ row: 11, column: 59 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition",
|
||||
fileName: "file1.php",
|
||||
language: "PHP",
|
||||
cursorPosition: { line: 12, character: 32 },
|
||||
definitionPositions: [
|
||||
{ row: 10, column: 26 }, // Person
|
||||
{ row: 10, column: 44 }, // Address
|
||||
],
|
||||
},
|
||||
{
|
||||
nodeType: "function_definition (inside a class)",
|
||||
fileName: "file1.php",
|
||||
language: "PHP",
|
||||
cursorPosition: { line: 26, character: 35 },
|
||||
definitionPositions: [
|
||||
{ row: 15, column: 29 }, // BaseClass
|
||||
{ row: 15, column: 55 }, // FirstInterface
|
||||
{ row: 15, column: 72 }, // SecondInterface
|
||||
{ row: 25, column: 43 }, // Person
|
||||
{ row: 25, column: 61 }, // Address
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
describe("RootPathContextService", () => {
|
||||
describe("TypeScript should return expected snippets when editing inside a:", () => {
|
||||
test.each(TEST_CASES)(
|
||||
"should look for correct type definitions when editing inside a $description",
|
||||
async ({ fileName, range, positions }) => {
|
||||
await testRootPathContext("typescript", fileName, range, positions);
|
||||
},
|
||||
);
|
||||
});
|
||||
test.each(TEST_CASES)(
|
||||
"Should look for correct type definitions when editing inside a $nodeType in $language",
|
||||
async ({ fileName, cursorPosition, definitionPositions }) => {
|
||||
await testRootPathContext(
|
||||
"files",
|
||||
fileName,
|
||||
cursorPosition,
|
||||
definitionPositions,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
# File: base_module.py
|
||||
|
||||
class BaseClass:
|
||||
def __init__(self):
|
||||
print("BaseClass initialized")
|
||||
|
||||
class Collection:
|
||||
def __init__(self):
|
||||
print("Collection initialized")
|
||||
|
||||
class Address:
|
||||
def __init__(self, street: str, city: str, zip_code: str):
|
||||
self.street = street
|
||||
self.city = city
|
||||
self.zip_code = zip_code
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.street}, {self.city}, {self.zip_code}"
|
||||
|
||||
class Person:
|
||||
def __init__(self, name: str, address: Address):
|
||||
self.name = name
|
||||
self.address = address
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} lives at {self.address}"
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace BaseNamespace;
|
||||
|
||||
use BaseNamespace\BaseClass;
|
||||
use BaseNamespace\Interfaces\FirstInterface;
|
||||
use BaseNamespace\Interfaces\SecondInterface;
|
||||
use BaseNamespace\Person;
|
||||
use BaseNamespace\Address;
|
||||
|
||||
function getAddress(Person $person): Address
|
||||
{
|
||||
return $person->getAddress();
|
||||
}
|
||||
|
||||
class Group extends BaseClass implements FirstInterface, SecondInterface
|
||||
{
|
||||
private array $people;
|
||||
|
||||
public function __construct(array $people)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->people = $people;
|
||||
}
|
||||
|
||||
public function getPersonAddress(Person $person): Address
|
||||
{
|
||||
return getAddress($person);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from .base_module import BaseClass, Collection, Person, Address
|
||||
from typing import List
|
||||
|
||||
def get_address(person: Person) -> Address:
|
||||
return person.address
|
||||
|
||||
class Group(BaseClass, Collection):
|
||||
def __init__(self, people: List[Person]) -> None:
|
||||
super().__init__()
|
||||
self.people = people
|
||||
|
||||
def get_person_address(self, person: Person) -> Address:
|
||||
return get_address(person)
|
||||
|
|
@ -3,46 +3,32 @@ import fs from "fs";
|
|||
import path from "path";
|
||||
|
||||
import Parser from "web-tree-sitter";
|
||||
import { Range } from "../../../..";
|
||||
import { Position } from "../../../..";
|
||||
import { testIde } from "../../../../test/util/fixtures";
|
||||
import { getAst, getTreePathAtCursor } from "../../../util/ast";
|
||||
import { ImportDefinitionsService } from "../../ImportDefinitionsService";
|
||||
import { RootPathContextService } from "../RootPathContextService";
|
||||
|
||||
function splitTextAtRange(fileContent: string, range: Range): [string, string] {
|
||||
function splitTextAtPosition(
|
||||
fileContent: string,
|
||||
position: Position,
|
||||
): [string, string] {
|
||||
const lines = fileContent.split("\n");
|
||||
let currentPos = 0;
|
||||
|
||||
if (range.start.line === range.end.line) {
|
||||
// If range is on the same line, calculate position once
|
||||
for (let i = 0; i < range.start.line; i++) {
|
||||
currentPos += lines[i].length + 1; // +1 for the newline character
|
||||
}
|
||||
const startPos = currentPos + range.start.character;
|
||||
const endPos = currentPos + range.end.character;
|
||||
return [fileContent.slice(0, startPos), fileContent.slice(endPos)];
|
||||
// Calculate position based on the provided line and character
|
||||
for (let i = 0; i < position.line; i++) {
|
||||
currentPos += lines[i].length + 1; // +1 for the newline character
|
||||
}
|
||||
const splitPos = currentPos + position.character;
|
||||
|
||||
// Calculate position of range start
|
||||
for (let i = 0; i < range.start.line; i++) {
|
||||
currentPos += lines[i].length + 1;
|
||||
}
|
||||
const startPos = currentPos + range.start.character;
|
||||
|
||||
// Calculate position of range end
|
||||
currentPos = 0;
|
||||
for (let i = 0; i < range.end.line; i++) {
|
||||
currentPos += lines[i].length + 1;
|
||||
}
|
||||
const endPos = currentPos + range.end.character;
|
||||
|
||||
return [fileContent.slice(0, startPos), fileContent.slice(endPos)];
|
||||
return [fileContent.slice(0, splitPos), fileContent.slice(splitPos)];
|
||||
}
|
||||
|
||||
export async function testRootPathContext(
|
||||
folderName: string,
|
||||
relativeFilepath: string,
|
||||
rangeToFill: Range,
|
||||
position: Position,
|
||||
expectedDefinitionPositions: Parser.Point[],
|
||||
) {
|
||||
// Create a mocked instance of RootPathContextService
|
||||
|
|
@ -76,9 +62,9 @@ export async function testRootPathContext(
|
|||
|
||||
// Get results of root path context
|
||||
const startPath = path.join(testFolderPath, relativeFilepath);
|
||||
const [prefix, suffix] = splitTextAtRange(
|
||||
const [prefix, suffix] = splitTextAtPosition(
|
||||
fs.readFileSync(startPath, "utf8"),
|
||||
rangeToFill,
|
||||
position,
|
||||
);
|
||||
const fileContents = prefix + suffix;
|
||||
const ast = await getAst(startPath, fileContents);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const filterTestCases = (tests: AutocompleteFileringTestInput[]) => {
|
|||
return tests;
|
||||
};
|
||||
|
||||
describe("llms/Mock", () => {
|
||||
describe("Autocomplete filtering tests", () => {
|
||||
beforeAll(async () => {
|
||||
tearDownTestDir();
|
||||
setUpTestDir();
|
||||
|
|
@ -24,27 +24,25 @@ describe("llms/Mock", () => {
|
|||
tearDownTestDir();
|
||||
});
|
||||
|
||||
describe("Autocomplete Filtering Tests", () => {
|
||||
beforeEach(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
});
|
||||
|
||||
describe("Should return unmodified LLM output", () => {
|
||||
it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))(
|
||||
"$description",
|
||||
async (testCase) => {
|
||||
await testAutocompleteFiltering(testCase);
|
||||
},
|
||||
);
|
||||
});
|
||||
describe("Should return unmodified LLM output", () => {
|
||||
it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))(
|
||||
"$description",
|
||||
async (testCase) => {
|
||||
await testAutocompleteFiltering(testCase);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("Should return modified LLM output", () => {
|
||||
it.each(filterTestCases(TEST_CASES_WITH_DIFF))(
|
||||
"$description",
|
||||
async (testCase) => {
|
||||
await testAutocompleteFiltering(testCase);
|
||||
},
|
||||
);
|
||||
});
|
||||
describe("Should return modified LLM output", () => {
|
||||
it.each(filterTestCases(TEST_CASES_WITH_DIFF))(
|
||||
"$description",
|
||||
async (testCase) => {
|
||||
await testAutocompleteFiltering(testCase);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -216,7 +216,10 @@ async function serializedToIntermediateConfig(
|
|||
promptFiles.push(...readAllGlobalPromptFiles());
|
||||
|
||||
for (const file of promptFiles) {
|
||||
slashCommands.push(slashCommandFromPromptFile(file.path, file.content));
|
||||
const slashCommand = slashCommandFromPromptFile(file.path, file.content);
|
||||
if (slashCommand) {
|
||||
slashCommands.push(slashCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { FREE_TRIAL_MODELS } from "./default";
|
|||
|
||||
export const TRIAL_FIM_MODEL = "codestral-latest";
|
||||
export const ONBOARDING_LOCAL_MODEL_TITLE = "Ollama";
|
||||
export const LOCAL_ONBOARDING_FIM_MODEL = "starcoder2:3b";
|
||||
export const LOCAL_ONBOARDING_FIM_MODEL = "qwen2.5-coder:1.5b";
|
||||
export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
|
||||
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ export function setupLocalConfig(
|
|||
...config.models.filter((model) => model.provider !== "free-trial"),
|
||||
],
|
||||
tabAutocompleteModel: {
|
||||
title: "Starcoder 3b",
|
||||
title: "Qwen2.5-Coder 1.5B",
|
||||
provider: "ollama",
|
||||
model: LOCAL_ONBOARDING_FIM_MODEL,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,13 +3,19 @@ import path from "path";
|
|||
import Handlebars from "handlebars";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { BaseContextProvider } from "../context";
|
||||
import { walkDir } from "../indexing/walkDir";
|
||||
import { stripImages } from "../llm/images";
|
||||
import { renderTemplatedString } from "../promptFiles/v1/renderTemplatedString";
|
||||
import { getBasename } from "../util/index";
|
||||
|
||||
import type { ChatHistory, ChatHistoryItem, ChatMessage, ContextItem, ContinueSDK, IContextProvider, IDE, SlashCommand } from "..";
|
||||
import type {
|
||||
ChatMessage,
|
||||
ContextItem,
|
||||
ContinueSDK,
|
||||
IContextProvider,
|
||||
IDE,
|
||||
SlashCommand,
|
||||
} from "..";
|
||||
|
||||
export const DEFAULT_PROMPTS_FOLDER = ".prompts";
|
||||
|
||||
|
|
@ -93,12 +99,16 @@ export async function createNewPromptFile(
|
|||
export function slashCommandFromPromptFile(
|
||||
path: string,
|
||||
content: string,
|
||||
): SlashCommand {
|
||||
const { name, description, systemMessage, prompt } = parsePromptFile(
|
||||
): SlashCommand | null {
|
||||
const { name, description, systemMessage, prompt, version } = parsePromptFile(
|
||||
path,
|
||||
content,
|
||||
);
|
||||
|
||||
if (version !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
|
|
@ -134,6 +144,7 @@ function parsePromptFile(path: string, content: string) {
|
|||
const preamble = YAML.parse(preambleRaw) ?? {};
|
||||
const name = preamble.name ?? getBasename(path).split(".prompt")[0];
|
||||
const description = preamble.description ?? name;
|
||||
const version = preamble.version ?? 2;
|
||||
|
||||
let systemMessage: string | undefined = undefined;
|
||||
if (prompt.includes("<system>")) {
|
||||
|
|
@ -141,7 +152,7 @@ function parsePromptFile(path: string, content: string) {
|
|||
prompt = prompt.split("</system>")[1].trim();
|
||||
}
|
||||
|
||||
return { name, description, systemMessage, prompt };
|
||||
return { name, description, systemMessage, prompt, version };
|
||||
}
|
||||
|
||||
function extractUserInput(input: string, commandName: string): string {
|
||||
|
|
@ -151,7 +162,11 @@ function extractUserInput(input: string, commandName: string): string {
|
|||
return input;
|
||||
}
|
||||
|
||||
async function renderPrompt(prompt: string, context: ContinueSDK, userInput: string) {
|
||||
async function renderPrompt(
|
||||
prompt: string,
|
||||
context: ContinueSDK,
|
||||
userInput: string,
|
||||
) {
|
||||
const helpers = getContextProviderHelpers(context);
|
||||
|
||||
// A few context providers that don't need to be in config.json to work in .prompt files
|
||||
|
|
|
|||
12
core/index.d.ts
vendored
12
core/index.d.ts
vendored
|
|
@ -45,12 +45,12 @@ export interface IndexingProgressUpdate {
|
|||
debugInfo?: string;
|
||||
}
|
||||
|
||||
export type PromptTemplate =
|
||||
| string
|
||||
| ((
|
||||
history: ChatMessage[],
|
||||
otherData: Record<string, string>,
|
||||
) => string | ChatMessage[]);
|
||||
export type PromptTemplateFunction = (
|
||||
history: ChatMessage[],
|
||||
otherData: Record<string, string>,
|
||||
) => string | ChatMessage[];
|
||||
|
||||
export type PromptTemplate = string | PromptTemplateFunction;
|
||||
|
||||
export interface ILLM extends LLMOptions {
|
||||
get providerName(): ModelProvider;
|
||||
|
|
|
|||
|
|
@ -362,11 +362,16 @@ export default class DocsService {
|
|||
isPreIndexedDoc: !!preIndexedDocs[startUrl],
|
||||
});
|
||||
|
||||
const docs: LanceDbDocsRow[] = await table
|
||||
.search(vector)
|
||||
.limit(nRetrieve)
|
||||
.where(`starturl = '${startUrl}'`)
|
||||
.execute();
|
||||
let docs: LanceDbDocsRow[] = [];
|
||||
try {
|
||||
docs = await table
|
||||
.search(vector)
|
||||
.limit(nRetrieve)
|
||||
.where(`starturl = '${startUrl}'`)
|
||||
.execute();
|
||||
} catch (e: any) {
|
||||
console.error("Error retrieving chunks from LanceDB", e);
|
||||
}
|
||||
|
||||
const hasIndexedDoc = await this.hasIndexedDoc(startUrl);
|
||||
|
||||
|
|
@ -553,9 +558,8 @@ export default class DocsService {
|
|||
private async getLanceTableNameFromEmbeddingsProvider(
|
||||
isPreIndexedDoc: boolean,
|
||||
) {
|
||||
const embeddingsProvider = await this.getEmbeddingsProvider(
|
||||
isPreIndexedDoc,
|
||||
);
|
||||
const embeddingsProvider =
|
||||
await this.getEmbeddingsProvider(isPreIndexedDoc);
|
||||
|
||||
const tableName = this.sanitizeLanceTableName(
|
||||
`${DocsService.lanceTableName}${embeddingsProvider.id}`,
|
||||
|
|
|
|||
|
|
@ -325,6 +325,11 @@ const preIndexedDocs: Record<
|
|||
rootUrl: "https://awscli.amazonaws.com/v2/documentation/api/latest/",
|
||||
faviconUrl: "https://docs.aws.amazon.com/favicon.ico",
|
||||
},
|
||||
"https://llama-stack.readthedocs.io/": {
|
||||
title: "Llama Stack",
|
||||
startUrl: "https://llama-stack.readthedocs.io/",
|
||||
rootUrl: "https://llama-stack.readthedocs.io/",
|
||||
},
|
||||
};
|
||||
|
||||
export default preIndexedDocs;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const DEFAULT_MAX_TOKENS = 2048;
|
||||
const DEFAULT_MAX_TOKENS = 4096;
|
||||
const DEFAULT_CONTEXT_LENGTH = 8096;
|
||||
const DEFAULT_TEMPERATURE = 0.5;
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ const DEFAULT_ARGS = {
|
|||
temperature: DEFAULT_TEMPERATURE,
|
||||
};
|
||||
|
||||
const GPT_4_CTX_LEN = 4096;
|
||||
const GPT_4_CTX_LEN = 128_000;
|
||||
|
||||
const CONTEXT_LENGTH_FOR_MODEL: { [name: string]: number } = {
|
||||
"gpt-3.5-turbo": 4096,
|
||||
|
|
@ -16,9 +16,9 @@ const CONTEXT_LENGTH_FOR_MODEL: { [name: string]: number } = {
|
|||
"gpt-35-turbo-16k": 16_384,
|
||||
"gpt-35-turbo-0613": 4096,
|
||||
"gpt-35-turbo": 4096,
|
||||
"gpt-4": GPT_4_CTX_LEN,
|
||||
"gpt-4-32k": GPT_4_CTX_LEN,
|
||||
"gpt-4-turbo-preview": GPT_4_CTX_LEN,
|
||||
"gpt-4": 4096,
|
||||
"gpt-4-32k": 32_000,
|
||||
"gpt-4-turbo-preview": 32_000,
|
||||
"gpt-4o": GPT_4_CTX_LEN,
|
||||
"gpt-4o-mini": GPT_4_CTX_LEN,
|
||||
"gpt-4-vision": GPT_4_CTX_LEN,
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ class ContinueProxy extends OpenAI {
|
|||
static providerName: ModelProvider = "continue-proxy";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
requestOptions: {
|
||||
headers: {
|
||||
"x-continue-unique-id": Telemetry.uniqueId,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
protected _getHeaders() {
|
||||
const headers: any = super._getHeaders();
|
||||
headers["x-continue-unique-id"] = Telemetry.uniqueId;
|
||||
return headers;
|
||||
}
|
||||
|
||||
supportsCompletions(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { ChatMessage, PromptTemplate } from "../../index.js";
|
||||
import { gptEditPrompt } from "./edit/gpt.js";
|
||||
|
||||
const simplifiedEditPrompt = `Consider the following code:
|
||||
\`\`\`{{{language}}}
|
||||
|
|
@ -18,49 +19,6 @@ Here is the edit requested:
|
|||
|
||||
Here is the code after editing:`;
|
||||
|
||||
const gptEditPrompt: PromptTemplate = (_, otherData) => {
|
||||
if (otherData?.codeToEdit?.trim().length === 0) {
|
||||
return `\
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}[BLANK]${otherData.codeToEdit}${otherData.suffix}
|
||||
\`\`\`
|
||||
|
||||
Above is the file of code that the user is currently editing in. Their cursor is located at the "[BLANK]". They have requested that you fill in the "[BLANK]" with code that satisfies the following request:
|
||||
|
||||
"${otherData.userInput}"
|
||||
|
||||
Please generate this code. Your output will be only the code that should replace the "[BLANK]", without repeating any of the prefix or suffix, without any natural language explanation, and without messing up indentation. Here is the code that will replace the "[BLANK]":`;
|
||||
}
|
||||
|
||||
const paragraphs = [
|
||||
"The user has requested a section of code in a file to be rewritten.",
|
||||
];
|
||||
if (otherData.prefix?.trim().length > 0) {
|
||||
paragraphs.push(`This is the prefix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
if (otherData.suffix?.trim().length > 0) {
|
||||
paragraphs.push(`This is the suffix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.suffix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
paragraphs.push(`This is the code to rewrite:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.codeToEdit}
|
||||
\`\`\`
|
||||
|
||||
The user's request is: "${otherData.userInput}"
|
||||
|
||||
Here is the rewritten code:`);
|
||||
|
||||
return paragraphs.join("\n\n");
|
||||
};
|
||||
|
||||
const codellamaInfillEditPrompt = "{{filePrefix}}<FILL>{{fileSuffix}}";
|
||||
|
||||
const START_TAG = "<START EDITING HERE>";
|
||||
|
|
@ -76,7 +34,7 @@ const osModelsEditPrompt: PromptTemplate = (history, otherData) => {
|
|||
!firstCharOfFirstLine;
|
||||
const suffixTag = isSuffix ? "<STOP EDITING HERE>" : "";
|
||||
const suffixExplanation = isSuffix
|
||||
? " When you get to \"<STOP EDITING HERE>\", end your response."
|
||||
? ' When you get to "<STOP EDITING HERE>", end your response.'
|
||||
: "";
|
||||
|
||||
// If neither prefilling nor /v1/completions are supported, we have to use a chat prompt without putting words in the model's mouth
|
||||
|
|
|
|||
44
core/llm/templates/edit/claude.ts
Normal file
44
core/llm/templates/edit/claude.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { PromptTemplateFunction } from "../../..";
|
||||
|
||||
export const claudeEditPrompt: PromptTemplateFunction = (_, otherData) => {
|
||||
if (otherData?.codeToEdit?.trim().length === 0) {
|
||||
return `\
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}[BLANK]${otherData.codeToEdit}${otherData.suffix}
|
||||
\`\`\`
|
||||
|
||||
Above is the file of code that the user is currently editing in. Their cursor is located at the "[BLANK]". They have requested that you fill in the "[BLANK]" with code that satisfies the following request:
|
||||
|
||||
"${otherData.userInput}"
|
||||
|
||||
Please generate this code. Your output will be only the code that should replace the "[BLANK]", without repeating any of the prefix or suffix, without any natural language explanation, and without messing up indentation. Here is the code that will replace the "[BLANK]":`;
|
||||
}
|
||||
|
||||
const paragraphs = [
|
||||
"The user has requested a section of code in a file to be rewritten.",
|
||||
];
|
||||
if (otherData.prefix?.trim().length > 0) {
|
||||
paragraphs.push(`This is the prefix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
if (otherData.suffix?.trim().length > 0) {
|
||||
paragraphs.push(`This is the suffix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.suffix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
paragraphs.push(`This is the code to rewrite:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.codeToEdit}
|
||||
\`\`\`
|
||||
|
||||
The user's request is: "${otherData.userInput}"
|
||||
|
||||
Here is the rewritten code:`);
|
||||
|
||||
return paragraphs.join("\n\n");
|
||||
};
|
||||
71
core/llm/templates/edit/gpt.ts
Normal file
71
core/llm/templates/edit/gpt.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import { PromptTemplateFunction } from "../../..";
|
||||
import { dedent } from "../../../util";
|
||||
|
||||
const gptInsertionEditPrompt: PromptTemplateFunction = (_, otherData) => {
|
||||
return dedent`
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}[BLANK]${otherData.codeToEdit}${otherData.suffix}
|
||||
\`\`\`
|
||||
|
||||
Above is the file of code that the user is currently editing in. Their cursor is located at the "[BLANK]". They have requested that you fill in the "[BLANK]" with code that satisfies the following request:
|
||||
|
||||
"${otherData.userInput}"
|
||||
|
||||
Please generate this code. Your output will be only the code that should replace the "[BLANK]", without repeating any of the prefix or suffix, without any natural language explanation, and without messing up indentation. Here is the code that will replace the "[BLANK]":`;
|
||||
};
|
||||
|
||||
const gptFullFileEditPrompt: PromptTemplateFunction = (_, otherData) => {
|
||||
return dedent`
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.codeToEdit}
|
||||
\`\`\`
|
||||
|
||||
Please rewrite the above file to address the following request:
|
||||
|
||||
${otherData.userInput}
|
||||
|
||||
You should rewrite the entire file without any natural language explanation. DO NOT surround the code in a code block and DO NOT explain yourself.`;
|
||||
};
|
||||
|
||||
export const gptEditPrompt: PromptTemplateFunction = (history, otherData) => {
|
||||
if (otherData?.codeToEdit?.trim().length === 0) {
|
||||
return gptInsertionEditPrompt(history, otherData);
|
||||
} else if (
|
||||
otherData?.prefix?.trim().length === 0 &&
|
||||
otherData?.suffix?.trim().length === 0
|
||||
) {
|
||||
return gptFullFileEditPrompt(history, otherData);
|
||||
}
|
||||
|
||||
const paragraphs = [
|
||||
"The user has requested a section of code in a file to be rewritten.",
|
||||
];
|
||||
|
||||
if (otherData.prefix?.trim().length > 0) {
|
||||
paragraphs.push(dedent`
|
||||
This is the prefix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.prefix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
if (otherData.suffix?.trim().length > 0) {
|
||||
paragraphs.push(dedent`
|
||||
This is the suffix of the file:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.suffix}
|
||||
\`\`\``);
|
||||
}
|
||||
|
||||
paragraphs.push(dedent`
|
||||
This is the code to rewrite:
|
||||
\`\`\`${otherData.language}
|
||||
${otherData.codeToEdit}
|
||||
\`\`\`
|
||||
|
||||
The user's request is: "${otherData.userInput}"
|
||||
|
||||
Here is the rewritten code:`);
|
||||
|
||||
return paragraphs.join("\n\n");
|
||||
};
|
||||
|
|
@ -1,46 +1,42 @@
|
|||
import path from "path";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { GlobalContext } from "../../util/GlobalContext";
|
||||
|
||||
import { DEFAULT_PROMPTS_FOLDER_V2 } from "./getPromptFiles";
|
||||
import { getPathModuleForIde } from "../../util/pathModule";
|
||||
|
||||
const FIRST_TIME_DEFAULT_PROMPT_FILE = `# This is an example ".prompt" file
|
||||
# It is used to define and reuse prompts within Continue
|
||||
# Continue will automatically create a context provider for each prompt in the .prompts folder
|
||||
# Each .prompt file can be accessed by typing "@prompts" in the Chat input
|
||||
|
||||
# A prompt file consists of two parts:
|
||||
# 1. Everything above the "---" is YAML. Here you can set "temperature", "description", and other options
|
||||
# 2. Everything below the "---" is the prompt body
|
||||
|
||||
# If you don't want to set any options, you don't need to include the "---"
|
||||
# If you do not want to set any options, you do not need to include the "---"
|
||||
|
||||
# In the body, you can reference:
|
||||
# 1. Files, using either absolute or relative (based on the workspace root) paths
|
||||
# e.g. @README.md
|
||||
# e.g. @src/test/test.py
|
||||
# e.g. @/Users/me/Desktop/my-project/src/test/test.py
|
||||
# 2. URLs
|
||||
# e.g. https://example.com
|
||||
# 3. Some context providers, like
|
||||
# e.g. @currentFile
|
||||
# e.g. @os
|
||||
# e.g. @repo-map
|
||||
# 1. Files, using either absolute or relative paths (based on the workspace root)
|
||||
# @README.md
|
||||
# @src/test/test.py
|
||||
# @/Users/me/Desktop/my-project/src/test/test.py
|
||||
# 2. URLs, for example
|
||||
# @https://example.com
|
||||
# 3. Context providers, for example
|
||||
# @currentFile
|
||||
# @os
|
||||
# @repo-map
|
||||
|
||||
# To learn more, see the full .prompt file reference: https://docs.continue.dev/features/prompt-files
|
||||
name: Example
|
||||
|
||||
# For example, here is how you would write a .prompt
|
||||
name: Example
|
||||
description: Example prompt file
|
||||
version: 2
|
||||
---
|
||||
@README.md
|
||||
|
||||
Please reference the above README.md file to understand the current project.
|
||||
`;
|
||||
|
||||
const DEFAULT_PROMPT_FILE = `version: 2
|
||||
---
|
||||
|
||||
`;
|
||||
Here is information about the current repo:
|
||||
|
||||
@README.md`;
|
||||
|
||||
const DEFAULT_PROMPT_FILE = "";
|
||||
|
||||
export async function createNewPromptFileV2(
|
||||
ide: IDE,
|
||||
|
|
@ -52,9 +48,11 @@ export async function createNewPromptFileV2(
|
|||
"No workspace directories found. Make sure you've opened a folder in your IDE.",
|
||||
);
|
||||
}
|
||||
const baseDir = path.join(
|
||||
const pathModule = await getPathModuleForIde(ide);
|
||||
|
||||
const baseDir = pathModule.join(
|
||||
workspaceDirs[0],
|
||||
promptPath ?? DEFAULT_PROMPTS_FOLDER_V2,
|
||||
promptPath ?? pathModule.join(".continue", "prompts"),
|
||||
);
|
||||
|
||||
// Find the first available filename
|
||||
|
|
@ -62,15 +60,21 @@ export async function createNewPromptFileV2(
|
|||
let promptFilePath: string;
|
||||
do {
|
||||
const suffix = counter === 0 ? "" : `-${counter}`;
|
||||
promptFilePath = path.join(baseDir, `new-prompt-file${suffix}.prompt`);
|
||||
promptFilePath = pathModule.join(
|
||||
baseDir,
|
||||
`new-prompt-file${suffix}.prompt`,
|
||||
);
|
||||
counter++;
|
||||
} while (await ide.fileExists(promptFilePath));
|
||||
|
||||
const globalContext = new GlobalContext();
|
||||
const PROMPT_FILE =
|
||||
new GlobalContext().get("hasAlreadyCreatedAPromptFile") === true
|
||||
globalContext.get("hasAlreadyCreatedAPromptFile") === true
|
||||
? DEFAULT_PROMPT_FILE
|
||||
: FIRST_TIME_DEFAULT_PROMPT_FILE;
|
||||
|
||||
globalContext.update("hasAlreadyCreatedAPromptFile", true);
|
||||
|
||||
await ide.writeFile(promptFilePath, PROMPT_FILE);
|
||||
await ide.openFile(promptFilePath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import path from "path";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { walkDir } from "../../indexing/walkDir";
|
||||
import { getPathModuleForIde } from "../../util/pathModule";
|
||||
import { readAllGlobalPromptFiles } from "../../util/paths";
|
||||
|
||||
async function getPromptFilesFromDir(
|
||||
|
|
@ -27,20 +26,23 @@ async function getPromptFilesFromDir(
|
|||
}
|
||||
}
|
||||
|
||||
export const DEFAULT_PROMPTS_FOLDER_V2 = ".prompts";
|
||||
|
||||
export async function getAllPromptFilesV2(
|
||||
ide: IDE,
|
||||
overridePromptFolder?: string,
|
||||
): Promise<{ path: string; content: string }[]> {
|
||||
const workspaceDirs = await ide.getWorkspaceDirs();
|
||||
let promptFiles: { path: string; content: string }[] = [];
|
||||
const pathModule = await getPathModuleForIde(ide);
|
||||
|
||||
promptFiles = (
|
||||
await Promise.all(
|
||||
workspaceDirs.map((dir) =>
|
||||
getPromptFilesFromDir(
|
||||
ide,
|
||||
path.join(dir, overridePromptFolder ?? DEFAULT_PROMPTS_FOLDER_V2),
|
||||
pathModule.join(
|
||||
dir,
|
||||
overridePromptFolder ?? pathModule.join(".continue", "prompts"),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ContextItem, ContextProviderExtras } from "../..";
|
||||
import { contextProviderClassFromName } from "../../context/providers";
|
||||
import URLContextProvider from "../../context/providers/URLContextProvider";
|
||||
import { getBasename } from "../../util";
|
||||
|
||||
import { getPreambleAndBody } from "./parse";
|
||||
|
||||
async function resolveAttachment(
|
||||
|
|
@ -15,6 +15,13 @@ async function resolveAttachment(
|
|||
if (contextProvider) {
|
||||
const items = await contextProvider.getContextItems("", extras);
|
||||
return items;
|
||||
} else {
|
||||
// Just instantiate it here
|
||||
const providerClass = contextProviderClassFromName(name) as any;
|
||||
if (providerClass) {
|
||||
const providerInstance = new providerClass({});
|
||||
return providerInstance.getContextItems("", extras);
|
||||
}
|
||||
}
|
||||
|
||||
// Files
|
||||
|
|
|
|||
|
|
@ -56,7 +56,12 @@ export interface EditModeArgs {
|
|||
highlightedCode: RangeInFileWithContents;
|
||||
}
|
||||
|
||||
export type EditStatus = "not-started" | "streaming" | "accepting" | "done";
|
||||
export type EditStatus =
|
||||
| "not-started"
|
||||
| "streaming"
|
||||
| "accepting"
|
||||
| "accepting:full-diff"
|
||||
| "done";
|
||||
|
||||
export interface ApplyState {
|
||||
streamId: string;
|
||||
|
|
@ -105,6 +110,6 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
applyCodeFromChat: [undefined, void];
|
||||
updateApplyState: [ApplyState, void];
|
||||
startEditMode: [EditModeArgs, void];
|
||||
setEditStatus: [{ status: EditStatus }, void];
|
||||
setEditStatus: [{ status: EditStatus; fileAfterEdit?: string }, void];
|
||||
exitEditMode: [undefined, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -135,4 +135,21 @@ World
|
|||
|
||||
expect(result).toBe("Hello\n\nWorld");
|
||||
});
|
||||
|
||||
it("should work with templated strings", () => {
|
||||
const language = "typescript";
|
||||
const code = "console.log('hello');\nconsole.log('world');";
|
||||
|
||||
const result = dedent`
|
||||
This is the prefix of the file:
|
||||
\`\`\`${language}
|
||||
${code}
|
||||
\`\`\``;
|
||||
|
||||
expect(result).toBe(`\
|
||||
This is the prefix of the file:
|
||||
\`\`\`${language}
|
||||
${code}
|
||||
\`\`\``);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@ export function removeQuotesAndEscapes(output: string): string {
|
|||
output = output.trim();
|
||||
|
||||
// Replace smart quotes
|
||||
output = output.replace("“", "\"");
|
||||
output = output.replace("”", "\"");
|
||||
output = output.replace("“", '"');
|
||||
output = output.replace("”", '"');
|
||||
output = output.replace("‘", "'");
|
||||
output = output.replace("’", "'");
|
||||
|
||||
// Remove escapes
|
||||
output = output.replace("\\\"", "\"");
|
||||
output = output.replace('\\"', '"');
|
||||
output = output.replace("\\'", "'");
|
||||
output = output.replace("\\n", "\n");
|
||||
output = output.replace("\\t", "\t");
|
||||
output = output.replace("\\\\", "\\");
|
||||
while (
|
||||
(output.startsWith("\"") && output.endsWith("\"")) ||
|
||||
(output.startsWith('"') && output.endsWith('"')) ||
|
||||
(output.startsWith("'") && output.endsWith("'"))
|
||||
) {
|
||||
output = output.slice(1, -1);
|
||||
|
|
@ -276,31 +276,55 @@ export function deduplicateArray<T>(
|
|||
export type TODO = any;
|
||||
|
||||
export function dedent(strings: TemplateStringsArray, ...values: any[]) {
|
||||
let result = strings.reduce(
|
||||
(acc, str, i) => acc + str + (values[i] || ""),
|
||||
"",
|
||||
);
|
||||
result = result.replace(/^\n/, "").replace(/\n\s*$/, "");
|
||||
let raw = "";
|
||||
for (let i = 0; i < strings.length; i++) {
|
||||
raw += strings[i];
|
||||
|
||||
// Handle the value if it exists
|
||||
if (i < values.length) {
|
||||
let value = String(values[i]);
|
||||
// If the value contains newlines, we need to adjust the indentation
|
||||
if (value.includes("\n")) {
|
||||
// Find the indentation level of the last line in strings[i]
|
||||
let lines = strings[i].split("\n");
|
||||
let lastLine = lines[lines.length - 1];
|
||||
let match = lastLine.match(/(^|\n)([^\S\n]*)$/);
|
||||
let indent = match ? match[2] : "";
|
||||
// Add indentation to all lines except the first line of value
|
||||
let valueLines = value.split("\n");
|
||||
valueLines = valueLines.map((line, index) =>
|
||||
index === 0 ? line : indent + line,
|
||||
);
|
||||
value = valueLines.join("\n");
|
||||
}
|
||||
raw += value;
|
||||
}
|
||||
}
|
||||
|
||||
// Now dedent the full string
|
||||
let result = raw.replace(/^\n/, "").replace(/\n\s*$/, "");
|
||||
let lines = result.split("\n");
|
||||
|
||||
// Remove leading white-space-only lines
|
||||
// Remove leading/trailing blank lines
|
||||
while (lines.length > 0 && lines[0].trim() === "") {
|
||||
lines.shift();
|
||||
}
|
||||
|
||||
// Remove trailing white-space-only lines
|
||||
while (lines.length > 0 && lines[lines.length - 1].trim() === "") {
|
||||
lines.pop();
|
||||
}
|
||||
|
||||
const minIndent = lines.reduce((min, line) => {
|
||||
if (line.trim() === "") {
|
||||
// Don't consider empty lines when calculating indentation
|
||||
return min;
|
||||
}
|
||||
const match = line.match(/^\s*/);
|
||||
return Math.min(min, match ? match[0].length : Infinity);
|
||||
}, Infinity);
|
||||
// Calculate minimum indentation (excluding empty lines)
|
||||
let minIndent = lines.reduce((min: any, line: any) => {
|
||||
if (line.trim() === "") return min;
|
||||
let match = line.match(/^(\s*)/);
|
||||
let indent = match ? match[1].length : 0;
|
||||
return min === null ? indent : Math.min(min, indent);
|
||||
}, null);
|
||||
|
||||
return lines.map((line) => line.slice(minIndent)).join("\n");
|
||||
if (minIndent !== null && minIndent > 0) {
|
||||
// Remove the minimum indentation from each line
|
||||
lines = lines.map((line) => line.slice(minIndent));
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
|
|
|||
13
core/util/pathModule.ts
Normal file
13
core/util/pathModule.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { PlatformPath, posix, win32 } from "node:path";
|
||||
import { IDE } from "..";
|
||||
|
||||
export type PathSep = "/" | "\\";
|
||||
|
||||
function getPathModuleFromPathSep(pathSep: PathSep): PlatformPath {
|
||||
return pathSep === "/" ? posix : win32;
|
||||
}
|
||||
|
||||
export async function getPathModuleForIde(ide: IDE): Promise<PlatformPath> {
|
||||
const pathSep = await ide.pathSep();
|
||||
return getPathModuleFromPathSep(pathSep as PathSep);
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ export function getPromptLogsPath(): string {
|
|||
}
|
||||
|
||||
export function getGlobalPromptsPath(): string {
|
||||
return path.join(getContinueGlobalPath(), ".prompts");
|
||||
return path.join(getContinueGlobalPath(), "prompts");
|
||||
}
|
||||
|
||||
export function readAllGlobalPromptFiles(
|
||||
|
|
|
|||
|
|
@ -26,26 +26,23 @@ The API keys for Codestral and the general Mistral APIs are different. If you ar
|
|||
|
||||
## Local, offline / self-hosted experience
|
||||
|
||||
For those preferring local execution or self-hosting,`StarCoder2-3b` offers a good balance of performance and quality for most users:
|
||||
For those preferring local execution or self-hosting,`Qwen2.5-Coder 1.5B` offers a good balance of performance and quality for most users:
|
||||
|
||||
```json title="config.json""
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "StarCoder2-3b",
|
||||
"model": "starcoder2:3b",
|
||||
"title": "Qwen2.5-Coder 1.5B",
|
||||
"model": "qwen2.5-coder:1.5b",
|
||||
"provider": "ollama"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Alternative experiences
|
||||
|
||||
- Completions too slow? Try `deepseek-coder:1.3b-base` for quicker completions on less powerful hardware
|
||||
- Have more compute? Use `deepseek-coder:6.7b-base` for potentially higher-quality suggestions
|
||||
Have more compute? Use `qwen2.5-coder:7b` for potentially higher-quality suggestions.
|
||||
|
||||
:::note
|
||||
|
||||
For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf). Use this path as the `model` value in your configuration.
|
||||
For LM Studio users, navigate to the "My Models" section, find your desired model, and copy the path (e.g., `Qwen/Qwen2.5-Coder-1.5B-Instruct-GGUF/wen2.5-coder-1.5b-instruct-q4_k_m.gguf`). Use this path as the `model` value in your configuration.
|
||||
|
||||
:::
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ If you want to have the best autocomplete experience, we recommend using Codestr
|
|||
If you'd like to run your autocomplete model locally, we recommend using Ollama. To do this, first download the latest version of Ollama from [here](https://ollama.ai). Then, run the following command to download our recommended model:
|
||||
|
||||
```bash
|
||||
ollama run starcoder2:3b
|
||||
ollama run qwen2.5-coder:1.5b
|
||||
```
|
||||
|
||||
Once it has been downloaded, you should begin to see completions in VS Code.
|
||||
|
|
@ -37,7 +37,7 @@ All of the configuration options available for chat models are available to use
|
|||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b",
|
||||
"model": "qwen2.5-coder:1.5b",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
...
|
||||
|
|
@ -52,7 +52,7 @@ The following can be configured in `config.json`:
|
|||
|
||||
### `tabAutocompleteModel`
|
||||
|
||||
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `starcoder-1b`, or `starcoder2-3b`.
|
||||
This is just another object like the ones in the `"models"` array of `config.json`. You can choose and configure any model you would like, but we strongly suggest using a small model made for tab-autocomplete, such as `deepseek-1b`, `qwen2.5-coder:1.5b`, or `starcoder2-3b`.
|
||||
|
||||
### `tabAutocompleteOptions`
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa
|
|||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b",
|
||||
"model": "qwen2.5-coder:1.5b",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
"tabAutocompleteOptions": {
|
||||
|
|
@ -101,16 +101,12 @@ Follow these steps to ensure that everything is set up correctly:
|
|||
|
||||
1. Make sure you have the "Enable Tab Autocomplete" setting checked (in VS Code, you can toggle by clicking the "Continue" button in the status bar, and in JetBrains by going to Settings -> Tools -> Continue).
|
||||
2. Make sure you have downloaded Ollama.
|
||||
3. Run `ollama run starcoder2:3b` to verify that the model is downloaded.
|
||||
3. Run `ollama run qwen2.5-coder:1.5b` to verify that the model is downloaded.
|
||||
4. Make sure that any other completion providers are disabled (e.g. Copilot), as they may interfere.
|
||||
5. Check the output of the logs to find any potential errors: <kbd>cmd/ctrl</kbd> + <kbd>shift</kbd> + <kbd>P</kbd> -> "Toggle Developer Tools" -> "Console" tab in VS Code, ~/.continue/logs/core.log in JetBrains.
|
||||
6. Check VS Code settings to make sure that `"editor.inlineSuggest.enabled"` is set to `true` (use <kbd>cmd/ctrl</kbd> + <kbd>,</kbd> then search for this and check the box)
|
||||
7. If you are still having issues, please let us know in our [Discord](https://discord.gg/vapESyrFmJ) and we'll help as soon as possible.
|
||||
|
||||
### Completions are slow
|
||||
|
||||
Depending on your hardware, you may want to try a smaller, faster model. If 3b isn't working for you we recommend trying `deepseek-coder:1.3b-base`.
|
||||
|
||||
### Completions are only ever single-line
|
||||
|
||||
To ensure that you receive multi-line completions, you can set `"multilineCompletions": "always"` in `tabAutocompleteOptions`. By default, it is `"auto"`. If you still find that you are only seeing single-line completions, this may be because some models tend to produce shorter completions when starting in the middle of a file. You can try temporarily moving text below your cursor out of your active file, or switching to a larger model.
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ We recommend configuring **Llama3.1 8B** as your chat model.
|
|||
|
||||
## Autocomplete model
|
||||
|
||||
We recommend configuring **StarCoder2 3B** as your autocomplete model.
|
||||
We recommend configuring **Qwen2.5-Coder 1.5B** as your autocomplete model.
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "StarCoder2 3B",
|
||||
"title": "Qwen2.5-Coder 1.5B",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b"
|
||||
"model": "qwen2.5-coder:1.5b"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ In Continue, these models are used to display inline [Autocomplete](../../autoco
|
|||
|
||||
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).
|
||||
If you want to run a model locally, we recommend `Qwen2.5-Coder 1.5B` with [Ollama](../model-providers/top-level/ollama.md#autocomplete-model).
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ keywords:
|
|||
]
|
||||
---
|
||||
|
||||

|
||||

|
||||
|
||||
**Continue is the leading open-source AI code assistant inside of [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) and [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension)**
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const config = {
|
|||
// to replace "en" with "zh-Hans".
|
||||
i18n: {
|
||||
defaultLocale: "en",
|
||||
locales: ["en"],
|
||||
locales: ["en", "zh-CN"],
|
||||
},
|
||||
|
||||
themes: [],
|
||||
|
|
@ -110,6 +110,10 @@ const config = {
|
|||
position: "right",
|
||||
className: "discord-navbar",
|
||||
},
|
||||
{
|
||||
type: "localeDropdown",
|
||||
position: "right",
|
||||
},
|
||||
],
|
||||
},
|
||||
footer: {
|
||||
|
|
|
|||
440
docs/i18n/zh-CN/code.json
Normal file
440
docs/i18n/zh-CN/code.json
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
{
|
||||
"theme.ErrorPageContent.title": {
|
||||
"message": "页面已崩溃。",
|
||||
"description": "The title of the fallback page when the page crashed"
|
||||
},
|
||||
"theme.BackToTopButton.buttonAriaLabel": {
|
||||
"message": "回到顶部",
|
||||
"description": "The ARIA label for the back to top button"
|
||||
},
|
||||
"theme.blog.archive.title": {
|
||||
"message": "历史博文",
|
||||
"description": "The page & hero title of the blog archive page"
|
||||
},
|
||||
"theme.blog.archive.description": {
|
||||
"message": "历史博文",
|
||||
"description": "The page & hero description of the blog archive page"
|
||||
},
|
||||
"theme.blog.paginator.navAriaLabel": {
|
||||
"message": "博文列表分页导航",
|
||||
"description": "The ARIA label for the blog pagination"
|
||||
},
|
||||
"theme.blog.paginator.newerEntries": {
|
||||
"message": "较新的博文",
|
||||
"description": "The label used to navigate to the newer blog posts page (previous page)"
|
||||
},
|
||||
"theme.blog.paginator.olderEntries": {
|
||||
"message": "较旧的博文",
|
||||
"description": "The label used to navigate to the older blog posts page (next page)"
|
||||
},
|
||||
"theme.blog.post.paginator.navAriaLabel": {
|
||||
"message": "博文分页导航",
|
||||
"description": "The ARIA label for the blog posts pagination"
|
||||
},
|
||||
"theme.blog.post.paginator.newerPost": {
|
||||
"message": "较新一篇",
|
||||
"description": "The blog post button label to navigate to the newer/previous post"
|
||||
},
|
||||
"theme.blog.post.paginator.olderPost": {
|
||||
"message": "较旧一篇",
|
||||
"description": "The blog post button label to navigate to the older/next post"
|
||||
},
|
||||
"theme.tags.tagsPageLink": {
|
||||
"message": "查看所有标签",
|
||||
"description": "The label of the link targeting the tag list page"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel": {
|
||||
"message": "切换浅色/暗黑模式(当前为{mode})",
|
||||
"description": "The ARIA label for the navbar color mode toggle"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel.mode.dark": {
|
||||
"message": "暗黑模式",
|
||||
"description": "The name for the dark color mode"
|
||||
},
|
||||
"theme.colorToggle.ariaLabel.mode.light": {
|
||||
"message": "浅色模式",
|
||||
"description": "The name for the light color mode"
|
||||
},
|
||||
"theme.docs.breadcrumbs.navAriaLabel": {
|
||||
"message": "页面路径",
|
||||
"description": "The ARIA label for the breadcrumbs"
|
||||
},
|
||||
"theme.docs.DocCard.categoryDescription.plurals": {
|
||||
"message": "{count} 个项目",
|
||||
"description": "The default description for a category card in the generated index about how many items this category includes"
|
||||
},
|
||||
"theme.docs.paginator.navAriaLabel": {
|
||||
"message": "文件选项卡",
|
||||
"description": "The ARIA label for the docs pagination"
|
||||
},
|
||||
"theme.docs.paginator.previous": {
|
||||
"message": "上一页",
|
||||
"description": "The label used to navigate to the previous doc"
|
||||
},
|
||||
"theme.docs.paginator.next": {
|
||||
"message": "下一页",
|
||||
"description": "The label used to navigate to the next doc"
|
||||
},
|
||||
"theme.docs.tagDocListPageTitle.nDocsTagged": {
|
||||
"message": "{count} 篇文档带有标签",
|
||||
"description": "Pluralized label for \"{count} docs tagged\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.docs.tagDocListPageTitle": {
|
||||
"message": "{nDocsTagged}「{tagName}」",
|
||||
"description": "The title of the page for a docs tag"
|
||||
},
|
||||
"theme.docs.versionBadge.label": {
|
||||
"message": "版本:{versionLabel}"
|
||||
},
|
||||
"theme.docs.versions.unreleasedVersionLabel": {
|
||||
"message": "此为 {siteTitle} {versionLabel} 版尚未发行的文档。",
|
||||
"description": "The label used to tell the user that he's browsing an unreleased doc version"
|
||||
},
|
||||
"theme.docs.versions.unmaintainedVersionLabel": {
|
||||
"message": "此为 {siteTitle} {versionLabel} 版的文档,现已不再积极维护。",
|
||||
"description": "The label used to tell the user that he's browsing an unmaintained doc version"
|
||||
},
|
||||
"theme.docs.versions.latestVersionSuggestionLabel": {
|
||||
"message": "最新的文档请参阅 {latestVersionLink} ({versionLabel})。",
|
||||
"description": "The label used to tell the user to check the latest version"
|
||||
},
|
||||
"theme.docs.versions.latestVersionLinkLabel": {
|
||||
"message": "最新版本",
|
||||
"description": "The label used for the latest version suggestion link label"
|
||||
},
|
||||
"theme.common.editThisPage": {
|
||||
"message": "编辑此页",
|
||||
"description": "The link label to edit the current page"
|
||||
},
|
||||
"theme.common.headingLinkTitle": {
|
||||
"message": "{heading}的直接链接",
|
||||
"description": "Title for link to heading"
|
||||
},
|
||||
"theme.lastUpdated.atDate": {
|
||||
"message": "于 {date} ",
|
||||
"description": "The words used to describe on which date a page has been last updated"
|
||||
},
|
||||
"theme.lastUpdated.byUser": {
|
||||
"message": "由 {user} ",
|
||||
"description": "The words used to describe by who the page has been last updated"
|
||||
},
|
||||
"theme.lastUpdated.lastUpdatedAtBy": {
|
||||
"message": "最后{byUser}{atDate}更新",
|
||||
"description": "The sentence used to display when a page has been last updated, and by who"
|
||||
},
|
||||
"theme.navbar.mobileVersionsDropdown.label": {
|
||||
"message": "选择版本",
|
||||
"description": "The label for the navbar versions dropdown on mobile view"
|
||||
},
|
||||
"theme.NotFound.title": {
|
||||
"message": "找不到页面",
|
||||
"description": "The title of the 404 page"
|
||||
},
|
||||
"theme.tags.tagsListLabel": {
|
||||
"message": "标签:",
|
||||
"description": "The label alongside a tag list"
|
||||
},
|
||||
"theme.AnnouncementBar.closeButtonAriaLabel": {
|
||||
"message": "关闭",
|
||||
"description": "The ARIA label for close button of announcement bar"
|
||||
},
|
||||
"theme.admonition.caution": {
|
||||
"message": "警告",
|
||||
"description": "The default label used for the Caution admonition (:::caution)"
|
||||
},
|
||||
"theme.admonition.danger": {
|
||||
"message": "危险",
|
||||
"description": "The default label used for the Danger admonition (:::danger)"
|
||||
},
|
||||
"theme.admonition.info": {
|
||||
"message": "信息",
|
||||
"description": "The default label used for the Info admonition (:::info)"
|
||||
},
|
||||
"theme.admonition.note": {
|
||||
"message": "备注",
|
||||
"description": "The default label used for the Note admonition (:::note)"
|
||||
},
|
||||
"theme.admonition.tip": {
|
||||
"message": "提示",
|
||||
"description": "The default label used for the Tip admonition (:::tip)"
|
||||
},
|
||||
"theme.admonition.warning": {
|
||||
"message": "注意",
|
||||
"description": "The default label used for the Warning admonition (:::warning)"
|
||||
},
|
||||
"theme.blog.sidebar.navAriaLabel": {
|
||||
"message": "最近博文导航",
|
||||
"description": "The ARIA label for recent posts in the blog sidebar"
|
||||
},
|
||||
"theme.CodeBlock.copied": {
|
||||
"message": "复制成功",
|
||||
"description": "The copied button label on code blocks"
|
||||
},
|
||||
"theme.CodeBlock.copyButtonAriaLabel": {
|
||||
"message": "复制代码到剪贴板",
|
||||
"description": "The ARIA label for copy code blocks button"
|
||||
},
|
||||
"theme.CodeBlock.copy": {
|
||||
"message": "复制",
|
||||
"description": "The copy button label on code blocks"
|
||||
},
|
||||
"theme.CodeBlock.wordWrapToggle": {
|
||||
"message": "切换自动换行",
|
||||
"description": "The title attribute for toggle word wrapping button of code block lines"
|
||||
},
|
||||
"theme.DocSidebarItem.expandCategoryAriaLabel": {
|
||||
"message": "展开侧边栏分类 '{label}'",
|
||||
"description": "The ARIA label to expand the sidebar category"
|
||||
},
|
||||
"theme.DocSidebarItem.collapseCategoryAriaLabel": {
|
||||
"message": "折叠侧边栏分类 '{label}'",
|
||||
"description": "The ARIA label to collapse the sidebar category"
|
||||
},
|
||||
"theme.NavBar.navAriaLabel": {
|
||||
"message": "主导航",
|
||||
"description": "The ARIA label for the main navigation"
|
||||
},
|
||||
"theme.navbar.mobileLanguageDropdown.label": {
|
||||
"message": "选择语言",
|
||||
"description": "The label for the mobile language switcher dropdown"
|
||||
},
|
||||
"theme.NotFound.p1": {
|
||||
"message": "我们找不到您要找的页面。",
|
||||
"description": "The first paragraph of the 404 page"
|
||||
},
|
||||
"theme.NotFound.p2": {
|
||||
"message": "请联系原始链接来源网站的所有者,并告知他们链接已损坏。",
|
||||
"description": "The 2nd paragraph of the 404 page"
|
||||
},
|
||||
"theme.TOCCollapsible.toggleButtonLabel": {
|
||||
"message": "本页总览",
|
||||
"description": "The label used by the button on the collapsible TOC component"
|
||||
},
|
||||
"theme.blog.post.readingTime.plurals": {
|
||||
"message": "阅读需 {readingTime} 分钟",
|
||||
"description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.blog.post.readMore": {
|
||||
"message": "阅读更多",
|
||||
"description": "The label used in blog post item excerpts to link to full blog posts"
|
||||
},
|
||||
"theme.blog.post.readMoreLabel": {
|
||||
"message": "阅读 {title} 的全文",
|
||||
"description": "The ARIA label for the link to full blog posts from excerpts"
|
||||
},
|
||||
"theme.docs.sidebar.collapseButtonTitle": {
|
||||
"message": "收起侧边栏",
|
||||
"description": "The title attribute for collapse button of doc sidebar"
|
||||
},
|
||||
"theme.docs.sidebar.collapseButtonAriaLabel": {
|
||||
"message": "收起侧边栏",
|
||||
"description": "The title attribute for collapse button of doc sidebar"
|
||||
},
|
||||
"theme.docs.breadcrumbs.home": {
|
||||
"message": "主页面",
|
||||
"description": "The ARIA label for the home page in the breadcrumbs"
|
||||
},
|
||||
"theme.docs.sidebar.navAriaLabel": {
|
||||
"message": "文档侧边栏",
|
||||
"description": "The ARIA label for the sidebar navigation"
|
||||
},
|
||||
"theme.docs.sidebar.closeSidebarButtonAriaLabel": {
|
||||
"message": "关闭导航栏",
|
||||
"description": "The ARIA label for close button of mobile sidebar"
|
||||
},
|
||||
"theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": {
|
||||
"message": "← 回到主菜单",
|
||||
"description": "The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)"
|
||||
},
|
||||
"theme.docs.sidebar.toggleSidebarButtonAriaLabel": {
|
||||
"message": "切换导航栏",
|
||||
"description": "The ARIA label for hamburger menu button of mobile navigation"
|
||||
},
|
||||
"theme.docs.sidebar.expandButtonTitle": {
|
||||
"message": "展开侧边栏",
|
||||
"description": "The ARIA label and title attribute for expand button of doc sidebar"
|
||||
},
|
||||
"theme.docs.sidebar.expandButtonAriaLabel": {
|
||||
"message": "展开侧边栏",
|
||||
"description": "The ARIA label and title attribute for expand button of doc sidebar"
|
||||
},
|
||||
"theme.SearchBar.seeAll": {
|
||||
"message": "查看全部 {count} 个结果"
|
||||
},
|
||||
"theme.SearchPage.documentsFound.plurals": {
|
||||
"message": "找到 {count} 份文件",
|
||||
"description": "Pluralized label for \"{count} documents found\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.SearchPage.existingResultsTitle": {
|
||||
"message": "「{query}」的搜索结果",
|
||||
"description": "The search page title for non-empty query"
|
||||
},
|
||||
"theme.SearchPage.emptyResultsTitle": {
|
||||
"message": "在文档中搜索",
|
||||
"description": "The search page title for empty query"
|
||||
},
|
||||
"theme.SearchPage.inputPlaceholder": {
|
||||
"message": "在此输入搜索字词",
|
||||
"description": "The placeholder for search page input"
|
||||
},
|
||||
"theme.SearchPage.inputLabel": {
|
||||
"message": "搜索",
|
||||
"description": "The ARIA label for search page input"
|
||||
},
|
||||
"theme.SearchPage.algoliaLabel": {
|
||||
"message": "通过 Algolia 搜索",
|
||||
"description": "The ARIA label for Algolia mention"
|
||||
},
|
||||
"theme.SearchPage.noResultsText": {
|
||||
"message": "未找到任何结果",
|
||||
"description": "The paragraph for empty search result"
|
||||
},
|
||||
"theme.SearchPage.fetchingNewResults": {
|
||||
"message": "正在获取新的搜索结果...",
|
||||
"description": "The paragraph for fetching new search results"
|
||||
},
|
||||
"theme.SearchBar.label": {
|
||||
"message": "搜索",
|
||||
"description": "The ARIA label and placeholder for search button"
|
||||
},
|
||||
"theme.SearchModal.searchBox.resetButtonTitle": {
|
||||
"message": "清除查询",
|
||||
"description": "The label and ARIA label for search box reset button"
|
||||
},
|
||||
"theme.SearchModal.searchBox.cancelButtonText": {
|
||||
"message": "取消",
|
||||
"description": "The label and ARIA label for search box cancel button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.recentSearchesTitle": {
|
||||
"message": "最近搜索",
|
||||
"description": "The title for recent searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.noRecentSearchesText": {
|
||||
"message": "没有最近搜索",
|
||||
"description": "The text when no recent searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.saveRecentSearchButtonTitle": {
|
||||
"message": "保存这个搜索",
|
||||
"description": "The label for save recent search button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.removeRecentSearchButtonTitle": {
|
||||
"message": "从历史记录中删除这个搜索",
|
||||
"description": "The label for remove recent search button"
|
||||
},
|
||||
"theme.SearchModal.startScreen.favoriteSearchesTitle": {
|
||||
"message": "收藏",
|
||||
"description": "The title for favorite searches"
|
||||
},
|
||||
"theme.SearchModal.startScreen.removeFavoriteSearchButtonTitle": {
|
||||
"message": "从收藏列表中删除这个搜索",
|
||||
"description": "The label for remove favorite search button"
|
||||
},
|
||||
"theme.SearchModal.errorScreen.titleText": {
|
||||
"message": "无法获取结果",
|
||||
"description": "The title for error screen of search modal"
|
||||
},
|
||||
"theme.SearchModal.errorScreen.helpText": {
|
||||
"message": "你可能需要检查网络连接。",
|
||||
"description": "The help text for error screen of search modal"
|
||||
},
|
||||
"theme.SearchModal.footer.selectText": {
|
||||
"message": "选中",
|
||||
"description": "The explanatory text of the action for the enter key"
|
||||
},
|
||||
"theme.SearchModal.footer.selectKeyAriaLabel": {
|
||||
"message": "Enter 键",
|
||||
"description": "The ARIA label for the Enter key button that makes the selection"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateText": {
|
||||
"message": "导航",
|
||||
"description": "The explanatory text of the action for the Arrow up and Arrow down key"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateUpKeyAriaLabel": {
|
||||
"message": "向上键",
|
||||
"description": "The ARIA label for the Arrow up key button that makes the navigation"
|
||||
},
|
||||
"theme.SearchModal.footer.navigateDownKeyAriaLabel": {
|
||||
"message": "向下键",
|
||||
"description": "The ARIA label for the Arrow down key button that makes the navigation"
|
||||
},
|
||||
"theme.SearchModal.footer.closeText": {
|
||||
"message": "关闭",
|
||||
"description": "The explanatory text of the action for Escape key"
|
||||
},
|
||||
"theme.SearchModal.footer.closeKeyAriaLabel": {
|
||||
"message": "Esc 键",
|
||||
"description": "The ARIA label for the Escape key button that close the modal"
|
||||
},
|
||||
"theme.SearchModal.footer.searchByText": {
|
||||
"message": "搜索提供",
|
||||
"description": "The text explain that the search is making by Algolia"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.noResultsText": {
|
||||
"message": "没有结果:",
|
||||
"description": "The text explains that there are no results for the following search"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.suggestedQueryText": {
|
||||
"message": "试试搜索",
|
||||
"description": "The text for the suggested query when no results are found for the following search"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.reportMissingResultsText": {
|
||||
"message": "认为这个查询应该有结果?",
|
||||
"description": "The text for the question where the user thinks there are missing results"
|
||||
},
|
||||
"theme.SearchModal.noResultsScreen.reportMissingResultsLinkText": {
|
||||
"message": "请告知我们。",
|
||||
"description": "The text for the link to report missing results"
|
||||
},
|
||||
"theme.SearchModal.placeholder": {
|
||||
"message": "搜索文档",
|
||||
"description": "The placeholder of the input of the DocSearch pop-up modal"
|
||||
},
|
||||
"theme.blog.post.plurals": {
|
||||
"message": "{count} 篇博文",
|
||||
"description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
|
||||
},
|
||||
"theme.blog.tagTitle": {
|
||||
"message": "{nPosts} 含有标签「{tagName}」",
|
||||
"description": "The title of the page for a blog tag"
|
||||
},
|
||||
"theme.blog.author.pageTitle": {
|
||||
"message": "{authorName} - {nPosts}",
|
||||
"description": "The title of the page for a blog author"
|
||||
},
|
||||
"theme.blog.authorsList.pageTitle": {
|
||||
"message": "Authors",
|
||||
"description": "The title of the authors page"
|
||||
},
|
||||
"theme.blog.authorsList.viewAll": {
|
||||
"message": "View All Authors",
|
||||
"description": "The label of the link targeting the blog authors page"
|
||||
},
|
||||
"theme.contentVisibility.unlistedBanner.title": {
|
||||
"message": "未列出页",
|
||||
"description": "The unlisted content banner title"
|
||||
},
|
||||
"theme.contentVisibility.unlistedBanner.message": {
|
||||
"message": "此页面未列出。搜索引擎不会对其索引,只有拥有直接链接的用户才能访问。",
|
||||
"description": "The unlisted content banner message"
|
||||
},
|
||||
"theme.contentVisibility.draftBanner.title": {
|
||||
"message": "Draft page",
|
||||
"description": "The draft content banner title"
|
||||
},
|
||||
"theme.contentVisibility.draftBanner.message": {
|
||||
"message": "This page is a draft. It will only be visible in dev and be excluded from the production build.",
|
||||
"description": "The draft content banner message"
|
||||
},
|
||||
"theme.ErrorPageContent.tryAgain": {
|
||||
"message": "重试",
|
||||
"description": "The label of the button to try again rendering when the React error boundary captures an error"
|
||||
},
|
||||
"theme.common.skipToMainContent": {
|
||||
"message": "跳到主要内容",
|
||||
"description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation"
|
||||
},
|
||||
"theme.tags.tagsPageTitle": {
|
||||
"message": "标签",
|
||||
"description": "The title of the tag list page"
|
||||
}
|
||||
}
|
||||
14
docs/i18n/zh-CN/docusaurus-plugin-content-blog/options.json
Normal file
14
docs/i18n/zh-CN/docusaurus-plugin-content-blog/options.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"title": {
|
||||
"message": "Blog",
|
||||
"description": "The title for the blog used in SEO"
|
||||
},
|
||||
"description": {
|
||||
"message": "Blog",
|
||||
"description": "The description for the blog used in SEO"
|
||||
},
|
||||
"sidebar.title": {
|
||||
"message": "Recent posts",
|
||||
"description": "The label for the left sidebar"
|
||||
}
|
||||
}
|
||||
50
docs/i18n/zh-CN/docusaurus-plugin-content-docs/current.json
Normal file
50
docs/i18n/zh-CN/docusaurus-plugin-content-docs/current.json
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
"version.label": {
|
||||
"message": "Next",
|
||||
"description": "The label for version current"
|
||||
},
|
||||
"sidebar.docsSidebar.category.Getting started": {
|
||||
"message": "开始",
|
||||
"description": "The label for category Getting started in sidebar docsSidebar"
|
||||
},
|
||||
"sidebar.docsSidebar.category.Chat": {
|
||||
"message": "聊天",
|
||||
"description": "The label for category Chat in sidebar docsSidebar"
|
||||
},
|
||||
"sidebar.docsSidebar.category.Autocomplete": {
|
||||
"message": "自动补全",
|
||||
"description": "The label for category Autocomplete in sidebar docsSidebar"
|
||||
},
|
||||
"sidebar.docsSidebar.category.Edit": {
|
||||
"message": "编辑",
|
||||
"description": "The label for category Edit in sidebar docsSidebar"
|
||||
},
|
||||
"sidebar.docsSidebar.category.Actions": {
|
||||
"message": "Actions",
|
||||
"description": "The label for category Actions in sidebar docsSidebar"
|
||||
},
|
||||
"sidebar.docsSidebar.link.Customize": {
|
||||
"message": "定制",
|
||||
"description": "The label for link Customize in sidebar docsSidebar, linking to /customize/overview"
|
||||
},
|
||||
"sidebar.customizingSidebar.category.Model providers": {
|
||||
"message": "模型提供者",
|
||||
"description": "The label for category Model providers in sidebar customizingSidebar"
|
||||
},
|
||||
"sidebar.customizingSidebar.category.More": {
|
||||
"message": "更多",
|
||||
"description": "The label for category More in sidebar customizingSidebar"
|
||||
},
|
||||
"sidebar.customizingSidebar.category.Model types": {
|
||||
"message": "模型类型",
|
||||
"description": "The label for category Model types in sidebar customizingSidebar"
|
||||
},
|
||||
"sidebar.customizingSidebar.category.Deep dives": {
|
||||
"message": "深入理解",
|
||||
"description": "The label for category Deep dives in sidebar customizingSidebar"
|
||||
},
|
||||
"sidebar.customizingSidebar.category.Tutorials": {
|
||||
"message": "教程",
|
||||
"description": "The label for category Tutorials in sidebar customizingSidebar"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
title: 上下文选择
|
||||
description: Actions \-上下文选择
|
||||
keywords: [上下文, 斜杠, 调试, 快速修复, 右击]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
## 斜杠命令
|
||||
|
||||
斜杠命令可以与更多的指令结合,包括 [上下文提供者](chat/context-selection.md) 或 [高亮代码](chat/context-selection.md) 。
|
||||
|
||||
例如,使用 "/edit" 斜杠命令,你应该描述你想要 LLM 执行的编辑。
|
||||
|
||||
一些斜杠命令不会理会你的输入,例如, "/share" 斜杠命令只是创建一个当前交谈的 markdown 副本,忽略任何你请求它做的。
|
||||
|
||||
## 快速 action
|
||||
|
||||
快速 action 总是显示在一个类和函数上,将会编辑那个类或函数,但是不会对外面的东西有影响。
|
||||
|
||||
## 右击 action
|
||||
|
||||
你选择的高亮代码将会包含在你的提示词中,和一些基于选择的 action 提前写好的指令一起。这是模型想要尝试的仅有的代码块。
|
||||
|
||||
## 调试 action
|
||||
|
||||
调试 action 选择最近运行的终端命令以及它的输出,然后插入以下提示词到聊天窗口中。没有更多的,不可见的信息发送给语言模型。
|
||||
|
||||
```
|
||||
I got the following error, can you please help explain how to fix it?
|
||||
|
||||
[ERROR_MESSAGE]
|
||||
```
|
||||
|
||||
## 快速修复
|
||||
|
||||
类似于调试 action ,快速 action 透明地添加提示词到聊天窗口中。当你选择 "Ask Continue" ,错误的上下 3 行会发送给聊天,跟上问题 "How do I fix the following problem in the above code?: [ERROR_MESSAGE]" 。
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: 它是如何工作的
|
||||
description: actions 是如何工作的
|
||||
keywords: [如何, 斜杠, 命令, 提示词, 右击, 快速修复, 调试, action]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
很多 action 基于模板提示词,可以使用 .prompt 文件配置,在底层有一些执行更复杂的代码。
|
||||
|
||||
action 生成行内 diff ,比如 "/edit", "/comment" 或右击 action ,使用与 [编辑](edit/how-it-works.md) 相同的提示词和响应处理逻辑。
|
||||
|
||||
要了解其他斜杠命令如何工作的, [在这里](../customize/slash-commands.md) 查看完整参考。
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
title: 如何定制
|
||||
description: 如何定制 actions
|
||||
keywords: [定制, actions]
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
## 内置的斜杠命令
|
||||
|
||||
Continue 有一个大的内置斜杠命令库,但是当你首次安装时,我们只显示最常用的一些,比如 "/edit", "/comment" 和 "/share" 。为了添加更多的 action ,你可以打开 [config.json](../customize/config.mdx) 并添加它们到 `slashCommands` 列表中。
|
||||
|
||||
## 定制斜杠命令
|
||||
|
||||
有两种方法添加定制斜杠命令:
|
||||
|
||||
1. 使用 `.prompt` 文件 - 这是大多数情况下推荐的。[在这里](../customize/deep-dives/prompt-files.md) 查看完整参考。
|
||||
2. 使用 `config.ts` - 这给你对于 LLM, IDE 和其他重要的入口可编程的访问,通过编写 JavaScript/TypeScript 函数
|
||||
|
||||
### 使用 `config.ts` 定制斜杠命令
|
||||
|
||||
<!-- TODO: We need a config.ts reference -->
|
||||
<!-- :::tip[config.ts]
|
||||
Before adding a custom slash command, we recommend reading the [introduction to `config.ts`](../customize/config.mdx).
|
||||
::: -->
|
||||
|
||||
如果你想比使用自然语言编写定制命令更进一步,你可以编写一个定制函数返回响应。这需要使用 `config.ts` 替代 `config.json` 。
|
||||
|
||||
要做这个,放一个新的 `SlashCommand` 对象到 `slashCommands` 列表中。这个对象包含 "name" ,你输入用来触发斜杠命令的名字, "description", 在下拉菜单中看到的描述,以及 "run" 。 `run` 函数是任何异步生成器,应该生成你希望流式地返回到 UI 的字符串。作为这个函数的一个参数,你可以访问 `ContinueSDK` 对象实用工具,例如访问 IDE 中确定的信息/action ,当前的语言模型,以及一些其他的实用工具。例如,这是一个生成 commit 说明的斜杠命令:
|
||||
|
||||
```typescript title="config.ts"
|
||||
export function modifyConfig(config: Config): Config {
|
||||
config.slashCommands?.push({
|
||||
name: "commit",
|
||||
description: "Write a commit message",
|
||||
run: async function* (sdk) {
|
||||
const diff = await sdk.ide.getDiff();
|
||||
for await (const message of sdk.llm.streamComplete(
|
||||
`${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`,
|
||||
{
|
||||
maxTokens: 20,
|
||||
},
|
||||
)) {
|
||||
yield message;
|
||||
}
|
||||
},
|
||||
});
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
<!-- TODO: We need a config.ts reference -->
|
||||
<!-- For full `config.ts` reference, see [here](reference/config-ts.md). -->
|
||||
|
||||
## 其他定制 action
|
||||
|
||||
目前,其他 action 触发器没有开放配置,但是我们计划在未来通过 .prompt 文件来允许。
|
||||
|
||||
<!-- For any actions defined in a .prompt file, you can [configure a specific model](TODO). -->
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
---
|
||||
title: Actions
|
||||
description: 如何使用 Actions
|
||||
sidebar_label: 如何使用它
|
||||
keywords: [如何, 斜杠, 命令, 提示词, 右击, 快速修复, 调试, 操作]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||

|
||||
|
||||
## 如何使用它
|
||||
|
||||
Actions 是常见用例的快捷方式。例如,你可能想要审查代码,编写测试,或添加一个文档字符串。
|
||||
|
||||
### 斜杠命令
|
||||
|
||||
最常见的调用 action 的方法是使用斜杠命令。通过输入 '/' 并在下拉框中选择,这里有快捷方式会被激活。例如,内置的 '/edit' 斜杠命令,让你可以直接在你的编辑器中流式地编辑。
|
||||
|
||||

|
||||
|
||||
一些最常用的斜杠命令默认是可用的,比如 "/edit", "/comment" 和 "/share" ,但是 Continue 有大量内置的其他选择的库。要启用它们,[在这里](../customize/slash-commands.md) 了解更多。
|
||||
|
||||
### prompt 文件
|
||||
|
||||
通过定义一个 ".prompt 文件" ,也可以编写你自己的斜杠命令。 prompt 文件可以是个简单的文本文件,但是也包含模板,所以你可以引用文件, URL ,高亮代码以及更多。
|
||||
|
||||
完整的 .prompt 文件可以参考 [这里](../customize/deep-dives/prompt-files.md) 。
|
||||
|
||||
:::tip[Prompt 库]
|
||||
为了帮助你开始,[我们精心编写了一个小的 `.prompt` 文件库](https://github.com/continuedev/prompt-file-examples) 。我们鼓励社区贡献到这个仓库,所以请考虑为你的 prompt 创建一个拉取请求!
|
||||
:::
|
||||
|
||||
以下是一个快速示例,设置一个使用 Jest 编写单元测试的 prompt 文件。
|
||||
|
||||
1. 在你的工作区的最高层级,创建一个名为 `.prompts/` 的目录。
|
||||
2. 在这个目录中,添加一个名为 `test.prompt` 的文件。这个文件的名称将是你用来生成提示词的斜杠命令的名称。
|
||||
3. 写入以下内容到 `test.prompt` 并保存。
|
||||
|
||||
```
|
||||
{{{ input }}}
|
||||
|
||||
Write unit tests for the above selected code, following each of these instructions:
|
||||
- Use `jest`
|
||||
- Properly set up and tear down
|
||||
- Include important edge cases
|
||||
- The tests should be complete and sophisticated
|
||||
- Give the tests just as chat output, don't edit any file
|
||||
- Don't explain how to set up `jest`
|
||||
```
|
||||
|
||||
现在要使用这个提示词,你可以高亮代码,并使用 `cmd/ctrl+L` 来选择它到 Continue 侧边栏中。
|
||||
|
||||
然后,输入 "/" 来查看斜杠命令列表,选择名为 "test" 的那个。按下回车, LLM 会响应你的 prompt 文件中给出的指令。
|
||||
|
||||
### action 的其他触发器 (VS Code)
|
||||
|
||||
:::info
|
||||
目前,所有这些只在 VS Code 中有效
|
||||
:::
|
||||
|
||||
为了让常见用例更可用,我们提供了一些其他方法来触发 action 。
|
||||
|
||||
#### 快速 action
|
||||
|
||||
快速 action 在你源码中的顶级类和函数上显示为按钮,让你可以一键触发 action 。它们也可以使用 .prompt 文件定制,来执行定制的 action 。
|
||||
|
||||

|
||||
|
||||
默认情况下,快速 action 是禁用的,但是可以在 VS Code 的设置中通过 "Continue: Enable Quick Actions" 启用。
|
||||
|
||||
#### 右击 action
|
||||
|
||||
右击 action 让你高亮期望的代码区域,右击,然后在下拉菜单中选择一个 action 。
|
||||
|
||||

|
||||
|
||||
#### 调试 action
|
||||
|
||||
调试 action 是 VS Code 扩展中一个特殊的内置键盘快捷方式。使用 `cmd/ctrl+shift+R` 来快速复制当前终端的内容到聊天侧边栏,并获得调试建议。
|
||||
|
||||
#### 快速修复
|
||||
|
||||
无论何时在你的代码中看到红色/黄色下划线表示错误,你可以把光标放到附近, VS Code 会显示一个灯泡图标。无论点击灯泡,或使用 `cmd/ctrl+.` 快捷键,将会显示一个快速修复的下拉菜单。其中之一是 "Ask Continue" action 。无论单击或再次使用 `cmd/ctrl+.` , Continue 将尝试帮助解决问题。
|
||||
|
||||

|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
title: 模型设置
|
||||
description: Actions 模型设置
|
||||
keywords: [模型]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
默认情况下, action 使用与 [聊天](chat/model-setup.mdx) 相同的模型,所以,对于执行的复杂指令,我们推荐相同的 400B+ 参数模型或者领先的模型之一。
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
title: 上下文选择
|
||||
description: 自动补全上下文选择
|
||||
keywords: [上下文, 自动补全, lsp, 最近的]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
自动补全会基于当前的光标位置自动地确定上下文。我们使用以下的技术来确定什么包含在提示词中:
|
||||
|
||||
### 文件前缀/后缀
|
||||
|
||||
我们总是包含你的文件中光标前后的代码。
|
||||
|
||||
### 来自语言服务协议的定义
|
||||
|
||||
类似于你如何在编辑器中使用 `cmd/ctrl + click` ,我们使用相同的工具 (LSP) 来增强 "转到定义" 。例如,如果你输入一个函数调用,我们将包含函数定义。或者,如果你在一个方法中写代码,我们将包含类型定义中的任何参数或返回类型。
|
||||
|
||||
### 导入文件
|
||||
|
||||
因为通常有很多导入,我们不能包含它们所有。相反,我们查找你的光标附近的标识,使用它所匹配的导入作为上下文。
|
||||
|
||||
### 最近的文件
|
||||
|
||||
我们自动考虑最近打开的或编辑的文件,并包含与当前补全相关的片段。
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: 它是如何工作的
|
||||
description: 自动补全是如何工作的
|
||||
keywords: [如何, 自动补全, 上下分]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
自动补全是一个 [复合人工智能系统](https://bair.berkeley.edu/blog/2024/02/18/compound-ai-systems/),使用检索方法和响应处理技术的结合。系统可以大致理解为三个部分。
|
||||
|
||||
## 时机
|
||||
|
||||
为了快速地显示建议,并且不需要发送太多请求,我们做了下面这些:
|
||||
|
||||
- 去抖动: 如果你快速输入,我们不会为每个按键创建一个请求。相反,我们等待直到你完成输入。
|
||||
- 缓存: 如果你的光标在一个我们已经生成补全的位置,这个补全将会被使用。例如,如果你回退,我们将可以直接显示你之前看到的建议。
|
||||
|
||||
## 上下文
|
||||
|
||||
就像 [上下文选择](context-selection.md) 页面解释的那样, Continue 使用了大量的检索方法,来查找你的代码库中相关的片断,包含在提示词中。
|
||||
|
||||
## 过滤
|
||||
|
||||
语言模型不是完美的,但是可以通过调整它们的输出接近完美。在显示建议之前,我们对响应做了大量的后处理,包括:
|
||||
|
||||
- 过滤出指定的 token
|
||||
- 当重新生成代码时,提前停止
|
||||
- 修复缩进
|
||||
|
||||
如果响应是坏的,我们也会偶尔过滤掉整个响应。这通常是因为过度的重复。
|
||||
|
||||
You can learn more about how it works in the [Autocomplete deep dive](../customize/deep-dives/autocomplete.md).
|
||||
|
||||
你可以在 [深入理解自动补全](../customize/deep-dives/autocomplete.md) 中了解它是如何工作的。
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
title: 如何定制
|
||||
description: 如何定制自动补全
|
||||
keywords: [定制]
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
Continue 在 [`config.json`](../customize/config.mdx) 提供少量的参数,对于你的特定需求和硬件能力,可以调整找到建议质量和系统性能之间的最佳平衡:
|
||||
|
||||
```json title="config.json"
|
||||
"tabAutocompleteOptions": {
|
||||
"useCopyBuffer": false,
|
||||
"maxPromptTokens": 400,
|
||||
"prefixPercentage": 0.5,
|
||||
"multilineCompletions": "always"
|
||||
}
|
||||
```
|
||||
|
||||
- `useCopyBuffer`: 决定剪贴板的内容是否包含在提示词构建中
|
||||
- `maxPromptTokens`: 设置提示词的最大 token 数,平衡上下文和速度
|
||||
- `prefixPercentage`: 决定提示词使用光标前代码的比例
|
||||
- `multilineCompletions`: 控制建议是否可以跨多行 ("always", "never" 或 "auto")
|
||||
|
||||
对于所有配置选项和它们的影响的综合指南,查看 [深入理解自动补全](../customize/deep-dives/autocomplete.md) 。
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
title: 自动补全
|
||||
description: 自动补全 \- 如何使用它
|
||||
sidebar_label: 如何使用它
|
||||
keywords: [如何]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||

|
||||
|
||||
## 如何使用它
|
||||
|
||||
自动补全随着你的输入提供行内代码建议。要启用它,只需要简单地点击状态栏中的 "Continue" 按钮,在你的 IDE 右下侧,或者在你的 IDE 设置中勾选 "启用 Tab 自动补全" 选项。
|
||||
|
||||
### 接受整个建议
|
||||
|
||||
按下 `Tab` ,接受整个建议
|
||||
|
||||
### 拒绝整个建议
|
||||
|
||||
按下 `Esc` ,拒绝整个建议
|
||||
|
||||
### 部分接受建议
|
||||
|
||||
对于更细粒度的控制,使用 `cmd/ctrl + →` 来逐字地接受部分建议。
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
title: 模型设置
|
||||
description: 自动补全 \- 模型设置
|
||||
keywords: [模型, 自动补全]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
## 最好的总体体验
|
||||
|
||||
为了最好的自动补全体验,我们推荐通过 [Mistral API](https://console.mistral.ai/) 使用 Codestral 。这个模型提供高质量的补全,使用极好的代码上下文理解:
|
||||
|
||||
```json title="config.json""
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
:::tip[Codestral API Key]
|
||||
Codestral 的 API key 和通常的 Mistral API 是不同的。如果你使用 Codestral ,你可能想要一个 Codestral API key ,但是如果你想分享 key 给团队或其他人想要使用 `api.mistral.ai` ,那么确保在你的 `tabAutocompleteModel` 中设置 `"apiBase": "https://api.mistral.ai/v1"` 。
|
||||
:::
|
||||
|
||||
## 本地的,离线的/自托管的体验
|
||||
|
||||
对于倾向于本地执行或自托管的, `StarCoder2-3b` 提供了一个对于大多数用户性能和质量的平衡:
|
||||
|
||||
```json title="config.json""
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "StarCoder2-3b",
|
||||
"model": "starcoder2:3b",
|
||||
"provider": "ollama"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 可替代的体验
|
||||
|
||||
- 补全太慢?在更弱的机器上,试试 `deepseek-coder:1.3b-base` 更快的补全
|
||||
- 有更多的计算?使用 `deepseek-coder:6.7b-base` 获取可能更高质量的建议
|
||||
|
||||
:::note
|
||||
对于 LM Studio 用户,导航到 "My Models" 章节,找到你想要的模型,复制它的路径 (例如, second-state/StarCoder2-3B-GGUF/starcoder2-3b-Q8_0.gguf) 。使用这个路径作为你的配置中的 `model` 值。
|
||||
:::
|
||||
|
||||
## 其他体验
|
||||
|
||||
有很多更多的模型或提供者可以用来补全。在 [这里](../customize/model-types/autocomplete.md) 查看它们。
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
title: 上下文选择
|
||||
description: 如何为聊天选择上下文
|
||||
keywords: [上下文]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
## 输入
|
||||
|
||||
输入一个问题或指令到输入框中是仅有的必须的上下文。所有列在下面选择和包含更多上下文的其他方法都是可选的。
|
||||
|
||||
## 高亮代码
|
||||
|
||||
你通过按下 `cmd/ctrl + L` (VS Code) 或 `cmd/ctrl + J` (JetBrains) 选择的高亮代码,将包含在你的提示词中,和你提供的输入一起。这是提供给模型的仅有的代码片段,除非你高亮更多的片段,或使用以下的选择方法之一。
|
||||
|
||||
## 活动文件
|
||||
|
||||
在发送请求时,你可以通过按下 `cmd/ctrl + opt + enter` 包含当前打开的文件作为上下文。
|
||||
|
||||
## 指定文件
|
||||
|
||||
你可以通过输入 [`@Files`](../customize/context-providers.md#files) 并选择文件,包含当前工作区中的指定文件作为上下文。
|
||||
|
||||
## 指定目录
|
||||
|
||||
你可以通过输入 [`@Folder`](../customize/context-providers.md#folders) 并选择目录,包含当前工作区中指定目录作为上下文。它像 [`@Codebase`](../customize/deep-dives/codebase.md) 一样工作,但是只包含指定目录中的文件。
|
||||
|
||||
## 整个代码库
|
||||
|
||||
你可以通过输入 [`@Codebase`](../customize/context-providers.md#codebase-retrieval) 包含整个代码库作为上下文。你可以 [在这里](../customize/deep-dives/codebase.md) 了解 `@Codebase` 是如何工作的。
|
||||
|
||||
## 文档网址
|
||||
|
||||
你可以通过输入 [`@Docs`](../customize/context-providers.md#documentation) 并选择文档网址,包含文档网址作文上下文。你可以 [在这里](../customize/deep-dives/docs.md) 了解 `@Docs` 是如何工作的。
|
||||
|
||||
## 终端内容
|
||||
|
||||
你可以通过输入 [`@Terminal`](../customize/context-providers.md#terminal) ,包含 IDE 中终端的内容作为上下文。
|
||||
|
||||
## Git diff
|
||||
|
||||
你可以通过输入 [`@Git Diff`](../customize/context-providers.md#git-diff) ,包含当前分支中你做的所有变更作为上下文。
|
||||
|
||||
## 其他上下文
|
||||
|
||||
你可以 [在这里](../customize/context-providers.md) 看到完整的内置上下文提供者列表,以及 [在这里](../customize/tutorials/build-your-own-context-provider.md) 看到如何创建你自己定制的上下文提供者。
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: 它是如何工作的
|
||||
description: 聊天是如何工作的
|
||||
keywords: [如何, 聊天, 工作]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
使用任何选择的代码片段,你使用 @ 选择的所有上下文,以及你的输入指令,在侧边栏中,我们将提示词给模型,让它提供一个响应。如果你询问跟进的问题,那么所有前面的会话上下文也会被包含。没有其他更多的上下文提供给模型。
|
||||
|
||||
模型的响应会直接流式地返回到侧边栏。每个响应中的代码片段将放在它自己的代码块中,每个代码块会给你一些按钮,“应用到当前文件”, “插入到光标处” 或 “复制” 。当你在会话的结尾按下 `cmd/ctrl + L` (VS Code) 或 `cmd/ctrl + J` (JetBrains) ,所有上下文会被清除,一个新的会话将会开始,让你可以开始一个新的任务。
|
||||
|
||||
如果你想查看聊天中发送给模型的确切的提示词,你可以 [在提示词日志中查看这个](troubleshooting.md#llm-prompt-logs) 。
|
||||
|
||||
You can learn more about how `@Codebase` works [here](../customize/deep-dives/codebase.md) and `@Docs` [here](../customize/deep-dives/docs.md).
|
||||
|
||||
你可以 [在这里](../customize/deep-dives/codebase.md) 了解 `@Codebase` 是如何工作的, 以及 [在这里](../customize/deep-dives/docs.md) 了解 `@Docs` 。
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
title: 如何定制
|
||||
description: 如何定制聊天
|
||||
keywords: [定制, 聊天]
|
||||
sidebar_position: 5
|
||||
---
|
||||
|
||||
这里有多种不同的方法来定制聊天
|
||||
|
||||
- 你可以配置 [`@Codebase`](../customize/deep-dives/codebase.md)
|
||||
- 你可以创建自己的 [定制代码 RAG](../customize/tutorials/custom-code-rag.md)
|
||||
- 你可以配置 [`@Docs`](../customize/deep-dives/docs.md)
|
||||
- 你可以 [构建自己的上下文提供者](../customize/tutorials/build-your-own-context-provider.md)
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
---
|
||||
title: 聊天
|
||||
description: 如何使用聊天
|
||||
sidebar_label: 如何使用它
|
||||
keywords: [如何, 使用, 聊天]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||

|
||||
|
||||
## 如何使用它
|
||||
|
||||
聊天方便向 LLM 寻求帮助,而不需要离开 IDE 。你发送一个任务给它,包含任何相关信息,它回复最可能完成那个任务的文本或代码。如果它没有给出你想要的,那么你可以发送追加的消息,来明确和调整它的建议,直到任务完成。
|
||||
|
||||
聊天最好用来理解和迭代代码或者作为搜索引擎查询的替代。
|
||||
|
||||
## 输入请求并按下回车
|
||||
|
||||
你发送一个问题给它,它回复答案。你告诉它解决一个问题,它提供一个解决方案。你请求一些代码,它生成代码。
|
||||
|
||||
## 高亮代码片段作为上下文
|
||||
|
||||
你使用鼠标选择代码片段,按下 `cmd/ctrl + L` (VS Code) 或 `cmd/ctrl + J` (JetBrains) 将它发送给 LLM ,然后让它给你解释,或者请求它以某种方式优化。
|
||||
|
||||
## 使用 @ 符号标记上下文
|
||||
|
||||
如果有来自代码库,文档, IDE 或其他工具的信息,你想要包含在上下文中,你可以输入 @ 来选择和包含它作为上下文。你可以在 [聊天上下文选择](context-selection.md) 中了解更多关于如何使用这个。
|
||||
|
||||
## 应用生成的代码到你的文件中
|
||||
|
||||
当 LLM 回复编辑到文件中,你可以点击 “应用” 按钮。这将更新编辑器中存在的代码,对建议的变更作出反应。
|
||||
|
||||
## 对于新的任务开始一个新的会话
|
||||
|
||||
一旦你完成任务,想要开始一个新的,按下 `cmd/ctrl + L` (VS Code) 或 `cmd/ctrl + J` (JetBrains) 来开始一个新的会话,确保只有下一个任务相关的上下文提供给 LLM 。
|
||||
|
||||
## 在不同的模型中切换
|
||||
|
||||
如果你配置了多个模型,你可以使用下拉框或按下 `cmd/ctrl + ’`在不同的模型中切换。
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
---
|
||||
title: 模型设置
|
||||
description: 如何设置一个聊天模型
|
||||
keywords: [模型]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
|
||||
:::info
|
||||
这个页面推荐聊天的模型和提供者。在 [这里](../customize/config.mdx) 了解更多关于如何设置你的 `config.json` 。
|
||||
:::
|
||||
|
||||
## 最好的总体体验
|
||||
|
||||
为了最好的总体聊天体验,你将想要使用一个 400B+ 参数模型或领先的模型之一。
|
||||
|
||||
### 来自 Anthropic 的 Claude Sonnet 3.5
|
||||
|
||||
我们现在最推荐的是来自 [Anthropic](../customize/model-providers/top-level/anthropic.md) 的 Claude Sonnet 3.5 。
|
||||
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"apiKey": "[ANTHROPIC_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### 来自 Meta 的 Llama 3.1 405B
|
||||
|
||||
如果你倾向于使用开放权重模型,那么来自 Meta 的 Llama 3.1 405B 是你当前的最好选择。你需要决定,通过 SaaS 模型提供者使用它(比如 [Together](../customize/model-providers/more/together.md) 或 [Groq](../customize/model-providers/more/groq.md))或者自托管使用它(比如使用 [vLLM](../customize/model-providers//more/vllm.md) 或 [Ollama](../customize/model-providers/top-level/ollama.md)) 。
|
||||
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Together">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "together",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "[TOGETHER_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Groq">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "groq",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "[GROQ_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="vLLM">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "vllm",
|
||||
"model": "llama3.1-405b"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="Ollama">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405B",
|
||||
"provider": "ollama",
|
||||
"model": "llama3.1-405b"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 来自 OpenAI 的 GPT-4o
|
||||
|
||||
如果你倾向于使用来自 [OpenAI](../customize/model-providers/top-level/openai.md) 的模型,那么我们推荐 GPT-4o 。
|
||||
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "GPT-4o",
|
||||
"provider": "openai",
|
||||
"model": "",
|
||||
"apiKey": "[OPENAI_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### 来自 Google 的 Gemini 1.5 Pro
|
||||
|
||||
如果你倾向于使用来自 [Google](../customize/model-providers/top-level/gemini.md) 的模型,那么我们推荐 Gemini 1.5 Pro 。
|
||||
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Gemini 1.5 Pro",
|
||||
"provider": "gemini",
|
||||
"model": "gemini-1.5-pro-latest",
|
||||
"apiKey": "[GEMINI_API_KEY]"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## 本地的,离线的体验
|
||||
|
||||
为了最好的本地的,离线的聊天体验,你想要你的机器上使用一个大的但是足够快的模型。
|
||||
|
||||
### Llama 3.1 8B
|
||||
|
||||
如果你的本地机器可以运行一个 8B 参数的模型,那么我们推荐在你的机器上运行 Llama 3.1 8B (比如使用 [Ollama](../customize/model-providers/top-level/ollama.md) 或 [LM Studio](../customize/model-providers/more/lmstudio.md))。
|
||||
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Ollama">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 8B",
|
||||
"provider": "ollama",
|
||||
"model": "llama3.1-8b"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="LM Studio">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 8B",
|
||||
"provider": "lmstudio",
|
||||
"model": "llama3.1-8b"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### DeepSeek Coder 2 16B
|
||||
|
||||
如果你的机器可以运行一个 16B 参数的模型,那么我们推荐运行 DeepSeek Coder 2 16B (比如使用 [Ollama](../customize/model-providers/top-level/ollama.md) 或 [LM Studio](../customize/model-providers/more/lmstudio.md))。
|
||||
|
||||
<Tabs groupId="providers">
|
||||
<TabItem value="Ollama">
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "DeepSeek Coder 2 16B",
|
||||
"provider": "ollama",
|
||||
"model": "deepseek-coder-v2:16b"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="LM Studio">
|
||||
|
||||
```json title="config.json"
|
||||
"models": [
|
||||
{
|
||||
"title": "DeepSeek Coder 2 16B",
|
||||
"provider": "lmstudio",
|
||||
"model": "deepseek-coder-v2:16b"
|
||||
}
|
||||
]
|
||||
```
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## 其他体验
|
||||
|
||||
除了以上提到的这些,还有更多的模型和提供者,你可以使用来聊天。在 [这里](../customize/model-types/chat.md) 了解更多。
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
title: 变更日志
|
||||
description: VSCode 和 JetBrains 扩展最新版本的变更日志
|
||||
keywords: [变更日志]
|
||||
hide_table_of_contents: true
|
||||
---
|
||||
|
||||
import VSCodeChangelog from "../../../../../../extensions/vscode/CHANGELOG.md";
|
||||
import JetBrainsChangelog from "../../../../../../extensions/intellij/CHANGELOG.md";
|
||||
|
||||
以下是 VSCode 和 JetBrains 扩展最新版本的变更日志。在 2024-07-02 之前,变更日志没有反映所有更新。
|
||||
|
||||
import TOCInline from "@theme/TOCInline";
|
||||
|
||||
<TOCInline
|
||||
toc={toc.filter(
|
||||
(node) =>
|
||||
node.value === "VSCode Changelog" || node.value === "JetBrains Changelog",
|
||||
)}
|
||||
/>
|
||||
|
||||
<hr />
|
||||
|
||||
## VSCode 变更日志
|
||||
|
||||
<VSCodeChangelog />
|
||||
|
||||
## JetBrains 变更日志
|
||||
|
||||
<JetBrainsChangelog />
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
title: config.json 参考
|
||||
keywords: [config.json, 配置, 选项]
|
||||
---
|
||||
|
||||
import Schema from "@site/static/schemas/config.json";
|
||||
import JSONSchemaViewer from "@theme/JSONSchemaViewer";
|
||||
|
||||
# 配置选项
|
||||
|
||||
以下显示在 `config.json` 定义的 JSON Schema 。
|
||||
|
||||
你还可以定义部分的 `config.json` 对象,在一个在你的工作区根目录名为 `.continuerc.json` 的文件中。这将应用在来自 `config.json` 的任何配置之上。
|
||||
|
||||
<JSONSchemaViewer
|
||||
schema={Schema}
|
||||
resolverOptions={{
|
||||
jsonPointer: "#/definitions/SerializedContinueConfig",
|
||||
}}
|
||||
/>
|
||||
|
||||
[查看源码](https://github.com/continuedev/continue/blob/main/extensions/vscode/config_schema.json)
|
||||
|
|
@ -0,0 +1,487 @@
|
|||
---
|
||||
title: 上下文提供者
|
||||
description: 输入 '@' 选择内容到 LLM 作为上下文
|
||||
keywords: [上下文, "@", 提供者, LLM]
|
||||
---
|
||||
|
||||
上下文提供者允许你输入 '@' ,看到一个上下文下拉框,都可以提供给 LLM 作为上下文。每个上下文提供者是一个插件,也就是说,如果你想要关联一些没有在这里看到的信息源,你可以请求(或构建!)一个新的上下文提供者。
|
||||
|
||||
举一个例子,比如你工作在解决一个新的 GitHub Issue 。你输入 '@Issue' 并选择你工作的那个。 Continue 现在可以看到 issue 标题和内容。你还知道那个 issue 关联到文件 'readme.md' 和 'helloNested.py' ,所以你输入 '@readme' 和 '@hello' 查看并选择它们。现在,这里有 3 个 "上下文条目" 在行内显示,和你的其他输入一起。
|
||||
|
||||

|
||||
|
||||
## 内置的上下文提供者
|
||||
|
||||
为了使用任何内置的上下文提供者,打开 `config.json` 并将它添加到 `contextProviders` 列表中。
|
||||
|
||||
### `@File`
|
||||
|
||||
关联你的当前工作区的任何文件。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "file"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Code`
|
||||
|
||||
关联你的项目中特定的函数或类。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Git Diff`
|
||||
|
||||
关联你对当前分支所在的所有修改。这是有用的,如果你想要在提交之前,总结你做了什么,或询问一个关于你的工作通用的评审。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "diff"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Terminal`
|
||||
|
||||
关联你的 IDE 终端的内容。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Docs`
|
||||
|
||||
关联任何文档网站的内容。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "docs"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
注意这只启用 `@Docs` 上下文提供者。
|
||||
|
||||
为了使用它,你需要添加一个文档网站到你的 `config.json` 。查看 [docs](../customize/deep-dives/docs.md) 页面获取更多信息。
|
||||
|
||||
### `@Open`
|
||||
|
||||
关联你打开的所有文件的内容。设置 `onlyPinned` 为 `true` 只关联固定的文件。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "open",
|
||||
"params": {
|
||||
"onlyPinned": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Codebase`
|
||||
|
||||
关联你的代码库中最相关的片段。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "codebase"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
在 [这里](../customize/deep-dives/codebase.md) 查看更多关于索引和检索。
|
||||
|
||||
### `@Folder`
|
||||
|
||||
使用和 `@Codebase` 相同的检索机制,但是只在一个单独的文件夹上。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "folder"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Search`
|
||||
|
||||
关联代码库搜索的结果,就像你从 VS Code 搜索获得的结果。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "search"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
这个上下文提供者是由 [ripgrep](https://github.com/BurntSushi/ripgrep) 支持的。
|
||||
|
||||
### `@Url`
|
||||
|
||||
关联给定 URL 的 markdown 转换内容。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "url"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Tree`
|
||||
|
||||
关联你当前工作区的结构。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "tree"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@Google`
|
||||
|
||||
关联 Google 搜索的结果。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "google",
|
||||
"params": {
|
||||
"serperApiKey": "<your serper.dev api key>"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
例如,输入 "@Google python tutorial" ,如果你想要搜索或讨论学习 Python 的方法。
|
||||
|
||||
注意:你可以在 [serper.dev](https://serper.dev) 免费获得 API key 。
|
||||
|
||||
### `@Issue`
|
||||
|
||||
关联一个 GitHub issue 的交谈信息。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "issue",
|
||||
"params": {
|
||||
"repos": [
|
||||
{
|
||||
"owner": "continuedev",
|
||||
"repo": "continue"
|
||||
}
|
||||
],
|
||||
"githubToken": "ghp_xxx"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
确保包含你自己的 [GitHub 个人访问 token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) 来避免频率限制。
|
||||
|
||||
### `@Gitlab Merge Request`
|
||||
|
||||
关联一个 Gitlab 上这个分支上打开的 MR 。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "gitlab-mr",
|
||||
"params": {
|
||||
"token": "..."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
你需要创建一个使用 `read_api` 范围的 [个人访问 token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)。
|
||||
|
||||
#### 使用自托管的 GitLab
|
||||
|
||||
你可以指定要访问的域名,通过在你的配置中设置 `domain` 参数。默认情况下是 `gitlab.com` 。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "gitlab-mr",
|
||||
"params": {
|
||||
"token": "...",
|
||||
"domain": "gitlab.example.com"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 过滤评论
|
||||
|
||||
如果你选择一些代码被编辑,你可以有上下文提供者过滤其他文件的评论。要启用这个特性,设置 `filterComments` 为 `true` 。
|
||||
|
||||
### `@Jira`
|
||||
|
||||
关联一个 Jira issue 的交谈信息。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "jira",
|
||||
"params": {
|
||||
"domain": "company.atlassian.net",
|
||||
"token ": "ATATT..."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
确认包含你自己的 [Atlassian API Token](https://id.atlassian.com/manage-profile/security/api-tokens) ,或者使用你的 `email` 和 `token` , token 设置为你的密码获得基本认证。如果你使用自己的 Atlassian API Token ,不要配置你的邮箱。
|
||||
|
||||
#### Jira Datacenter 支持
|
||||
|
||||
这个上下文提供者支持 Jira API 版本 2 和 3 。默认情况下,它将使用版本 3 ,因为这是云版本使用的,但是如果你有 datacenter 版本的 Jira ,你需要使用 `apiVersion` 属性设置 API Version 为 2 。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "jira",
|
||||
"params": {
|
||||
"apiVersion": "2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Issue 查询
|
||||
|
||||
默认情况下,以下查询用来查找 issue :
|
||||
|
||||
```jql
|
||||
assignee = currentUser() AND resolution = Unresolved order by updated DESC
|
||||
```
|
||||
|
||||
你可以覆盖这个查询,通过设置 `issueQuery` 参数。
|
||||
|
||||
### `@Postgres`
|
||||
|
||||
关联表的 schema ,和一些示例行
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "postgres",
|
||||
"params": {
|
||||
"host": "localhost",
|
||||
"port": 5436,
|
||||
"user": "myuser",
|
||||
"password": "catsarecool",
|
||||
"database": "animals",
|
||||
"schema": "public",
|
||||
"sampleRows": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
仅需要的配置是那些创建数据库连接所需要的: `host`, `port`, `user`, `password` 和 `database` 。
|
||||
|
||||
默认情况下, `schema` 过滤器设置为 `public` , `sampleRows` 设置为 3 。你可以取消设置 schema ,如果你想要包含所有 schema 的表。
|
||||
|
||||
[这是一个简单的 demo](https://github.com/continuedev/continue/pull/859) 。
|
||||
|
||||
### `@Database`
|
||||
|
||||
关联 Sqlite, Postgres 和 MySQL 数据库的表 schema 。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "database",
|
||||
"params": {
|
||||
"connections": [
|
||||
{
|
||||
"name": "examplePostgres",
|
||||
"connection_type": "postgres",
|
||||
"connection": {
|
||||
"user": "username",
|
||||
"host": "localhost",
|
||||
"database": "exampleDB",
|
||||
"password": "yourPassword",
|
||||
"port": 5432
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "exampleSqlite",
|
||||
"connection_type": "sqlite",
|
||||
"connection": {
|
||||
"filename": "/path/to/your/sqlite/database.db"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
每个连接应该有一个单独的名称,`connection_type` ,以及每个数据库类型特定的必须的连接参数。
|
||||
|
||||
可用的连接类型:
|
||||
|
||||
- `postgres`
|
||||
- `mysql`
|
||||
- `sqlite`
|
||||
|
||||
### `@Locals`
|
||||
|
||||
关联调试器中本地变量的内容。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "locals",
|
||||
"params": {
|
||||
"stackDepth": 3
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
使用最多 _n_ 级 (默认是 3) 的当前线程的调用栈。
|
||||
|
||||
### `@Repository Map`
|
||||
|
||||
关联你的代码库的概览。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "repo-map"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
提供一个文件列表,以及这些文件中的最高级的类、函数和方法的调用签名。这帮助模型更好地理解,一段特定的代码如何关联其他的代码库。
|
||||
|
||||
在出现的子菜单中,你可以选择 `Entire codebase` 或指定一个子文件夹,来生成仓库映射。
|
||||
|
||||
这个上下文提供者想法来自 [Aider's repository map](https://aider.chat/2023/10/22/repomap.html) 。
|
||||
|
||||
### `@Operating System`
|
||||
|
||||
关联你当前操作系统的架构和平台。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "os"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `@HTTP`
|
||||
|
||||
HttpContextProvider 创建一个 POST 请求到配置中的 url 。服务器必须返回 200 OK ,以及一个 ContextItem 对象或一个 ContextItems 列表。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "http",
|
||||
"params": {
|
||||
"url": "https://api.example.com/v1/users",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
接收的 URL 应该接收下面的参数:
|
||||
```json title="POST parameters"
|
||||
{
|
||||
query: string,
|
||||
fullInput: string
|
||||
}
|
||||
```
|
||||
|
||||
响应 200 OK 应该是一个有以下结构的 JSON 对象:
|
||||
```json title="Response"
|
||||
[
|
||||
{
|
||||
"name": "",
|
||||
"description": "",
|
||||
"content": ""
|
||||
}
|
||||
]
|
||||
|
||||
// OR
|
||||
{
|
||||
"name": "",
|
||||
"description": "",
|
||||
"content": ""
|
||||
}
|
||||
```
|
||||
|
||||
### 请求上下文提供者
|
||||
|
||||
没有看到你想要的?[在这里](https://github.com/continuedev/continue/issues/new?assignees=TyDunn&labels=enhancement&projects=&template=feature-request-%F0%9F%92%AA.md&title=) 创建一个 issue 来请求一个新的上下文提供者。
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
---
|
||||
title: 自动补全
|
||||
keywords: [自动补全]
|
||||
---
|
||||
|
||||
### 设置 Codestral (推荐)
|
||||
|
||||
如果你想要有最好的自动补全体验,我们推荐使用 Codestral ,它可以通过 [Mistral API](https://console.mistral.ai/) 使用。要做这个,获取一个 API key 并把它添加到你的 `config.json` 中:
|
||||
|
||||
```json
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 设置 Ollama (默认)
|
||||
|
||||
如果你想要本地运行自己的自动补全模型,我们推荐使用 Ollama 。要做这个,首先从 [这里](https://ollama.ai) 下载最新版的 Ollama 。然后,运行下面的命令下载我们推荐的模型:
|
||||
|
||||
```bash
|
||||
ollama run starcoder2:3b
|
||||
```
|
||||
|
||||
一旦它下载完成,你应该可以再 VS Code 中看到补全。
|
||||
|
||||
### 设置自定义模型
|
||||
|
||||
所有配置选项对聊天可用的模型对 tab 自动补全可用。例如,如果你想要使用一个远程 Ollama 实例,你应该编辑你的 `config.json` 像这样(注意,它不在 models 列表中):
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
如果你对可用选项不熟悉,你可以在 [这里](../config.mdx) 查找完整的参考。
|
||||
|
||||
## 配置选项
|
||||
|
||||
以下可以在 `config.json` 配置:
|
||||
|
||||
### `tabAutocompleteModel`
|
||||
|
||||
这是另一个对象,就像 `config.json` 中的 `"models"` 列表。你可以选择和配置任何你想要的模型,但是我们强烈建议使用针对 tab 自动补全的小的模型,例如 `deepseek-1b`, `starcoder-1b` 或 `starcoder2-3b` 。
|
||||
|
||||
### `tabAutocompleteOptions`
|
||||
|
||||
这个对象允许你定制 tab 自动补全的行为。可用的选项显示在下面,你可以在 [这里](https://github.com/continuedev/continue/blob/fbeb2e4fe15d4b434a30a136f74b672485c852d9/core/util/parameters.ts) 找到它们的默认值。
|
||||
|
||||
- `disable`: 禁用自动补全(也可以在 IDE 配置中完成)
|
||||
- `template`: 一个用来自动补全的可选的模板字符串。它使用 Mustache 模板语言渲染,并且传递 'prefix' 和 'suffix' 变量。(字符串)
|
||||
- `useCopyBuffer`: 决定 copy buffer 是否考虑为构建提示词。(布尔型)
|
||||
- `useFileSuffix`: 决定是否使用文件后缀在提示词中。(布尔型)
|
||||
- `maxPromptTokens`: 提示词使用的 token 的最大数量。一个较小的数字生成较快的补全,但是较少的上下文。(数字)
|
||||
- `prefixPercentage`: 输入专注于前缀的百分比。(数字)
|
||||
- `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number)
|
||||
- `maxSuffixPercentage`: 提示词专注于后缀的最大百分比。(数字)
|
||||
- `debounceDelay`: 在按键之后触发自动补全的毫秒延迟。(数字)
|
||||
- `multilineCompletions`: 是否启用多行补全 ("always", "never" 或 "auto") 。默认情况下是 "auto" 。
|
||||
- `useCache`: 是否缓存和重新使用补全,当提示词与前一个相同时。对于测试的目的可能是有用的。
|
||||
- `useOtherFiles`: 是否包含当前文件之外的文件的上下文。关闭这个预期会减少补全的准确性,但是对于测试可能是有用的。
|
||||
- `disableInFiles`: 一个你想要禁用 tab 自动补全的 glob 模式的文件列表。
|
||||
|
||||
### 完整示例
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Tab Autocomplete Model",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b",
|
||||
"apiBase": "https://<my endpoint>"
|
||||
},
|
||||
"tabAutocompleteOptions": {
|
||||
"debounceDelay": 500,
|
||||
"maxPromptTokens": 1500,
|
||||
"disableInFiles": ["*.md"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 我想要更好的补全,是否应该使用 GPT-4 ?
|
||||
|
||||
可能出乎意料,答案是否定的。我们推荐的自动补全模型是通过高度特定提示词格式训练的,这运行它们响应请求来补全代码(在 [这里](https://github.com/continuedev/continue/blob/d2bc6359e8ebf647892ec953e418042dc7f8a685/core/autocomplete/templates.ts) 查看这些提示词的示例)。一些最好的商业化模型,比如 GPT-4 或 Claude 不是通过这种提示词格式训练的,这意味着它们不能生成有用的补全。幸运地,好的自动补全不需要很大的模型。大多数先进的自动补全模型不大于 10b 参数,增加超过这个没有明显地提高性能。
|
||||
|
||||
### 我没有看到任何补全
|
||||
|
||||
查看下面的步骤,确认所有东西设置正确:
|
||||
|
||||
1. 确保你有 "Enable Tab Autocomplete" 设置勾选,(在 VS Code 中,你可以切换,通过点击状态栏中的 "Continue" 按钮,在 JetBrains 中,通过 Settings -> Tools -> Continue )。
|
||||
2. 确保你下载了 Ollama 。
|
||||
3. 运行 `ollama run starcoder2:3b` 确认模型下载完成。
|
||||
4. 确保任何其他补全提供者被禁用(例如 Copilot ),它们可能会干扰。
|
||||
5. 检查输出的日志,查找可能得错误( cmd/ctrl+shift+p -> "Toggle Developer Tools" -> "Console" tab 在 VS Code 中,~/.continue/logs/core.log 在 JetBrains 中)。
|
||||
6. 检查 VS Code 设置,确保 `"editor.inlineSuggest.enabled"` 设置为 `true` (使用 `cmd/ctrl+,` 然后搜索这个并勾选方框)
|
||||
7. 如果你仍然有问题,请在我们的 [Discord](https://discord.gg/vapESyrFmJ) 让我们知道,我们将会尽快提供帮助。
|
||||
|
||||
### 补全太慢
|
||||
|
||||
基于你的硬件,你想要尝试一个更小、更快的模型。如果 3b 不能对你有效工作,我们推荐尝试 `deepseek-coder:1.3b-base` 。
|
||||
|
||||
### 补全总是单行的
|
||||
|
||||
为了确保你能收到多行补全,你可以设置 `"multilineCompletions": "always"` 再 `tabAutocompleteOptions` 中。默认情况下,它是 `"auto"` 。如果你仍然发现你只能看到单行补全,这可能是因为一些模型偏向产生短的补全,当在文件中开始时。你可以尝试临时移动光标下的文本到激活文件外,或者切换到一个更大的模型。
|
||||
|
||||
### 我是否可以配置自动补全 "trigger key" ?
|
||||
|
||||
是的,在 VS Code 中,如果你不想要自动显示建议,你可以:
|
||||
|
||||
1. 设置 `"editor.inlineSuggest.enabled": false` 在 VS Code 设置中,禁止自动建议
|
||||
2. 打开 "快捷键" (cmd/ctrl+k, cmd/ctrl+s) 并查找 `editor.action.inlineSuggest.trigger`
|
||||
3. 点击 "+" 图标添加一个新的键绑定
|
||||
4. 按下你想要触发建议的键组合(例如 `ctrl+space`)
|
||||
5. 现在,无论何时你想要查看建议,按下键绑定(例如,`ctrl+space` )来手动触发建议
|
||||
|
||||
### 是否有快捷键一次接受一行?
|
||||
|
||||
这是 VS Code 的一个内置特性,但是比较隐藏。查看这个很好的 [StackOverflow 回答](https://stackoverflow.com/questions/72228174/accept-line-by-line-from-autocompletion/78001122#78001122) 获取更多信息。
|
||||
|
||||
### 如何关闭自动补全
|
||||
|
||||
#### VS Code
|
||||
|
||||
点击屏幕右下角状态栏中的 "Continue" 按钮。选择标志会变成 "cancel" 符号,你将不会再看到补全。你可以再次点击它,重新打开补全。
|
||||
|
||||
另外,打开 VS Code 设置,搜索 "Continue" 并取消勾选 "Enable Tab Autocomplete" 方框。
|
||||
|
||||
#### JetBrains
|
||||
|
||||
打开 Settings -> Tools -> Continue 并取消勾选 "Enable Tab Autocomplete" 方框。
|
||||
|
||||
#### 反馈
|
||||
|
||||
如果你关闭自动补全,我们想要知道如何提高!请让我们知道,在我们的 [Discord](https://discord.gg/vapESyrFmJ) 或者在 GitHub 提交一个 issue 。
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
---
|
||||
description: 与你的代码库交互
|
||||
keywords: [交互, 嵌入, 重排器, 代码库, 试验性的]
|
||||
---
|
||||
|
||||
# @Codebase
|
||||
|
||||
Continue 索引你的代码库,以便它可以之后自动地拉取你的工作区最相关的上下文。这是通过基于嵌入的检索和关键字搜索结合完成的。默认情况下,所有嵌入都是通过 `all-MiniLM-L6-v2` 本地计算的,保存在 `~/.continue/index` 。
|
||||
|
||||
目前,代码库检索功能可用在 "codebase" 和 "folder" 上下文提供者。你可以使用它们,通过在输入框输入 `@Codebase` 或 `@Folder` ,然后询问问题。输入框的内容将会与其他代码库(或目录)的嵌入进行比较,来决定相关的文件。
|
||||
|
||||
这是一些通用的使用情况,它是有用的:
|
||||
|
||||
- 询问关于你的代码库的高级别问题
|
||||
- "我如何添加一个新的端点到服务器?"
|
||||
- "我们是否再任何地方使用 VS Code 的 CodeLens 特性?"
|
||||
- "这里是否有任何写好的代码将 HTML 转换为 markdown ?"
|
||||
- 生成代码,使用已有的示例作为参考
|
||||
- "生成一个新的有日期选择器的 React 组件,使用与已有组件相同的模式"
|
||||
- "使用 Python 的 argparse 编写一个这个项目的 CLI 应用的草稿"
|
||||
- "实现一个 `foo` 方法在 `bar` 类中, 根据在其他 `baz` 子类中看到的模式"
|
||||
- 使用 `@Folder` 询问关于特定目录的问题,增加相关结果的可能性
|
||||
- "这个目录的主要目的是什么?"
|
||||
- "我们如何使用 VS Code 的 CodeLens API ?"
|
||||
- 或者任何上面的示例,但是使用 `@Folder` 代替 `@Codebase`
|
||||
|
||||
这是一些使用情况,它是没用的:
|
||||
|
||||
- 当你想要 LLM 查看你的代码库中的 _字面上每个_ 文件
|
||||
- "查找 `foo` 函数被调用的每个地方"
|
||||
- "检查我们的代码库,查找任何拼写错误"
|
||||
- 重构
|
||||
- "添加一个新的参数到 `bar` 函数并更新使用方法"
|
||||
|
||||
## 配置
|
||||
|
||||
这里有一些选项,让你可以配置 codebase 上下文提供者的行为。这些可以再 `config.json` 设置,对于 codebase 和 folder 上下文提供者是一样的:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "codebase",
|
||||
"params": {
|
||||
"nRetrieve": 25,
|
||||
"nFinal": 5,
|
||||
"useReranking": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `nRetrieve`
|
||||
|
||||
从向量数据库开始检索的结果数量(默认值: 25)
|
||||
|
||||
### `nFinal`
|
||||
|
||||
重排之后使用的结果的最终数量(默认值:5)
|
||||
|
||||
### `useReranking`
|
||||
|
||||
是否使用重排,允许最初选择 `nRetrieve` 结果,然后使用 LLM 选择最上面的 `nFinal` 结果(默认值: true)
|
||||
|
||||
## 在索引中忽略文件
|
||||
|
||||
Continue 遵守 `.gitignore` 文件,为了确定哪些文件不需要索引。如果你想要忽略更多的文件,你可以添加它们到 `.continueignore` 文件,它遵守和 `.gitignore` 完全相同的规则。
|
||||
|
||||
如果你想要查看哪些文件被 Continue 索引,元数据存储在 `~/.continue/index/index.sqlite` 。你可以使用工具,比如 [DB Browser for SQLite](https://sqlitebrowser.org/) 查看这个文件是的 `tag_catalog` 表。
|
||||
|
||||
如果你需要强制刷新索引,重新加载 VS Code 窗口使用 `cmd/ctrl + shift + p` + "Reload Window" 。
|
||||
|
||||
## 仓库 map
|
||||
|
||||
Claude 3, Llama 3.1, Gemini 1.5 和 GPT-4o 家族的模型在代码库检索时会自动地使用 [仓库 map](../context-providers.md#repository-map) ,允许模型理解你的代码库的结构,并使用它回答问题。当前,仓库 map 仅包含代码库中的文件路径。
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
---
|
||||
description: 了解如何在 Continue 中访问和搜索你的项目文档
|
||||
keywords: [文档, 索引, 上下文提供者, 嵌入, 文档]
|
||||
toc_max_heading_level: 5
|
||||
---
|
||||
|
||||
# @Docs
|
||||
|
||||
[`@Docs` 上下文提供者](http://localhost:3000/customization/context-providers#documentation) 允许你直接通过 Continue 与自己的文档交互。这个特性运行你索引任何静态网站或 Github markdown 页面,让你在编码时访问和利用你的文档更方便。
|
||||
|
||||
## 启用 `@Docs` 上下文提供者
|
||||
|
||||
为了启用 `@Docs` 上下文提供者,你需要添加它到你的 `config.json` 文件中的上下文提供者列表。
|
||||
|
||||
```json
|
||||
{
|
||||
"contextProviders": [
|
||||
{
|
||||
"name": "docs"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 它是如何工作的
|
||||
|
||||
`@Docs` 上下文提供者通过爬取指定的文档网站工作,生成嵌入,把它们保存再本地。这个过程允许快速有效地访问你的文档内容。
|
||||
|
||||
1. 我们爬取指定的文档网站
|
||||
2. 生成内容的嵌入
|
||||
3. 本地保存嵌入在你的机器上
|
||||
4. 通过 `@Docs` 上下文提供者提供访问索引内容
|
||||
|
||||
## 预先索引文档网站
|
||||
|
||||
我们提供一个流行的框架和库的预先索引文档网站的选择。你可以 [在这里查看可用的预先索引网站和请求附加内容](https://github.com/continuedev/continue/blob/main/core/indexing/docs/preIndexedDocs.ts) 列表。
|
||||
|
||||
## 索引你自己的文档
|
||||
|
||||
### 通过 `@Docs` 上下文提供者
|
||||
|
||||
为了添加一个单独的文档网站,我们推荐使用 `@Docs` 上下文提供者。
|
||||
|
||||
1. 在聊天面板输入 `@Docs` ,点击回车
|
||||
2. 输入 "add" 并选择 "Add Docs" 选项
|
||||
3. 输入需要的信息到对话框
|
||||
|
||||
索引将在提交之后开始。
|
||||
|
||||
### 通过 `config.json`
|
||||
|
||||
为了添加多个文档网站,我们推荐批量添加它们到你的 `config.json` 文件中。索引将在文件保存后开始。
|
||||
|
||||
[docs 的配置 schema](https://github.com/continuedev/continue/blob/v0.9.212-vscode/extensions/vscode/config_schema.json#L1943-L1973) 如下:
|
||||
|
||||
```json
|
||||
"docs": [
|
||||
{
|
||||
"title": "Continue",
|
||||
"startUrl": "https://docs.continue.dev/intro",
|
||||
"rootUrl": "https://docs.continue.dev",
|
||||
"faviconUrl": "https://docs.continue.dev/favicon.ico",
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
- `title`: 文档网站的名称,用来在 UI 中进行识别。
|
||||
- `startUrl`: 索引进程开始的 URL 。
|
||||
- `rootUrl`: 文档网站的基本 URL ,用来确定哪个页面索引。
|
||||
- `faviconUrl`: 网站 favicon 的 URL ,用来在 UI 中进行视觉识别。
|
||||
|
||||
## 使用 `useChromiumForDocsCrawling` 爬取动态生成的网站
|
||||
|
||||
默认情况下,我们使用一个轻量的工具爬取文档网站,它不能渲染使用 JavaScript 动态生成的网站。
|
||||
|
||||
If you want to crawl a site that is dynamically generated, or you get an error while attempting to crawl a site, you can enable the experimental `useChromiumForDocsCrawling` feature in your `config.json`. This will download and install Chromium to `~/.continue/.utils`.
|
||||
|
||||
如果你想要爬取一个动态生成的网站,或者当你爬取网站时得到一个错误,你可以在你的 `config.json` 启用试验性的 `useChromiumForDocsCrawling` 特性。这将下载并安装 Chromium 到 `~/.continue/.utils` 。
|
||||
|
||||
```json title="config.json"
|
||||
"experimental": {
|
||||
"useChromiumForDocsCrawling": true
|
||||
}
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 索引内容多长时间更新?
|
||||
|
||||
当前,我们没有自动地重新索引你的文档。如果你想要强制重新刷新,你可以使用下面的命令: `Continue: Docs Force Re-Index` 。
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
title: 提示词文件
|
||||
---
|
||||
|
||||
提示词文件提供一个方便的方式,来标准化通用模式,并与你的团队分享一批 LLM 提示词。它们让构建和使用这些提示词更简单。
|
||||
|
||||
## 快速开始
|
||||
|
||||
:::tip[提示词库]
|
||||
为了帮助你开始,[我们精心编写了一个小的 `.prompt` 文件库](https://github.com/continuedev/prompt-file-examples)。我们鼓励社区贡献到这个仓库,所有请考虑为你的 prompt 创建一个拉取请求!
|
||||
:::
|
||||
|
||||
以下是一个快速示例,设置一个 prompt 文件使用 Jest 编写单元测试。
|
||||
|
||||
1. 创建一个名为 `.prompts/` 的目录,再你的工作区的最高层级。
|
||||
2. 添加一个名为 `test.prompt` 的文件到这个目录中。这个文件的名称将是斜杠命令的名称,你用来生成提示词。
|
||||
3. 写入以下内容到 `test.prompt` 并保存。
|
||||
|
||||
```
|
||||
temperature: 0.5
|
||||
maxTokens: 4096
|
||||
---
|
||||
<system>
|
||||
You are an expert programmer
|
||||
</system>
|
||||
|
||||
{{{ input }}}
|
||||
|
||||
Write unit tests for the above selected code, following each of these instructions:
|
||||
- Use `jest`
|
||||
- Properly set up and tear down
|
||||
- Include important edge cases
|
||||
- The tests should be complete and sophisticated
|
||||
- Give the tests just as chat output, don't edit any file
|
||||
- Don't explain how to set up `jest`
|
||||
```
|
||||
|
||||
现在使用这个提示词,你可以高亮代码,并使用 `cmd/ctrl+L` 来选择它到 Continue 侧边栏中。
|
||||
|
||||
然后,输入 "/" 来查看斜杠命令列表,选择名为 "test" 的那个。按下 enter ,LLM 会响应你的 prompt 文件中给出的指令。
|
||||
|
||||
## 格式
|
||||
|
||||
格式来自 [HumanLoops 的 .prompt 文件](https://docs.humanloop.com/docs/prompt-file-format) ,并通过额外的模板,使用上下文提供者和内置的变量,使用 [Handlebars 语法](https://handlebarsjs.com/guide/) 。
|
||||
|
||||
:::info
|
||||
这个格式的当前状态时试验性的,并且可能变更
|
||||
:::
|
||||
|
||||
### preamble
|
||||
|
||||
"preamble" 是 `---` 分隔符之上的任何东西,让你可以指定模型参数。它使用 YAML 语法,当前支持以下参数:
|
||||
|
||||
- `name`
|
||||
- `temperature`
|
||||
- `topP`
|
||||
- `topK`
|
||||
- `minP`
|
||||
- `presencePenalty`
|
||||
- `frequencyPenalty`
|
||||
- `mirostat`
|
||||
- `stop`
|
||||
- `maxTokens`
|
||||
- `description`
|
||||
|
||||
如果你不需要任何这些参数,你可以对 preamble 留空,不需要包含 `---` 分隔符。
|
||||
|
||||
### 系统信息
|
||||
|
||||
为了添加一个系统信息,使用 `<system></system>` tag 开始 body ,例如上面的例子,并将你的系统信息放入其中。
|
||||
|
||||
### 内置变量
|
||||
|
||||
下面的内置变量当前是可用的:
|
||||
|
||||
- `{{{ input }}}` - 侧边栏中输入框中与斜杠命令一起发送的全部文本
|
||||
- `{{{ currentFile }}}` - 当前在你的 IDE 中打开的文件
|
||||
- `{{{ ./path/to/file.js }}}` - 可以直接引用的任何文件
|
||||
|
||||
### 上下文提供者
|
||||
|
||||
任何你添加到配置中的 [上下文提供者](../context-providers.md) ,可以使用上下文提供者的名称引用。接收输入的上下文提供者也支持。
|
||||
|
||||
- `{{{ terminal }}}` - 终端的内容
|
||||
- `{{{ url "https://github.com/continuedev/continue" }}}` - URL 的内容
|
||||
|
||||
## 反馈
|
||||
|
||||
如果你有关于提高 `.prompt` 文件格式的想法,请在 [Discord](https://discord.gg/NWtdYexhMs) 提出。
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
title: 开发数据
|
||||
description: 收集你如何构建软件的数据
|
||||
keywords: [开发数据, dev 数据, LLM-辅助开发]
|
||||
---
|
||||
|
||||
当使用 Continue 时,你自动地收集如何构建软件的数据。默认情况下,这个开发数据保存在你本地机器上的 `.continue/dev_data` 。与你最终提交的代码结合,它可以用来提高你或你的团队使用的 LLM (如果你允许) 。
|
||||
|
||||
你可以了解更多关于开发数据是如何生成的,作为 LLM 辅助编程的副产品,以及为什么我们相信你应该现在开始收集它: [It’s time to collect data on how you build software](https://blog.continue.dev/its-time-to-collect-data-on-how-you-build-software)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 858 KiB |
|
|
@ -0,0 +1,18 @@
|
|||
# SambaNova Cloud
|
||||
|
||||
SambaNova 云是一个运行大型 AI 模型的云平台,有 Llama 3.1 70B/405B 性能的世界记录。你可以在 [这里](https://cloud.sambanova.ai/) 登录,在最初的欢迎屏幕复制你的 API key ,然后在 [模型列表](https://community.sambanova.ai/t/quick-start-guide/104) 任何模型上点击 play 按钮。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "SambaNova Llama 3.1 405B",
|
||||
"provider": "sambanova",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/SambaNova.ts)
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Cloudflare Workers AI
|
||||
|
||||
Cloudflare Workers AI 可以在 Continue 中用来聊天或 tab 自动补全。要设置 Cloudflare Workers AI ,添加以下配置到你的 `config.json` 文件中:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"accountId": "YOUR CLOUDFLARE ACCOUNT ID",
|
||||
"apiKey": "YOUR CLOUDFLARE API KEY",
|
||||
"contextLength": 2400,
|
||||
"completionOptions": {
|
||||
"maxTokens": 500
|
||||
},
|
||||
"model": "@cf/meta/llama-3-8b-instruct", // This can be the name of any model supported by Workers AI
|
||||
"provider": "cloudflare",
|
||||
"title": "Llama 3 8B"
|
||||
},
|
||||
{
|
||||
"accountId": "YOUR CLOUDFLARE ACCOUNT ID",
|
||||
"apiKey": "YOUR CLOUDFLARE API KEY",
|
||||
"contextLength": 2400,
|
||||
"completionOptions": {
|
||||
"maxTokens": 500
|
||||
},
|
||||
"model": "@hf/thebloke/deepseek-coder-6.7b-instruct-awq",
|
||||
"provider": "cloudflare",
|
||||
"title": "DeepSeek Coder 6.7b Instruct"
|
||||
}
|
||||
...
|
||||
"tabAutocompleteModel": {
|
||||
"accountId": "YOUR CLOUDFLARE ACCOUNT ID",
|
||||
"apiKey": "YOUR CLOUDFLARE API KEY",
|
||||
"model": "@hf/thebloke/deepseek-coder-6.7b-base-awq",
|
||||
"provider": "cloudflare",
|
||||
"title": "DeepSeek 7b"
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
访问 [Cloudflare dashboard](https://dash.cloudflare.com/) 来 [创建 API key](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) 。
|
||||
|
||||
在 Workers AI 重看 [可用的模型](https://developers.cloudflare.com/workers-ai/models/)
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Cloudflare.ts)
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# Cohere
|
||||
|
||||
在使用 Cohere 之前,访问 [Cohere dashboard](https://dashboard.cohere.com/api-keys) 创建 API key 。
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Command-R Plus** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Cohere",
|
||||
"provider": "cohere",
|
||||
"model": "command-r-plus",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
Cohere 当前没有提供任何自动补全模型。
|
||||
|
||||
[点击这里](../../model-types/autocomplete.md) 查看自动补全模型提供者列表。
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **embed-english-v3.0** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "cohere",
|
||||
"model": "embed-english-v3.0",
|
||||
"apiKey": "<COHERE_API_KEY>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
我们推荐配置 **rerank-english-v3.0** 作为你的重排序模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "cohere",
|
||||
"params": {
|
||||
"model": "rerank-english-v3.0",
|
||||
"apiKey": "<COHERE_API_KEY>"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# DeepInfra
|
||||
|
||||
[DeepInfra](https://deepinfra.com) 提供很低费用的开源模型推理。要开始使用 DeepInfra ,在 [这里](https://deepinfra.com/dash) 获取你的 API key 。然后,在 [这里](https://deepinfra.com/models?type=text-generation) 找到你想要使用的模型,并复制模型的名称。 Continue 可以配置使用 `DeepInfra` LLM 类,比如这里的例子:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"provider": "deepinfra",
|
||||
"title": "DeepInfra",
|
||||
"model": "mistralai/Mixtral-8x7B-Instruct-v0.1",
|
||||
"apiKey": "<API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/DeepInfra.ts)
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Flowise
|
||||
|
||||
[Flowise](https://flowiseai.com/) 是一个 低代码/无代码 拖拽工具,目标是让人们更容易地可视化构建 LLM 应用。 Continue 可以配置使用 `Flowise` LLM 类,比如这里的例子:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"provider": "flowise",
|
||||
"title": "Flowise",
|
||||
"model": "<MODEL>",
|
||||
"apiBase": "<API_BASE>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Flowise.ts)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: 免费试用
|
||||
slug: ../free-trial
|
||||
---
|
||||
|
||||
`"免费试用"` 提供者提供新用户在 Continue 快速尝试最好的体验,通过一个安全的代理服务器使用我们的 API key 。为了避免滥用,我们要求你使用 Github 登录,你可以在下面看到更多。
|
||||
|
||||
虽然 Continue 扩展总是免费使用,我们不能为所有用户提供无限免费 LLM 使用。你最终需要:
|
||||
|
||||
1. 选择一个开源模型免费使用 [本地的](../top-level/ollama.md), 或者
|
||||
2. 添加你自己的 [Anthropic](../top-level/anthropic.md) API key 或者 [其他的 LLM 提供者](/customize/model-providers)
|
||||
|
||||
## 试用的常见问题
|
||||
|
||||
Continue 要求免费试用用户登录,让我们可以避免我们的 API 端点滥用。如果你不使用免费试用,我们不会要求你登录。
|
||||
|
||||
### 我如何停止 Continue 询问我登录?
|
||||
|
||||
移除 "models" 列表或 "tabAutocompleteModel" 中 `"provider": "free-trial"` 的所有模型,我们将不会再请求登录。
|
||||
|
||||
### 什么信息被收集?
|
||||
|
||||
Continue 使用你的 GitHub 用户名,没有其他信息,唯一的目的是限制请求。
|
||||
|
||||
### 如果我没有登录,会发生什么?
|
||||
|
||||
如果你没有登录,你仍然可以使用 Continue 的每个特性,你只需要提供自己的 LLM ,不论使用 API key 或运行本地的模型。
|
||||
|
||||
### 遥测与登录有什么关系?
|
||||
|
||||
它没有。我们没有关联你的 GitHub 用户名到遥测数据。
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Groq
|
||||
|
||||
Groq 提供开源语言模型最快的可用推理,包含整个 Llama 3.1 家族。
|
||||
|
||||
1. 从 [这里](https://console.groq.com/keys) 获取 API key
|
||||
2. 像这样更新你的 Continue 配置文件:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama 3.1 405b",
|
||||
"provider": "groq",
|
||||
"model": "llama3.1-405b",
|
||||
"apiKey": "<API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# HuggingFace 推理端点
|
||||
|
||||
Hugging Face 推理端点是一个在任何云上设置开源语言模型实例的简单的方式。在 [这里](https://huggingface.co/settings/billing)注册帐号并添加账单 , 在 [这里](https://ui.endpoints.huggingface.co) 访问推理端点,点击 "New endpoint" ,并填写表单,(例如,选择一个模型 [WizardCoder-Python-34B-V1.0](https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0)) ,然后通过点击 "Create Endpoint" 部署你的模型。修改 `~/.continue/config.json` 像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Hugging Face Inference API",
|
||||
"provider": "huggingface-inference-api",
|
||||
"model": "MODEL_NAME",
|
||||
"apiKey": "YOUR_HF_TOKEN",
|
||||
"apiBase": "INFERENCE_API_ENDPOINT_URL"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/HuggingFaceInferenceAPI.ts)
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
# IPEX-LLM
|
||||
|
||||
:::info
|
||||
[**IPEX-LLM**](https://github.com/intel-analytics/ipex-llm) 是一个 PyTorch 库,用来在 Intel CPU 和 GPU 上运行 LLM ,(例如,有 iGPU 的 PC ,独立 GPU ,比如, Arc A-Series, Flex 和 Max),有着很低的延迟。
|
||||
:::
|
||||
|
||||
IPEX-LLM 支持加速托管在 Intel GPU 上的 Ollama 后端。从 IPEX-LLM 官方文档查看 [这个指南](https://ipex-llm.readthedocs.io/en/latest/doc/LLM/Quickstart/ollama_quickstart.html),关于如何安装和运行通过 IPEX-LLM 在 Intel GPU 上的 Ollama 服务加速。你可以如下配置 Continue 使用 IPEX-LLM 加速 `"ollama"` 提供者:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "IPEX-LLM",
|
||||
"provider": "ollama",
|
||||
"model": "AUTODETECT"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
如果你想要访问来自其他机器的 Ollama 服务,确保你在执行 `ollama serve` 命令之前, set 或 export 环境变量 `OLLAMA_HOST=0.0.0.0` 。然后,在 Continue 配置中,设置 `'apiBase'` 与远程机器的 IP 地址 / 端口一致。也就是, Continue 可以配置为:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "IPEX-LLM",
|
||||
"provider": "ollama",
|
||||
"model": "AUTODETECT",
|
||||
"apiBase": "http://your-ollama-service-ip:11434"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
:::tip
|
||||
如果你想要在 Continue 中第一次与模型交谈之前预加载模型,你需要查看 [这里](https://ipex-llm.readthedocs.io/en/latest/doc/LLM/Quickstart/continue_quickstart.html#pull-and-prepare-the-model) 获取更多信息。
|
||||
:::
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
# Kindo
|
||||
|
||||
Kindo 对你的机构 AI 操作提供集中控制,当支持不同的商业和开源模型时,确保数据安全和内部原则兼容。要开始使用,在 [这里](https://app.kindo.ai/) 注册,在 [API keys 页面](https://app.kindo.ai/settings/api) 创建你的 API key ,在 [plugins 标签页](https://app.kindo.ai/plugins) 中,从支持的模型列表中选择一个模型。
|
||||
|
||||
## 配置示例
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "kindo",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"apiKey": "<KINDO_API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## tab 自动补全配置示例
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": [
|
||||
{
|
||||
"title": "WhiteRabbitNeo",
|
||||
"provider": "kindo",
|
||||
"model": "/models/WhiteRabbitNeo-33B-DeepSeekCoder",
|
||||
"apiKey": "<KINDO_API_KEY>"
|
||||
},
|
||||
{
|
||||
"title": "DeepSeek",
|
||||
"provider": "kindo",
|
||||
"model": "deepseek-ai/deepseek-coder-33b-instruct",
|
||||
"apiKey": "<KINDO_API_KEY>"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 安全性
|
||||
|
||||
要更新你的机构模型访问,在 [安全性设置](https://app.kindo.ai/security-settings) 中调整控制。
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
# LlamaCpp
|
||||
|
||||
运行 llama.cpp server 二进制文件打开 API 服务器。如果你运行一个远程服务器,确保设置 host 为 0.0.0.0 :
|
||||
|
||||
```shell
|
||||
.\server.exe -c 4096 --host 0.0.0.0 -t 16 --mlock -m models\meta\llama\codellama-7b-instruct.Q8_0.gguf
|
||||
```
|
||||
|
||||
在它设置和运行之后,修改 `~/.continue/config.json` 像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama CPP",
|
||||
"provider": "llama.cpp",
|
||||
"model": "MODEL_NAME",
|
||||
"apiBase": "http://localhost:8080"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/LlamaCpp.ts)
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Llamafile
|
||||
|
||||
[llamafile](https://github.com/Mozilla-Ocho/llamafile#readme) 是一个自包含的二进制文件,可以运行一个开源 LLM 。你可以像下面这样在 config.json 配置这个提供者:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llamafile",
|
||||
"provider": "llamafile",
|
||||
"model": "mistral-7b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Llamafile.ts)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# LM Studio
|
||||
|
||||
[LM Studio](https://lmstudio.ai) 是一个 Mac, Windows 和 Linux 的应用,让本地运行开源模型更简单,并提供很好的 UI 。要开始使用 LM Studio ,从网站上下载它,使用 UI 下载一个模型,然后打开本地推理服务器。 Continue 可以配置来使用 `LMStudio` LLM 类:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "LM Studio",
|
||||
"provider": "lmstudio",
|
||||
"model": "llama2-7b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 设置一个远程实例
|
||||
|
||||
要配置一个 LM Studio 的远程实例,在 config.json 中,添加 `"apiBase"` 属性到你的模型中:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"title": "LM Studio",
|
||||
"model": "codestral",
|
||||
"provider": "lmstudio",
|
||||
"apiBase": "http://x.x.x.x:1234/v1/"
|
||||
}
|
||||
```
|
||||
|
||||
`apiBase` 现在将会代替默认的 `http://localhost:1234/v1` 。
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/LMStudio.ts)
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# Msty
|
||||
|
||||
[Msty](https://msty.app/) 是一个 Windows, Mac 和 Linux 的应用,让运行本地开源模型上线很容易,包括 Llama-2, DeepSeek Coder 等。不需要使用你的终端,运行命令或任何东西。只需要从网站下载应用,点击按钮,就会启动和运行。然后, Continue 可以配置使用 `Msty` LLM 类:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Msty",
|
||||
"provider": "msty",
|
||||
"model": "deepseek-coder:6.7b",
|
||||
"completionOptions": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 完成选项
|
||||
|
||||
除了模型类型,你还可以配置一些 Msty 运行模型的参数。
|
||||
|
||||
- temperature: options.temperature - 这是一个控制生成文本的随机性的参数。较高的值导致更有创造性,但是可能更少的有条理的输入,而更低的值导致更可预测和目标明确的输出。
|
||||
- top_p: options.topP - 这个设置一个阈值 (在 0 和 1 之前) ,用来控制预测 token 的多样性。模型生成 token ,通过它们的概率分布,但是也考虑 top-k 最可能的 token 。
|
||||
- top_k: options.topK - 这个参数限制唯一 token 的数量,当考虑生成序列的下一个 token 时。较高的值增加生成序列的多样性,而较低的值导致更明确的输出。
|
||||
- num_predict: options.maxTokens - 这个决定生成 token 的最大数量 (字或字符) ,对于给定的输入提示词。
|
||||
- num_thread: options.numThreads - 这是多线程配置选项,控制模型并发使用多少个线程。更到的值导致更快的生成时间,但是也会增加内存使用和复杂性。在本地运行模型时,设置这个为 1 或 2 ,低于你的 CPU 可以处理的线程数量,留给你的 GUI 一些。
|
||||
|
||||
## 认证
|
||||
|
||||
如果你需要发送自定义头来认证,你可以使用 `requestOptions.headers` 属性,像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Msty",
|
||||
"provider": "msty",
|
||||
"model": "deepseek-coder:6.7b",
|
||||
"requestOptions": {
|
||||
"headers": {
|
||||
"Authorization": "Bearer xxx"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Msty.ts)
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
# OpenRouter
|
||||
|
||||
OpenRouter 是一个对于商业的和开源的模型统一的接口,给你最好的模型,最好的价格。你可以在 [这里](https://openrouter.ai/signup) 注册,在 [keys 页面](https://openrouter.ai/keys) 创建你的 API key ,然后从 [支持模型列表](https://openrouter.ai/models) 中选择一个模型。
|
||||
|
||||
修改 `~/.continue/config.json` 如下:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "OpenRouter LLaMA 70 8B",
|
||||
"provider": "openrouter",
|
||||
"model": "meta-llama/llama-3-70b-instruct",
|
||||
"apiBase": "https://openrouter.ai/api/v1",
|
||||
"apiKey": "..."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
为了使用比如提供者推理或模型路由配置的特性,在你的插件配置中添加这些参数到 `models[].requestsOptions.extraBodyProperties` 字段。
|
||||
|
||||
例如,为了抑制额外的长提示词被压缩,你可以明确地关闭这个特性,像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
...
|
||||
"requestOptions": {
|
||||
"extraBodyProperties": {
|
||||
"transforms": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
在 [这里](https://openrouter.ai/docs) 了解更多可用的设置。
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# ReplicateLLM
|
||||
|
||||
Replicate 是一个很好的选项,对于新发布的语言模型或你通过他们的平台部署的模型。在 [这里](https://replicate.ai/) 注册一个帐号,复制你的 API key ,然后从 [Replicate Streaming 列表](https://replicate.com/collections/streaming-language-models) 选择任何模型。修改 `~/.continue/config.json` 看起来像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Replicate CodeLLama",
|
||||
"provider": "replicate",
|
||||
"model": "codellama-13b",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
If you don't specify the `model` parameter, it will default to `replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781`.
|
||||
|
||||
如果你没有指定 `model` 参数,它将默认是 `replicate/llama-2-70b-chat:58d078176e02c219e11eb4da5a02a7830a283b14cf8f94537af893ccff5ee781`.
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Replicate.ts)
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# AWS SageMaker
|
||||
|
||||
SageMaker 提供者支持使用 [LMI](https://docs.djl.ai/docs/serving/serving/docs/lmi/index.html) 部署的 SageMaker 端点。
|
||||
|
||||
为了设置 SageMaker ,添加以下到你的 `config.json` 文件中:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "deepseek-6.7b-instruct",
|
||||
"provider": "sagemaker",
|
||||
"model": "lmi-model-deepseek-coder-xxxxxxx",
|
||||
"region": "us-west-2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
模型中的值是你部署的 SageMaker 端点名称。
|
||||
|
||||
认证可以通过临时的或长期的证书,在 `~/.aws/credentials` 中名为 "sagemaker" 的属性中设置。
|
||||
|
||||
```title="~/.aws/credentials
|
||||
[sagemaker]
|
||||
aws_access_key_id = abcdefg
|
||||
aws_secret_access_key = hijklmno
|
||||
aws_session_token = pqrstuvwxyz # Optional: means short term creds.
|
||||
```
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# TextGenWebUI
|
||||
|
||||
TextGenWebUI 是一个综合的,开源语言模型 UI 和本地服务器。你可以使用 OpenAI-兼容服务器插件设置它,然后在你的 `config.json` 配置它,像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Text Generation WebUI",
|
||||
"provider": "text-gen-webui",
|
||||
"apiBase": "http://localhost:5000",
|
||||
"model": "MODEL_NAME"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Together
|
||||
|
||||
Together API 是一个运行大 AI 模型的云平台。你可以在 [这里](https://api.together.xyz/signup) 注册,在最初欢迎屏幕复制你的 API key ,然后在 [Together 模型列表](https://docs.together.ai/docs/models-inference) 的任何模型上点击 play 按钮。修改 `~/.continue/config.json` 像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Together CodeLlama",
|
||||
"provider": "together",
|
||||
"model": "codellama-13b",
|
||||
"apiKey": "YOUR_API_KEY"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Together.ts)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# vLLM
|
||||
|
||||
通过 vLLM 使用 `vllm serve` 运行 OpenAI-兼用 服务器。查看他们的 [服务器文档](https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html) 和 [引擎参数文档](https://docs.vllm.ai/en/latest/models/engine_args.html) 。
|
||||
|
||||
```shell
|
||||
vllm serve NousResearch/Meta-Llama-3-8B-Instruct --max-model-len 1024
|
||||
```
|
||||
|
||||
Continue 底层实现使用 [OpenAI](../top-level/openai.md) 并自动选择可用的模型。你只需要设置 `apiBase` ,像这样:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "My vLLM OpenAI-compatible server",
|
||||
"apiBase": "http://localhost:8000/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
[查看代码](https://github.com/continuedev/continue/blob/main/core/llm/llms/Vllm.ts)
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
# IBM watsonx
|
||||
|
||||
watsonx, 由 IBM 开发,提供不同的预训练 AI 基础模型,可以用来自然语言处理 (NLP) ,计算机视觉和语音识别任务。
|
||||
|
||||
## 设置
|
||||
|
||||
为了访问 watsonx 模型,可以通过在 IBM 云的 watsonx SaaS 或者使用专有的 watsonx.ai 软件实例。
|
||||
|
||||
### watsonx.ai SaaS - IBM 云
|
||||
|
||||
为了开始使用 watsonx SaaS ,访问 [注册页面](https://dataplatform.cloud.ibm.com/registration/stepone?context=wx) 。如果你没有已有的 IBM 云帐号,可以注册免费试用。
|
||||
|
||||
为了使用 Continue 认证 watsonx.ai SaaS ,你需要创建一个项目,然后 [设置 API key](https://www.ibm.com/docs/en/mas-cd/continuous-delivery?topic=cli-creating-your-cloud-api-key) 。然后,在 Continue 中:
|
||||
|
||||
- 设置 **watsonx URL** 为你的 watsonx SaaS 端点,例如 `https://us-south.ml.cloud.ibm.com` 使用 US 南方区域。
|
||||
- 设置 **watsonx Project ID** 为你的 watsonx 项目 ID 。
|
||||
- 设置 **watsonx API Key** 为你的 watsonx API Key 。
|
||||
|
||||
### watsonx.ai 软件
|
||||
|
||||
为了使用 Continue 认证你的 watsonx.ai 软件实例,你可以使用 `username/password` 或 `ZenApiKey` 方法:
|
||||
|
||||
1. _选项 1_ (推荐): 使用 `ZenApiKey` 认证:
|
||||
- 设置 **watsonx URL** 为你的 watsonx 软件端点,例如 `https://cpd-watsonx.apps.example.com` 。
|
||||
- 设置 **watsonx Project ID** 为你的 watsonx 项目 ID 。
|
||||
- 设置 **watsonx API Key** 为你的 watsonx Zen API Key 。要生成它:
|
||||
1. 登录到 CPD 网页客户端。
|
||||
2. 在工具栏中,点击头像。
|
||||
3. 点击 **简介和设置** 。
|
||||
4. 点击 **API key** > **生成新的 key** 。
|
||||
5. 点击 **生成** 。
|
||||
6. 点击 **复制** 并保存你的 key 到安全的地方。如果丢失,你不能恢复这个 key 。
|
||||
7. 生成你的 ZenApiKey ,通过在你喜欢的终端中运行下面的命令: `echo "<username>:<apikey>" | base64` ,替换 `<username>` 为你的 CPD username 和 `<apikey>` 为你刚刚创建的 API key 。
|
||||
2. _选项 2_: 使用 `username/password` 认证:
|
||||
- 设置 **watsonx URL** 为你的 watsonx 软件端点,例如 `https://cpd-watsonx.apps.example.com` 。
|
||||
- 设置 **watsonx Project ID** 为你的 watsonx 项目 ID 。
|
||||
- 设置 **watsonx API Key** 为你的 watsonx 用户名和密码,使用 `username:password` 格式。
|
||||
|
||||
## 配置
|
||||
|
||||
添加下面的配置到你的 `config.json` 文件来使用 watsonx 提供者。填写 `watsonxCreds` ,使用你在设置步骤中获取的认证信息。
|
||||
|
||||
```json title="~/.continue/config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"model": "model ID",
|
||||
"title": "watsonx - Model Name",
|
||||
"watsonxUrl": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
|
||||
"watsonxProjectId": "PROJECT_ID",
|
||||
"watsonxCreds": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
|
||||
"watsonxApiVersion": "2023-05-29",
|
||||
"provider": "watsonx"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
`watsonxAPIVersion` 是可选的,默认为最新版。
|
||||
|
||||
### 配置选项
|
||||
|
||||
如果你使用一个自定义的端点,添加完整的 watsonx URL 到 `watsonxFullUrl` 。当设置了 `watsonxFullUrl` , `watsonxUrl` 和 `watsonxApiVersion` 会被忽略。
|
||||
|
||||
```json title="~/.continue/config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"model": "model ID",
|
||||
"title": "watsonx - Model Name",
|
||||
"watsonxUrl": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
|
||||
"watsonxProjectId": "PROJECT_ID",
|
||||
"watsonxCreds": "API_KEY",
|
||||
"watsonxApiVersion": "2023-05-29",
|
||||
"provider": "watsonx",
|
||||
"watsonxFullUrl": "https://us-south.ml.cloud.ibm.com/m1/v1/text/generation"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||

|
||||
|
|
@ -0,0 +1,67 @@
|
|||
---
|
||||
title: Anthropic
|
||||
slug: ../anthropic
|
||||
---
|
||||
|
||||
:::info
|
||||
你可以从 [Anthropic 控制台](https://console.anthropic.com/account/keys) 获取 API key 。
|
||||
:::
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Claude 3.5 Sonnet** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
Anthropic 当前没有提供任何自动补全模型。
|
||||
|
||||
[点击这里](../../model-types/autocomplete.md) 查看自动补全模型提供者列表。
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
Anthropic 当前没有提供任何嵌入模型。
|
||||
|
||||
[点击这里](../../model-types/embeddings.md) 查看嵌入模型提供者列表。
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Anthropic 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
||||
## 提示词缓存
|
||||
|
||||
Anthropic 提供 [Claude 的提示词缓存](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching) 。
|
||||
|
||||
为了打开系统消息和逐轮交谈的缓存,像下面这样更新你的模型配置:
|
||||
|
||||
```json
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
// Enable prompt caching
|
||||
"cacheBehavior": {
|
||||
"cacheSystemMessage": true,
|
||||
"cacheConversation": true
|
||||
},
|
||||
"title": "Anthropic",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
---
|
||||
title: Azure OpenAI
|
||||
slug: ../azure
|
||||
---
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **GPT-4o** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
"models": [{
|
||||
"title": "GPT-4o",
|
||||
"provider": "azure",
|
||||
"model": "gpt-4o",
|
||||
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
|
||||
"engine": "<YOUR_ENGINE>",
|
||||
"apiVersion": "<YOUR_API_VERSION>",
|
||||
"apiType": "azure",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}]
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
我们推荐配置 **Codestral** 作为你的自动补全模型。
|
||||
|
||||
```json title="config.json"
|
||||
"tabAutocompleteModel": [{
|
||||
"title": "Codestral",
|
||||
"provider": "azure",
|
||||
"model": "codestral-latest",
|
||||
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
|
||||
"engine": "<YOUR_ENGINE>",
|
||||
"apiVersion": "<YOUR_API_VERSION>",
|
||||
"apiType": "azure",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}]
|
||||
```
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **text-embedding-3-large** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
"embeddingsProvider": {
|
||||
"provider": "azure",
|
||||
"model": "text-embedding-3-large",
|
||||
"apiBase": "<YOUR_DEPLOYMENT_BASE>",
|
||||
"engine": "<YOUR_ENGINE>",
|
||||
"apiVersion": "<YOUR_API_VERSION>",
|
||||
"apiType": "azure",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Azure OpenAI 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型列表。
|
||||
|
||||
## 隐私
|
||||
|
||||
如果你想要使用 OpenAI 模型,但是担心隐私问题,你可以使用 Azure OpenAI 服务,它是符合 GDPR 和 HIPAA 的。
|
||||
|
||||
:::info[获取访问]
|
||||
你需要申请 Azure OpenAI 服务的访问。响应时间通常是几天。
|
||||
|
||||
**[点击这里申请 Azure OpenAI 服务的访问](https://azure.microsoft.com/en-us/products/ai-services/openai-service)**
|
||||
:::
|
||||
|
||||
## 通用模型配置
|
||||
|
||||
Azure OpenAI 需要配置一些额外的参数,例如模型引擎和 API 版本。
|
||||
|
||||
要在 _Azure AI Studio_ 查找这个信息,首先选择你想要连接的模型。然后访问 _Endpoint_ > _Target URI_ 。
|
||||
|
||||
例如, Target URI `<https://just-an-example.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2023-03-15-preview>` 匹配以下配置:
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "GPT-4o Azure",
|
||||
"model": "gpt-4o",
|
||||
"provider": "azure",
|
||||
"apiBase": "https://just-an-example.openai.azure.com",
|
||||
"apiType": "azure",
|
||||
"engine": "gpt-4o",
|
||||
"apiVersion": "2023-03-15-preview",
|
||||
"apiKey": "<MY_API_KEY>"
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
---
|
||||
title: Amazon Bedrock
|
||||
slug: ../bedrock
|
||||
---
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Claude 3.5 Sonnet** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "bedrock",
|
||||
"model": "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
||||
"region": "us-east-1",
|
||||
"profile": "bedrock"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
Bedrock 当前不支持任何自动补全模型。
|
||||
|
||||
[点击这里](../../model-types/autocomplete.md) 查看自动补全模型提供者列表。
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 [`amazon.titan-embed-text-v2:0`](https://docs.aws.amazon.com/bedrock/latest/devguide/models.html#amazon.titan-embed-text-v2-0) 作为你的嵌入模型。
|
||||
|
||||
```json title="~/.continue/config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"title": "Embeddings Model",
|
||||
"provider": "bedrock",
|
||||
"model": "amazon.titan-embed-text-v2:0",
|
||||
"region": "us-west-2"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Bedrock 当前没有任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
||||
## 认证
|
||||
|
||||
认证可以通过 `~/.aws/credentials` 配置属性中临时的或长期的证书,(例如 "bedrock") 。
|
||||
|
||||
```title="~/.aws/credentials
|
||||
[bedrock]
|
||||
aws_access_key_id = abcdefg
|
||||
aws_secret_access_key = hijklmno
|
||||
aws_session_token = pqrstuvwxyz # Optional: means short term creds.
|
||||
```
|
||||
|
||||
## 定制导入模型
|
||||
|
||||
为了设置 Bedrock 使用定制导入模型,将下面的配置添加到你的 `config.json` 文件中:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "AWS Bedrock deepseek-coder-6.7b-instruct",
|
||||
"provider": "bedrockimport",
|
||||
"model": "deepseek-coder-6.7b-instruct",
|
||||
"modelArn": "arn:aws:bedrock:us-west-2:XXXXX:imported-model/XXXXXX",
|
||||
"region": "us-west-2",
|
||||
"profile": "bedrock"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
认证可以通过 `~/.aws/credentials` 配置属性中临时的或长期的证书,(例如 "bedrock") 。
|
||||
|
||||
```title="~/.aws/credentials
|
||||
[bedrock]
|
||||
aws_access_key_id = abcdefg
|
||||
aws_secret_access_key = hijklmno
|
||||
aws_session_token = pqrstuvwxyz # Optional: means short term creds.
|
||||
```
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
title: DeepSeek
|
||||
slug: ../deepseek
|
||||
---
|
||||
|
||||
:::info
|
||||
你可以从 [DeepSeek 控制台](https://www.deepseek.com/) 获取 API key 。
|
||||
:::
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **DeepSeek Chat** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "DeepSeek Chat",
|
||||
"provider": "deepseek",
|
||||
"model": "deepseek-chat",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
我们推荐配置 **DeepSeek Coder** 作为你的自动补全模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "DeepSeek Coder",
|
||||
"provider": "deepseek",
|
||||
"model": "deepseek-coder"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
DeepSeek 当前没有提供任何嵌入模型。
|
||||
|
||||
[点击这里](../../model-types/embeddings.md) 查看嵌入模型提供者列表。
|
||||
|
||||
## 重排序模型
|
||||
|
||||
DeepSeek 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
---
|
||||
title: Gemini
|
||||
slug: ../gemini
|
||||
---
|
||||
|
||||
:::info
|
||||
你可以从 [Google AI Studio](https://aistudio.google.com/) 获取 API key 。
|
||||
:::
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Gemini 1.5 Pro** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Gemini 1.5 Pro",
|
||||
"provider": "gemini",
|
||||
"model": "gemini-1.5-pro-latest",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
Gemini 当前没有提供任何自动补全模型。
|
||||
|
||||
[点击这里](../../model-types/autocomplete.md) 查看自动补全模型提供者列表。
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **text-embedding-004** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "gemini",
|
||||
"model": "models/text-embedding-004",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Gemini 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: Mistral
|
||||
slug: ../mistral
|
||||
---
|
||||
|
||||
:::info
|
||||
你可以从 [Mistral Dashboard](https://console.mistral.ai) 获取 API key 。注意 Codestral (codestral.mistral.ai) 的 API key 是与所有其他模型 (api.mistral.ai) 不同的。
|
||||
:::
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Mistral Large** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Mistral Large",
|
||||
"provider": "mistral",
|
||||
"model": "mistral-large-latest",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
我们推荐配置 **Codestral** 作为你的自动补全模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "Codestral",
|
||||
"provider": "mistral",
|
||||
"model": "codestral-latest"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **Mistral Embed** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "mistral",
|
||||
"model": "mistral-embed",
|
||||
"apiKey": "[API_KEY]",
|
||||
"apiBase": "https://api.mistral.ai/v1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Mistral 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
title: Ollama
|
||||
slug: ../ollama
|
||||
---
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **Llama3.1 8B** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "Llama3.1 8B",
|
||||
"provider": "ollama",
|
||||
"model": "llama3.1:8b"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
我们推荐配置 **StarCoder2 3B** 作为你的自动补全模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"tabAutocompleteModel": {
|
||||
"title": "StarCoder2 3B",
|
||||
"provider": "ollama",
|
||||
"model": "starcoder2:3b"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **Nomic Embed Text** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "ollama",
|
||||
"model": "nomic-embed-text"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
Ollama 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
---
|
||||
title: OpenAI
|
||||
slug: ../openai
|
||||
---
|
||||
|
||||
:::info
|
||||
你可以从 [OpenAI 控制台](https://platform.openai.com/account/api-keys) 获取 API key
|
||||
:::
|
||||
|
||||
## 聊天模型
|
||||
|
||||
我们推荐配置 **GPT-4o** 作为你的聊天模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "GPT-4o",
|
||||
"provider": "openai",
|
||||
"model": "gpt-4o",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 自动补全模型
|
||||
|
||||
OpenAI 当前没有提供任何自动补全模型。
|
||||
|
||||
[点击这里](../../model-types/autocomplete.md) 查看自动补全模型提供者列表。
|
||||
|
||||
## 嵌入模型
|
||||
|
||||
我们推荐配置 **text-embedding-3-large** 作为你的嵌入模型。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "openai",
|
||||
"model": "text-embedding-3-large",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 重排序模型
|
||||
|
||||
OpenAI 当前没有提供任何重排序模型。
|
||||
|
||||
[点击这里](../../model-types/reranking.md) 查看重排序模型提供者列表。
|
||||
|
||||
## OpenAI 兼容服务器 / API
|
||||
|
||||
OpenAI 兼容服务器
|
||||
|
||||
- [KoboldCpp](https://github.com/lostruins/koboldcpp)
|
||||
- [text-gen-webui](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/openai#setup--installation)
|
||||
- [FastChat](https://github.com/lm-sys/FastChat/blob/main/docs/openai_api.md)
|
||||
- [LocalAI](https://localai.io/basics/getting_started/)
|
||||
- [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)
|
||||
|
||||
OpenAI 兼容 API
|
||||
|
||||
- [Anyscale Endpoints](https://github.com/continuedev/deploy-os-code-llm#others)
|
||||
- [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints)
|
||||
|
||||
如果你使用 OpenAI 兼容服务器 / API ,你可以像这样修改 `apiBase` :
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"title": "OpenAI-compatible server / API",
|
||||
"provider": "openai",
|
||||
"model": "MODEL_NAME",
|
||||
"apiKey": "EMPTY",
|
||||
"apiBase": "http://localhost:8000/v1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
为了使用 `chat/completions` 代替 `completions` 端点,你可以设置
|
||||
|
||||
```json
|
||||
"useLegacyCompletionsEndpoint": false
|
||||
```
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: 自动补全模型
|
||||
description: 自动补全模型
|
||||
keywords: [自动补全]
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
"自动补全模型" 是一个训练在称为中间填充 (FIM) 的特定的格式上的 LLM 。这种格式设计为,给出代码文件的前缀和后缀,预测中间是什么。这种任务很特殊,一方面意味着模型可以较小 (甚至一个 3B 参数模型可以表现很好)。另一方面,这意味着聊天模型,虽然更大,但是表现更差。
|
||||
|
||||
在 Continue 中,这些模型用来随着你的输入显示行内 [自动补全](../../autocomplete/how-to-use-it.md) 建议。
|
||||
|
||||
## 推荐的自动补全模型
|
||||
|
||||
如果你有使用任何模型的能力,我们推荐通过 [Mistral](../model-providers/top-level/mistral.md#autocomplete-model) 使用 `Codestral` 。
|
||||
|
||||
如果你想要在本地运行模型,我们推荐通过 [Ollama](../model-providers/top-level/ollama.md#autocomplete-model) 使用 `Starcoder2-3B` 。
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: 聊天模型
|
||||
description: 聊天模型
|
||||
keywords: [聊天]
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
"聊天模型" 是一个训练为在交谈格式中响应的 LLM 。因为它们应该回答通用问题和生成复杂代码,最好的聊天模型通常是很大的,通常 405B+ 参数。在 Continue 中,这些模型用来 [聊天](../../chat/how-to-use-it.md) , [编辑](../../edit/how-to-use-it.md) 和 [Actions](../../actions/how-to-use-it.md) 。
|
||||
|
||||
## 推荐的聊天模型
|
||||
|
||||
如果你有使用任何模型的能力,我们推荐 [Claude 3.5 Sonnet](../model-providers/top-level/anthropic.md) 。
|
||||
|
||||
否则,以下是一些最好的选择:
|
||||
|
||||
- [GPT-4o](../model-providers/top-level/openai.md)
|
||||
- [Gemini 1.5 Pro](../model-providers/top-level/gemini.md)
|
||||
- [Llama3.1 405B](../tutorials/llama3.1.md)
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
---
|
||||
title: 嵌入模型
|
||||
description: 嵌入模型
|
||||
keywords: [嵌入]
|
||||
sidebar_position: 3
|
||||
---
|
||||
|
||||
"嵌入模型" 是训练用来转换一部分文本为向量,可以在之后快速的与其他向量比较,决定部分文本的相似性。嵌入模型通常比 LLM 小得多,在比较中非常快速和便宜。
|
||||
|
||||
在 Continue 中,嵌入是在索引是生成的,然后由 [@Codebase](../deep-dives/codebase.md) 使用,来实现对你的代码库的相似性搜索。
|
||||
|
||||
## 推荐的嵌入模型
|
||||
|
||||
如果你有使用任何模型的能力,我们推荐 `voyage-code-2` ,它独立列在下面,和其他的嵌入模型选项一起。
|
||||
|
||||
如果你想本地生成嵌入,我们推荐通过 [Ollama](../model-providers/top-level/ollama.md#embeddings-model) 使用 `nomic-embed-text` 。
|
||||
|
||||
### Voyage AI
|
||||
|
||||
在从 [这里](https://www.voyageai.com/) 获取 API key 后,你可以像这样配置:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "voyage",
|
||||
"model": "voyage-code-2",
|
||||
"apiKey": "<VOYAGE_API_KEY>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Ollama
|
||||
|
||||
查看 [这个](../model-providers/top-level/ollama.md#embeddings-model) 获取如何使用 Ollama 来嵌入的指令。
|
||||
|
||||
### Transformers.js (当前只有 VS Code)
|
||||
|
||||
[Transformers.js](https://huggingface.co/docs/transformers.js/index) 是流行的 [Transformers](https://huggingface.co/transformers/) 库一个 JavaScript 移植。它允许嵌入完全在本地计算。模型使用的是 `all-MiniLM-L6-v2` ,与 Continue 扩展一起,当你没有明确配置嵌入提供者时,作为默认使用。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "transformers.js"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 文本嵌入推理
|
||||
|
||||
[Hugging Face 文本嵌入推理](https://huggingface.co/docs/text-embeddings-inference/en/index) 允许你托管自己的嵌入端点。你可以如下配置嵌入使用自己的端点:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"embeddingsProvider": {
|
||||
"provider": "huggingface-tei",
|
||||
"apiBase": "http://localhost:8080"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### OpenAI
|
||||
|
||||
查看 [这里](../model-providers/top-level/openai.md#embeddings-model) 获取如何使用 OpenAI 嵌入的指令。
|
||||
|
||||
### Cohere
|
||||
|
||||
查看 [这里](../model-providers/more/cohere.md#embeddings-model) 获取如何使用 Cohere 嵌入的指令。
|
||||
|
||||
### Gemini
|
||||
|
||||
查看 [这里](../model-providers/top-level/gemini.md#embeddings-model) 获取如何使用 Gemini 嵌入的指令。
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
---
|
||||
title: 重排序模型
|
||||
description: 重排序模型
|
||||
keywords: [重排序]
|
||||
sidebar_position: 4
|
||||
---
|
||||
|
||||
"重排序模型" 是训练为采用两部分文本(通常一个用户问题和一个文档)并返回 0 和 1 之间的相关性得分,估算文档回答问题的可用性。重排序通常远小于 LLM ,在比较中非常快速和便宜。
|
||||
|
||||
在 Continue 中,重排序用在 [@Codebase](../deep-dives/codebase.md) ,为了在向量搜索之后选择最想关的代码片断。
|
||||
|
||||
## 推荐的重排序模型
|
||||
|
||||
如果你有使用任何模型的能力,我们推荐 Voyage AI 的 `rerank-1` ,它独立列在下面,和其他的重排序选项一起。
|
||||
|
||||
### Voyage AI
|
||||
|
||||
Voyage AI 提供代码最好的重排序模型, 使用他们的 `rerank-1` 模型。在从 [这里](https://www.voyageai.com/) 获取 API key 后,你可以像这样配置:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "voyage",
|
||||
"params": {
|
||||
"model": "rerank-1",
|
||||
"apiKey": "<VOYAGE_API_KEY>"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cohere
|
||||
|
||||
在 [这里](https://docs.cohere.com/docs/rerank-2) 查看 Cohere 对于重排序的文档。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "cohere",
|
||||
"params": {
|
||||
"model": "rerank-english-v3.0",
|
||||
"apiKey": "<COHERE_API_KEY>"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### LLM
|
||||
|
||||
如果你只能访问一个单独的 LLM ,那么你可以使用它作为重排器。这是不推荐的,除非真正需要,因为它将会更昂贵,并且仍然比上面这些特殊任务训练的模型慢。注意,如果你使用本地的模型,这将不会工作,例如使用 Ollama ,因为会创建太多的并发请求。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "llm",
|
||||
"params": {
|
||||
"modelTitle": "My Model Title"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`"modelTitle"` 字段必须匹配在你的 `config.json` 中 "models" 列表中的一个模型。
|
||||
|
||||
### 文本嵌入推理
|
||||
|
||||
[Hugging Face 文本嵌入推理](https://huggingface.co/docs/text-embeddings-inference/en/index) 允许你托管自己的 [重排器端点](https://huggingface.github.io/text-embeddings-inference/#/Text%20Embeddings%20Inference/rerank) 。你可以像这样配置你的重排器:
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "huggingface-tei",
|
||||
"params": {
|
||||
"apiBase": "http://localhost:8080",
|
||||
"truncate": true,
|
||||
"truncation_direction": "Right"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 免费试用 (Voyage AI)
|
||||
|
||||
Continue 提供 Voyage AI 重排序模型的免费试用。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"reranker": {
|
||||
"name": "free-trial"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: 概览
|
||||
description: 定制 Continue 简介
|
||||
keywords: [定制, 配置, 配置]
|
||||
---
|
||||
|
||||
Continue 可以深度定制。这个主要通过编辑位于 `~/.continue/config.json` (MacOS / Linux) 或 `%USERPROFILE%\.continue\config.json` (Windows) 的本地文件实现。 `config.json` 在你第一次使用 Continue 时创建。
|
||||
|
||||
## 开始
|
||||
|
||||
要打开 `config.json` ,在 Continue 聊天侧边栏的右下角点击 "齿轮" 图标。当编辑这个文件时,你可以使用 IntelliSense ,随着你的输入来查看有效的选项,或者你可以查看 [完整参考](./config.mdx) 。
|
||||
|
||||
当你保存 `config.json` 时, Continue 会自动地刷新,应用你的变更。
|
||||
|
||||
## 每个工作区的配置
|
||||
|
||||
如果你想要限制指定的配置到一个特定的工作区,你可以添加一个 `.continuerc.json` 到你的项目根目录。它有和 `config.json` 相同的 [定义](./config.mdx) ,会自动地应用到本地 `config.json` 之上。
|
||||
|
||||
## 可编程的配置
|
||||
|
||||
`config.json` 可以处理大多数需要的配置,所以我们推荐在可能的情况下使用它。不过,如果你需要可编程的配置 Continue ,你可以使用 `config.ts` ,它位于 `~/.continue/config.ts` (MacOS / Linux) 或 `%USERPROFILE%\.continue\config.ts` (Windows) 。
|
||||
|
||||
例如,如何使用 `config.ts` ,查看 [编写定制斜杠命令](./tutorials/build-your-own-slash-command.md#custom-slash-commands) 或者 [编写定制上下文提供者](./tutorials/build-your-own-context-provider.md) 。
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
---
|
||||
title: 斜杠命令
|
||||
description: 以 '/' 为开头激活的快捷方式
|
||||
keywords: [斜杠命令, 自定义命令, 步骤]
|
||||
---
|
||||
|
||||
斜杠命令是可以通过输入 '/' 来激活,并从下拉框中选择的快捷方式。例如,内置的 '/edit' 斜杠命令,让你可以直接在你的编辑器中流式地编辑。
|
||||
|
||||

|
||||
|
||||
## 内置的斜杠命令
|
||||
|
||||
为了使用任何内置的斜杠命令,打开 `config.json` 并添加它到 `slashCommands` 列表中。
|
||||
|
||||
### `/Edit`
|
||||
|
||||
使用 `ctrl/cmd + L` (VS Code) 或 `ctrl/cmd + J` (JetBrains) 选择代码,然后输入 `/Edit` ,跟着编辑的指令。 Continue 将会流式地在一个并排 diff 编辑器中修改。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "edit",
|
||||
"description": "Edit highlighted code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Comment`
|
||||
|
||||
Comment 工作就像 `/Edit` ,除了它将自动地给 LLM 注释代码的提示词。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "comment",
|
||||
"description": "Write comments for the highlighted code"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Share`
|
||||
|
||||
生成一个关于你当前聊天历史的可分享的 markdown 副本。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "share",
|
||||
"description": "Export the current chat session to markdown",
|
||||
"params": { "outputDir": "~/.continue/session-transcripts" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
使用 `outputDir` 参数指定你想要把 markdown 文件保存在哪里。
|
||||
|
||||
### `/Cmd`
|
||||
|
||||
通过自然语言生成一个 shell 命令,并且(只在 VS Code 中)自动地粘贴它到终端中。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "cmd",
|
||||
"description": "Generate a shell command"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Commit`
|
||||
|
||||
显示给 LLM 你当前的 git diff ,并询问生成一个 commit 消息。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "commit",
|
||||
"description": "Generate a commit message for the current changes"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Http`
|
||||
|
||||
编写一个自定义的斜杠命令,在你自己的 HTTP 端点。在参数对象中对于你设置的端点设置 'url' 。端点应该返回一个字符串更新序列,将会流式地输出到 Continue 侧边栏。查看我们基本的 [FastAPI 示例](https://github.com/continuedev/continue/blob/74002369a5e435735b83278fb965e004ae38a97d/core/context/providers/context_provider_server.py#L34-L45) 作为参考。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "http",
|
||||
"description": "Does something custom",
|
||||
"params": { "url": "<my server endpoint>" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Issue`
|
||||
|
||||
描述你想要生成的 issue , Continue 会转换为格式良好的标题和正文,然后给你一个草稿的链接,让你可以提交。确保设置你想要生成 issue 的仓库的 URL 。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "issue",
|
||||
"description": "Generate a link to a drafted GitHub issue",
|
||||
"params": { "repositoryUrl": "https://github.com/continuedev/continue" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/So`
|
||||
|
||||
StackOverflow 斜杠命令将会自动地拉取 StackOverflow 的结果来回答你的问题,引用链接和它的答案一起。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "so",
|
||||
"description": "Reference StackOverflow to answer the question"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### `/Onboard`
|
||||
|
||||
Onboard 斜杠命令帮助你熟悉一个新的项目,通过分析项目结构, README 和依赖文件。它发现关键目录,解释它们的目的,并高亮使用的流行的包。另外,它提供对项目架构的了解。
|
||||
|
||||
```json title="config.json"
|
||||
{
|
||||
"slashCommands": [
|
||||
{
|
||||
"name": "onboard",
|
||||
"description": "Familiarize yourself with the codebase"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,250 @@
|
|||
---
|
||||
title: 构建你自己的上下文提供者
|
||||
---
|
||||
|
||||
## 入门示例
|
||||
|
||||
要编写你自己的上下文提供者,你只需要实现 `CustomContextProvider` 接口:
|
||||
|
||||
```typescript
|
||||
interface CustomContextProvider {
|
||||
title: string;
|
||||
displayTitle?: string;
|
||||
description?: string;
|
||||
renderInlineAs?: string;
|
||||
type?: ContextProviderType;
|
||||
getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]>;
|
||||
loadSubmenuItems?: (
|
||||
args: LoadSubmenuItemsArgs,
|
||||
) => Promise<ContextSubmenuItem[]>;
|
||||
}
|
||||
```
|
||||
|
||||
作为一个例子,比如你有一系列内部文件索引到一个向量数据库中。你设置了一个简单的 REST API ,允许内部用户查询和获取相关的片段。这个上下文提供者将会发送请求到这个服务器,并从向量数据库返回结果。返回的类型 `getContextItems` _必须_ 是一个包含所有以下属性的实例的列表:
|
||||
|
||||
- `name`: 上下文条目的名称,将会展示为标题
|
||||
- `description`: 上下文条目的一个较长的描述
|
||||
- `content`: 上下文条目的实际内容,将会发送给 LLM 作为上下文
|
||||
|
||||
```typescript title="~/.continue/config.ts"
|
||||
const RagContextProvider: CustomContextProvider = {
|
||||
title: "rag",
|
||||
displayTitle: "RAG",
|
||||
description:
|
||||
"Retrieve snippets from our vector database of internal documents",
|
||||
|
||||
getContextItems: async (
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> => {
|
||||
const response = await fetch("https://internal_rag_server.com/retrieve", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ query }),
|
||||
});
|
||||
|
||||
const results = await response.json();
|
||||
|
||||
return results.map((result) => ({
|
||||
name: result.title,
|
||||
description: result.title,
|
||||
content: result.contents,
|
||||
}));
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
它可以被添加到 `config.ts` 像这样:
|
||||
|
||||
```typescript title="~/.continue/config.ts"
|
||||
export function modifyConfig(config: Config): Config {
|
||||
if (!config.contextProviders) {
|
||||
config.contextProviders = [];
|
||||
}
|
||||
config.contextProviders.push(RagContextProvider);
|
||||
return config;
|
||||
}
|
||||
```
|
||||
|
||||
不需要对 `config.json` 做修改。
|
||||
|
||||
## 定制有 submenu 或 query 的上下文提供者
|
||||
|
||||
这里有 3 种类型的上下文提供者:"normal", "query" 和 "submenu" 。 "normal" 类型是默认的,就是你目前所看到的。
|
||||
|
||||
**"query"** 类型用来当你想要显示文本框给用户,然后使用那个文本框的内容生成上下文条目。内置示例包含 "search" 和 "google" 。这个文本是传递给 `getContextItems` 中的 "query" 参数。为了实现一个 "query" 上下文提供者,简单地设置 `"type": "query"` 在你的定制上下文提供者实例中。
|
||||
|
||||
**"submenu"** 类型用来当你想要在下拉框显示一个可搜索条目列表。内置示例包含 "issue" 和 "folder" 。为了实现一个 "submenu" 上下文提供者,设置 `"type": "submenu"` 并实现 `loadSubmenuItems` 和 `getContextItems` 函数。这是一个例子,显示当前工作区所有 README 文件的列表:
|
||||
|
||||
```typescript title="~/.continue/config.ts"
|
||||
const ReadMeContextProvider: CustomContextProvider = {
|
||||
title: "readme",
|
||||
displayTitle: "README",
|
||||
description: "Reference README.md files in your workspace",
|
||||
type: "submenu",
|
||||
|
||||
getContextItems: async (
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> => {
|
||||
// 'query' is the filepath of the README selected from the dropdown
|
||||
const content = await extras.ide.readFile(query);
|
||||
return [
|
||||
{
|
||||
name: getFolder(query),
|
||||
description: getFolderAndBasename(query),
|
||||
content,
|
||||
},
|
||||
];
|
||||
},
|
||||
|
||||
loadSubmenuItems: async (
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> => {
|
||||
// Filter all workspace files for READMEs
|
||||
const allFiles = await args.ide.listWorkspaceContents();
|
||||
const readmes = allFiles.filter((filepath) =>
|
||||
filepath.endsWith("README.md"),
|
||||
);
|
||||
|
||||
// Return the items that will be shown in the dropdown
|
||||
return readmes.map((filepath) => {
|
||||
return {
|
||||
id: filepath,
|
||||
title: getFolder(filepath),
|
||||
description: getFolderAndBasename(filepath),
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export function modifyConfig(config: Config): Config {
|
||||
if (!config.contextProviders) {
|
||||
config.contextProviders = [];
|
||||
}
|
||||
config.contextProviders.push(ReadMeContextProvider);
|
||||
return config;
|
||||
}
|
||||
|
||||
function getFolder(path: string): string {
|
||||
return path.split(/[\/\\]/g).slice(-2)[0];
|
||||
}
|
||||
|
||||
function getFolderAndBasename(path: string): string {
|
||||
return path
|
||||
.split(/[\/\\]/g)
|
||||
.slice(-2)
|
||||
.join("/");
|
||||
}
|
||||
```
|
||||
|
||||
以上示例的信息流如下:
|
||||
|
||||
1. 用户输入 `@readme` 并从下拉框中选择,现在显示子菜单,他们可以搜索任何 `loadSubmenuItems` 返回的条目。
|
||||
2. 用户在子菜单中选择 README 之一,输入其他输入,并按下回车。
|
||||
3. 选择的 `ContextSubmenuItem` 的 id 传递给 `getContextItems` 作为 `query` 参数。在这个例子中,它是 README 的文件路径。
|
||||
4. 然后 `getContextItems` 函数使用 `query` 获取 README 的完整内容,并在返回上下文条目之前格式化内容,它会包含在提示词之中。
|
||||
|
||||
## 导入外部模块
|
||||
|
||||
为了包含外部的 Node 模块在你的 config.ts 中,在 `~/.continue` 文件夹运行 `npm install <module_name>` ,然后在 config.ts 中导入它们。
|
||||
|
||||
Continue 将使用 [esbuild](https://esbuild.github.io/) 打包你的 `config.ts` 和任何依赖到一个单独的 Javascript 文件。确切使用的配置可以在 [这里](https://github.com/continuedev/continue/blob/5c9874400e223bbc9786a8823614a2e501fbdaf7/extensions/vscode/src/ideProtocol.ts#L45-L52) 找到。
|
||||
|
||||
## `CustomContextProvider` 参考
|
||||
|
||||
- `title`: 上下文提供者的标识符
|
||||
- `displayTitle` (可选):在下拉框中显示的标题
|
||||
- `description` (可选):当鼠标悬停时,在下拉框中显示的较长的描述
|
||||
- `type` (可选):上下文提供者的类型。可选项是 "normal", "query" 和 "submenu" 。默认是 "normal" 。
|
||||
- `renderInlineAs` (可选):将会在提示词上面渲染的字符串。如果没有值提供, `displayTitle` 将会被sisyphus。可以提供空字符串来禁止渲染默认的 `displayTitle` 。
|
||||
- `getContextItems`: A function that returns the documents to include in the prompt. It should return a list of `ContextItem`s, and is given access to the following arguments:
|
||||
- `getContextItems`: 一个返回包含在提示词中文档的函数。它应该返回一个 `ContextItem` 列表,并可以访问以下参数:
|
||||
- `extras.fullInput`: 一个代表用户在文本框中完整输入的字符串。这可以用来生成嵌入,与一批其他的嵌入文档比较
|
||||
- `extras.embeddingsProvider`: 嵌入提供者有一个 `embed` 函数,将会转换文本 (例如 `fullInput`) 为嵌入
|
||||
- `extras.llm`: 当前默认的 LLM ,你可以用来创建补全请求
|
||||
- `extras.ide`: 一个 `IDE` 类的实例,让你可以收集来自 IDE 的不同来源的信息,包括终端的内容,打开文件的列表,或追额当前打开文件中的任何警告。
|
||||
- `query`: (not currently used) A string representing the query
|
||||
- `query`: (当前没有使用) 代表 query 的字符串
|
||||
- `loadSubmenuItems` (可选): 一个返回 `ContextSubmenuItem` 列表的函数,显示在子菜单中。它可以访问 `IDE` ,同样传递给 `getContextItems` 。
|
||||
|
||||
## 使用其他语言编写上下文提供者
|
||||
|
||||
如果你想要用除了 TypeScript 的其他语言编写上下文提供者,你可以使用 "http" 上下文提供者,来调用一个托管你自己代码的服务器。添加上下文提供者到 `config.json` ,像这样:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "http",
|
||||
"params": {
|
||||
"url": "https://myserver.com/context-provider",
|
||||
"title": "http",
|
||||
"description": "Custom HTTP Context Provider",
|
||||
"displayTitle": "My Custom Context"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- Then, create a server that responds to requests as are made from [HttpContextProvider.ts](../../../core/context/providers/HttpContextProvider.ts). See the `hello` endpoint in [context_provider_server.py](../../../core/context/providers/context_provider_server.py) for an example that uses FastAPI. -->
|
||||
|
||||
## VSCode 的扩展 API
|
||||
|
||||
Continue 暴露一个 API ,从第三方 VSCode 扩展注册上下文提供者。这是有用的,如果你有一个 VSCode 扩展,提供一些额外的上下文,你想要在 Continue 中使用。为了使用这个 API ,添加以下内容到你的 `package.json` :
|
||||
|
||||
```json
|
||||
{
|
||||
"extensionDependencies": ["continue.continue"]
|
||||
}
|
||||
```
|
||||
|
||||
或者复制 `~/.continue/type/core/index.d.ts` 到你的扩展仓库。
|
||||
|
||||
然后,你可以使用 `registerCustomContextProvider` 函数注册你的上下文提供者。你定制的上下文提供者必须实现 `IContextProvider` 接口。
|
||||
这是一个例子:
|
||||
|
||||
```typescript
|
||||
import * as vscode from "vscode";
|
||||
|
||||
class MyCustomProvider implements IContextProvider {
|
||||
get description(): ContextProviderDescription {
|
||||
return {
|
||||
title: "custom",
|
||||
displayTitle: "Custom",
|
||||
description: "Custom description",
|
||||
type: "normal",
|
||||
};
|
||||
}
|
||||
|
||||
async getContextItems(
|
||||
query: string,
|
||||
extras: ContextProviderExtras,
|
||||
): Promise<ContextItem[]> {
|
||||
return [
|
||||
{
|
||||
name: "Custom",
|
||||
description: "Custom description",
|
||||
content: "Custom content",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async loadSubmenuItems(
|
||||
args: LoadSubmenuItemsArgs,
|
||||
): Promise<ContextSubmenuItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// create an instance of your custom provider
|
||||
const customProvider = new MyCustomProvider();
|
||||
|
||||
// get Continue extension using vscode API
|
||||
const continueExt = vscode.extensions.getExtension("continue.continue");
|
||||
|
||||
// get the API from the extension
|
||||
const continueApi = continueExt?.exports;
|
||||
|
||||
// register your custom provider
|
||||
continueApi?.registerCustomContextProvider(customProvider);
|
||||
```
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
title: 构建你自己的斜杠命令
|
||||
---
|
||||
|
||||
这里有两种方式可以添加自定义斜杠命令:
|
||||
|
||||
1. 使用自然语言提示词 - 这个比较简单,只需要编写一个字符串或字符串模板。
|
||||
2. 使用一个自定义函数 - 这个给你完全访问 Continue SDK 并允许你编写任意的 Typescript 代码。
|
||||
|
||||
### "自定义命令" (使用自然语言)
|
||||
|
||||
你可以添加自定义斜杠命令,通过添加到 `config.json` 中的 `customCommands` 属性。
|
||||
|
||||
- `name`: 命令的名称,使用 `/name` 触发
|
||||
- `description`: 命令的一个简短描述,会出现在下拉框中
|
||||
- `prompt`: 一个模板的提示词发送给 LLM
|
||||
|
||||
当你频繁使用一个提示词时,自定义命令很好用。例如,如果你精心制作了一个很好的提示词,频繁地问 LLM 检查你代码中的错误,你可以添加一个命令,像这样:
|
||||
|
||||
```json title="config.json"
|
||||
customCommands=[{
|
||||
"name": "check",
|
||||
"description": "Check for mistakes in my code",
|
||||
"prompt": "{{{ input }}}\n\nPlease read the highlighted code and check for any mistakes. You should look for the following, and be extremely vigilant:\n- Syntax errors\n- Logic errors\n- Security vulnerabilities\n- Performance issues\n- Anything else that looks wrong\n\nOnce you find an error, please explain it as clearly as possible, but without using extra words. For example, instead of saying 'I think there is a syntax error on line 5', you should say 'Syntax error on line 5'. Give your answer as one bullet point per mistake found."
|
||||
}]
|
||||
```
|
||||
|
||||
#### 模板
|
||||
|
||||
`prompt` 属性支持 Handlebars 语法的模板。你可以使用以下参数:
|
||||
|
||||
- `input` (在上面的例子中使用): 斜杠命令的任何额外输入。例如,如果你输入 `/test only write one test` , `input` 将是 `only write one test` 。这还将包含高亮的代码块。
|
||||
- 文件名称: 你可以引用任何文件,通过提供绝对路径或当前工作目录的相对路径。
|
||||
|
||||
### 自定义斜杠命令
|
||||
|
||||
如果你想要比使用自然语言编写自定义命令更进一步,你可以编写一个自定义函数返回响应。这需要使用 `config.ts` 代替 `config.json` 。
|
||||
|
||||
为了做这个,放一个新的 `SlashCommand` 对象到 `slashCommands` 列表中。这个对象包含 "name" ,你用来触发斜杠命令的名称, "description" ,在下拉菜单中看到的描述,以及 "run" 。 `run` 函数是任何异步生成器,应该生成你想要流式输出到 UI 的字符串。作为函数的参数,你可以访问一个有实用工具的 `ContinueSDK` 对象,例如访问 IDE 中的当前信息/action ,当前语言模型,以及一些其他实用工具。例如,这是一个生成 commit 信息的斜杠命令:
|
||||
|
||||
```typescript title="~/.continue/config.ts"
|
||||
export function modifyConfig(config: Config): Config {
|
||||
config.slashCommands?.push({
|
||||
name: "commit",
|
||||
description: "Write a commit message",
|
||||
run: async function* (sdk) {
|
||||
const diff = await sdk.ide.getDiff();
|
||||
for await (const message of sdk.llm.streamComplete(
|
||||
`${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`,
|
||||
{
|
||||
maxTokens: 20,
|
||||
},
|
||||
)) {
|
||||
yield message;
|
||||
}
|
||||
},
|
||||
});
|
||||
return config;
|
||||
}
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue