diff --git a/.changes/unreleased/Added-20241113-165958.yaml b/.changes/unreleased/Added-20241113-165958.yaml new file mode 100644 index 000000000..95aaa7c70 --- /dev/null +++ b/.changes/unreleased/Added-20241113-165958.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: .continuerules file to set system prompt +time: 2024-11-13T16:59:58.544875-08:00 diff --git a/.changes/unreleased/Added-20241113-170006.yaml b/.changes/unreleased/Added-20241113-170006.yaml new file mode 100644 index 000000000..bc254f8d9 --- /dev/null +++ b/.changes/unreleased/Added-20241113-170006.yaml @@ -0,0 +1,4 @@ +project: extensions/vscode +kind: Added +body: .prompt files v2 +time: 2024-11-13T17:00:06.855468-08:00 diff --git a/.github/workflows/auto-assign.yaml b/.github/workflows/auto-assign.yaml index 3108307e5..dc5388ef3 100644 --- a/.github/workflows/auto-assign.yaml +++ b/.github/workflows/auto-assign.yaml @@ -14,7 +14,7 @@ jobs: uses: pozil/auto-assign-issue@v2 with: repo-token: ${{ secrets.CI_GITHUB_TOKEN }} - assignees: sestinj,Patrick-Erichsen + assignees: sestinj,Patrick-Erichsen,tomasz-stefaniak,RomneyDa numOfAssignee: 1 - name: "Add default labels" uses: actions-ecosystem/action-add-labels@v1 diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 31b64bae1..b73cdb3ad 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -213,8 +213,8 @@ jobs: git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - - name: Pull latest changes - run: git pull origin main + - name: Pull latest changes from release + run: git fetch origin ${{ github.ref }} && git checkout ${{ github.ref }} # 1. Download the artifacts - uses: actions/download-artifact@v4 @@ -237,21 +237,3 @@ jobs: run: | cd extensions/vscode npx ovsx publish -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix - - # 4. Update the package.json version and push changes - # - name: Update version in package.json - # run: | - # cd extensions/vscode - # npm version patch - - # - name: Commit changes - # run: | - # git config --local user.email "action@github.com" - # git config --local user.name "GitHub Action" - # git commit -am "๐Ÿ’š Update package.json version [skip ci]" - - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ github.ref }} diff --git a/.instructions b/.instructions new file mode 100644 index 000000000..bad5d9689 --- /dev/null +++ b/.instructions @@ -0,0 +1 @@ +Give concise responses. diff --git a/binary/package-lock.json b/binary/package-lock.json index 0d67a4725..a27e6ee97 100644 --- a/binary/package-lock.json +++ b/binary/package-lock.json @@ -74,7 +74,7 @@ "jsdom": "^24.0.0", "launchdarkly-node-client-sdk": "^3.2.0", "llm-code-highlighter": "^0.0.14", - "lru-cache": "^10.2.2", + "lru-cache": "^11.0.2", "mac-ca": "^3.1.0", "node-fetch": "^3.3.2", "node-html-markdown": "^1.3.0", @@ -99,6 +99,7 @@ "vectordb": "^0.4.20", "web-tree-sitter": "^0.21.0", "win-ca": "^3.5.1", + "wink-nlp-utils": "^2.1.0", "workerpool": "^9.1.3", "yaml": "^2.4.2", "zod": "^3.23.8" @@ -135,12 +136,12 @@ } }, "node_modules/@75lb/deep-merge": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz", - "integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz", + "integrity": "sha512-08K9ou5VNbheZFxM5tDWoqjA3ImC50DiuuJ2tj1yEPRfkp8lLLg6XAaJ4On+a0yAXor/8ay5gHnAIshRM44Kpw==", "peer": true, "dependencies": { - "lodash.assignwith": "^4.2.0", + "lodash": "^4.17.21", "typical": "^7.1.1" }, "engines": { @@ -2749,12 +2750,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -3545,9 +3546,9 @@ "optional": true }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -5037,10 +5038,10 @@ "node": ">=8" } }, - "node_modules/lodash.assignwith": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", - "integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==", + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "peer": true }, "node_modules/lodash.camelcase": { diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 24815f501..9667352fd 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -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; diff --git a/core/autocomplete/README.md b/core/autocomplete/README.md index c02be2b01..9baf9cd4b 100644 --- a/core/autocomplete/README.md +++ b/core/autocomplete/README.md @@ -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://" }, "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). diff --git a/core/autocomplete/context/ImportDefinitionsService.ts b/core/autocomplete/context/ImportDefinitionsService.ts index 0df08f096..525834a95 100644 --- a/core/autocomplete/context/ImportDefinitionsService.ts +++ b/core/autocomplete/context/ImportDefinitionsService.ts @@ -2,7 +2,7 @@ import { IDE } from "../.."; import { RangeInFileWithContents } from "../../commands/util"; import { PrecalculatedLruCache } from "../../util/LruCache"; import { - TSQueryType, + getFullLanguageName, getParserForFile, getQueryForFile, } from "../../util/treeSitter"; @@ -47,7 +47,11 @@ export class ImportDefinitionsService { }, ], }); - const query = await getQueryForFile(filepath, TSQueryType.Imports); + const language = getFullLanguageName(filepath); + const query = await getQueryForFile( + filepath, + `import-queries/${language}.scm`, + ); if (!query) { return { imports: {}, diff --git a/core/autocomplete/context/root-path-context/RootPathContextService.ts b/core/autocomplete/context/root-path-context/RootPathContextService.ts index b381f2166..0147df151 100644 --- a/core/autocomplete/context/root-path-context/RootPathContextService.ts +++ b/core/autocomplete/context/root-path-context/RootPathContextService.ts @@ -4,11 +4,31 @@ import { LRUCache } from "lru-cache"; import Parser from "web-tree-sitter"; import { IDE } from "../../.."; -import { getQueryForFile } from "../../../util/treeSitter"; +import { + getFullLanguageName, + getQueryForFile, + IGNORE_PATH_PATTERNS, + LanguageName, +} from "../../../util/treeSitter"; 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({ max: 100, @@ -24,10 +44,15 @@ export class RootPathContextService { } private static TYPES_TO_USE = new Set([ + "arrow_function", + "generator_function_declaration", "program", "function_declaration", + "function_definition", "method_definition", + "method_declaration", "class_declaration", + "class_definition", ]); /** @@ -49,6 +74,7 @@ export class RootPathContextService { node: Parser.SyntaxNode, ): Promise { const snippets: AutocompleteSnippet[] = []; + const language = getFullLanguageName(filepath); let query: Parser.Query | undefined; switch (node.type) { @@ -56,9 +82,13 @@ export class RootPathContextService { this.importDefinitionsService.get(filepath); break; default: + // const type = node.type; + // console.log(getSyntaxTreeString(node)); + // debugger; + query = await getQueryForFile( filepath, - `root-path-context-queries/${node.type}`, + `root-path-context-queries/${language}/${node.type}.scm`, ); break; } @@ -67,15 +97,24 @@ export class RootPathContextService { return snippets; } - await Promise.all( - query.matches(node).map(async (match) => { - for (const item of match.captures) { + const queries = query.matches(node).map(async (match) => { + for (const item of match.captures) { + try { const endPosition = item.node.endPosition; - const newSnippets = await this.getSnippets(filepath, endPosition); + const newSnippets = await this.getSnippets( + filepath, + endPosition, + language, + ); snippets.push(...newSnippets); + } catch (e) { + debugger; + throw e; } - }), - ); + } + }); + + await Promise.all(queries); return snippets; } @@ -83,6 +122,7 @@ export class RootPathContextService { private async getSnippets( filepath: string, endPosition: Parser.Point, + language: LanguageName, ): Promise { const definitions = await this.ide.gotoDefinition({ filepath, @@ -92,11 +132,20 @@ export class RootPathContextService { }, }); const newSnippets = await Promise.all( - definitions.map(async (def) => ({ - ...def, - contents: await this.ide.readRangeInFile(def.filepath, def.range), - })), + definitions + .filter((definition) => { + const isIgnoredPath = IGNORE_PATH_PATTERNS[language]?.some( + (pattern) => pattern.test(definition.filepath), + ); + + return !isIgnoredPath; + }) + .map(async (def) => ({ + ...def, + contents: await this.ide.readRangeInFile(def.filepath, def.range), + })), ); + return newSnippets; } @@ -112,6 +161,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 = diff --git a/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts b/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts index 597d37d12..a954dda84 100644 --- a/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts +++ b/core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts @@ -1,41 +1,55 @@ +import { PYTHON_TEST_CASES, TYPESCRIPT_TEST_CASES } from "./testCases"; import { testRootPathContext } from "./testUtils"; const TEST_CASES = [ + ...PYTHON_TEST_CASES, + ...TYPESCRIPT_TEST_CASES, { - description: "function", - fileName: "file1.ts", - range: { - start: { line: 10, character: 2 }, - end: { line: 10, character: 24 }, - }, - positions: [ - { row: 9, column: 34 }, // Person - { row: 9, column: 44 }, // 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 ], }, { - description: "class method", - fileName: "file1.ts", - range: { - start: { line: 22, character: 4 }, - end: { line: 22, character: 30 }, - }, - positions: [ - { row: 13, column: 29 }, // BaseClass - { row: 13, column: 55 }, // FirstInterface - { row: 13, column: 72 }, // SecondInterface - { row: 21, column: 33 }, // Person - { row: 21, column: 43 }, // Address + nodeType: "method_declaration", + 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 + ], + }, + { + nodeType: "function_declaration", + fileName: "file1.go", + language: "Go", + cursorPosition: { line: 7, character: 21 }, + definitionPositions: [ + { row: 6, column: 33 }, // models.User + { row: 6, column: 50 }, // models.Address ], }, ]; describe("RootPathContextService", () => { - describe("TypeScript should return expected snippets when editing inside a:", () => { + describe("should look for correct type definitions", () => { 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); + "$language: $nodeType", + async ({ fileName, cursorPosition, definitionPositions }) => { + await testRootPathContext( + "files", + fileName, + cursorPosition, + definitionPositions, + ); }, ); }); diff --git a/core/autocomplete/context/root-path-context/test/files/__init__.py b/core/autocomplete/context/root-path-context/test/files/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/core/autocomplete/context/root-path-context/test/files/base_module.py b/core/autocomplete/context/root-path-context/test/files/base_module.py new file mode 100644 index 000000000..cf0dc0abb --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/base_module.py @@ -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}" diff --git a/core/autocomplete/context/root-path-context/test/files/file1.go b/core/autocomplete/context/root-path-context/test/files/file1.go new file mode 100644 index 000000000..94eec171c --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/file1.go @@ -0,0 +1,9 @@ +package main + +import ( + "core/autocomplete/context/root-path-context/test/files/models" +) + +func getAddress(user *models.User) *models.Address { + return user.Address +} \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/file1.php b/core/autocomplete/context/root-path-context/test/files/file1.php new file mode 100644 index 000000000..a72f805e0 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/file1.php @@ -0,0 +1,32 @@ +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); + } +} + +?> \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/python/classes.py b/core/autocomplete/context/root-path-context/test/files/python/classes.py new file mode 100644 index 000000000..d752d8433 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/python/classes.py @@ -0,0 +1,11 @@ +class Group(BaseClass, Person): + pass + +class Group(metaclass=MetaGroup): + pass + +class Group(BaseClass[Address], Gathering[Person]): + pass + +class Group(List[Address], Person[str]): + pass \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/python/functions.py b/core/autocomplete/context/root-path-context/test/files/python/functions.py new file mode 100644 index 000000000..74a9d8b58 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/python/functions.py @@ -0,0 +1,42 @@ +from typing import List, Union, TypeVar, Generic + +T = TypeVar('T') + +class Address: + pass + +class Person: + pass + +class PersonWithGeneric(Generic[T]): + pass + + +def get_address(person: Person) -> Address: + pass + +def get_group_address(people: Group[Person]) -> Group[Address]: + pass + +def log_person(person: Person) -> None: + pass + +def get_hardcoded_address() -> Address: + pass + +def log_person_or_address(value: Union[Person, Address]) -> Union[Person, Address]: + pass + +def log_person_and_address(person: Person, address: Address) -> None: + pass + +def get_address_generator(person: Person) -> Generator[Address, None, None]: + yield + + +class Group: + def log_person_and_address(self, person: Person, address: Address) -> None: + pass + +async def get_person(address: Address) -> Person: + pass \ No newline at end of file diff --git a/core/autocomplete/context/root-path-context/test/files/typescript/arrowFunctions.ts b/core/autocomplete/context/root-path-context/test/files/typescript/arrowFunctions.ts new file mode 100644 index 000000000..aadffe065 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/typescript/arrowFunctions.ts @@ -0,0 +1,29 @@ +// @ts-nocheck + +const getAddress = (person: Person): Address => { + // TODO +}; + +const logPerson = (person: Person) => { + // TODO +}; + +const getHardcodedAddress = (): Address => { + // TODO +}; + +const getAddresses = (people: Person[]): Address[] => { + // TODO +}; + +const logPersonWithAddres = (person: Person
): Person
=> { + // TODO +}; + +const logPersonOrAddress = (person: Person | Address): Person | Address => { + // TODO +}; + +const logPersonAndAddress = (person: Person, address: Address) => { + // TODO +}; diff --git a/core/autocomplete/context/root-path-context/test/files/typescript/classMethods.ts b/core/autocomplete/context/root-path-context/test/files/typescript/classMethods.ts new file mode 100644 index 000000000..08f7506a7 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/typescript/classMethods.ts @@ -0,0 +1,35 @@ +// @ts-nocheck + +class Group { + getPersonAddress(person: Person): Address { + // TODO + } + + getHardcodedAddress(): Address { + // TODO + } + + addPerson(person: Person) { + // TODO + } + + addPeople(people: Person[]) { + // TODO + } + + getAddresses(people: Person[]): Address[] { + // TODO + } + + logPersonWithAddress(person: Person
): Person
{ + // TODO + } + + logPersonOrAddress(person: Person | Address): Person | Address { + // TODO + } + + logPersonAndAddress(person: Person, address: Address) { + // TODO + } +} diff --git a/core/autocomplete/context/root-path-context/test/files/typescript/classes.ts b/core/autocomplete/context/root-path-context/test/files/typescript/classes.ts new file mode 100644 index 000000000..8bb829986 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/typescript/classes.ts @@ -0,0 +1,9 @@ +// @ts-nocheck + +class Group extends BaseClass {} + +class Group implements FirstInterface {} + +class Group extends BaseClass implements FirstInterface, SecondInterface {} + +class Group extends BaseClass implements FirstInterface {} diff --git a/core/autocomplete/context/root-path-context/test/files/typescript/functions.ts b/core/autocomplete/context/root-path-context/test/files/typescript/functions.ts new file mode 100644 index 000000000..bb9d39c85 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/typescript/functions.ts @@ -0,0 +1,33 @@ +// @ts-nocheck + +function getAddress(person: Person): Address { + // TODO +} + +function getFirstAddress(people: Person[]): Address { + // TODO +} + +function logPerson(person: Person) { + // TODO +} + +function getHardcodedAddress(): Address { + // TODO +} + +function getAddresses(people: Person[]): Address[] { + // TODO +} + +function logPersonWithAddress(person: Person
): Person
{ + // TODO +} + +function logPersonOrAddress(person: Person | Address): Person | Address { + // TODO +} + +function logPersonAndAddress(person: Person, address: Address) { + // TODO +} diff --git a/core/autocomplete/context/root-path-context/test/files/typescript/generators.ts b/core/autocomplete/context/root-path-context/test/files/typescript/generators.ts new file mode 100644 index 000000000..79811b478 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/files/typescript/generators.ts @@ -0,0 +1,33 @@ +// @ts-nocheck + +function* getAddress(person: Person): Address { + // TODO +} + +function* getFirstAddress(people: Person[]): Address { + // TODO +} + +function* logPerson(person: Person) { + // TODO +} + +function* getHardcodedAddress(): Address { + // TODO +} + +function* getAddresses(people: Person[]): Address[] { + // TODO +} + +function* logPersonWithAddress(person: Person
): Person
{ + // TODO +} + +function* logPersonOrAddress(person: Person | Address): Person | Address { + // TODO +} + +function* logPersonAndAddress(person: Person, address: Address) { + // TODO +} diff --git a/core/autocomplete/context/root-path-context/test/testCases/index.ts b/core/autocomplete/context/root-path-context/test/testCases/index.ts new file mode 100644 index 000000000..7859fc23d --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/testCases/index.ts @@ -0,0 +1,2 @@ +export * from "./python"; +export * from "./typescript"; diff --git a/core/autocomplete/context/root-path-context/test/testCases/python.ts b/core/autocomplete/context/root-path-context/test/testCases/python.ts new file mode 100644 index 000000000..9c8d46e43 --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/testCases/python.ts @@ -0,0 +1,145 @@ +export const FUNCTIONS = [ + { + nodeType: "function_definition with argument and return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 15, character: 8 }, + definitionPositions: [ + { row: 14, column: 30 }, // Person + { row: 14, column: 42 }, // Address + ], + }, + { + nodeType: + "function_definition with generic argument and generic return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 18, character: 8 }, + definitionPositions: [ + { row: 17, column: 35 }, // Group + { row: 17, column: 42 }, // Person + { row: 17, column: 53 }, // Group + { row: 17, column: 61 }, // Address + ], + }, + { + nodeType: "function_definition with single argument and None return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 21, character: 8 }, + definitionPositions: [ + { row: 20, column: 29 }, // Person + ], + }, + { + nodeType: "function_definition with no arguments and single return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 24, character: 8 }, + definitionPositions: [ + { row: 23, column: 38 }, // Address + ], + }, + { + nodeType: "function_definition with Union arguments and Union return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 27, character: 8 }, + definitionPositions: [ + { row: 26, column: 45 }, // Person + { row: 26, column: 54 }, // Address + { row: 26, column: 72 }, // Person + { row: 26, column: 81 }, // Address + ], + }, + { + nodeType: + "function_definition with multiple arguments and None return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 30, character: 8 }, + definitionPositions: [ + { row: 29, column: 41 }, // Person + { row: 29, column: 59 }, // Address + ], + }, + { + nodeType: "function_definition with one argument and Generator return type", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 33, character: 9 }, + definitionPositions: [ + { row: 32, column: 40 }, // Person + { row: 32, column: 62 }, // Address + ], + }, + { + nodeType: "function_definition inside a class", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 38, character: 12 }, + definitionPositions: [ + { row: 37, column: 51 }, // Person + { row: 37, column: 69 }, // Address + ], + }, + { + nodeType: "function_definition of an async function", + fileName: "python/functions.py", + language: "Python", + cursorPosition: { line: 41, character: 8 }, + definitionPositions: [ + { row: 40, column: 37 }, // Address + { row: 40, column: 48 }, // Person + ], + }, +]; + +export const CLASSES = [ + { + nodeType: "class_definition with multiple superclasses", + fileName: "python/classes.py", + language: "Python", + cursorPosition: { line: 1, character: 8 }, + definitionPositions: [ + { row: 0, column: 21 }, // BaseClass + { row: 0, column: 29 }, // Person + ], + }, + { + nodeType: "class_definition with multiple superclasses", + fileName: "python/classes.py", + language: "Python", + cursorPosition: { line: 4, character: 8 }, + definitionPositions: [ + { row: 3, column: 31 }, // MetaGroup + ], + }, + { + nodeType: "class_definition with generic superclasses", + fileName: "python/classes.py", + language: "Python", + cursorPosition: { line: 7, character: 8 }, + definitionPositions: [ + { row: 6, column: 21 }, // BaseClass + { row: 6, column: 29 }, // Address + { row: 6, column: 41 }, // Gathering + { row: 6, column: 48 }, // Person + ], + }, + { + nodeType: "class_definition with generic superclasses (built in types)", + fileName: "python/classes.py", + language: "Python", + cursorPosition: { line: 10, character: 8 }, + definitionPositions: [ + { row: 9, column: 24 }, // Address + { row: 9, column: 33 }, // Person + ], + }, +]; + +export const PYTHON_TEST_CASES = [ + // ...FUNCTIONS, + ...CLASSES, +]; diff --git a/core/autocomplete/context/root-path-context/test/testCases/typescript.ts b/core/autocomplete/context/root-path-context/test/testCases/typescript.ts new file mode 100644 index 000000000..ddda2bfde --- /dev/null +++ b/core/autocomplete/context/root-path-context/test/testCases/typescript.ts @@ -0,0 +1,397 @@ +const FUNCTIONS = [ + { + nodeType: "function_declaration with a param and a return type", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 3, character: 9 }, + definitionPositions: [ + { row: 2, column: 34 }, // Person + { row: 2, column: 44 }, // Address + ], + }, + { + nodeType: "function_declaration with array param", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 7, character: 9 }, + definitionPositions: [ + { row: 6, column: 39 }, // Person + { row: 6, column: 51 }, // Address + ], + }, + { + nodeType: "function_declaration without return type", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 11, character: 9 }, + definitionPositions: [ + { row: 10, column: 33 }, // Person + ], + }, + { + nodeType: "function_declaration without params", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 15, character: 9 }, + definitionPositions: [ + { row: 14, column: 39 }, // Person + ], + }, + { + nodeType: "function_declaration with array params and array return type", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 19, character: 9 }, + definitionPositions: [ + { row: 18, column: 36 }, // Person + { row: 18, column: 48 }, // Address + ], + }, + { + nodeType: + "function_declaration with generic params and generic return type", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 23, character: 9 }, + definitionPositions: [ + { row: 22, column: 44 }, // Person + { row: 22, column: 52 }, // Address + { row: 22, column: 62 }, // Person + { row: 22, column: 70 }, // Address + ], + }, + { + nodeType: + "function_declaration with union type params and union return type", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 27, character: 9 }, + definitionPositions: [ + { row: 26, column: 42 }, // Person + { row: 26, column: 52 }, // Address + { row: 26, column: 61 }, // Person + { row: 26, column: 71 }, // Address + ], + }, + { + nodeType: "function_declaration with two arguments", + fileName: "typescript/functions.ts", + language: "TypeScript", + cursorPosition: { line: 31, character: 9 }, + definitionPositions: [ + { row: 30, column: 43 }, // Person + { row: 30, column: 61 }, // Address + ], + }, +]; + +const GENERATORS = [ + { + nodeType: "function_declaration with a param and a return type", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 3, character: 9 }, + definitionPositions: [ + { row: 2, column: 35 }, // Person + { row: 2, column: 45 }, // Address + ], + }, + { + nodeType: "function_declaration with array param", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 7, character: 9 }, + definitionPositions: [ + { row: 6, column: 40 }, // Person + { row: 6, column: 52 }, // Address + ], + }, + { + nodeType: "function_declaration without return type", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 11, character: 9 }, + definitionPositions: [ + { row: 10, column: 34 }, // Person + ], + }, + { + nodeType: "function_declaration without params", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 15, character: 9 }, + definitionPositions: [ + { row: 14, column: 40 }, // Person + ], + }, + { + nodeType: "function_declaration with array params and array return type", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 19, character: 9 }, + definitionPositions: [ + { row: 18, column: 37 }, // Person + { row: 18, column: 49 }, // Address + ], + }, + { + nodeType: + "function_declaration with generic params and generic return type", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 23, character: 9 }, + definitionPositions: [ + { row: 22, column: 45 }, // Person + { row: 22, column: 53 }, // Address + { row: 22, column: 63 }, // Person + { row: 22, column: 71 }, // Address + ], + }, + { + nodeType: + "function_declaration with union type params and union return type", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 27, character: 9 }, + definitionPositions: [ + { row: 26, column: 43 }, // Person + { row: 26, column: 53 }, // Address + { row: 26, column: 62 }, // Person + { row: 26, column: 72 }, // Address + ], + }, + { + nodeType: "function_declaration with two arguments", + fileName: "typescript/generators.ts", + language: "TypeScript", + cursorPosition: { line: 31, character: 9 }, + definitionPositions: [ + { row: 30, column: 44 }, // Person + { row: 30, column: 62 }, // Address + ], + }, +]; + +const ARROW_FUNCTIONS = [ + { + nodeType: "arrow_function with a param and a return type", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 3, character: 9 }, + definitionPositions: [ + { row: 2, column: 34 }, // Person + { row: 2, column: 44 }, // Address + ], + }, + { + nodeType: "arrow_function without return type", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 7, character: 9 }, + definitionPositions: [ + { row: 6, column: 33 }, // Person + ], + }, + { + nodeType: "arrow_function without params", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 11, character: 9 }, + definitionPositions: [ + { row: 10, column: 39 }, // Person + ], + }, + { + nodeType: "arrow_function with array params and array return type", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 15, character: 9 }, + definitionPositions: [ + { row: 14, column: 36 }, // Person + { row: 14, column: 48 }, // Address + ], + }, + { + nodeType: "arrow_function with generic params and generic return type", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 19, character: 9 }, + definitionPositions: [ + { row: 18, column: 43 }, // Person + { row: 18, column: 51 }, // Address + { row: 18, column: 61 }, // Person + { row: 18, column: 69 }, // Address + ], + }, + { + nodeType: "arrow_function with union type params and union return type", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 23, character: 9 }, + definitionPositions: [ + { row: 22, column: 42 }, // Person + { row: 22, column: 52 }, // Address + { row: 22, column: 61 }, // Person + { row: 22, column: 71 }, // Address + ], + }, + { + nodeType: "arrow_function with two arguments", + fileName: "typescript/arrowFunctions.ts", + language: "TypeScript", + cursorPosition: { line: 27, character: 11 }, + definitionPositions: [ + { row: 26, column: 43 }, // Person + { row: 26, column: 61 }, // Address + ], + }, +]; + +const CLASS_METHODS = [ + { + nodeType: "method_declaration with a param and a return type", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 4, character: 11 }, + definitionPositions: [ + { row: 3, column: 33 }, // Person + { row: 3, column: 43 }, // Address + ], + }, + { + nodeType: "method_declaration without arguments", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 8, character: 11 }, + definitionPositions: [ + { row: 7, column: 32 }, // Address + ], + }, + { + nodeType: "method_declaration without return type", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 12, character: 11 }, + definitionPositions: [ + { row: 11, column: 26 }, // Person + ], + }, + { + nodeType: "method_declaration with array type arguments", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 16, character: 11 }, + definitionPositions: [ + { row: 15, column: 26 }, // Person + ], + }, + { + nodeType: + "method_declaration with array type arguments and array type return", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 20, character: 11 }, + definitionPositions: [ + { row: 19, column: 29 }, // Person + { row: 19, column: 41 }, // Address + ], + }, + { + nodeType: + "method_declaration with with generic params and generic return type", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 24, character: 11 }, + definitionPositions: [ + { row: 23, column: 37 }, // Person + { row: 23, column: 45 }, // Address + { row: 23, column: 55 }, // Person + { row: 23, column: 63 }, // Address + ], + }, + { + nodeType: "method_declaration with union type params and union return type", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 28, character: 11 }, + definitionPositions: [ + { row: 27, column: 35 }, // Person + { row: 27, column: 45 }, // Address + { row: 27, column: 54 }, // Person + { row: 27, column: 64 }, // Address + ], + }, + { + nodeType: "method_declaration with two arguments", + fileName: "typescript/classMethods.ts", + language: "TypeScript", + cursorPosition: { line: 32, character: 11 }, + definitionPositions: [ + { row: 31, column: 36 }, // Person + { row: 31, column: 54 }, // Address + ], + }, +]; + +const CLASS_DEFINITIONS = [ + { + nodeType: "class_declaration with base class", + fileName: "typescript/classes.ts", + language: "TypeScript", + cursorPosition: { line: 2, character: 31 }, + definitionPositions: [ + { row: 2, column: 29 }, // BaseClass + ], + }, + { + nodeType: "class_declaration with interface", + fileName: "typescript/classes.ts", + language: "TypeScript", + cursorPosition: { line: 4, character: 39 }, + definitionPositions: [ + { row: 4, column: 37 }, // FirstInterface + ], + }, + { + nodeType: "class_declaration with base class and multiple interfaces", + fileName: "typescript/classes.ts", + language: "TypeScript", + cursorPosition: { line: 6, character: 74 }, + definitionPositions: [ + { row: 6, column: 29 }, // BaseClass + { row: 6, column: 55 }, // FirstInterface + { row: 6, column: 72 }, // SecondInterface + ], + }, + { + nodeType: "class_declaration with base class and multiple interfaces", + fileName: "typescript/classes.ts", + language: "TypeScript", + cursorPosition: { line: 6, character: 74 }, + definitionPositions: [ + { row: 6, column: 29 }, // BaseClass + { row: 6, column: 55 }, // FirstInterface + { row: 6, column: 72 }, // SecondInterface + ], + }, + { + nodeType: "class_declaration with generic base class and generic interface", + fileName: "typescript/classes.ts", + language: "TypeScript", + cursorPosition: { line: 8, character: 69 }, + definitionPositions: [ + { row: 8, column: 29 }, // BaseClass + { row: 8, column: 61 }, // FirstInterface + { row: 8, column: 34 }, // User + { row: 8, column: 66 }, // User + ], + }, +]; + +export const TYPESCRIPT_TEST_CASES = [ + ...FUNCTIONS, + ...GENERATORS, + ...ARROW_FUNCTIONS, + ...CLASS_METHODS, + ...CLASS_DEFINITIONS, +]; diff --git a/core/autocomplete/context/root-path-context/test/testUtils.ts b/core/autocomplete/context/root-path-context/test/testUtils.ts index 503383fd2..7a5c22aba 100644 --- a/core/autocomplete/context/root-path-context/test/testUtils.ts +++ b/core/autocomplete/context/root-path-context/test/testUtils.ts @@ -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); @@ -98,6 +84,7 @@ export async function testRootPathContext( index + 1, expect.any(String), // filepath argument position, + expect.any(String), // language argument ); }); } diff --git a/core/autocomplete/context/root-path-context/test/typescript/file1.ts b/core/autocomplete/context/root-path-context/test/typescript/file1.ts deleted file mode 100644 index ba09c5709..000000000 --- a/core/autocomplete/context/root-path-context/test/typescript/file1.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - Address, - Person, - BaseClass, - FirstInterface, - SecondInterface, - // @ts-ignore -} from "./types"; - -function getAddress(person: Person): Address { - return person.address; -} - -class Group extends BaseClass implements FirstInterface, SecondInterface { - people: Person[]; - - constructor(people: Person[]) { - super(); - this.people = people; - } - - getPersonAddress(person: Person): Address { - return getAddress(person); - } -} diff --git a/core/autocomplete/filtering/BracketMatchingService.ts b/core/autocomplete/filtering/BracketMatchingService.ts index d4415259e..da7d38e61 100644 --- a/core/autocomplete/filtering/BracketMatchingService.ts +++ b/core/autocomplete/filtering/BracketMatchingService.ts @@ -1,3 +1,13 @@ +export const BRACKETS: { [key: string]: string } = { + "(": ")", + "{": "}", + "[": "]", +}; +export const BRACKETS_REVERSE: { [key: string]: string } = { + ")": "(", + "}": "{", + "]": "[", +}; /** * We follow the policy of only completing bracket pairs that we started * But sometimes we started the pair in a previous autocomplete suggestion @@ -6,30 +16,18 @@ export class BracketMatchingService { private openingBracketsFromLastCompletion: string[] = []; private lastCompletionFile: string | undefined = undefined; - static BRACKETS: { [key: string]: string } = { "(": ")", "{": "}", "[": "]" }; - static BRACKETS_REVERSE: { [key: string]: string } = { - ")": "(", - "}": "{", - "]": "[", - }; - handleAcceptedCompletion(completion: string, filepath: string) { this.openingBracketsFromLastCompletion = []; const stack: string[] = []; for (let i = 0; i < completion.length; i++) { const char = completion[i]; - if (Object.keys(BracketMatchingService.BRACKETS).includes(char)) { + if (Object.keys(BRACKETS).includes(char)) { // It's an opening bracket stack.push(char); - } else if ( - Object.values(BracketMatchingService.BRACKETS).includes(char) - ) { + } else if (Object.values(BRACKETS).includes(char)) { // It's a closing bracket - if ( - stack.length === 0 || - BracketMatchingService.BRACKETS[stack.pop()!] !== char - ) { + if (stack.length === 0 || BRACKETS[stack.pop()!] !== char) { break; } } @@ -63,17 +61,12 @@ export class BracketMatchingService { (prefix.split("\n").pop() ?? "") + (suffix.split("\n")[0] ?? ""); for (let i = 0; i < currentLine.length; i++) { const char = currentLine[i]; - if (Object.keys(BracketMatchingService.BRACKETS).includes(char)) { + if (Object.keys(BRACKETS).includes(char)) { // It's an opening bracket stack.push(char); - } else if ( - Object.values(BracketMatchingService.BRACKETS).includes(char) - ) { + } else if (Object.values(BRACKETS).includes(char)) { // It's a closing bracket - if ( - stack.length === 0 || - BracketMatchingService.BRACKETS[stack.pop()!] !== char - ) { + if (stack.length === 0 || BRACKETS[stack.pop()!] !== char) { break; } } @@ -87,7 +80,7 @@ export class BracketMatchingService { if (suffix[i] === " ") { continue; } - const openBracket = BracketMatchingService.BRACKETS_REVERSE[suffix[i]]; + const openBracket = BRACKETS_REVERSE[suffix[i]]; if (!openBracket) { break; } @@ -115,19 +108,14 @@ export class BracketMatchingService { const allLines = all.split("\n"); for (let i = 0; i < chunk.length; i++) { const char = chunk[i]; - if (Object.values(BracketMatchingService.BRACKETS).includes(char)) { + if (Object.values(BRACKETS).includes(char)) { // It's a closing bracket - if ( - stack.length === 0 || - BracketMatchingService.BRACKETS[stack.pop()!] !== char - ) { + if (stack.length === 0 || BRACKETS[stack.pop()!] !== char) { // If the stack is empty or the top of the stack doesn't match the current closing bracket yield chunk.slice(0, i); return; // Stop the generator if the closing bracket doesn't have a matching opening bracket in the stream } - } else if ( - Object.keys(BracketMatchingService.BRACKETS).includes(char) - ) { + } else if (Object.keys(BRACKETS).includes(char)) { // It's an opening bracket stack.push(char); } diff --git a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts index 5576ee26b..6097ff797 100644 --- a/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts +++ b/core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts @@ -6,6 +6,7 @@ import { stopAtStopTokens } from "./charStream"; import { avoidEmptyComments, avoidPathLine, + noDoubleNewlineAfterClosingBracket, showWhateverWeHaveAtXMs, skipPrefixes, stopAtLines, @@ -47,6 +48,7 @@ export class StreamTransformPipeline { ); lineGenerator = avoidPathLine(lineGenerator, helper.lang.singleLineComment); lineGenerator = skipPrefixes(lineGenerator); + lineGenerator = noDoubleNewlineAfterClosingBracket(lineGenerator); for (const lineFilter of helper.lang.lineFilters ?? []) { lineGenerator = lineFilter({ lines: lineGenerator, fullStop }); diff --git a/core/autocomplete/filtering/streamTransforms/charStream.test.ts b/core/autocomplete/filtering/streamTransforms/charStream.test.ts index 7ab8923fc..b466ae3cd 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.test.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.test.ts @@ -157,4 +157,20 @@ describe("stopAtStopTokens", () => { expect(output.join("")).toBe("Hello world!"); }); + + it("should handle stop token when remaining buffer is smaller than maximum stop token length", async () => { + const mockStream = createMockStream(["Hello world!STOP"]); + const stopTokens: string[] = [ + "STOP", + "STOP_TOKEN_THAT_IS_LARGER_THAN_BUFFER", + ]; + const result = stopAtStopTokens(mockStream, stopTokens); + + const output = []; + for await (const char of result) { + output.push(char); + } + + expect(output.join("")).toBe("Hello world!"); + }); }); diff --git a/core/autocomplete/filtering/streamTransforms/charStream.ts b/core/autocomplete/filtering/streamTransforms/charStream.ts index 79fc33a0d..9f37e1f58 100644 --- a/core/autocomplete/filtering/streamTransforms/charStream.ts +++ b/core/autocomplete/filtering/streamTransforms/charStream.ts @@ -70,7 +70,8 @@ export async function* noFirstCharNewline(stream: AsyncGenerator) { * 2. Otherwise, buffers incoming chunks and checks for stop tokens. * 3. Yields characters one by one if no stop token is found at the start of the buffer. * 4. Stops yielding and returns if a stop token is encountered. - * 5. After the stream ends, yields any remaining buffered characters. + * 5. After the stream ends, filters encountered stop tokens in remaining buffer. + * 6. Yields any remaining buffered characters. */ export async function* stopAtStopTokens( stream: AsyncGenerator, @@ -106,6 +107,10 @@ export async function* stopAtStopTokens( } } } + // Filter out the possible stop tokens from remaining buffer + stopTokens.forEach((token) => { + buffer = buffer.replace(token, ""); + }); // Yield any remaining characters in the buffer for (const char of buffer) { diff --git a/core/autocomplete/filtering/streamTransforms/lineStream.ts b/core/autocomplete/filtering/streamTransforms/lineStream.ts index 8c7936e2d..160fc9d85 100644 --- a/core/autocomplete/filtering/streamTransforms/lineStream.ts +++ b/core/autocomplete/filtering/streamTransforms/lineStream.ts @@ -2,6 +2,7 @@ import { distance } from "fastest-levenshtein"; import { DiffLine } from "../../.."; import { LineStream } from "../../../diff/util"; +import { BRACKETS, BRACKETS_REVERSE } from "../BracketMatchingService"; export type LineFilter = (args: { lines: LineStream; @@ -545,3 +546,43 @@ export async function* showWhateverWeHaveAtXMs( } } } + +export async function* noDoubleNewlineAfterClosingBracket( + lines: LineStream, +): LineStream { + const bracketTypeCounts = new Map(); + + for await (const line of lines) { + if (line.trim() === "") { + // Double newline detected + // Check if any bracket counts are negative + let hasNegativeCount = false; + for (const count of bracketTypeCounts.values()) { + if (count < 0) { + hasNegativeCount = true; + break; + } + } + if (hasNegativeCount) { + // Stop the generator if we've closed brackets we didn't open + return; + } + } + + yield line; + + // Update bracket counts + for (const char of line) { + if (BRACKETS[char]) { + // It's an opening bracket + const count = bracketTypeCounts.get(char) || 0; + bracketTypeCounts.set(char, count + 1); + } else if (BRACKETS_REVERSE[char]) { + // It's a closing bracket + const openingBracket = BRACKETS_REVERSE[char]; + const count = bracketTypeCounts.get(openingBracket) || 0; + bracketTypeCounts.set(openingBracket, count - 1); + } + } + } +} diff --git a/core/autocomplete/filtering/streamTransforms/noDoubleNewlineAfterClosingBracket.test.ts b/core/autocomplete/filtering/streamTransforms/noDoubleNewlineAfterClosingBracket.test.ts new file mode 100644 index 000000000..a25b5d4bf --- /dev/null +++ b/core/autocomplete/filtering/streamTransforms/noDoubleNewlineAfterClosingBracket.test.ts @@ -0,0 +1,166 @@ +import { noDoubleNewlineAfterClosingBracket } from "./lineStream"; + +describe("noDoubleNewlineAfterClosingBracket", () => { + // Helper function to convert an array to an async generator + async function* arrayToAsyncGenerator(array: T[]): AsyncGenerator { + for (const item of array) { + yield item; + } + } + + // Helper function to collect lines from the async generator + async function collectLines(lines: AsyncIterable): Promise { + const result: string[] = []; + for await (const line of lines) { + result.push(line); + } + return result; + } + + test("should yield all lines when no double newline and no unmatched brackets", async () => { + const inputLines = [ + "function test() {", + ' console.log("Hello World");', + "}", + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); + + test("should yield all lines when double newline but brackets are matched", async () => { + const inputLines = [ + "function test() {", + ' console.log("Hello World");', + "}", + "", + "", + "// End of function", + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); + + test("should stop yielding after double newline when unmatched closing bracket is found before double newline", async () => { + const inputLines = [ + // "function test() {", + ' console.log("Hello World");', + // Unmatched closing bracket + "}", + "", + "", + "// This should not be yielded", + 'console.log("End");', + ]; + const expectedOutputLines = [' console.log("Hello World");', "}"]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(expectedOutputLines); + }); + + test("should yield all lines when unmatched brackets but no double newline", async () => { + const inputLines = [ + "function test() {", + ' console.log("Hello World");', + "}", + // Unmatched closing bracket + ")", + "// Continue code", + 'console.log("End");', + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); + + test("should continue yielding if unmatched closing bracket occurs after double newline", async () => { + const inputLines = [ + "function test() {", + ' console.log("Hello World");', + "}", + "", + "", + // Unmatched closing bracket after double newline + ")", + 'console.log("End");', + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); + + test("should yield all lines when brackets are matched even with double newline", async () => { + const inputLines = [ + "const arr = [", + " 1, 2, 3,", + "];", + "", + "", + "console.log(arr);", + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); + + test("should stop yielding when unmatched closing bracket occurs before double newline", async () => { + const inputLines = [ + "if (condition) {", + " doSomething();", + "}", + // Unmatched closing bracket + "}", + "", + "", + "doSomethingElse();", + ]; + const expectedOutputLines = [ + "if (condition) {", + " doSomething();", + "}", + "}", + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(expectedOutputLines); + }); + + test("should yield all lines when no unmatched closing brackets and double newline", async () => { + const inputLines = [ + "while (true) {", + " // Infinite loop", + "}", + "", + "", + "// Loop exited", + ]; + const lines = arrayToAsyncGenerator(inputLines); + const outputLines = await collectLines( + noDoubleNewlineAfterClosingBracket(lines), + ); + + expect(outputLines).toEqual(inputLines); + }); +}); diff --git a/core/autocomplete/filtering/test/filter.test.ts b/core/autocomplete/filtering/test/filter.test.ts index b2e025a4b..e6c07b951 100644 --- a/core/autocomplete/filtering/test/filter.test.ts +++ b/core/autocomplete/filtering/test/filter.test.ts @@ -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); + }, + ); }); }); diff --git a/core/autocomplete/filtering/test/testCases.ts b/core/autocomplete/filtering/test/testCases.ts index 406faf66f..f0584ab48 100644 --- a/core/autocomplete/filtering/test/testCases.ts +++ b/core/autocomplete/filtering/test/testCases.ts @@ -63,7 +63,7 @@ function sayHello() { `, llmOutput: `world!"); `, - expectedCompletion: "world!\");", + expectedCompletion: 'world!");', }, { description: "Should autocomplete Java when inside a block", @@ -131,10 +131,6 @@ public class Calculator { } `, expectedCompletion: ` - } - - public void subtract(double number) { - result -= number; }`, }, { @@ -489,8 +485,8 @@ echo calculateArea(5, 3);`, $colors = array("Red", "Green", <|fim|>); echo "First color is: " . $colors[0];`, - llmOutput: "\"Blue\"", - expectedCompletion: "\"Blue\"", + llmOutput: '"Blue"', + expectedCompletion: '"Blue"', filename: "colors.php", }, { @@ -775,8 +771,10 @@ func main() { FROM users u WHERE u.active = 1 <|fim|>`, - llmOutput: " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", - expectedCompletion: " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", + llmOutput: + " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", + expectedCompletion: + " AND EXISTS (SELECT 1 FROM transactions t WHERE t.user_id = u.id AND t.amount > 100)", }, { description: @@ -817,8 +815,8 @@ func main() {

Description text.

`, - llmOutput: "alt=\"Description of image\"", - expectedCompletion: "alt=\"Description of image\"", + llmOutput: 'alt="Description of image"', + expectedCompletion: 'alt="Description of image"', filename: "test.html", }, { @@ -930,8 +928,8 @@ public class App { <|fim|> ] }`, - llmOutput: ", { \"id\": 3, \"name\": \"Charlie\" }", - expectedCompletion: ", { \"id\": 3, \"name\": \"Charlie\" }", + llmOutput: ', { "id": 3, "name": "Charlie" }', + expectedCompletion: ', { "id": 3, "name": "Charlie" }', }, { description: "Should autocomplete within a CSV record", @@ -1237,8 +1235,8 @@ class Counter { :age 30 <|fim|> (println "User information loaded"))`, - llmOutput: ":location \"Unknown\"}", - expectedCompletion: ":location \"Unknown\"}", + llmOutput: ':location "Unknown"}', + expectedCompletion: ':location "Unknown"}', filename: "test.clj", }, { @@ -1301,8 +1299,8 @@ if (grade >= 90) { } else { print("C") }`, - llmOutput: "print(\"B\")", - expectedCompletion: "print(\"B\")", + llmOutput: 'print("B")', + expectedCompletion: 'print("B")', }, { description: "Should autocomplete R ggplot2 plot structure", @@ -1324,8 +1322,8 @@ ggplot(data=mtcars, aes(x=wt, y=mpg)) + <|fim|> } }`, - llmOutput: "s\"Hello, my name is $name and I am $age years old.\"", - expectedCompletion: "s\"Hello, my name is $name and I am $age years old.\"", + llmOutput: 's"Hello, my name is $name and I am $age years old."', + expectedCompletion: 's"Hello, my name is $name and I am $age years old."', }, { @@ -1335,8 +1333,8 @@ ggplot(data=mtcars, aes(x=wt, y=mpg)) + case class Person(name: String, age: Int, address: Address) val alice = Person("Alice", 30, Address("Wonderland", <|fim|>))`, - llmOutput: "\"12345\")", - expectedCompletion: "\"12345\")", + llmOutput: '"12345")', + expectedCompletion: '"12345")', }, { @@ -2066,8 +2064,8 @@ export default { /> `, - llmOutput: "name=\"World\"", - expectedCompletion: "name=\"World\"", + llmOutput: 'name="World"', + expectedCompletion: 'name="World"', }, { diff --git a/core/autocomplete/generation/GeneratorReuseManager.test.ts b/core/autocomplete/generation/GeneratorReuseManager.test.ts new file mode 100644 index 000000000..2454377d3 --- /dev/null +++ b/core/autocomplete/generation/GeneratorReuseManager.test.ts @@ -0,0 +1,215 @@ +import { jest } from "@jest/globals"; +import { GeneratorReuseManager } from "./GeneratorReuseManager"; + +function createMockGenerator( + data: string[], + delay: number = 0, +): () => AsyncGenerator { + const mockGenerator = async function* () { + for (const chunk of data) { + yield chunk; + + if (delay > 0) { + await new Promise((resolve) => setTimeout(resolve, delay)); + } + } + }; + const newGenerator = jest + .fn<() => AsyncGenerator>() + .mockReturnValue(mockGenerator()); + + return newGenerator; +} + +describe("GeneratorReuseManager", () => { + let reuseManager: GeneratorReuseManager; + let onErrorMock: jest.Mock; + + beforeEach(() => { + onErrorMock = jest.fn(); + reuseManager = new GeneratorReuseManager(onErrorMock); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("creates new generator when there is no current generator", async () => { + const data = ["hello ", "world"]; + const newGenerator = createMockGenerator(data); + + const prefix = ""; + + const generator = reuseManager.getGenerator(prefix, newGenerator, true); + + const output: string[] = []; + for await (const chunk of generator) { + output.push(chunk); + } + + expect(output).toEqual(data); + expect(newGenerator).toHaveBeenCalledTimes(1); + }); + + test("reuses generator when prefix matches pending completion", async () => { + const newGenerator = createMockGenerator(["llo ", "world"]); + + // First call with initial prefix + const prefix1 = "he"; + const generator1 = reuseManager.getGenerator(prefix1, newGenerator, true); + + const output1: string[] = []; + for await (const chunk of generator1) { + output1.push(chunk); + } + + expect(output1).toEqual(["llo ", "world"]); + + // Second call with extended prefix that matches pending completion + const prefix2 = "hello "; + const generator2 = reuseManager.getGenerator(prefix2, newGenerator, true); + + const output2: string[] = []; + for await (const chunk of generator2) { + output2.push(chunk); + } + + expect(output2).toEqual(["world"]); + + // Ensure generator was reused (newGenerator should be called only once) + expect(newGenerator).toHaveBeenCalledTimes(1); + }); + + test("creates new generator when prefix does not match pending completion", async () => { + const data = ["goodbye ", "world"]; + const newGenerator = createMockGenerator(data); + + // Initial generator with different prefix + reuseManager.pendingGeneratorPrefix = "hello "; + reuseManager.pendingCompletion = "world"; + + const prefix = "good"; + const generator = reuseManager.getGenerator(prefix, newGenerator, true); + + const output: string[] = []; + for await (const chunk of generator) { + output.push(chunk); + } + + expect(output).toEqual(data); + // Ensure a new generator was created + expect(newGenerator).toHaveBeenCalledTimes(1); + }); + + test("handles multiline=false by stopping at newline", async () => { + const data = ["first line\n", "second line"]; + const newGenerator = createMockGenerator(data); + + const prefix = ""; + const generator = reuseManager.getGenerator(prefix, newGenerator, false); + + const output: string[] = []; + for await (const chunk of generator) { + output.push(chunk); + } + + expect(output).toEqual(["first line"]); + // Ensure it stops after the first newline + }); + + test("handles multiline=true by not stopping at newline", async () => { + const data = ["first line\n", "second line"]; + const newGenerator = createMockGenerator(data); + + const prefix = ""; + const generator = reuseManager.getGenerator(prefix, newGenerator, true); + + const output: string[] = []; + for await (const chunk of generator) { + output.push(chunk); + } + + expect(output).toEqual(data); + }); + + test("cancels previous generator when creating a new one", async () => { + const data1 = ["data from generator 1", "not generated"]; + const data2 = ["data from generator 2"]; + + const newGenerator1 = createMockGenerator(data1, 1000); // Delay so we have the chance to cancel it + const newGenerator2 = createMockGenerator(data2); + + const prefix1 = "prefix1"; + const prefix2 = "prefix2"; + + // First generator + const generator1 = reuseManager.getGenerator(prefix1, newGenerator1, true); + const output1: string[] = []; + for await (const chunk of generator1) { + output1.push(chunk); + // Simulate the generator being canceled before completing + reuseManager.currentGenerator?.cancel(); + } + + expect(output1.length).toEqual(1); + expect(output1[0]).toEqual(data1[0]); + + // Second generator + const generator2 = reuseManager.getGenerator(prefix2, newGenerator2, true); + const output2: string[] = []; + for await (const chunk of generator2) { + output2.push(chunk); + } + + expect(output2).toEqual(data2); + }); + + test("calls onError when generator throws an error", async () => { + const error = new Error("Generator error"); + const mockGenerator = async function* () { + throw error; + }; + const newGenerator = jest + .fn<() => AsyncGenerator>() + .mockReturnValue(mockGenerator()); + + const prefix = ""; + const generator = reuseManager.getGenerator(prefix, newGenerator, true); + + const output: string[] = []; + await expect(async () => { + for await (const chunk of generator) { + output.push(chunk); + } + }).not.toThrow(); // getGenerator handles errors internally + + expect(onErrorMock).toHaveBeenCalledWith(error); + expect(output).toEqual([]); + }); + + test("handles backspacing by creating new generator when prefix is shorter", async () => { + const data = ["hello world"]; + const newGenerator1 = createMockGenerator(data); + const newGenerator2 = createMockGenerator(data); + + // First prefix + const prefix1 = "hello world"; + const generator1 = reuseManager.getGenerator(prefix1, newGenerator1, true); + const output1: string[] = []; + for await (const chunk of generator1) { + output1.push(chunk); + } + + // Simulate backspace (prefix is shorter) + const prefix2 = "hello worl"; + const generator2 = reuseManager.getGenerator(prefix2, newGenerator2, true); + const output2: string[] = []; + for await (const chunk of generator2) { + output2.push(chunk); + } + + // Ensure a new generator was created + expect(newGenerator1).toHaveBeenCalledTimes(1); + expect(newGenerator2).toHaveBeenCalledTimes(1); + }); +}); diff --git a/core/autocomplete/generation/GeneratorReuseManager.ts b/core/autocomplete/generation/GeneratorReuseManager.ts index 7a67e686f..0b19183ce 100644 --- a/core/autocomplete/generation/GeneratorReuseManager.ts +++ b/core/autocomplete/generation/GeneratorReuseManager.ts @@ -21,47 +21,54 @@ export class GeneratorReuseManager { this.currentGenerator = listenableGen; } + private shouldReuseExistingGenerator(prefix: string): boolean { + return ( + !!this.currentGenerator && + !!this.pendingGeneratorPrefix && + (this.pendingGeneratorPrefix + this.pendingCompletion).startsWith( + prefix, + ) && + // for e.g. backspace + this.pendingGeneratorPrefix?.length <= prefix?.length + ); + } + async *getGenerator( prefix: string, newGenerator: () => AsyncGenerator, multiline: boolean, ): AsyncGenerator { - // Check if current can be reused - if ( - !( - this.currentGenerator && - this.pendingGeneratorPrefix && - (this.pendingGeneratorPrefix + this.pendingCompletion).startsWith( - prefix, - ) && - // for e.g. backspace - this.pendingGeneratorPrefix?.length <= prefix?.length - ) - ) { + // If we can't reuse, then create a new generator + if (!this.shouldReuseExistingGenerator(prefix)) { // Create a wrapper over the current generator to fix the prompt this._createListenableGenerator(newGenerator(), prefix); } - let alreadyTyped = prefix.slice(this.pendingGeneratorPrefix?.length) || ""; + // Already typed characters are those that are new in the prefix from the old generator + let typedSinceLastGenerator = + prefix.slice(this.pendingGeneratorPrefix?.length) || ""; for await (let chunk of this.currentGenerator?.tee() ?? []) { if (!chunk) { continue; } - while (chunk.length && alreadyTyped.length) { - if (chunk[0] === alreadyTyped[0]) { - alreadyTyped = alreadyTyped.slice(1); + + // Ignore already typed characters in the completion + while (chunk.length && typedSinceLastGenerator.length) { + if (chunk[0] === typedSinceLastGenerator[0]) { + typedSinceLastGenerator = typedSinceLastGenerator.slice(1); chunk = chunk.slice(1); } else { break; } } + // Break at newline unless we are in multiline mode const newLineIndex = chunk.indexOf("\n"); - if (multiline || newLineIndex === -1) { - yield chunk; - } else { + if (newLineIndex >= 0 && !multiline) { yield chunk.slice(0, newLineIndex); break; + } else if (chunk !== "") { + yield chunk; } } } diff --git a/core/autocomplete/generation/ListenableGenerator.test.ts b/core/autocomplete/generation/ListenableGenerator.test.ts new file mode 100644 index 000000000..69797959e --- /dev/null +++ b/core/autocomplete/generation/ListenableGenerator.test.ts @@ -0,0 +1,149 @@ +import { jest } from "@jest/globals"; +import { ListenableGenerator } from "./ListenableGenerator"; + +describe("ListenableGenerator", () => { + // Helper function to create an async generator + async function* asyncGenerator(values: T[], delay = 0) { + for (const value of values) { + if (delay > 0) { + await new Promise((resolve) => setTimeout(resolve, delay)); + } + yield value; + } + } + + it("should yield values from the source generator via tee()", async () => { + const values = [1, 2, 3]; + const source = asyncGenerator(values); + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const result: number[] = []; + for await (const value of lg.tee()) { + result.push(value); + } + + expect(result).toEqual(values); + expect(onError).not.toHaveBeenCalled(); + }); + + it("should allow listeners to receive values", async () => { + const values = [1, 2, 3]; + const source = asyncGenerator(values, 10); // Introduce delay to simulate async behavior + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const listener = jest.fn(); + + // Add listener after some delay to simulate late subscription + setTimeout(() => { + lg.listen(listener); + }, 15); + + // Wait for generator to finish + await new Promise((resolve) => setTimeout(resolve, 50)); + + expect(listener).toHaveBeenCalledWith(1); + expect(listener).toHaveBeenCalledWith(2); + expect(listener).toHaveBeenCalledWith(3); + // Listener should receive null at the end + expect(listener).toHaveBeenCalledWith(null); + }); + + it("should buffer values for listeners added after some values have been yielded", async () => { + const values = [1, 2, 3]; + const source = asyncGenerator(values, 10); + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const initialListener = jest.fn(); + + lg.listen(initialListener); + + // Wait for the first value to be yielded + await new Promise((resolve) => setTimeout(resolve, 15)); + + // Add a second listener + const newListener = jest.fn(); + lg.listen(newListener); + + // Wait for generator to finish + await new Promise((resolve) => setTimeout(resolve, 50)); + + // Both listeners should have received all values + [initialListener, newListener].forEach((listener) => { + expect(listener).toHaveBeenCalledWith(1); + expect(listener).toHaveBeenCalledWith(2); + expect(listener).toHaveBeenCalledWith(3); + expect(listener).toHaveBeenCalledWith(null); + }); + }); + + it("should handle cancellation", async () => { + const values = [1, 2, 3, 4, 5]; + const source = asyncGenerator(values, 10); + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const result: number[] = []; + const teeIterator = lg.tee(); + + const consume = async () => { + for await (const value of teeIterator) { + result.push(value); + if (value === 3) { + lg.cancel(); + } + } + }; + + await consume(); + + expect(result).toEqual([1, 2, 3]); + expect(lg["_isEnded"]).toBe(true); + }); + + it("should call onError when the source generator throws an error", async () => { + async function* errorGenerator() { + yield 1; + throw new Error("Test error"); + } + + const source = errorGenerator(); + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const result: number[] = []; + for await (const value of lg.tee()) { + result.push(value); + } + + expect(result).toEqual([1]); + expect(onError).toHaveBeenCalledTimes(1); + expect(onError).toHaveBeenCalledWith(new Error("Test error")); + }); + + it("should notify listeners when the generator ends", async () => { + const values = [1, 2, 3]; + const source = asyncGenerator(values); + const onError = jest.fn(); + + const lg = new ListenableGenerator(source, onError); + + const listener = jest.fn(); + lg.listen(listener); + + // Wait for the generator to finish + await new Promise((resolve) => setTimeout(resolve, 10)); + + expect(listener).toHaveBeenCalledWith(1); + expect(listener).toHaveBeenCalledWith(2); + expect(listener).toHaveBeenCalledWith(3); + expect(listener).toHaveBeenCalledWith(null); + }); +}); diff --git a/core/autocomplete/util/AutocompleteLoggingService.ts b/core/autocomplete/util/AutocompleteLoggingService.ts index ff0c5d493..96261e646 100644 --- a/core/autocomplete/util/AutocompleteLoggingService.ts +++ b/core/autocomplete/util/AutocompleteLoggingService.ts @@ -37,6 +37,7 @@ export class AutocompleteLoggingService { if (this._outcomes.has(completionId)) { const outcome = this._outcomes.get(completionId)!; + outcome.accepted = true; this.logAutocompleteOutcome(outcome); this._outcomes.delete(completionId); return outcome; @@ -94,7 +95,6 @@ export class AutocompleteLoggingService { } private logAutocompleteOutcome(outcome: AutocompleteOutcome) { - outcome.accepted = true; logDevData("autocomplete", outcome); const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome; void Telemetry.capture( diff --git a/core/config/getSystemPromptDotFile.ts b/core/config/getSystemPromptDotFile.ts new file mode 100644 index 000000000..03690dd47 --- /dev/null +++ b/core/config/getSystemPromptDotFile.ts @@ -0,0 +1,27 @@ +import { IDE } from ".."; + +export const SYSTEM_PROMPT_DOT_FILE = ".continuerules"; + +export async function getSystemPromptDotFile(ide: IDE): Promise { + const dirs = await ide.getWorkspaceDirs(); + + let prompts: string[] = []; + const pathSep = await ide.pathSep(); + for (const dir of dirs) { + const dotFile = `${dir}${pathSep}${SYSTEM_PROMPT_DOT_FILE}`; + if (await ide.fileExists(dotFile)) { + try { + const content = await ide.readFile(dotFile); + prompts.push(content); + } catch (e) { + // ignore if file doesn't exist + } + } + } + + if (!prompts.length) { + return null; + } + + return prompts.join("\n\n"); +} diff --git a/core/config/load.ts b/core/config/load.ts index a10948210..b692b36bf 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -64,6 +64,7 @@ import { defaultSlashCommandsJetBrains, defaultSlashCommandsVscode, } from "./default"; +import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; import { DEFAULT_PROMPTS_FOLDER, getPromptFiles, @@ -215,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); + } } } @@ -732,6 +736,11 @@ async function loadFullConfigNode( return { errors, config: undefined, configLoadInterrupted: true }; } + const systemPromptDotFile = await getSystemPromptDotFile(ide); + if (systemPromptDotFile) { + serialized.systemMessage = systemPromptDotFile; + } + // Convert serialized to intermediate config let intermediate = await serializedToIntermediateConfig(serialized, ide); diff --git a/core/config/onboarding.ts b/core/config/onboarding.ts index fa6d54945..6b05ca59f 100644 --- a/core/config/onboarding.ts +++ b/core/config/onboarding.ts @@ -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, }, diff --git a/core/config/promptFile.ts b/core/config/promptFile.ts index ba7a039de..aa19f3b0c 100644 --- a/core/config/promptFile.ts +++ b/core/config/promptFile.ts @@ -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("")) { @@ -141,7 +152,7 @@ function parsePromptFile(path: string, content: string) { prompt = prompt.split("")[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 diff --git a/core/config/validation.ts b/core/config/validation.ts index ebcbb623d..062c0eaed 100644 --- a/core/config/validation.ts +++ b/core/config/validation.ts @@ -34,6 +34,18 @@ export function validateConfig(config: SerializedContinueConfig) { message: `Model at index ${index} has an invalid 'provider'.`, }); } + + if (model.contextLength && model.completionOptions?.maxTokens) { + const difference = + model.contextLength - model.completionOptions.maxTokens; + + if (difference < 1000) { + errors.push({ + fatal: false, + message: `Model "${model.title}" has a contextLength of ${model.contextLength} and a maxTokens of ${model.completionOptions.maxTokens}. This leaves only ${difference} tokens for input context and will likely result in your inputs being truncated.`, + }); + } + } }); } diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index a290589e4..ba2bf29b6 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -92,7 +92,7 @@ class DocsContextProvider extends BaseContextProvider { await docsService.isJetBrainsAndPreIndexedDocsProvider(); if (isJetBrainsAndPreIndexedDocsProvider) { - await extras.ide.showToast( + void extras.ide.showToast( "error", `${DocsService.preIndexedDocsEmbeddingsProvider.id} is configured as ` + "the embeddings provider, but it cannot be used with JetBrains. " + diff --git a/core/core.ts b/core/core.ts index 6df1482ef..853666174 100644 --- a/core/core.ts +++ b/core/core.ts @@ -83,7 +83,7 @@ export class Core { constructor( private readonly messenger: IMessenger, private readonly ide: IDE, - private readonly onWrite: (text: string) => Promise = async () => { }, + private readonly onWrite: (text: string) => Promise = async () => {}, ) { // Ensure .continue directory is created setupInitialDotContinueDirectory(); @@ -149,7 +149,7 @@ export class Core { void this.ide.getWorkspaceDirs().then(async (dirs) => { // Respect pauseCodebaseIndexOnStart user settings if (ideSettings.pauseCodebaseIndexOnStart) { - await this.messenger.request("indexProgress", { + void this.messenger.request("indexProgress", { progress: 1, desc: "Initial Indexing Skipped", status: "paused", @@ -174,7 +174,7 @@ export class Core { this.configHandler, ide, getLlm, - (e) => { }, + (e) => {}, (..._) => Promise.resolve([]), ); @@ -684,9 +684,14 @@ export class Core { await codebaseIndexer.clearIndexes(); } - const dirs = data?.dirs ?? await this.ide.getWorkspaceDirs(); + const dirs = data?.dirs ?? (await this.ide.getWorkspaceDirs()); await this.refreshCodebaseIndex(dirs); }); + on("index/forceReIndexFiles", async ({ data }) => { + if (data?.files?.length) { + await this.refreshCodebaseIndexFiles(data.files); + } + }); on("index/setPaused", (msg) => { new GlobalContext().update("indexingPaused", msg.data); this.indexingPauseToken.paused = msg.data; @@ -722,14 +727,29 @@ export class Core { } private indexingCancellationController: AbortController | undefined; + private async sendIndexingErrorTelemetry(update: IndexingProgressUpdate) { + console.debug( + "Indexing failed with error: ", + update.desc, + update.debugInfo, + ); + void Telemetry.capture( + "indexing_error", + { + error: update.desc, + stack: update.debugInfo, + }, + false, + ); + } - private async refreshCodebaseIndex(dirs: string[]) { + private async refreshCodebaseIndex(paths: string[]) { if (this.indexingCancellationController) { this.indexingCancellationController.abort(); } this.indexingCancellationController = new AbortController(); - for await (const update of (await this.codebaseIndexerPromise).refresh( - dirs, + for await (const update of (await this.codebaseIndexerPromise).refreshDirs( + paths, this.indexingCancellationController.signal, )) { let updateToSend = { ...update }; @@ -743,19 +763,41 @@ export class Core { this.indexingState = updateToSend; if (update.status === "failed") { - console.debug( - "Indexing failed with error: ", - update.desc, - update.debugInfo, - ); - void Telemetry.capture( - "indexing_error", - { - error: update.desc, - stack: update.debugInfo, - }, - false, - ); + void this.sendIndexingErrorTelemetry(update); + } + } + + this.messenger.send("refreshSubmenuItems", undefined); + this.indexingCancellationController = undefined; + } + + private async refreshCodebaseIndexFiles(files: string[]) { + // Can be cancelled by codebase index but not vice versa + if ( + this.indexingCancellationController && + !this.indexingCancellationController.signal.aborted + ) { + return console.debug( + "Codebase indexing already in progress, skipping indexing of files\n" + + files.join("\n"), + ); + } + this.indexingCancellationController = new AbortController(); + for await (const update of (await this.codebaseIndexerPromise).refreshFiles( + files, + )) { + let updateToSend = { ...update }; + if (update.status === "failed") { + updateToSend.status = "done"; + updateToSend.desc = "Indexing complete"; + updateToSend.progress = 1.0; + } + + void this.messenger.request("indexProgress", updateToSend); + this.indexingState = updateToSend; + + if (update.status === "failed") { + void this.sendIndexingErrorTelemetry(update); } } diff --git a/core/index.d.ts b/core/index.d.ts index b8e941f28..c30119968 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -45,12 +45,12 @@ export interface IndexingProgressUpdate { debugInfo?: string; } -export type PromptTemplate = - | string - | (( - history: ChatMessage[], - otherData: Record, - ) => string | ChatMessage[]); +export type PromptTemplateFunction = ( + history: ChatMessage[], + otherData: Record, +) => string | ChatMessage[]; + +export type PromptTemplate = string | PromptTemplateFunction; export interface ILLM extends LLMOptions { get providerName(): ModelProvider; @@ -200,11 +200,16 @@ export interface IContextProvider { loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise; } +export interface Checkpoint { + [filepath: string]: string; +} + export interface PersistedSessionInfo { history: ChatHistory; title: string; workspaceDirectory: string; sessionId: string; + checkpoints?: Checkpoint[]; } export interface SessionInfo { @@ -654,7 +659,8 @@ type ModelProvider = | "askSage" | "vertexai" | "nebius" - | "xAI"; + | "xAI" + | "moonshot"; export type ModelName = | "AUTODETECT" @@ -749,7 +755,11 @@ export type ModelName = | "starcoder-1b" | "starcoder-3b" | "starcoder2-3b" - | "stable-code-3b"; + | "stable-code-3b" + // Moonshot + | "moonshot-v1-8k" + | "moonshot-v1-32k" + | "moonshot-v1-128k"; export interface RequestOptions { timeout?: number; diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts index 8e1edcc7b..0138817f6 100644 --- a/core/indexing/CodeSnippetsIndex.ts +++ b/core/indexing/CodeSnippetsIndex.ts @@ -3,12 +3,17 @@ import Parser from "web-tree-sitter"; import { getBasename, getLastNPathParts } from "../util/"; import { migrate } from "../util/paths"; import { - TSQueryType, + getFullLanguageName, getParserForFile, getQueryForFile, } from "../util/treeSitter"; -import { DatabaseConnection, SqliteDb, tagToString, truncateSqliteLikePattern } from "./refreshIndex"; +import { + DatabaseConnection, + SqliteDb, + tagToString, + truncateSqliteLikePattern, +} from "./refreshIndex"; import { IndexResultType, MarkCompleteCallback, @@ -31,7 +36,7 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { relativeExpectedTime: number = 1; artifactId = "codeSnippets"; - constructor(private readonly ide: IDE) { } + constructor(private readonly ide: IDE) {} private static async _createTables(db: DatabaseConnection) { await db.exec(`CREATE TABLE IF NOT EXISTS code_snippets ( @@ -183,7 +188,12 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { } const ast = parser.parse(contents); - const query = await getQueryForFile(filepath, TSQueryType.CodeSnippets); + + const language = getFullLanguageName(filepath); + const query = await getQueryForFile( + filepath, + `code-snippet-queries/${language}.scm`, + ); const matches = query?.matches(ast.rootNode); if (!matches) { @@ -386,7 +396,9 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex { const db = await SqliteDb.get(); await CodeSnippetsCodebaseIndex._createTables(db); - const likePatterns = workspaceDirs.map((dir) => truncateSqliteLikePattern(`${dir}%`)); + const likePatterns = workspaceDirs.map((dir) => + truncateSqliteLikePattern(`${dir}%`), + ); const placeholders = likePatterns.map(() => "?").join(" OR path LIKE "); const query = ` diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 5b59c39fa..ee2f108f7 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -89,7 +89,7 @@ describe("CodebaseIndexer", () => { const abortSignal = abortController.signal; const updates = []; - for await (const update of codebaseIndexer.refresh( + for await (const update of codebaseIndexer.refreshDirs( [TEST_DIR], abortSignal, )) { @@ -98,6 +98,16 @@ describe("CodebaseIndexer", () => { return updates; } + async function refreshIndexFiles(files: string[]) { + const updates = []; + for await (const update of codebaseIndexer.refreshFiles( + files, + )) { + updates.push(update); + } + return updates; + } + async function getAllIndexedFiles() { const files = await testIndex.getIndexedFilesForTags( await testIde.getTags(testIndex.artifactId), @@ -158,6 +168,15 @@ describe("CodebaseIndexer", () => { expect(indexed.some((file) => file.endsWith("main.py"))).toBe(true); }); + test("should successfuly re-index specific files", async () => { + // Could add more specific tests for this but uses similar logic + const before = await getAllIndexedFiles(); + await refreshIndexFiles(before); + + const after = await getAllIndexedFiles(); + expect(after.length).toBe(before.length); + }); + test("should successfully re-index after adding a file", async () => { addToTestDir([["main.rs", TEST_RS]]); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index b4962d182..5c70f8bad 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -17,6 +17,7 @@ import { RefreshIndexResults, } from "./types.js"; import { walkDirAsync } from "./walkDir.js"; +import { getBasename } from "../util/index.js"; export class PauseToken { constructor(private _paused: boolean) {} @@ -144,13 +145,52 @@ export class CodebaseIndexer { } } - async *refresh( - workspaceDirs: string[], + async *refreshFiles( + files: string[], + ): AsyncGenerator { + let progress = 0; + if (files.length === 0) { + yield { + progress: 1, + desc: "Indexing Complete", + status: "done", + }; + } + + const progressPer = 1 / files.length; + try { + for (const file of files) { + yield { + progress, + desc: `Indexing file ${file}...`, + status: "indexing", + }; + await this.refreshFile(file); + + progress += progressPer; + + if (this.pauseToken.paused) { + yield* this.yieldUpdateAndPause(); + } + } + + yield { + progress: 1, + desc: "Indexing Complete", + status: "done", + }; + } catch (err) { + yield this.handleErrorAndGetProgressUpdate(err); + } + } + + async *refreshDirs( + dirs: string[], abortSignal: AbortSignal, ): AsyncGenerator { let progress = 0; - if (workspaceDirs.length === 0) { + if (dirs.length === 0) { yield { progress, desc: "Nothing to index", @@ -175,11 +215,9 @@ export class CodebaseIndexer { }; } - let completedDirs = 0; - // Wait until Git Extension has loaded to report progress // so we don't appear stuck at 0% while waiting - await this.ide.getRepoName(workspaceDirs[0]); + await this.ide.getRepoName(dirs[0]); yield { progress, @@ -188,16 +226,16 @@ export class CodebaseIndexer { }; const beginTime = Date.now(); - for (const directory of workspaceDirs) { + for (const directory of dirs) { const dirBasename = await this.basename(directory); yield { progress, desc: `Discovering files in ${dirBasename}...`, status: "indexing", }; - const workspaceFiles = []; + const directoryFiles = []; for await (const p of walkDirAsync(directory, this.ide)) { - workspaceFiles.push(p); + directoryFiles.push(p); if (abortSignal.aborted) { yield { progress: 1, @@ -218,7 +256,7 @@ export class CodebaseIndexer { try { for await (const updateDesc of this.indexFiles( directory, - workspaceFiles, + directoryFiles, branch, repoName, )) { @@ -240,7 +278,7 @@ export class CodebaseIndexer { nextLogThreshold += 0.025; this.logProgress( beginTime, - Math.floor(workspaceFiles.length * updateDesc.progress), + Math.floor(directoryFiles.length * updateDesc.progress), updateDesc.progress, ); } @@ -347,18 +385,18 @@ export class CodebaseIndexer { } private async *indexFiles( - workspaceDir: string, - workspaceFiles: string[], + directory: string, + files: string[], branch: string, repoName: string | undefined, ): AsyncGenerator { - const stats = await this.ide.getLastModified(workspaceFiles); + const stats = await this.ide.getLastModified(files); const indexesToBuild = await this.getIndexesToBuild(); let completedIndexCount = 0; let progress = 0; for (const codebaseIndex of indexesToBuild) { const tag: IndexTag = { - directory: workspaceDir, + directory, branch, artifactId: codebaseIndex.artifactId, }; diff --git a/core/indexing/docs/DocsCrawler.ts b/core/indexing/docs/DocsCrawler.ts index cb9146ab5..599c4202a 100644 --- a/core/indexing/docs/DocsCrawler.ts +++ b/core/indexing/docs/DocsCrawler.ts @@ -79,7 +79,7 @@ class DocsCrawler { ); if (didInstall) { - await this.ide.showToast( + void this.ide.showToast( "info", `Successfully installed Chromium! Retrying crawl of: ${startUrl.toString()}`, ); diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 979af63d0..dde15f502 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -157,7 +157,7 @@ export default class DocsService { params: {}, }); - await this.ide.showToast( + void this.ide.showToast( "info", "Successfuly added docs context provider", ); @@ -183,7 +183,7 @@ export default class DocsService { while (!(await generator.next()).done) {} } - await this.ide.showToast("info", "Docs indexing completed"); + void this.ide.showToast("info", "Docs indexing completed"); } async list() { @@ -254,6 +254,8 @@ export default class DocsService { if (processedPages === maxKnownPages) { maxKnownPages *= 2; } + + await new Promise((resolve) => setTimeout(resolve, 50)); } void Telemetry.capture("docs_pages_crawled", { @@ -362,11 +364,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 +560,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}`, @@ -737,7 +743,7 @@ export default class DocsService { if (isJetBrainsAndPreIndexedDocsProvider) { // A bit noisy for teams users whom have no choice if their admin is the one who didn't setup an embeddingsProvider - // this.ide.showToast( + // void this.ide.showToast( // "error", // "The 'transformers.js' embeddings provider currently cannot be used to index " + // "documentation in JetBrains. To enable documentation indexing, you can use " + diff --git a/core/indexing/docs/crawlers/ChromiumCrawler.ts b/core/indexing/docs/crawlers/ChromiumCrawler.ts index ee49270a8..e2feb4c59 100644 --- a/core/indexing/docs/crawlers/ChromiumCrawler.ts +++ b/core/indexing/docs/crawlers/ChromiumCrawler.ts @@ -242,7 +242,7 @@ export class ChromiumInstaller { ChromiumCrawler.setUseChromiumForDocsCrawling(false); - await this.ide.showToast("error", "Failed to install Chromium"); + void this.ide.showToast("error", "Failed to install Chromium"); return false; } diff --git a/core/indexing/docs/preIndexedDocs.ts b/core/indexing/docs/preIndexedDocs.ts index 48b777b21..01935af9e 100644 --- a/core/indexing/docs/preIndexedDocs.ts +++ b/core/indexing/docs/preIndexedDocs.ts @@ -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; diff --git a/core/llm/autodetect.ts b/core/llm/autodetect.ts index 17f104a52..8e475d01e 100644 --- a/core/llm/autodetect.ts +++ b/core/llm/autodetect.ts @@ -49,7 +49,7 @@ const PROVIDER_HANDLES_TEMPLATING: ModelProvider[] = [ "mistral", "sambanova", "vertexai", - "watsonx" + "watsonx", ]; const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ @@ -63,7 +63,8 @@ const PROVIDER_SUPPORTS_IMAGES: ModelProvider[] = [ "sagemaker", "continue-proxy", "openrouter", - "vertexai" + "vertexai", + "azure", ]; const MODEL_SUPPORTS_IMAGES: string[] = [ @@ -116,12 +117,13 @@ const PARALLEL_PROVIDERS: ModelProvider[] = [ "huggingface-inference-api", "huggingface-tgi", "mistral", + "moonshot", "free-trial", "replicate", "together", "sambanova", "nebius", - "vertexai" + "vertexai", ]; function llmCanGenerateInParallel( @@ -148,9 +150,10 @@ function autodetectTemplateType(model: string): TemplateType | undefined { lower.includes("chat-bison") || lower.includes("pplx") || lower.includes("gemini") || - lower.includes("grok") + lower.includes("grok")|| + lower.includes("moonshot") ) { - return undefined; + return undefined; } if (lower.includes("llama3")) { diff --git a/core/llm/constants.ts b/core/llm/constants.ts index 52265d509..59a9c301a 100644 --- a/core/llm/constants.ts +++ b/core/llm/constants.ts @@ -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, diff --git a/core/llm/countTokens.ts b/core/llm/countTokens.ts index 7ae3da1b7..9b30ad4bc 100644 --- a/core/llm/countTokens.ts +++ b/core/llm/countTokens.ts @@ -323,6 +323,27 @@ function pruneChatHistory( return chatHistory; } +function messageIsEmpty(message: ChatMessage): boolean { + if (typeof message.content === "string") { + return message.content.trim() === ""; + } + if (Array.isArray(message.content)) { + return message.content.every( + (item) => !item.imageUrl && item.text?.trim() === "", + ); + } + return false; +} + +function addSpaceToAnyEmptyMessages(messages: ChatMessage[]): ChatMessage[] { + return messages.map((message) => { + if (messageIsEmpty(message)) { + message.content = " "; + } + return message; + }); +} + function compileChatMessages( modelName: string, msgs: ChatMessage[] | undefined, @@ -333,12 +354,14 @@ function compileChatMessages( functions: any[] | undefined = undefined, systemMessage: string | undefined = undefined, ): ChatMessage[] { - const msgsCopy = msgs + let msgsCopy = msgs ? msgs .map((msg) => ({ ...msg })) .filter((msg) => msg.content !== "" && msg.role !== "system") : []; + msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy); + if (prompt) { const promptMsg: ChatMessage = { role: "user", diff --git a/core/llm/llms/Moonshot.ts b/core/llm/llms/Moonshot.ts new file mode 100644 index 000000000..022fa8af2 --- /dev/null +++ b/core/llm/llms/Moonshot.ts @@ -0,0 +1,59 @@ +import { CompletionOptions, LLMOptions, ModelProvider } from "../../index.js"; +import { streamSse } from "../stream.js"; +import { osModelsEditPrompt } from "../templates/edit.js"; + +import OpenAI from "./OpenAI.js"; + +class Moonshot extends OpenAI { + static providerName: ModelProvider = "moonshot"; + static defaultOptions: Partial = { + apiBase: "https://api.moonshot.cn/v1/", + model: "moonshot-v1-8k", + promptTemplates: { + edit: osModelsEditPrompt, + }, + useLegacyCompletionsEndpoint: false, + }; + maxStopWords: number | undefined = 16; + + supportsFim(): boolean { + return true; + } + + async *_streamFim( + prefix: string, + suffix: string, + options: CompletionOptions, + ): AsyncGenerator { + const endpoint = new URL("v1/chat/completions", this.apiBase); + const resp = await this.fetch(endpoint, { + method: "POST", + body: JSON.stringify({ + model: options.model, + messages: [ + { + role: "user", + content: prefix + "[fill]" + suffix, + }, + ], + max_tokens: options.maxTokens, + temperature: options.temperature, + top_p: options.topP, + frequency_penalty: options.frequencyPenalty, + presence_penalty: options.presencePenalty, + stop: options.stop, + stream: true, + }), + headers: { + "Content-Type": "application/json", + Accept: "application/json", + Authorization: `Bearer ${this.apiKey}`, + }, + }); + for await (const chunk of streamSse(resp)) { + yield chunk.choices[0].delta.content; + } + } +} + +export default Moonshot; diff --git a/core/llm/llms/index.ts b/core/llm/llms/index.ts index 48088dc34..121f0f46d 100644 --- a/core/llm/llms/index.ts +++ b/core/llm/llms/index.ts @@ -31,6 +31,7 @@ import Llamafile from "./Llamafile"; import LMStudio from "./LMStudio"; import Mistral from "./Mistral"; import Mock from "./Mock"; +import Moonshot from "./Moonshot"; import Msty from "./Msty"; import Nebius from "./Nebius"; import Nvidia from "./Nvidia"; @@ -54,6 +55,7 @@ const LLMs = [ FreeTrial, Gemini, Llamafile, + Moonshot, Ollama, Replicate, TextGenWebUI, diff --git a/core/llm/llms/stubs/ContinueProxy.ts b/core/llm/llms/stubs/ContinueProxy.ts index 0d04f77f5..97dec3a35 100644 --- a/core/llm/llms/stubs/ContinueProxy.ts +++ b/core/llm/llms/stubs/ContinueProxy.ts @@ -13,13 +13,14 @@ class ContinueProxy extends OpenAI { static providerName: ModelProvider = "continue-proxy"; static defaultOptions: Partial = { 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; } diff --git a/core/llm/templates/edit.ts b/core/llm/templates/edit.ts index ce0c0dc75..e6ad4d6b6 100644 --- a/core/llm/templates/edit.ts +++ b/core/llm/templates/edit.ts @@ -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}}{{fileSuffix}}"; const START_TAG = ""; @@ -76,7 +34,7 @@ const osModelsEditPrompt: PromptTemplate = (history, otherData) => { !firstCharOfFirstLine; const suffixTag = isSuffix ? "" : ""; const suffixExplanation = isSuffix - ? " When you get to \"\", end your response." + ? ' When you get to "", 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 diff --git a/core/llm/templates/edit/claude.ts b/core/llm/templates/edit/claude.ts new file mode 100644 index 000000000..5ec103fa9 --- /dev/null +++ b/core/llm/templates/edit/claude.ts @@ -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"); +}; diff --git a/core/llm/templates/edit/gpt.ts b/core/llm/templates/edit/gpt.ts new file mode 100644 index 000000000..4dcc39523 --- /dev/null +++ b/core/llm/templates/edit/gpt.ts @@ -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"); +}; diff --git a/core/package-lock.json b/core/package-lock.json index 633d60c99..e817a7c6f 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -101,12 +101,12 @@ } }, "node_modules/@75lb/deep-merge": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.1.tgz", - "integrity": "sha512-xvgv6pkMGBA6GwdyJbNAnDmfAIR/DfWhrj9jgWh3TY7gRm3KO46x/GPjRg6wJ0nOepwqrNxFfojebh0Df4h4Tw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz", + "integrity": "sha512-08K9ou5VNbheZFxM5tDWoqjA3ImC50DiuuJ2tj1yEPRfkp8lLLg6XAaJ4On+a0yAXor/8ay5gHnAIshRM44Kpw==", "peer": true, "dependencies": { - "lodash.assignwith": "^4.2.0", + "lodash": "^4.17.21", "typical": "^7.1.1" }, "engines": { @@ -5832,15 +5832,23 @@ "node": "*" } }, + "node_modules/aws-ssl-profiles": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", + "integrity": "sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==", + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/aws4": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.0.tgz", "integrity": "sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g==" }, "node_modules/axios": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.1.tgz", - "integrity": "sha512-+LV37nQcd1EpFalkXksWNBiA17NZ5m5/WspmHGmZmdx1qBOg/VNq/c4eRJiA9VQQHBOs+N0ZhhdU10h2TyNK7Q==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -7331,27 +7339,27 @@ } }, "node_modules/engine.io-client": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", - "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz", + "integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", - "ws": "~8.11.0", + "ws": "~8.17.1", "xmlhttprequest-ssl": "~2.0.0" } }, "node_modules/engine.io-client/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -10868,12 +10876,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lodash.assignwith": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", - "integrity": "sha512-ZznplvbvtjK2gMvnQ1BR/zqPFZmS6jbK4p+6Up4xcRYA7yMIwxHCfbTcrYxXKzzqLsQ05eJPVznEW3tuwV7k1g==", - "peer": true - }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -10910,6 +10912,20 @@ "node": "20 || >=22" } }, + "node_modules/lru.min": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/lru.min/-/lru.min-1.1.1.tgz", + "integrity": "sha512-FbAj6lXil6t8z4z3j0E5mfRlPzxkySotzUHwRXjlpRh10vc6AI6WN62ehZj82VG7M20rqogJ0GLwar2Xa05a8Q==", + "engines": { + "bun": ">=1.0.0", + "deno": ">=1.30.0", + "node": ">=8.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wellwelwel" + } + }, "node_modules/mac-ca": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/mac-ca/-/mac-ca-3.1.0.tgz", @@ -11068,28 +11084,17 @@ } }, "node_modules/micromatch": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.6.tgz", - "integrity": "sha512-Y4Ypn3oujJYxJcMacVgcs92wofTHxp9FzfDpQON4msDefoC0lb3ETvQLOdLcbhSwU1bz8HrL/1sygfBIHudrkQ==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { "braces": "^3.0.3", - "picomatch": "^4.0.2" + "picomatch": "^2.3.1" }, "engines": { "node": ">=8.6" } }, - "node_modules/micromatch/node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -11293,15 +11298,16 @@ } }, "node_modules/mysql2": { - "version": "3.9.7", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.7.tgz", - "integrity": "sha512-KnJT8vYRcNAZv73uf9zpXqNbvBG7DJrs+1nACsjZP1HMJ1TgXEy8wnNilXAn/5i57JizXKtrUtwDB7HxT9DDpw==", + "version": "3.11.4", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.11.4.tgz", + "integrity": "sha512-Z2o3tY4Z8EvSRDwknaC40MdZ3+m0sKbpnXrShQLdxPrAvcNli7jLrD2Zd2IzsRMw4eK9Yle500FDmlkIqp+krg==", "dependencies": { + "aws-ssl-profiles": "^1.1.1", "denque": "^2.1.0", "generate-function": "^2.3.1", "iconv-lite": "^0.6.3", "long": "^5.2.1", - "lru-cache": "^8.0.0", + "lru.min": "^1.0.0", "named-placeholders": "^1.1.3", "seq-queue": "^0.0.5", "sqlstring": "^2.3.2" @@ -11310,14 +11316,6 @@ "node": ">= 8.0" } }, - "node_modules/mysql2/node_modules/lru-cache": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-8.0.5.tgz", - "integrity": "sha512-MhWWlVnuab1RG5/zMRRcVGXZLCXrZTgfwMikgzCegsPnG62yDQo5JnqKkrK4jO5iKqDAZGItAqN5CtKBCBWRUA==", - "engines": { - "node": ">=16.14" - } - }, "node_modules/named-placeholders": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/named-placeholders/-/named-placeholders-1.1.3.tgz", @@ -12253,7 +12251,6 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, "engines": { "node": ">=8.6" }, diff --git a/core/promptFiles/v2/createNewPromptFile.ts b/core/promptFiles/v2/createNewPromptFile.ts index 8f85baf55..0a8adc25d 100644 --- a/core/promptFiles/v2/createNewPromptFile.ts +++ b/core/promptFiles/v2/createNewPromptFile.ts @@ -1,46 +1,39 @@ -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 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 +45,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 +57,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); } diff --git a/core/promptFiles/v2/getPromptFiles.ts b/core/promptFiles/v2/getPromptFiles.ts index c78068899..0353746be 100644 --- a/core/promptFiles/v2/getPromptFiles.ts +++ b/core/promptFiles/v2/getPromptFiles.ts @@ -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"), + ), ), ), ) diff --git a/core/promptFiles/v2/renderPromptFile.ts b/core/promptFiles/v2/renderPromptFile.ts index bb70b19a2..89b36b0a8 100644 --- a/core/promptFiles/v2/renderPromptFile.ts +++ b/core/promptFiles/v2/renderPromptFile.ts @@ -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 diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 2c9af1433..e30de4673 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -147,6 +147,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { undefined | { dirs?: string[]; shouldClearIndexes?: boolean }, void, ]; + "index/forceReIndexFiles": [undefined | { files?: string[] }, void]; "index/indexingProgressBarInitialized": [undefined, void]; completeOnboarding: [ { diff --git a/core/protocol/ideWebview.ts b/core/protocol/ideWebview.ts index 55cb3a9b9..c833c3a7a 100644 --- a/core/protocol/ideWebview.ts +++ b/core/protocol/ideWebview.ts @@ -27,6 +27,7 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { }, void, ]; + overwriteFile: [{ filepath: string; prevFileContent: string | null }, void]; showTutorial: [undefined, void]; showFile: [{ filepath: string }, void]; openConfigJson: [undefined, void]; @@ -37,10 +38,11 @@ export type ToIdeFromWebviewProtocol = ToIdeFromWebviewOrCoreProtocol & { insertAtCursor: [{ text: string }, void]; copyText: [{ text: string }, void]; "jetbrains/editorInsetHeight": [{ height: number }, void]; + "jetbrains/isOSREnabled": [undefined, void]; "vscode/openMoveRightMarkdown": [undefined, void]; setGitHubAuthToken: [{ token: string }, void]; - acceptDiff: [{ filepath: string }, void]; - rejectDiff: [{ filepath: string }, void]; + acceptDiff: [{ filepath: string; streamId?: string }, void]; + rejectDiff: [{ filepath: string; streamId?: string }, void]; "edit/sendPrompt": [ { prompt: MessageContent; range: RangeInFileWithContents }, void, @@ -56,13 +58,24 @@ 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 type ApplyStateStatus = + | "streaming" // Changes are being applied to the file + | "done" // All changes have been applied, awaiting user to accept/reject + | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed" export interface ApplyState { streamId: string; - status?: "streaming" | "done" | "closed"; + status?: ApplyStateStatus; numDiffs?: number; filepath?: string; + fileContent?: string; } export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { @@ -98,6 +111,7 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & { setTheme: [{ theme: any }, void]; setColors: [{ [key: string]: string }, void]; "jetbrains/editorInsetRefresh": [undefined, void]; + "jetbrains/isOSREnabled": [boolean, void]; addApiKey: [undefined, void]; setupLocalConfig: [undefined, void]; incrementFtc: [undefined, void]; @@ -105,6 +119,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]; }; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 1c0f5e962..21ac52c8d 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -41,6 +41,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "stats/getTokensPerModel", "index/setPaused", "index/forceReIndex", + "index/forceReIndexFiles", "index/indexingProgressBarInitialized", "completeOnboarding", "addAutocompleteModel", @@ -60,5 +61,5 @@ export const CORE_TO_WEBVIEW_PASS_THROUGH: (keyof ToWebviewFromCoreProtocol)[] = "isContinueInputFocused", "didChangeAvailableProfiles", "setTTSActive", - "getWebviewHistoryLength" + "getWebviewHistoryLength", ]; diff --git a/core/util/dedent.test.ts b/core/util/dedent.test.ts index 3b0d526e1..95908ab4a 100644 --- a/core/util/dedent.test.ts +++ b/core/util/dedent.test.ts @@ -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} +\`\`\``); + }); }); diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index de71c15e2..42900edb5 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -20,7 +20,7 @@ import { GetGhTokenArgs } from "../protocol/ide.js"; import { getContinueGlobalPath } from "./paths.js"; class FileSystemIde implements IDE { - constructor(private readonly workspaceDir: string) { } + constructor(private readonly workspaceDir: string) {} showToast( type: ToastType, message: string, @@ -36,7 +36,7 @@ class FileSystemIde implements IDE { } gotoDefinition(location: Location): Promise { - throw new Error("Method not implemented."); + return Promise.resolve([]); } onDidChangeActiveTextEditor(callback: (filepath: string) => void): void { return; diff --git a/core/util/index.ts b/core/util/index.ts index 531ff1959..7f46278f9 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -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( 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"); } diff --git a/core/util/pathModule.ts b/core/util/pathModule.ts new file mode 100644 index 000000000..8b06ab56c --- /dev/null +++ b/core/util/pathModule.ts @@ -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 { + const pathSep = await ide.pathSep(); + return getPathModuleFromPathSep(pathSep as PathSep); +} diff --git a/core/util/paths.ts b/core/util/paths.ts index f8b70159f..d606f095d 100644 --- a/core/util/paths.ts +++ b/core/util/paths.ts @@ -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( diff --git a/core/util/treeSitter.ts b/core/util/treeSitter.ts index b877a251b..9118b80ee 100644 --- a/core/util/treeSitter.ts +++ b/core/util/treeSitter.ts @@ -3,81 +3,116 @@ import * as path from "node:path"; import Parser, { Language } from "web-tree-sitter"; -export const supportedLanguages: { [key: string]: string } = { - cpp: "cpp", - hpp: "cpp", - cc: "cpp", - cxx: "cpp", - hxx: "cpp", - cp: "cpp", - hh: "cpp", - inc: "cpp", - // Depended on this PR: https://github.com/tree-sitter/tree-sitter-cpp/pull/173 - // ccm: "cpp", - // c++m: "cpp", - // cppm: "cpp", - // cxxm: "cpp", - cs: "c_sharp", - c: "c", - h: "c", - css: "css", - php: "php", - phtml: "php", - php3: "php", - php4: "php", - php5: "php", - php7: "php", - phps: "php", - "php-s": "php", - bash: "bash", - sh: "bash", - json: "json", - ts: "typescript", - mts: "typescript", - cts: "typescript", - tsx: "tsx", - // vue: "vue", // tree-sitter-vue parser is broken - // The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part - // yaml: "yaml", - // yml: "yaml", - elm: "elm", - js: "javascript", - jsx: "javascript", - mjs: "javascript", - cjs: "javascript", - py: "python", - ipynb: "python", - pyw: "python", - pyi: "python", - el: "elisp", - emacs: "elisp", - ex: "elixir", - exs: "elixir", - go: "go", - eex: "embedded_template", - heex: "embedded_template", - leex: "embedded_template", - html: "html", - htm: "html", - java: "java", - lua: "lua", - ocaml: "ocaml", - ml: "ocaml", - mli: "ocaml", - ql: "ql", - res: "rescript", - resi: "rescript", - rb: "ruby", - erb: "ruby", - rs: "rust", - rdl: "systemrdl", - toml: "toml", - sol: "solidity", +export enum LanguageName { + CPP = "cpp", + C_SHARP = "c_sharp", + C = "c", + CSS = "css", + PHP = "php", + BASH = "bash", + JSON = "json", + TYPESCRIPT = "typescript", + TSX = "tsx", + ELM = "elm", + JAVASCRIPT = "javascript", + PYTHON = "python", + ELISP = "elisp", + ELIXIR = "elixir", + GO = "go", + EMBEDDED_TEMPLATE = "embedded_template", + HTML = "html", + JAVA = "java", + LUA = "lua", + OCAML = "ocaml", + QL = "ql", + RESCRIPT = "rescript", + RUBY = "ruby", + RUST = "rust", + SYSTEMRDL = "systemrdl", + TOML = "toml", + SOLIDITY = "solidity", +} - // jl: "julia", - // swift: "swift", - // kt: "kotlin", - // scala: "scala", +export const supportedLanguages: { [key: string]: LanguageName } = { + cpp: LanguageName.CPP, + hpp: LanguageName.CPP, + cc: LanguageName.CPP, + cxx: LanguageName.CPP, + hxx: LanguageName.CPP, + cp: LanguageName.CPP, + hh: LanguageName.CPP, + inc: LanguageName.CPP, + // Depended on this PR: https://github.com/tree-sitter/tree-sitter-cpp/pull/173 + // ccm: LanguageName.CPP, + // c++m: LanguageName.CPP, + // cppm: LanguageName.CPP, + // cxxm: LanguageName.CPP, + cs: LanguageName.C_SHARP, + c: LanguageName.C, + h: LanguageName.C, + css: LanguageName.CSS, + php: LanguageName.PHP, + phtml: LanguageName.PHP, + php3: LanguageName.PHP, + php4: LanguageName.PHP, + php5: LanguageName.PHP, + php7: LanguageName.PHP, + phps: LanguageName.PHP, + "php-s": LanguageName.PHP, + bash: LanguageName.BASH, + sh: LanguageName.BASH, + json: LanguageName.JSON, + ts: LanguageName.TYPESCRIPT, + mts: LanguageName.TYPESCRIPT, + cts: LanguageName.TYPESCRIPT, + tsx: LanguageName.TSX, + // vue: LanguageName.VUE, // tree-sitter-vue parser is broken + // The .wasm file being used is faulty, and yaml is split line-by-line anyway for the most part + // yaml: LanguageName.YAML, + // yml: LanguageName.YAML, + elm: LanguageName.ELM, + js: LanguageName.JAVASCRIPT, + jsx: LanguageName.JAVASCRIPT, + mjs: LanguageName.JAVASCRIPT, + cjs: LanguageName.JAVASCRIPT, + py: LanguageName.PYTHON, + ipynb: LanguageName.PYTHON, + pyw: LanguageName.PYTHON, + pyi: LanguageName.PYTHON, + el: LanguageName.ELISP, + emacs: LanguageName.ELISP, + ex: LanguageName.ELIXIR, + exs: LanguageName.ELIXIR, + go: LanguageName.GO, + eex: LanguageName.EMBEDDED_TEMPLATE, + heex: LanguageName.EMBEDDED_TEMPLATE, + leex: LanguageName.EMBEDDED_TEMPLATE, + html: LanguageName.HTML, + htm: LanguageName.HTML, + java: LanguageName.JAVA, + lua: LanguageName.LUA, + ocaml: LanguageName.OCAML, + ml: LanguageName.OCAML, + mli: LanguageName.OCAML, + ql: LanguageName.QL, + res: LanguageName.RESCRIPT, + resi: LanguageName.RESCRIPT, + rb: LanguageName.RUBY, + erb: LanguageName.RUBY, + rs: LanguageName.RUST, + rdl: LanguageName.SYSTEMRDL, + toml: LanguageName.TOML, + sol: LanguageName.SOLIDITY, + + // jl: LanguageName.JULIA, + // swift: LanguageName.SWIFT, + // kt: LanguageName.KOTLIN, + // scala: LanguageName.SCALA, +}; + +export const IGNORE_PATH_PATTERNS: Partial> = { + [LanguageName.TYPESCRIPT]: [/.*node_modules/], + [LanguageName.JAVASCRIPT]: [/.*node_modules/], }; export async function getParserForFile(filepath: string) { @@ -128,15 +163,9 @@ export async function getLanguageForFile( } } -export enum TSQueryType { - CodeSnippets = "code-snippet-queries", - Imports = "import-queries", - // Used in RootPathContextService.ts - FunctionDeclaration = "root-path-context-queries/function_declaration", - MethodDefinition = "root-path-context-queries/method_definition", - FunctionDefinition = "root-path-context-queries/function_definition", - MethodDeclaration = "root-path-context-queries/method_declaration", -} +export const getFullLanguageName = (filepath: string) => { + return supportedLanguages[filepath.split(".").pop() ?? ""]; +}; export async function getQueryForFile( filepath: string, @@ -147,7 +176,6 @@ export async function getQueryForFile( return undefined; } - const fullLangName = supportedLanguages[filepath.split(".").pop() ?? ""]; const sourcePath = path.join( __dirname, "..", @@ -155,7 +183,6 @@ export async function getQueryForFile( ? ["extensions", "vscode", "tree-sitter"] : ["tree-sitter"]), queryPath, - `${fullLangName}.scm`, ); if (!fs.existsSync(sourcePath)) { return undefined; diff --git a/core/util/tts.ts b/core/util/tts.ts index 9bde6e57c..efae302c2 100644 --- a/core/util/tts.ts +++ b/core/util/tts.ts @@ -82,10 +82,10 @@ export class TTS { return; } - TTS.messenger.request("setTTSActive", true); + void TTS.messenger.request("setTTSActive", true); TTS.handle?.once("exit", () => { - TTS.messenger.request("setTTSActive", false); + void TTS.messenger.request("setTTSActive", false); }); } diff --git a/docs/docs/autocomplete/model-setup.md b/docs/docs/autocomplete/model-setup.md index 05136e546..8aae88c75 100644 --- a/docs/docs/autocomplete/model-setup.md +++ b/docs/docs/autocomplete/model-setup.md @@ -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. ::: diff --git a/docs/docs/chat/how-to-customize.md b/docs/docs/chat/how-to-customize.md index 943d5e7ac..9df6ec020 100644 --- a/docs/docs/chat/how-to-customize.md +++ b/docs/docs/chat/how-to-customize.md @@ -7,6 +7,7 @@ sidebar_position: 5 There are a number of different ways to customize Chat +- You can add a [`.continuerules`](../customize/deep-dives/rules.md) file to the root of your project to customize the system prompt - You can configure [`@Codebase`](../customize/deep-dives/codebase.md) - You can create your own [custom code RAG](../customize/tutorials/custom-code-rag.md) - You can configure [`@Docs`](../customize/deep-dives/docs.md) diff --git a/docs/docs/customize/deep-dives/autocomplete.md b/docs/docs/customize/deep-dives/autocomplete.md index 2ae2435d5..9e03aa756 100644 --- a/docs/docs/customize/deep-dives/autocomplete.md +++ b/docs/docs/customize/deep-dives/autocomplete.md @@ -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://" }, ... @@ -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://" }, "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: cmd/ctrl + shift + P -> "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 cmd/ctrl + , 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. diff --git a/docs/docs/customize/deep-dives/prompt-files.md b/docs/docs/customize/deep-dives/prompt-files.md index 928e01543..e69902a42 100644 --- a/docs/docs/customize/deep-dives/prompt-files.md +++ b/docs/docs/customize/deep-dives/prompt-files.md @@ -6,42 +6,30 @@ Prompt files provide a convenient way to standardize common patterns and share a ## Quick start -:::tip[Prompt library] + -Below is a quick example of setting up a prompt file to write unit tests using Jest. +Below is a quick example of setting up a prompt file to de -1. Create a folder called `.prompts/` at the top level of your workspace. -2. Add a file called `test.prompt` to this folder. The name of this file will be the name of the slash command you will use to generate your prompt. -3. Write the following contents to `test.prompt` and save. +1. Create a folder called `.continue/prompts` at the top level of your workspace (or you can use the button in the UI by typing @, selecting "Prompt Files", and selecting "New Prompt File"). +2. Add a file called `rails.prompt` to this folder. +3. Write the following contents to `rails.prompt` and save. ``` -temperature: 0.5 -maxTokens: 4096 +name: Rails Project +description: Information about this project --- - -You are an expert programmer - - -{{{ 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` +Attached is a summary of the current Ruby on Rails application, including the @Gemfile and database schema in @db/schema.rb ``` Now to use this prompt, you can highlight code and use cmd/ctrl + L to select it in the Continue sidebar. -Then, type "/" to see the list of slash commands and choose the one called "test". Press enter and the LLM will respond given the instructions from your prompt file. +Then, type "@", select "Prompt files", and choose the one called "Rails Project". You can now ask any question as usual and the LLM will have the information from your .prompt file. ## Format -The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to use context providers and built-in variables using [Handlebars syntax](https://handlebarsjs.com/guide/). +The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers. :::info The current state of this format is experimental and subject to change @@ -51,38 +39,19 @@ The current state of this format is experimental and subject to change The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters: -- `name` -- `temperature` -- `topP` -- `topK` -- `minP` -- `presencePenalty` -- `frequencyPenalty` -- `mirostat` -- `stop` -- `maxTokens` -- `description` +- `name` - The display title +- `description` - The description you will see in the dropdown +- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set) If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator. -### System message +### Context -To add a system message, start the body with `` tags like in the example above and place your system message inside. +Many [context provider](../context-providers.md) can be referenced by typing "@" followed by the name of the context provider. -### Built-in variables - -The following built-in variables are currently available: - -- `{{{ input }}}` - The full text from the input box in the sidebar that is sent along with the slash command -- `{{{ currentFile }}}` - The currently open file in your IDE -- `{{{ ./path/to/file.js }}}` - Any file can be directly referenced - -### Context providers - -Any [context provider](../context-providers.md) that you have added to your config can be referenced using the name of the context provider. Context providers that receive an input are also supported. - -- `{{{ terminal }}}` - The contents of the terminal -- `{{{ url "https://github.com/continuedev/continue" }}}` - The contents of a URL +- `@terminal` - The contents of the terminal +- `@https://github.com/continuedev/continue` - The contents of a URL +- `@src/index.ts` - The contents of a file ## Feedback diff --git a/docs/docs/customize/deep-dives/rules.md b/docs/docs/customize/deep-dives/rules.md new file mode 100644 index 000000000..30100aaeb --- /dev/null +++ b/docs/docs/customize/deep-dives/rules.md @@ -0,0 +1,27 @@ +--- +description: Learn how to customize the system prompt with a `.continuerules` file +keywords: [rules, .continuerules, system, prompt, message] +--- + +# `.continuerules` + +You can create a project-specific system message by adding a `.continuerules` file to the root of your project. This file is raw text and its contents will be inserted into the system message for all LLM requests. + +## Simple Examples + +- If you want concise answers: + +```title=.continuerules +Please provide concise answers. Do explain obvious concepts. You can assume that I am knowledgable about most programming topics. +``` + +- If you want to ensure certain practices are followed, for example in React: + +```title=.continuerules +Whenever you are writing React code, make sure to +- use functional components instead of class components +- use hooks for state management +- define an interface for your component props +- use Tailwind CSS for styling +- modularize components into smaller, reusable pieces +``` diff --git a/docs/docs/customize/model-providers/moonshot.md b/docs/docs/customize/model-providers/moonshot.md new file mode 100644 index 000000000..64017d1bd --- /dev/null +++ b/docs/docs/customize/model-providers/moonshot.md @@ -0,0 +1,60 @@ +# Moonshot + +[Moonshot AI](https://platform.moonshot.cn/) provides high-quality large language model services with competitive pricing and excellent performance. + +## Configuration + +To use Moonshot AI models, you need to: + +1. Get an API key from [Moonshot AI Platform](https://platform.moonshot.cn/) +2. Add the following configuration to your `config.json`: + +```json +{ + "models": [ + { + "title": "Moonshot", + "provider": "moonshot", + "model": "moonshot-v1-8k", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` + +## Available Models + +Moonshot AI currently provides the following models: + +- `moonshot-v1-8k`: Base model with 8K context window +- `moonshot-v1-32k`: Base model with 32K context window +- `moonshot-v1-128k`: Base model with 128K context window + +## Configuration Options + +| Option | Description | Default | +|--------|-------------|---------| +| `apiKey` | Moonshot API key | Required | +| `apiBase` | API base URL | `https://api.moonshot.cn/v1/` | +| `model` | Model name to use | `moonshot-v1-8k` | + +## Example + +Here's a complete configuration example: + +```json +{ + "models": [ + { + "title": "Moonshot-8K", + "provider": "moonshot", + "model": "moonshot-v1-8k", + "apiKey": "YOUR_API_KEY", + "completionOptions": { + "temperature": 0.7, + "topP": 0.95, + "maxTokens": 2048 + } + } + ] +} diff --git a/docs/docs/customize/model-providers/top-level/ollama.md b/docs/docs/customize/model-providers/top-level/ollama.md index ae97d30c3..ed96ac385 100644 --- a/docs/docs/customize/model-providers/top-level/ollama.md +++ b/docs/docs/customize/model-providers/top-level/ollama.md @@ -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" } } ``` diff --git a/docs/docs/customize/model-types/autocomplete.md b/docs/docs/customize/model-types/autocomplete.md index 64d39c893..d85920605 100644 --- a/docs/docs/customize/model-types/autocomplete.md +++ b/docs/docs/customize/model-types/autocomplete.md @@ -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). diff --git a/docs/docs/introduction.md b/docs/docs/introduction.md index b3f6d87d6..64f83436d 100644 --- a/docs/docs/introduction.md +++ b/docs/docs/introduction.md @@ -15,7 +15,7 @@ keywords: ] --- -![Continue Logo](/img/intro.png) +![Continue Logo](../static/img/intro.png) **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)** diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 2562c918a..207011d64 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -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: { diff --git a/docs/i18n/zh-CN/code.json b/docs/i18n/zh-CN/code.json new file mode 100644 index 000000000..09908d027 --- /dev/null +++ b/docs/i18n/zh-CN/code.json @@ -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" + } +} diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-blog/options.json b/docs/i18n/zh-CN/docusaurus-plugin-content-blog/options.json new file mode 100644 index 000000000..9239ff706 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-blog/options.json @@ -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" + } +} diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current.json b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current.json new file mode 100644 index 000000000..e4e781f70 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current.json @@ -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" + } +} diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/context-selection.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/context-selection.md new file mode 100644 index 000000000..428aeb2df --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/context-selection.md @@ -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]" ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-it-works.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-it-works.md new file mode 100644 index 000000000..9403093f8 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-it-works.md @@ -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) ๆŸฅ็œ‹ๅฎŒๆ•ดๅ‚่€ƒใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.md new file mode 100644 index 000000000..940fedc65 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-customize.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` ๅฎšๅˆถๆ–œๆ ๅ‘ฝไปค + + + + +ๅฆ‚ๆžœไฝ ๆƒณๆฏ”ไฝฟ็”จ่‡ช็„ถ่ฏญ่จ€็ผ–ๅ†™ๅฎšๅˆถๅ‘ฝไปคๆ›ด่ฟ›ไธ€ๆญฅ๏ผŒไฝ ๅฏไปฅ็ผ–ๅ†™ไธ€ไธชๅฎšๅˆถๅ‡ฝๆ•ฐ่ฟ”ๅ›žๅ“ๅบ”ใ€‚่ฟ™้œ€่ฆไฝฟ็”จ `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; +} +``` + + + + +## ๅ…ถไป–ๅฎšๅˆถ action + +็›ฎๅ‰๏ผŒๅ…ถไป– action ่งฆๅ‘ๅ™จๆฒกๆœ‰ๅผ€ๆ”พ้…็ฝฎ๏ผŒไฝ†ๆ˜ฏๆˆ‘ไปฌ่ฎกๅˆ’ๅœจๆœชๆฅ้€š่ฟ‡ .prompt ๆ–‡ไปถๆฅๅ…่ฎธใ€‚ + + diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md new file mode 100644 index 000000000..f265a9885 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/how-to-use-it.md @@ -0,0 +1,85 @@ +--- +title: Actions +description: ๅฆ‚ไฝ•ไฝฟ็”จ Actions +sidebar_label: ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ +keywords: [ๅฆ‚ไฝ•, ๆ–œๆ , ๅ‘ฝไปค, ๆ็คบ่ฏ, ๅณๅ‡ป, ๅฟซ้€Ÿไฟฎๅค, ่ฐƒ่ฏ•, ๆ“ไฝœ] +sidebar_position: 1 +--- + +![actions](/img/actions.gif) + +## ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ + +Actions ๆ˜ฏๅธธ่ง็”จไพ‹็š„ๅฟซๆทๆ–นๅผใ€‚ไพ‹ๅฆ‚๏ผŒไฝ ๅฏ่ƒฝๆƒณ่ฆๅฎกๆŸฅไปฃ็ ๏ผŒ็ผ–ๅ†™ๆต‹่ฏ•๏ผŒๆˆ–ๆทปๅŠ ไธ€ไธชๆ–‡ๆกฃๅญ—็ฌฆไธฒใ€‚ + +### ๆ–œๆ ๅ‘ฝไปค + +ๆœ€ๅธธ่ง็š„่ฐƒ็”จ action ็š„ๆ–นๆณ•ๆ˜ฏไฝฟ็”จๆ–œๆ ๅ‘ฝไปคใ€‚้€š่ฟ‡่พ“ๅ…ฅ '/' ๅนถๅœจไธ‹ๆ‹‰ๆก†ไธญ้€‰ๆ‹ฉ๏ผŒ่ฟ™้‡Œๆœ‰ๅฟซๆทๆ–นๅผไผš่ขซๆฟ€ๆดปใ€‚ไพ‹ๅฆ‚๏ผŒๅ†…็ฝฎ็š„ '/edit' ๆ–œๆ ๅ‘ฝไปค๏ผŒ่ฎฉไฝ ๅฏไปฅ็›ดๆŽฅๅœจไฝ ็š„็ผ–่พ‘ๅ™จไธญๆตๅผๅœฐ็ผ–่พ‘ใ€‚ + +![slash-commands](/img/slash-commands.png) + +ไธ€ไบ›ๆœ€ๅธธ็”จ็š„ๆ–œๆ ๅ‘ฝไปค้ป˜่ฎคๆ˜ฏๅฏ็”จ็š„๏ผŒๆฏ”ๅฆ‚ "/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 ใ€‚ + +![quick-actions](/img/quick-actions.png) + +้ป˜่ฎคๆƒ…ๅ†ตไธ‹๏ผŒๅฟซ้€Ÿ action ๆ˜ฏ็ฆ็”จ็š„๏ผŒไฝ†ๆ˜ฏๅฏไปฅๅœจ VS Code ็š„่ฎพ็ฝฎไธญ้€š่ฟ‡ "Continue: Enable Quick Actions" ๅฏ็”จใ€‚ + +#### ๅณๅ‡ป action + +ๅณๅ‡ป action ่ฎฉไฝ ้ซ˜ไบฎๆœŸๆœ›็š„ไปฃ็ ๅŒบๅŸŸ๏ผŒๅณๅ‡ป๏ผŒ็„ถๅŽๅœจไธ‹ๆ‹‰่œๅ•ไธญ้€‰ๆ‹ฉไธ€ไธช action ใ€‚ + +![context-menu](/img/context-menu.png) + +#### ่ฐƒ่ฏ• action + +่ฐƒ่ฏ• action ๆ˜ฏ VS Code ๆ‰ฉๅฑ•ไธญไธ€ไธช็‰นๆฎŠ็š„ๅ†…็ฝฎ้”ฎ็›˜ๅฟซๆทๆ–นๅผใ€‚ไฝฟ็”จ `cmd/ctrl+shift+R` ๆฅๅฟซ้€Ÿๅคๅˆถๅฝ“ๅ‰็ปˆ็ซฏ็š„ๅ†…ๅฎนๅˆฐ่Šๅคฉไพง่พนๆ ๏ผŒๅนถ่Žทๅพ—่ฐƒ่ฏ•ๅปบ่ฎฎใ€‚ + +#### ๅฟซ้€Ÿไฟฎๅค + +ๆ— ่ฎบไฝ•ๆ—ถๅœจไฝ ็š„ไปฃ็ ไธญ็œ‹ๅˆฐ็บข่‰ฒ/้ป„่‰ฒไธ‹ๅˆ’็บฟ่กจ็คบ้”™่ฏฏ๏ผŒไฝ ๅฏไปฅๆŠŠๅ…‰ๆ ‡ๆ”พๅˆฐ้™„่ฟ‘๏ผŒ VS Code ไผšๆ˜พ็คบไธ€ไธช็ฏๆณกๅ›พๆ ‡ใ€‚ๆ— ่ฎบ็‚นๅ‡ป็ฏๆณก๏ผŒๆˆ–ไฝฟ็”จ `cmd/ctrl+.` ๅฟซๆท้”ฎ๏ผŒๅฐ†ไผšๆ˜พ็คบไธ€ไธชๅฟซ้€Ÿไฟฎๅค็š„ไธ‹ๆ‹‰่œๅ•ใ€‚ๅ…ถไธญไน‹ไธ€ๆ˜ฏ "Ask Continue" action ใ€‚ๆ— ่ฎบๅ•ๅ‡ปๆˆ–ๅ†ๆฌกไฝฟ็”จ `cmd/ctrl+.` ๏ผŒ Continue ๅฐ†ๅฐ่ฏ•ๅธฎๅŠฉ่งฃๅ†ณ้—ฎ้ข˜ใ€‚ + +![ask-continue](/img/ask-continue.png) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/model-setup.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/model-setup.md new file mode 100644 index 000000000..abfff3275 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/actions/model-setup.md @@ -0,0 +1,8 @@ +--- +title: ๆจกๅž‹่ฎพ็ฝฎ +description: Actions ๆจกๅž‹่ฎพ็ฝฎ +keywords: [ๆจกๅž‹] +sidebar_position: 2 +--- + +้ป˜่ฎคๆƒ…ๅ†ตไธ‹๏ผŒ action ไฝฟ็”จไธŽ [่Šๅคฉ](chat/model-setup.mdx) ็›ธๅŒ็š„ๆจกๅž‹๏ผŒๆ‰€ไปฅ๏ผŒๅฏนไบŽๆ‰ง่กŒ็š„ๅคๆ‚ๆŒ‡ไปค๏ผŒๆˆ‘ไปฌๆŽจ่็›ธๅŒ็š„ 400B+ ๅ‚ๆ•ฐๆจกๅž‹ๆˆ–่€…้ข†ๅ…ˆ็š„ๆจกๅž‹ไน‹ไธ€ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/context-selection.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/context-selection.md new file mode 100644 index 000000000..4ae6f0a56 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/context-selection.md @@ -0,0 +1,24 @@ +--- +title: ไธŠไธ‹ๆ–‡้€‰ๆ‹ฉ +description: ่‡ชๅŠจ่กฅๅ…จไธŠไธ‹ๆ–‡้€‰ๆ‹ฉ +keywords: [ไธŠไธ‹ๆ–‡, ่‡ชๅŠจ่กฅๅ…จ, lsp, ๆœ€่ฟ‘็š„] +sidebar_position: 3 +--- + +่‡ชๅŠจ่กฅๅ…จไผšๅŸบไบŽๅฝ“ๅ‰็š„ๅ…‰ๆ ‡ไฝ็ฝฎ่‡ชๅŠจๅœฐ็กฎๅฎšไธŠไธ‹ๆ–‡ใ€‚ๆˆ‘ไปฌไฝฟ็”จไปฅไธ‹็š„ๆŠ€ๆœฏๆฅ็กฎๅฎšไป€ไนˆๅŒ…ๅซๅœจๆ็คบ่ฏไธญ๏ผš + +### ๆ–‡ไปถๅ‰็ผ€/ๅŽ็ผ€ + +ๆˆ‘ไปฌๆ€ปๆ˜ฏๅŒ…ๅซไฝ ็š„ๆ–‡ไปถไธญๅ…‰ๆ ‡ๅ‰ๅŽ็š„ไปฃ็ ใ€‚ + +### ๆฅ่‡ช่ฏญ่จ€ๆœๅŠกๅ่ฎฎ็š„ๅฎšไน‰ + +็ฑปไผผไบŽไฝ ๅฆ‚ไฝ•ๅœจ็ผ–่พ‘ๅ™จไธญไฝฟ็”จ `cmd/ctrl + click` ๏ผŒๆˆ‘ไปฌไฝฟ็”จ็›ธๅŒ็š„ๅทฅๅ…ท (LSP) ๆฅๅขžๅผบ "่ฝฌๅˆฐๅฎšไน‰" ใ€‚ไพ‹ๅฆ‚๏ผŒๅฆ‚ๆžœไฝ ่พ“ๅ…ฅไธ€ไธชๅ‡ฝๆ•ฐ่ฐƒ็”จ๏ผŒๆˆ‘ไปฌๅฐ†ๅŒ…ๅซๅ‡ฝๆ•ฐๅฎšไน‰ใ€‚ๆˆ–่€…๏ผŒๅฆ‚ๆžœไฝ ๅœจไธ€ไธชๆ–นๆณ•ไธญๅ†™ไปฃ็ ๏ผŒๆˆ‘ไปฌๅฐ†ๅŒ…ๅซ็ฑปๅž‹ๅฎšไน‰ไธญ็š„ไปปไฝ•ๅ‚ๆ•ฐๆˆ–่ฟ”ๅ›ž็ฑปๅž‹ใ€‚ + +### ๅฏผๅ…ฅๆ–‡ไปถ + +ๅ› ไธบ้€šๅธธๆœ‰ๅพˆๅคšๅฏผๅ…ฅ๏ผŒๆˆ‘ไปฌไธ่ƒฝๅŒ…ๅซๅฎƒไปฌๆ‰€ๆœ‰ใ€‚็›ธๅ๏ผŒๆˆ‘ไปฌๆŸฅๆ‰พไฝ ็š„ๅ…‰ๆ ‡้™„่ฟ‘็š„ๆ ‡่ฏ†๏ผŒไฝฟ็”จๅฎƒๆ‰€ๅŒน้…็š„ๅฏผๅ…ฅไฝœไธบไธŠไธ‹ๆ–‡ใ€‚ + +### ๆœ€่ฟ‘็š„ๆ–‡ไปถ + +ๆˆ‘ไปฌ่‡ชๅŠจ่€ƒ่™‘ๆœ€่ฟ‘ๆ‰“ๅผ€็š„ๆˆ–็ผ–่พ‘็š„ๆ–‡ไปถ๏ผŒๅนถๅŒ…ๅซไธŽๅฝ“ๅ‰่กฅๅ…จ็›ธๅ…ณ็š„็‰‡ๆฎตใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-it-works.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-it-works.md new file mode 100644 index 000000000..44c6c07c4 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-it-works.md @@ -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) ไธญไบ†่งฃๅฎƒๆ˜ฏๅฆ‚ไฝ•ๅทฅไฝœ็š„ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.md new file mode 100644 index 000000000..5e7b8fad2 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-customize.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) ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-use-it.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-use-it.md new file mode 100644 index 000000000..d649ae3c9 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/how-to-use-it.md @@ -0,0 +1,25 @@ +--- +title: ่‡ชๅŠจ่กฅๅ…จ +description: ่‡ชๅŠจ่กฅๅ…จ \- ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ +sidebar_label: ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ +keywords: [ๅฆ‚ไฝ•] +sidebar_position: 1 +--- + +![autocomplete](/img/autocomplete.gif) + +## ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ + +่‡ชๅŠจ่กฅๅ…จ้š็€ไฝ ็š„่พ“ๅ…ฅๆไพ›่กŒๅ†…ไปฃ็ ๅปบ่ฎฎใ€‚่ฆๅฏ็”จๅฎƒ๏ผŒๅช้œ€่ฆ็ฎ€ๅ•ๅœฐ็‚นๅ‡ป็Šถๆ€ๆ ไธญ็š„ "Continue" ๆŒ‰้’ฎ๏ผŒๅœจไฝ ็š„ IDE ๅณไธ‹ไพง๏ผŒๆˆ–่€…ๅœจไฝ ็š„ IDE ่ฎพ็ฝฎไธญๅ‹พ้€‰ "ๅฏ็”จ Tab ่‡ชๅŠจ่กฅๅ…จ" ้€‰้กนใ€‚ + +### ๆŽฅๅ—ๆ•ดไธชๅปบ่ฎฎ + +ๆŒ‰ไธ‹ `Tab` ๏ผŒๆŽฅๅ—ๆ•ดไธชๅปบ่ฎฎ + +### ๆ‹’็ปๆ•ดไธชๅปบ่ฎฎ + +ๆŒ‰ไธ‹ `Esc` ๏ผŒๆ‹’็ปๆ•ดไธชๅปบ่ฎฎ + +### ้ƒจๅˆ†ๆŽฅๅ—ๅปบ่ฎฎ + +ๅฏนไบŽๆ›ด็ป†็ฒ’ๅบฆ็š„ๆŽงๅˆถ๏ผŒไฝฟ็”จ `cmd/ctrl + โ†’` ๆฅ้€ๅญ—ๅœฐๆŽฅๅ—้ƒจๅˆ†ๅปบ่ฎฎใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/model-setup.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/model-setup.md new file mode 100644 index 000000000..01747b24c --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/autocomplete/model-setup.md @@ -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) ๆŸฅ็œ‹ๅฎƒไปฌใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/context-selection.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/context-selection.md new file mode 100644 index 000000000..761554eb6 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/context-selection.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) ็œ‹ๅˆฐๅฆ‚ไฝ•ๅˆ›ๅปบไฝ ่‡ชๅทฑๅฎšๅˆถ็š„ไธŠไธ‹ๆ–‡ๆไพ›่€…ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-it-works.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-it-works.md new file mode 100644 index 000000000..87323824a --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-it-works.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` ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-customize.md new file mode 100644 index 000000000..ed56b125c --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-customize.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-use-it.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-use-it.md new file mode 100644 index 000000000..ce2acac9d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/how-to-use-it.md @@ -0,0 +1,39 @@ +--- +title: ่Šๅคฉ +description: ๅฆ‚ไฝ•ไฝฟ็”จ่Šๅคฉ +sidebar_label: ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ +keywords: [ๅฆ‚ไฝ•, ไฝฟ็”จ, ่Šๅคฉ] +sidebar_position: 1 +--- + +![chat](/img/chat.gif) + +## ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ + +่Šๅคฉๆ–นไพฟๅ‘ 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 + โ€™`ๅœจไธๅŒ็š„ๆจกๅž‹ไธญๅˆ‡ๆขใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx new file mode 100644 index 000000000..fe24f18fb --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/chat/model-setup.mdx @@ -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)๏ผ‰ ใ€‚ + + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "together", + "model": "llama3.1-405b", + "apiKey": "[TOGETHER_API_KEY]" + } + ] + ``` + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "groq", + "model": "llama3.1-405b", + "apiKey": "[GROQ_API_KEY]" + } + ] + ``` + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "vllm", + "model": "llama3.1-405b" + } + ] + ``` + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 405B", + "provider": "ollama", + "model": "llama3.1-405b" + } + ] + ``` + + + +### ๆฅ่‡ช 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)๏ผ‰ใ€‚ + + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 8B", + "provider": "ollama", + "model": "llama3.1-8b" + } + ] + ``` + + + ```json title="config.json" + "models": [ + { + "title": "Llama 3.1 8B", + "provider": "lmstudio", + "model": "llama3.1-8b" + } + ] + ``` + + + +### 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)๏ผ‰ใ€‚ + + + + ```json title="config.json" + "models": [ + { + "title": "DeepSeek Coder 2 16B", + "provider": "ollama", + "model": "deepseek-coder-v2:16b" + } + ] + ``` + + + + + ```json title="config.json" + "models": [ + { + "title": "DeepSeek Coder 2 16B", + "provider": "lmstudio", + "model": "deepseek-coder-v2:16b" + } + ] + ``` + + + + +## ๅ…ถไป–ไฝ“้ชŒ + +้™คไบ†ไปฅไธŠๆๅˆฐ็š„่ฟ™ไบ›๏ผŒ่ฟ˜ๆœ‰ๆ›ดๅคš็š„ๆจกๅž‹ๅ’Œๆไพ›่€…๏ผŒไฝ ๅฏไปฅไฝฟ็”จๆฅ่Šๅคฉใ€‚ๅœจ [่ฟ™้‡Œ](../customize/model-types/chat.md) ไบ†่งฃๆ›ดๅคšใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/changelog.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/changelog.mdx new file mode 100644 index 000000000..ab9b5cb58 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/changelog.mdx @@ -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"; + + + node.value === "VSCode Changelog" || node.value === "JetBrains Changelog", + )} +/> + +
+ +## VSCode ๅ˜ๆ›ดๆ—ฅๅฟ— + + + +## JetBrains ๅ˜ๆ›ดๆ—ฅๅฟ— + + diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/config.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/config.mdx new file mode 100644 index 000000000..95f05dba5 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/config.mdx @@ -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` ็š„ไปปไฝ•้…็ฝฎไน‹ไธŠใ€‚ + + + +[ๆŸฅ็œ‹ๆบ็ ](https://github.com/continuedev/continue/blob/main/extensions/vscode/config_schema.json) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/context-providers.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/context-providers.md new file mode 100644 index 000000000..e8667ae57 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/context-providers.md @@ -0,0 +1,487 @@ +--- +title: ไธŠไธ‹ๆ–‡ๆไพ›่€… +description: ่พ“ๅ…ฅ '@' ้€‰ๆ‹ฉๅ†…ๅฎนๅˆฐ LLM ไฝœไธบไธŠไธ‹ๆ–‡ +keywords: [ไธŠไธ‹ๆ–‡, "@", ๆไพ›่€…, LLM] +--- + +ไธŠไธ‹ๆ–‡ๆไพ›่€…ๅ…่ฎธไฝ ่พ“ๅ…ฅ '@' ๏ผŒ็œ‹ๅˆฐไธ€ไธชไธŠไธ‹ๆ–‡ไธ‹ๆ‹‰ๆก†๏ผŒ้ƒฝๅฏไปฅๆไพ›็ป™ LLM ไฝœไธบไธŠไธ‹ๆ–‡ใ€‚ๆฏไธชไธŠไธ‹ๆ–‡ๆไพ›่€…ๆ˜ฏไธ€ไธชๆ’ไปถ๏ผŒไนŸๅฐฑๆ˜ฏ่ฏด๏ผŒๅฆ‚ๆžœไฝ ๆƒณ่ฆๅ…ณ่”ไธ€ไบ›ๆฒกๆœ‰ๅœจ่ฟ™้‡Œ็œ‹ๅˆฐ็š„ไฟกๆฏๆบ๏ผŒไฝ ๅฏไปฅ่ฏทๆฑ‚๏ผˆๆˆ–ๆž„ๅปบ๏ผ๏ผ‰ไธ€ไธชๆ–ฐ็š„ไธŠไธ‹ๆ–‡ๆไพ›่€…ใ€‚ + +ไธพไธ€ไธชไพ‹ๅญ๏ผŒๆฏ”ๅฆ‚ไฝ ๅทฅไฝœๅœจ่งฃๅ†ณไธ€ไธชๆ–ฐ็š„ GitHub Issue ใ€‚ไฝ ่พ“ๅ…ฅ '@Issue' ๅนถ้€‰ๆ‹ฉไฝ ๅทฅไฝœ็š„้‚ฃไธชใ€‚ Continue ็Žฐๅœจๅฏไปฅ็œ‹ๅˆฐ issue ๆ ‡้ข˜ๅ’Œๅ†…ๅฎนใ€‚ไฝ ่ฟ˜็Ÿฅ้“้‚ฃไธช issue ๅ…ณ่”ๅˆฐๆ–‡ไปถ 'readme.md' ๅ’Œ 'helloNested.py' ๏ผŒๆ‰€ไปฅไฝ ่พ“ๅ…ฅ '@readme' ๅ’Œ '@hello' ๆŸฅ็œ‹ๅนถ้€‰ๆ‹ฉๅฎƒไปฌใ€‚็Žฐๅœจ๏ผŒ่ฟ™้‡Œๆœ‰ 3 ไธช "ไธŠไธ‹ๆ–‡ๆก็›ฎ" ๅœจ่กŒๅ†…ๆ˜พ็คบ๏ผŒๅ’Œไฝ ็š„ๅ…ถไป–่พ“ๅ…ฅไธ€่ตทใ€‚ + +![ไธŠไธ‹ๆ–‡ๆก็›ฎ](/img/context-provider-example.png) + +## ๅ†…็ฝฎ็š„ไธŠไธ‹ๆ–‡ๆไพ›่€… + +ไธบไบ†ไฝฟ็”จไปปไฝ•ๅ†…็ฝฎ็š„ไธŠไธ‹ๆ–‡ๆไพ›่€…๏ผŒๆ‰“ๅผ€ `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": "" + } + } + ] +} +``` + +ไพ‹ๅฆ‚๏ผŒ่พ“ๅ…ฅ "@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 ๆฅ่ฏทๆฑ‚ไธ€ไธชๆ–ฐ็š„ไธŠไธ‹ๆ–‡ๆไพ›่€…ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md new file mode 100644 index 000000000..ea07525ee --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/autocomplete.md @@ -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://" + }, + ... +} +``` + +ๅฆ‚ๆžœไฝ ๅฏนๅฏ็”จ้€‰้กนไธ็†Ÿๆ‚‰๏ผŒไฝ ๅฏไปฅๅœจ [่ฟ™้‡Œ](../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://" + }, + "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 ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/codebase.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/codebase.md new file mode 100644 index 000000000..eb55aa668 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/codebase.md @@ -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 ไป…ๅŒ…ๅซไปฃ็ ๅบ“ไธญ็š„ๆ–‡ไปถ่ทฏๅพ„ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md new file mode 100644 index 000000000..79862b38f --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/docs.md @@ -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` ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/prompt-files.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/prompt-files.md new file mode 100644 index 000000000..bbcd0d36b --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/deep-dives/prompt-files.md @@ -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 +--- + +You are an expert programmer + + +{{{ 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 ็•™็ฉบ๏ผŒไธ้œ€่ฆๅŒ…ๅซ `---` ๅˆ†้š”็ฌฆใ€‚ + +### ็ณป็ปŸไฟกๆฏ + +ไธบไบ†ๆทปๅŠ ไธ€ไธช็ณป็ปŸไฟกๆฏ๏ผŒไฝฟ็”จ `` 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) ๆๅ‡บใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/development-data.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/development-data.md new file mode 100644 index 000000000..c9541a4c4 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/development-data.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/assets/watsonx2.gif b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/assets/watsonx2.gif new file mode 100644 index 000000000..e37443ad6 Binary files /dev/null and b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/assets/watsonx2.gif differ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/SambaNova.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/SambaNova.md new file mode 100644 index 000000000..79e142ca9 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/SambaNova.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cloudflare.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cloudflare.md new file mode 100644 index 000000000..227539ff5 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cloudflare.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cohere.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cohere.md new file mode 100644 index 000000000..274c1942d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/cohere.md @@ -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": "" + } +} +``` + +## ้‡ๆŽ’ๅบๆจกๅž‹ + +ๆˆ‘ไปฌๆŽจ่้…็ฝฎ **rerank-english-v3.0** ไฝœไธบไฝ ็š„้‡ๆŽ’ๅบๆจกๅž‹ใ€‚ + +```json title="config.json" +{ + "embeddingsProvider": { + "provider": "cohere", + "params": { + "model": "rerank-english-v3.0", + "apiKey": "" + } + } +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/deepinfra.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/deepinfra.md new file mode 100644 index 000000000..990003ebb --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/deepinfra.md @@ -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": "" + } + ] +} +``` + +[ๆŸฅ็œ‹ไปฃ็ ](https://github.com/continuedev/continue/blob/main/core/llm/llms/DeepInfra.ts) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/flowise.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/flowise.md new file mode 100644 index 000000000..33a3290d7 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/flowise.md @@ -0,0 +1,18 @@ +# Flowise + +[Flowise](https://flowiseai.com/) ๆ˜ฏไธ€ไธช ไฝŽไปฃ็ /ๆ— ไปฃ็  ๆ‹–ๆ‹ฝๅทฅๅ…ท๏ผŒ็›ฎๆ ‡ๆ˜ฏ่ฎฉไบบไปฌๆ›ดๅฎนๆ˜“ๅœฐๅฏ่ง†ๅŒ–ๆž„ๅปบ LLM ๅบ”็”จใ€‚ Continue ๅฏไปฅ้…็ฝฎไฝฟ็”จ `Flowise` LLM ็ฑป๏ผŒๆฏ”ๅฆ‚่ฟ™้‡Œ็š„ไพ‹ๅญ๏ผš + +```json title="config.json" +{ + "models": [ + { + "provider": "flowise", + "title": "Flowise", + "model": "", + "apiBase": "" + } + ] +} +``` + +[ๆŸฅ็œ‹ไปฃ็ ](https://github.com/continuedev/continue/blob/main/core/llm/llms/Flowise.ts) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/free-trial.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/free-trial.md new file mode 100644 index 000000000..746038bdf --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/free-trial.md @@ -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 ็”จๆˆทๅๅˆฐ้ฅๆต‹ๆ•ฐๆฎใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/groq.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/groq.md new file mode 100644 index 000000000..a86a420f3 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/groq.md @@ -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": "" + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/huggingfaceinferenceapi.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/huggingfaceinferenceapi.md new file mode 100644 index 000000000..450bfd365 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/huggingfaceinferenceapi.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/ipex_llm.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/ipex_llm.md new file mode 100644 index 000000000..b946d4dd5 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/ipex_llm.md @@ -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) ่Žทๅ–ๆ›ดๅคšไฟกๆฏใ€‚ +::: diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/kindo.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/kindo.md new file mode 100644 index 000000000..6129b47f2 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/kindo.md @@ -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": "" + } + ] +} +``` + +## tab ่‡ชๅŠจ่กฅๅ…จ้…็ฝฎ็คบไพ‹ + +```json title="config.json" +{ + "tabAutocompleteModel": [ + { + "title": "WhiteRabbitNeo", + "provider": "kindo", + "model": "/models/WhiteRabbitNeo-33B-DeepSeekCoder", + "apiKey": "" + }, + { + "title": "DeepSeek", + "provider": "kindo", + "model": "deepseek-ai/deepseek-coder-33b-instruct", + "apiKey": "" + } + ] +} +``` + +## ๅฎ‰ๅ…จๆ€ง + +่ฆๆ›ดๆ–ฐไฝ ็š„ๆœบๆž„ๆจกๅž‹่ฎฟ้—ฎ๏ผŒๅœจ [ๅฎ‰ๅ…จๆ€ง่ฎพ็ฝฎ](https://app.kindo.ai/security-settings) ไธญ่ฐƒๆ•ดๆŽงๅˆถใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamacpp.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamacpp.md new file mode 100644 index 000000000..4ad70bd79 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamacpp.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamafile.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamafile.md new file mode 100644 index 000000000..9c270ce5c --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/llamafile.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/lmstudio.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/lmstudio.md new file mode 100644 index 000000000..faea201a8 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/lmstudio.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/msty.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/msty.md new file mode 100644 index 000000000..90a44f650 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/msty.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/openrouter.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/openrouter.md new file mode 100644 index 000000000..aa0e32a3b --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/openrouter.md @@ -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) ไบ†่งฃๆ›ดๅคšๅฏ็”จ็š„่ฎพ็ฝฎใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/replicatellm.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/replicatellm.md new file mode 100644 index 000000000..dc4d6b80d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/replicatellm.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/sagemaker.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/sagemaker.md new file mode 100644 index 000000000..5b804dedd --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/sagemaker.md @@ -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. +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/textgenwebui.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/textgenwebui.md new file mode 100644 index 000000000..45768c776 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/textgenwebui.md @@ -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" + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/together.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/together.md new file mode 100644 index 000000000..ba68e222c --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/together.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/vllm.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/vllm.md new file mode 100644 index 000000000..28378cfe7 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/vllm.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/watsonx.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/watsonx.md new file mode 100644 index 000000000..6924ae390 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/more/watsonx.md @@ -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 ":" | base64` ๏ผŒๆ›ฟๆข `` ไธบไฝ ็š„ CPD username ๅ’Œ `` ไธบไฝ ๅˆšๅˆšๅˆ›ๅปบ็š„ 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" + } + ] +} +``` + +## ไฝฟ็”จ + +![usage-gif](../assets/watsonx2.gif) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/anthropic.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/anthropic.md new file mode 100644 index 000000000..7380e7673 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/anthropic.md @@ -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]" + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/azure.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/azure.md new file mode 100644 index 000000000..6fa50faaa --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/azure.md @@ -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": "", + "engine": "", + "apiVersion": "", + "apiType": "azure", + "apiKey": "" +}] +``` + +## ่‡ชๅŠจ่กฅๅ…จๆจกๅž‹ + +ๆˆ‘ไปฌๆŽจ่้…็ฝฎ **Codestral** ไฝœไธบไฝ ็š„่‡ชๅŠจ่กฅๅ…จๆจกๅž‹ใ€‚ + +```json title="config.json" +"tabAutocompleteModel": [{ + "title": "Codestral", + "provider": "azure", + "model": "codestral-latest", + "apiBase": "", + "engine": "", + "apiVersion": "", + "apiType": "azure", + "apiKey": "" +}] +``` + +## ๅตŒๅ…ฅๆจกๅž‹ + +ๆˆ‘ไปฌๆŽจ่้…็ฝฎ **text-embedding-3-large** ไฝœไธบไฝ ็š„ๅตŒๅ…ฅๆจกๅž‹ใ€‚ + +```json title="config.json" +"embeddingsProvider": { + "provider": "azure", + "model": "text-embedding-3-large", + "apiBase": "", + "engine": "", + "apiVersion": "", + "apiType": "azure", + "apiKey": "" +} +``` + +## ้‡ๆŽ’ๅบๆจกๅž‹ + +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 `` ๅŒน้…ไปฅไธ‹้…็ฝฎ๏ผš + +```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": "" +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/bedrock.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/bedrock.md new file mode 100644 index 000000000..a1a4d6234 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/bedrock.md @@ -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. +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/deepseek.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/deepseek.md new file mode 100644 index 000000000..61e01e701 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/deepseek.md @@ -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) ๆŸฅ็œ‹้‡ๆŽ’ๅบๆจกๅž‹ๆไพ›่€…ๅˆ—่กจใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/gemini.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/gemini.md new file mode 100644 index 000000000..13778e379 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/gemini.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) ๆŸฅ็œ‹้‡ๆŽ’ๅบๆจกๅž‹ๆไพ›่€…ๅˆ—่กจใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/mistral.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/mistral.md new file mode 100644 index 000000000..2e853affc --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/mistral.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) ๆŸฅ็œ‹้‡ๆŽ’ๅบๆจกๅž‹ๆไพ›่€…ๅˆ—่กจใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/ollama.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/ollama.md new file mode 100644 index 000000000..9119116ef --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/ollama.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) ๆŸฅ็œ‹้‡ๆŽ’ๅบๆจกๅž‹ๆไพ›่€…ๅˆ—่กจใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/openai.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/openai.md new file mode 100644 index 000000000..ba84723da --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-providers/top-level/openai.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 +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/autocomplete.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/autocomplete.md new file mode 100644 index 000000000..174491438 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/autocomplete.md @@ -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` ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/chat.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/chat.md new file mode 100644 index 000000000..c49051360 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/chat.md @@ -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) diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/embeddings.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/embeddings.md new file mode 100644 index 000000000..78cbc03c2 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/embeddings.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": "" + } +} +``` + +### 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 ๅตŒๅ…ฅ็š„ๆŒ‡ไปคใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/reranking.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/reranking.md new file mode 100644 index 000000000..4e530b985 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/model-types/reranking.md @@ -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": "" + } + } +} +``` + +### Cohere + +ๅœจ [่ฟ™้‡Œ](https://docs.cohere.com/docs/rerank-2) ๆŸฅ็œ‹ Cohere ๅฏนไบŽ้‡ๆŽ’ๅบ็š„ๆ–‡ๆกฃใ€‚ + +```json title="config.json" +{ + "reranker": { + "name": "cohere", + "params": { + "model": "rerank-english-v3.0", + "apiKey": "" + } + } +} +``` + +### 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" + } +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/overview.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/overview.md new file mode 100644 index 000000000..784c0bd59 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/overview.md @@ -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) ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/slash-commands.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/slash-commands.md new file mode 100644 index 000000000..778a36522 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/slash-commands.md @@ -0,0 +1,153 @@ +--- +title: ๆ–œๆ ๅ‘ฝไปค +description: ไปฅ '/' ไธบๅผ€ๅคดๆฟ€ๆดป็š„ๅฟซๆทๆ–นๅผ +keywords: [ๆ–œๆ ๅ‘ฝไปค, ่‡ชๅฎšไน‰ๅ‘ฝไปค, ๆญฅ้ชค] +--- + +ๆ–œๆ ๅ‘ฝไปคๆ˜ฏๅฏไปฅ้€š่ฟ‡่พ“ๅ…ฅ '/' ๆฅๆฟ€ๆดป๏ผŒๅนถไปŽไธ‹ๆ‹‰ๆก†ไธญ้€‰ๆ‹ฉ็š„ๅฟซๆทๆ–นๅผใ€‚ไพ‹ๅฆ‚๏ผŒๅ†…็ฝฎ็š„ '/edit' ๆ–œๆ ๅ‘ฝไปค๏ผŒ่ฎฉไฝ ๅฏไปฅ็›ดๆŽฅๅœจไฝ ็š„็ผ–่พ‘ๅ™จไธญๆตๅผๅœฐ็ผ–่พ‘ใ€‚ + +![slash-commands](/img/slash-commands.png) + +## ๅ†…็ฝฎ็š„ๆ–œๆ ๅ‘ฝไปค + +ไธบไบ†ไฝฟ็”จไปปไฝ•ๅ†…็ฝฎ็š„ๆ–œๆ ๅ‘ฝไปค๏ผŒๆ‰“ๅผ€ `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": "" } + } + ] +} +``` + +### `/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" + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-context-provider.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-context-provider.md new file mode 100644 index 000000000..735f405de --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-context-provider.md @@ -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; + loadSubmenuItems?: ( + args: LoadSubmenuItemsArgs, + ) => Promise; +} +``` + +ไฝœไธบไธ€ไธชไพ‹ๅญ๏ผŒๆฏ”ๅฆ‚ไฝ ๆœ‰ไธ€็ณปๅˆ—ๅ†…้ƒจๆ–‡ไปถ็ดขๅผ•ๅˆฐไธ€ไธชๅ‘้‡ๆ•ฐๆฎๅบ“ไธญใ€‚ไฝ ่ฎพ็ฝฎไบ†ไธ€ไธช็ฎ€ๅ•็š„ 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 => { + 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 => { + // '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 => { + // 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 ` ๏ผŒ็„ถๅŽๅœจ 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" + } +} +``` + + + +## 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 { + return [ + { + name: "Custom", + description: "Custom description", + content: "Custom content", + }, + ]; + } + + async loadSubmenuItems( + args: LoadSubmenuItemsArgs, + ): Promise { + 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); +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md new file mode 100644 index 000000000..755bb2b14 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/build-your-own-slash-command.md @@ -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; +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/custom-code-rag.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/custom-code-rag.md new file mode 100644 index 000000000..118e7945d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/custom-code-rag.md @@ -0,0 +1,148 @@ +# ๅฎšๅˆถไปฃ็  RAG + +่™ฝ็„ถ Continue ็š„ [@Codebase](../deep-dives/codebase.md) ๅผ€็ฎฑๅณ็”จ๏ผŒไฝ ๅฏ่ƒฝๆƒณ่ฆ่ฎพ็ฝฎ่‡ชๅทฑ็š„ๅ‘้‡ๆ•ฐๆฎๅบ“๏ผŒๅนถๆž„ๅปบไธ€ไธชๅฎšๅˆถ็š„ๆฃ€็ดขๅขžๅผบ็”Ÿๆˆ๏ผˆRAG๏ผ‰็ณป็ปŸใ€‚่ฟ™ๅ…่ฎธไฝ ่ฎฟ้—ฎไธๅœจๆœฌๅœฐๅฏ็”จ็š„ไปฃ็ ๏ผŒๅฏนๆฏไธช็”จๆˆทๆฏๆฌก็ดขๅผ•ไปฃ็ ๏ผŒๆˆ–่€…ๅŒ…ๅซๅฎšๅˆถ็š„้€ป่พ‘ใ€‚ๅœจ่ฟ™ไธชๆŒ‡ๅ—ไธญ๏ผŒๆˆ‘ไปฌๅฐ†ๅฑ•็คบๆž„ๅปบ่ฟ™ไธช็š„ๆญฅ้ชคใ€‚ + +## ๆญฅ้ชค 1 ๏ผš้€‰ๆ‹ฉๅตŒๅ…ฅๆจกๅž‹ + +ๅฆ‚ๆžœๅฏ่ƒฝ๏ผŒๆˆ‘ไปฌๆŽจ่ไฝฟ็”จ [`voyage-code-2`](https://docs.voyageai.com/docs/embeddings) ๏ผŒๅฎƒๅฐ†็ป™ๅ‡บๆœ€ๅ‡†็กฎ็š„็ญ”ๆกˆ๏ผŒๅ…ณไบŽไปปไฝ•ๅทฒๅญ˜็š„ไปฃ็ ๅตŒๅ…ฅๆจกๅž‹ใ€‚ไฝ ๅฏไปฅๅœจ [่ฟ™้‡Œ](https://dash.voyageai.com/api-keys) ่Žทๅ– API key ใ€‚ๅ› ไธบไป–้—จ็š„ API ๆ˜ฏ [OpenAI-ๅ…ผๅฎน็š„](https://docs.voyageai.com/reference/embeddings-api) ๏ผŒไฝ ๅฏไปฅไฝฟ็”จไปปไฝ• OpenAI ๅฎขๆˆท็ซฏๆขๅ‡บ URL ใ€‚ + +## ๆญฅ้ชค 2 ๏ผš้€‰ๆ‹ฉๅ‘้‡ๆจกๅž‹ + +่ฟ™้‡Œๆœ‰ไธ€ไบ›ๅฏ็”จ็š„ๅ‘้‡ๆ•ฐๆฎๅบ“๏ผŒไฝ†ๆ˜ฏๅ› ไธบๅคงๅคšๆ•ฐๅ‘้‡ๆ•ฐๆฎๅบ“่ƒฝๅคŸ่‰ฏๅฅฝๅœฐๅค„็†ๅคง็š„ไปฃ็ ๅบ“๏ผŒๆˆ‘ไปฌๆŽจ่้€‰ๆ‹ฉ่ฎพ็ฝฎๅ’Œๅฎž้ชŒ็ฎ€ๅ•็š„ไธ€ไธชใ€‚ + +[LanceDB](https://lancedb.github.io/lancedb/basic/) ๆ˜ฏไธ€ไธชๅพˆๅฅฝ็š„้€‰ๆ‹ฉ๏ผŒๅ› ไธบๅฎƒๅฏไปฅๅœจๅ†…ๅญ˜ไธญ่ฟ่กŒ๏ผŒๆœ‰ Python ๅ’Œ Node.js ๅบ“ใ€‚่ฟ™ๆ„ๅ‘ณ็€๏ผŒๅœจๅผ€ๅง‹็š„ๆ—ถๅ€™๏ผŒไฝ ๅฏไปฅไธ“ๆณจไบŽ็ผ–ๅ†™ไปฃ็ ๏ผŒ่€Œไธๆ˜ฏ่ฎพ็ฝฎๅŸบ็ก€่ฎพๆ–ฝใ€‚ๅฆ‚ๆžœไฝ ๅทฒ็ป้€‰ๆ‹ฉไบ†ๅ‘้‡ๆ•ฐๆฎๅบ“๏ผŒ้‚ฃไนˆไฝฟ็”จ่ฟ™ไธชไปฃๆ›ฟ LanceDB ไนŸๆ˜ฏไธ€ไธชๅฅฝ็š„้€‰ๆ‹ฉใ€‚ + +## ๆญฅ้ชค 3 ๏ผš้€‰ๆ‹ฉไธ€ไธช "ๅˆ†ๅ—" ็ญ–็•ฅ + +ๅคงๅคšๆ•ฐๅตŒๅ…ฅๆจกๅž‹ๅช่ƒฝไธ€ๆฌกๅค„็†ๆœ‰้™็š„ๆ–‡ๆœฌๆ•ฐ้‡ใ€‚ไธบไบ†่งฃๅ†ณ่ฟ™ไธช้—ฎ้ข˜๏ผŒๆˆ‘ไปฌ "ๅˆ†ๅ—" ๆˆ‘ไปฌ็š„ไปฃ็ ๅˆฐ่พƒๅฐ็š„้ƒจๅˆ†ใ€‚ + +ๅฆ‚ๆžœไฝ ไฝฟ็”จ `voyage-code-2` ๏ผŒๅฎƒๅฏไปฅๆœ‰ๆœ€ๅคง 16,000 token ไธŠไธ‹ๆ–‡้•ฟๅบฆ๏ผŒ่ถณๅคŸๅฎน็บณๅคงๅคšๆ•ฐๆ–‡ไปถใ€‚่ฟ™ๆ„ๅ‘ณ็€๏ผŒๅœจๅผ€ๅง‹็š„ๆ—ถๅ€™๏ผŒไฝ ๅฏไปฅไฝฟ็”จๆ›ดๆœด็ด ็š„็ญ–็•ฅ้ฟๅ…่ถ…่ฟ‡้™ๅˆถใ€‚ไธบไบ†ๆœ€็ฎ€ๅ•ๅˆฐๆœ€็ปผๅˆ๏ผŒไฝ ๅฏไปฅไฝฟ็”จ 3 ๅˆ†ๅ—็ญ–็•ฅ๏ผš + +1. ๆˆชๆ–ญๆ–‡ไปถ๏ผŒๅฝ“ๅฎƒ่ถ…่ฟ‡ไธŠไธ‹ๆ–‡้•ฟๅบฆ๏ผšๅœจ่ฟ™็งๆƒ…ๅ†ตไธ‹๏ผŒไฝ ๆ€ปๆ˜ฏๆฏไธชๆ–‡ไปถๆœ‰ 1 ไธชๅˆ†ๅ—ใ€‚ +2. ๆ‹†ๅˆ†ๆ–‡ไปถๅˆฐไธ€ไธชๅ›บๅฎš้•ฟๅบฆ็š„ๅˆ†ๅ—๏ผšไปŽๆ–‡ไปถ็š„ๆœ€ไธŠ้ขๅผ€ๅง‹๏ผŒๆทปๅŠ ไฝ ๅฝ“ๅ‰ๅˆ†ๅ—็š„่กŒ๏ผŒ็›ดๅˆฐๅฎƒๅˆฐ่พพ้™ๅˆถ๏ผŒ็„ถๅŽๅผ€ๅง‹ไธ€ไธชๆ–ฐ็š„ๅˆ†ๅ—ใ€‚ +3. ไฝฟ็”จไธ€ไธช้€’ๅฝ’็š„๏ผŒๅŸบไบŽๆŠฝ่ฑก่ฏญๆณ•ๆ ‘๏ผˆAST๏ผ‰็š„็ญ–็•ฅ๏ผš่ฟ™ๆ˜ฏๆœ€ๅ‡†็กฎ็š„๏ผŒไฝ†ๆ˜ฏๆœ€ๅคๆ‚็š„ใ€‚ๅœจๅคงๅคšๆ•ฐๆƒ…ๅ†ตไธ‹๏ผŒ้€š่ฟ‡ไฝฟ็”จ (1) ๆˆ– (2) ๏ผŒไฝ ๅฏไปฅ่Žทๅพ—ๅฅฝ็š„่ดจ้‡็ป“ๆžœ๏ผŒไฝ†ๆ˜ฏๅฆ‚ๆžœไฝ ๆƒณ่ฆๅฐ่ฏ•่ฟ™ไธช๏ผŒไฝ ๅฏไปฅๆŸฅๆ‰พไธ€ไธชๅ‚่€ƒ็คบไพ‹๏ผŒๅœจ [ๆˆ‘ไปฌ็š„ไปฃ็  chunker](https://github.com/continuedev/continue/blob/main/core/indexing/chunk/code.ts) ๆˆ–ๅœจ [LlamaIndex](https://docs.llamaindex.ai/en/stable/api_reference/node_parsers/code/) ใ€‚ + +ๅƒๅพ€ๅธธไธ€ๆ ท๏ผŒๅœจ่ฟ™ไธชๆŒ‡ๅ—ไธญ๏ผŒๆˆ‘ไปฌๆŽจ่ๅผ€ๅง‹็š„็ญ–็•ฅ๏ผŒไฝฟ็”จ 20% ็š„ๅŠชๅŠ›่Žทๅพ— 80% ็š„ๆ”ถ็›Šใ€‚ + +## ๆญฅ้ชค 4 ๏ผšๆ”พๅœจไธ€่ตทไธ€ไธช็ดขๅผ•่„šๆœฌ + +Indexing, in which we will insert your code into the vector database in a retrievable format, happens in three steps: + +็ดขๅผ•๏ผŒๆˆ‘ไปฌๅฐ†ไปฅๅฏๆฃ€็ดข็š„ๆ ผๅผๆ’ๅ…ฅไฝ ็š„ไปฃ็ ๅˆฐๅ‘้‡ๆ•ฐๆฎๅบ“๏ผŒๆœ‰ไปฅไธ‹ไธ‰ไธชๆญฅ้ชค๏ผš + +1. ๅˆ†ๅ— +2. ็”ŸๆˆๅตŒๅ…ฅ +3. ๆ’ๅ…ฅๅˆฐๅ‘้‡ๆ•ฐๆฎๅบ“ + +ไฝฟ็”จ LanceDB ๏ผŒๆˆ‘ไปฌๅฏไปฅๅŒๆ—ถๅšๆญฅ้ชค 2 ๅ’Œ 3 ๏ผŒๅƒ [ไป–้—จ็š„ๆ–‡ๆกฃ](https://lancedb.github.io/lancedb/basic/#using-the-embedding-api) ๆ‰€ๆ่ฟฐ็š„ใ€‚ๅฆ‚ๆžœไฝ ไฝฟ็”จ Voyage AI ๏ผŒๅฎƒๅฏไปฅ้…็ฝฎๅƒไธ‹้ข่ฟ™ๆ ท๏ผš + +```python +from lancedb.pydantic import LanceModel, Vector +from lancedb.embeddings import get_registry + +db = lancedb.connect("/tmp/db") +func = get_registry().get("openai").create( + name="voyage-code-2", + base_url="https://api.voyageai.com/v1/", + api_key=os.environ["VOYAGE_API_KEY"], +) + +class CodeChunks(LanceModel): + filename: str + text: str = func.SourceField() + # 1536 is the embedding dimension of the `voyage-code-2` model. + vector: Vector(1536) = func.VectorField() + +table = db.create_table("code_chunks", schema=CodeChunks, mode="overwrite") +table.add([ + {"text": "print('hello world!')", filename: "hello.py"}, + {"text": "print('goodbye world!')", filename: "goodbye.py"} +]) + +query = "greetings" +actual = table.search(query).limit(1).to_pydantic(CodeChunks)[0] +print(actual.text) +``` + +:::tip +ๅฆ‚ๆžœไฝ ็ดขๅผ•่ถ…่ฟ‡ไธ€ไธชไป“ๅบ“๏ผŒๆœ€ๅฅฝไฟๅญ˜ๅฎƒไปฌๅˆฐไธๅŒ็š„ "table" ๏ผˆLanceDB ไฝฟ็”จ็š„ๆœฏ่ฏญ๏ผ‰ๆˆ– "collection" ๏ผˆไธ€ไบ›ๅ…ถไป–ๅ‘้‡ๆ•ฐๆฎๅบ“ไฝฟ็”จ็š„ๆœฏ่ฏญ๏ผ‰ใ€‚ๅฏๆ›ฟไปฃ็š„ๅšๆณ•๏ผŒๆทปๅŠ ไธ€ไธช "repository" ๅญ—ๆฎต๏ผŒ็„ถๅŽ้€š่ฟ‡่ฟ™ไธช่ฟ‡ๆปคๆ˜ฏๆ€ง่ƒฝ่พƒไฝŽ็š„ใ€‚ +::: + +ไธ็ฎกไฝ ้€‰ๆ‹ฉ็š„ๆ˜ฏๅ“ชไธชๆ•ฐๆฎๅบ“ๆˆ–ๆจกๅž‹๏ผŒไฝ ็š„่„šๆœฌๅบ”่ฏฅ่ฟญไปฃไฝ ๆƒณ่ฆ็ดขๅผ•็š„ๆ‰€ๆœ‰ๆ–‡ไปถ๏ผŒๅฏนๅฎƒไปฌๅˆ†ๅ—๏ผŒ็”Ÿๆˆๆฏไธชๅˆ†ๅ—็š„ๅตŒๅ…ฅ๏ผŒ็„ถๅŽๆ’ๅ…ฅๆ‰€ๆœ‰ๅˆ†ๅ—ๅˆฐไฝ ็š„ๅ‘้‡ๆ•ฐๆฎๅบ“ใ€‚ + +## ๆญฅ้ชค 5 ๏ผš่ฟ่กŒไฝ ็š„็ดขๅผ•่„šๆœฌ + +:::tip +ๅœจไธ€ไธชๅฎŒๆˆ็š„็”Ÿไบง็‰ˆๆœฌ๏ผŒไฝ ๆƒณ่ฆๆž„ๅปบ "่‡ชๅŠจ็š„๏ผŒๅขž้‡็š„็ดขๅผ•" ๏ผŒไปฅไพฟๆ— ่ฎบไปปไฝ•ๆ—ถๅ€™ๆ–‡ไปถๅ˜ๆ›ด๏ผŒ้‚ฃไธชๆ–‡ไปถๆฒกๆœ‰ๅˆซ็š„่‡ชๅŠจ้‡ๆ–ฐ็ดขๅผ•ใ€‚่ฟ™ๆœ‰ๅฎŒๅ…จๆœ€ๆ–ฐๅตŒๅ…ฅ็š„ๆ”ถ็›Šๅ’Œ่พƒไฝŽ็š„่Šฑ่ดนใ€‚ + +ไนŸๅฐฑๆ˜ฏ่ฏด๏ผŒๆˆ‘ไปฌๅผบ็ƒˆๆŽจ่๏ผŒๅœจๅฐ่ฏ•่ฟ™ไธชไน‹ๅ‰๏ผŒ้ฆ–ๅ…ˆๆž„ๅปบๅ’Œๆต‹่ฏ•ๆตๆฐด็บฟใ€‚้™ค้žไฝ ็š„ไปฃ็ ๅบ“้ข‘็นๅœฐๆ•ดไธช้‡ๅ†™๏ผŒไธ€ไธชๅฎŒๆ•ด็š„็ดขๅผ•ๅˆทๆ–ฐ๏ผŒๆ˜ฏ่ถณๅคŸ็š„ๅ’Œๅˆ็†็š„ไพฟๅฎœใ€‚ +::: + +ๅœจ่ฟ™ไธช็‚นไธŠ๏ผŒไฝ ็ผ–ๅ†™ไบ†ไฝ ็š„็ดขๅผ•่„šๆœฌ๏ผŒๆต‹่ฏ•ๅฏไปฅไปŽไฝ ็š„ๅ‘้‡ๆ•ฐๆฎๅบ“ๅšๆŸฅ่ฏขใ€‚็Žฐๅœจ๏ผŒไฝ ๆƒณ่ฆไป€ไนˆๆ—ถๅ€™่ฟ่กŒ็ดขๅผ•่„šๆœฌ็š„่ฎกๅˆ’ใ€‚ + +ๅœจๅผ€ๅง‹็š„ๆ—ถๅ€™๏ผŒไฝ ๅฏ่ƒฝๆ‰‹ๅŠจ่ฟ่กŒๅฎƒใ€‚ไธ€ๆ—ฆไฝ ็กฎ่ฎค๏ผŒไฝ ๅฎšๅˆถ็š„ RAG ๆไพ›ไบ†ๅ€ผ๏ผŒๅ‡†ๅค‡ๅฅฝ้•ฟๆœŸไฝฟ็”จ๏ผŒ้‚ฃไนˆไฝ ๅฏไปฅ่ฎพ็ฝฎไธ€ไธช cron ไปปๅŠก๏ผŒๅฎšๆœŸๅœฐ่ฟ่กŒๅฎƒใ€‚ๅ› ไธบไปฃ็ ๅบ“ๅœจ็Ÿญ็š„ๆ—ถ้—ดๅ†…ไธไผšๅคง้‡ๅ˜ๆ›ด๏ผŒไฝ ไธไผšๆƒณ่ฆ้‡ๆ–ฐ็ดขๅผ•่ถ…่ฟ‡ไธ€ๅคฉไธ€ๆฌกใ€‚ๆฏๅ‘จไธ€ๆฌกๆˆ–ๆฏๆœˆไธ€ๆฌก็”š่‡ณๅฏ่ƒฝๆ˜ฏ่ถณๅคŸ็š„ใ€‚ + +## ๆญฅ้ชค 6 ๏ผš่ฎพ็ฝฎไฝ ็š„ๆœๅŠกๅ™จ + +ไธบไบ† Continue ๆ‰ฉๅฑ•่ƒฝๅคŸ่ฎฟ้—ฎไฝ ็š„ๅฎšๅˆถ RAG ็ณป็ปŸ๏ผŒไฝ ้œ€่ฆ่ฎพ็ฝฎๆœๅŠกๅ™จใ€‚่ฟ™ไธชๆœๅŠกๅ™จ่ดŸ่ดฃๆŽฅๆ”ถๆฅ่‡ชๆ‰ฉๅฑ•็š„ๆŸฅ่ฏข๏ผŒๆŸฅ่ฏขๅ‘้‡ๆ•ฐๆฎๅบ“๏ผŒ่ฟ”ๅ›ž Continue ๆƒณ่ฆ็š„ๆ ผๅผ็š„็ป“ๆžœใ€‚ + +่ฟ™ๆ˜ฏไธ€ไธชไฝฟ็”จ FastAPI ็š„ๅ‚่€ƒๅฎž็Žฐ๏ผŒ้€‚็”จไบŽๅค„็†ๆฅ่‡ช Continue ็š„ "http" ไธŠไธ‹ๆ–‡ๆไพ›่€…็š„่ฏทๆฑ‚ใ€‚ + +```python +""" +This is an example of a server that can be used with the "http" context provider. +""" + +from fastapi import FastAPI +from pydantic import BaseModel + + +class ContextProviderInput(BaseModel): + query: str + fullInput: str + + +app = FastAPI() + + +@app.post("/retrieve") +async def create_item(item: ContextProviderInput): + results = [] # TODO: Query your vector database here. + + # Construct the "context item" format expected by Continue + context_items = [] + for result in results: + context_items.append({ + "name": result.filename, + "description": result.filename, + "content": result.text, + }) + + return context_items +``` + +ๅœจไฝ ่ฎพ็ฝฎๆœๅŠกๅ™จไน‹ๅŽ๏ผŒไฝ ๅฏไปฅ้…็ฝฎ Continue ไฝฟ็”จๅฎƒ๏ผŒ้€š่ฟ‡ๆทปๅŠ  "http" ไธŠไธ‹ๆ–‡ๆไพ›่€…ๅˆฐไฝ ็š„ `config.json` ไธญ็š„ `contextProviders` ๅˆ—่กจ๏ผš + +```json title="config.json" +{ + "name": "http", + "params": { + "url": "https://myserver.com/retrieve", + "title": "http", + "description": "Custom HTTP Context Provider", + "displayTitle": "My Custom Context" + } +} +``` + +## ๆญฅ้ชค 7 ๏ผˆ้ขๅค–็š„๏ผ‰๏ผš่ฎพ็ฝฎ้‡ๆŽ’ๅบ + +ๅฆ‚ๆžœไฝ ๆƒณ่ฆๆ้ซ˜ไฝ ็š„็ป“ๆžœ็š„่ดจ้‡๏ผŒไธ€ไธชๅฅฝ็š„้ฆ–ๅ…ˆ็š„ๆญฅ้ชคๆ˜ฏๆทปๅŠ ้‡ๆŽ’ๅบใ€‚่ฟ™ๆถ‰ๅŠๅˆฐ่Žทๅ–ไธ€ไธชๆ›ดๅคง็š„ๆฅ่‡ชๅ‘้‡ๆ•ฐๆฎๅบ“็š„ๅˆๅง‹็ป“ๆžœๆฑ ๏ผŒ็„ถๅŽไฝฟ็”จ้‡ๆŽ’ๅบๆจกๅž‹ๅฏนๅฎƒไปฌ่ฟ›่กŒๆŽ’ๅบ๏ผŒไปŽๆœ€้ซ˜ๅˆฐๆœ€ไฝŽ็›ธๅ…ณๆ€งใ€‚่ฟ™ๆ˜ฏๆœ‰ๆ•ˆ็š„๏ผŒๅ› ไธบ้‡ๆŽ’ๅบๆจกๅž‹ๅฏไปฅๆ‰ง่กŒไธ€ไธช็จ้ซ˜็š„่ฎก็ฎ—๏ผŒๅœจไธ€ไธชๅฐ็š„ๆœ€้ซ˜็ป“ๆžœไธŠ๏ผŒๆ‰€ไปฅๅฏไปฅ็ป™ๅ‡บๆฏ”็›ธไผผๆ€งๆœ็ดขๆ›ดๅ‡†็กฎ็š„ๆŽ’ๅบ๏ผŒๅฎƒ้œ€่ฆๆœ็ดขๆ•ฐๆฎๅบ“ไธญๆ‰€ๆœ‰็š„ๆก็›ฎใ€‚ + +ไพ‹ๅฆ‚๏ผŒๅฆ‚ๆžœไฝ ๆƒณ่ฆๅฏนไบŽๆฏไธชๆŸฅ่ฏข่ฟ”ๅ›ž 10 ไธชๅฎŒๆ•ด็š„็ป“ๆžœ๏ผŒ้‚ฃไนˆไฝ ๅฏไปฅ๏ผš + +1. ไฝฟ็”จ็›ธไผผๆ€งๆœ็ดขไปŽๅ‘้‡ๆ•ฐๆฎๅบ“ๆฃ€็ดข ~50 ไธช็ป“ๆžœ +2. ๅ‘้€ๆ‰€ๆœ‰่ฟ™ 50 ไธช็ป“ๆžœๅˆฐ้‡ๆŽ’ๅ™จ API ๏ผŒไธŽๆŸฅ่ฏขไธ€่ตท๏ผŒไธบไบ†่Žทๅ–ๆฏไธช็ป“ๆžœ็š„็›ธๅ…ณๆ€งๅˆ†ๆ•ฐ +3. ้€š่ฟ‡็›ธๅ…ณๆ€งๅˆ†ๆ•ฐๅฏน็ป“ๆžœ่ฟ›่กŒๆŽ’ๅบ๏ผŒๅนถ่ฟ”ๅ›žๆœ€ๅ‰้ข 10 ไธช + +ๆˆ‘ไปฌๆŽจ่ไฝฟ็”จๆฅ่‡ช Voyage AI ็š„ `rerank-1` ๆจกๅž‹๏ผŒๅฎƒๆœ‰ไฝฟ็”จ็คบไพ‹ [ๅœจ่ฟ™้‡Œ](https://docs.voyageai.com/docs/reranker) ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/how-to-self-host-a-model.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/how-to-self-host-a-model.md new file mode 100644 index 000000000..c9a611b19 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/how-to-self-host-a-model.md @@ -0,0 +1,76 @@ +--- +title: ๅฆ‚ไฝ•่‡ชๆ‰˜็ฎกๆจกๅž‹ +--- + +ไฝ ๅฏไปฅๅœจไฝ ็š„ [AWS](https://github.com/continuedev/deploy-os-code-llm#aws), [GCP](https://github.com/continuedev/deploy-os-code-llm#gcp), [Azure](https://github.com/continuedev/deploy-os-code-llm#azure), [Lambda](https://lambdalabs.com/) ๆˆ– [ๅ…ถไป–ไบ‘](https://github.com/continuedev/deploy-os-code-llm#others-2) ไธŠ้ƒจ็ฝฒๆจกๅž‹๏ผŒไฝฟ็”จ๏ผš + +- [HuggingFace TGI](https://github.com/continuedev/deploy-os-code-llm#tgi) +- [vLLM](https://github.com/continuedev/deploy-os-code-llm#vllm) +- [SkyPilot](https://github.com/continuedev/deploy-os-code-llm#skypilot) +- [Anyscale Private Endpoints](https://github.com/continuedev/deploy-os-code-llm#anyscale-private-endpoints) (OpenAI ๅ…ผๅฎน API) +- [Lambda](https://github.com/continuedev/deploy-os-code-llm#lambda) + +## ่‡ชๆ‰˜็ฎกๅผ€ๆบๆจกๅž‹ + +ๅฏนไบŽๅพˆๅคšๆƒ…ๅ†ต๏ผŒ Continue ๅ†…็ฝฎ็š„ๆไพ›่€…ๆˆ–ไฝ ไฝฟ็”จ็š„ API ๆ˜ฏ OpenAI-ๅ…ผๅฎน็š„๏ผŒ่ฟ™็งๆƒ…ๅ†ตไธ‹๏ผŒไฝ ๅฏไปฅไฝฟ็”จ "openai" ๆไพ›่€…๏ผŒไฟฎๆ”น "baseUrl" ๆŒ‡ๅ‘ๆœๅŠกๅ™จใ€‚ + +ไธ่ฟ‡๏ผŒๅฆ‚ๆžœ่ฟ™ไบ›ๆƒ…ๅ†ต้ƒฝไธๆ˜ฏ๏ผŒไฝ ้œ€่ฆ็ผ–ๅ†™ไธ€ไธชๆ–ฐ็š„ LLM ๅฏน่ฑกใ€‚ + +## ่ฎค่ฏ + +ๅฏนไบŽไปปไฝ•ๆไพ›่€…๏ผŒๅŸบๆœฌ่ฎค่ฏๅฏไปฅ้€š่ฟ‡ไฝฟ็”จ `apiKey` ๅญ—ๆฎตๅฎŒๆˆ๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Ollama", + "provider": "ollama", + "model": "llama2-7b", + "apiKey": "xxx" + } + ] +} +``` + +่ฟ™ไผš่ฝฌๆขไธบ header `"Authorization": "Bearer xxx"` ใ€‚ + +ๅฆ‚ๆžœไฝ ้œ€่ฆๅ‘้€ๅฎšๅˆถ็š„ header ๆฅ่ฎค่ฏ๏ผŒไฝ ๅฏ่ƒฝไฝฟ็”จ `requestOptions.headers` ๅฑžๆ€ง๏ผŒๆฏ”ๅฆ‚่ฟ™้‡Œไพ‹ๅญไธญ็š„ Ollama ๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Ollama", + "provider": "ollama", + "model": "llama2-7b", + "requestOptions": { + "headers": { + "X-Auth-Token": "xxx" + } + } + } + ] +} +``` + +็ฑปไผผๅœฐ๏ผŒๅฆ‚ๆžœไฝ ็š„ๆจกๅž‹้œ€่ฆ Certificate ๆฅ่ฎค่ฏ๏ผŒไฝ ๅฏ่ƒฝไฝฟ็”จ `requestOptions.clientCertificate` ๅฑžๆ€ง๏ผŒๆฏ”ๅฆ‚ไธ‹้ข็š„ไพ‹ๅญ๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Ollama", + "provider": "ollama", + "model": "llama2-7b", + "requestOptions": { + "clientCertificate": { + "cert": "C:\tempollama.pem", + "key": "C:\tempollama.key", + "passphrase": "c0nt!nu3" + } + } + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md new file mode 100644 index 000000000..2453fbd94 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/llama3.1.md @@ -0,0 +1,113 @@ +--- +title: Continue ไฝฟ็”จ Llama 3.1 +description: Continue ๅฆ‚ไฝ•ไฝฟ็”จ Llama 3.1 +keywords: [llama, meta, togetherai, ollama, replicate] +--- + +Continue ่ฎฉไฝฟ็”จๆœ€ๆ–ฐ็š„ๅผ€ๅ…ƒๆจกๅž‹็ผ–็ ๅ˜ๅพ—็ฎ€ๅ•๏ผŒๅŒ…ๆ‹ฌๆ•ดไธช Llama 3.1 ๅฎถๆ—ๆจกๅž‹ใ€‚ + +ๅฆ‚ๆžœไฝ ่ฟ˜ๆฒกๆœ‰ๅฎ‰่ฃ… Continue ๏ผŒไฝ ๅฏไปฅๅฎ‰่ฃ… [VS Code ๅœจ่ฟ™้‡Œ](https://marketplace.visualstudio.com/items?itemName=Continue.continue) ๆˆ–่€… [JetBrains ๅœจ่ฟ™้‡Œ](https://plugins.jetbrains.com/plugin/22707-continue) ใ€‚ๅฏนไบŽๆ›ด้€š็”จ็š„ๅฎšๅˆถ Continue ็š„ไฟกๆฏ๏ผŒๆŸฅ็œ‹ [ๆˆ‘ไปฌ็š„ๅฎšๅˆถๆ–‡ๆกฃ](../overview.md) ใ€‚ + +ไธ‹้ข๏ผŒๆˆ‘ไปฌๅˆ†ไบซไธ€ไบ›ๆœ€็ฎ€ๅ•็š„้…็ฝฎๅ’Œ่ฟ่กŒ๏ผŒๅŸบไบŽไฝ ็š„ไฝฟ็”จๆƒ…ๅ†ตใ€‚ + +## Ollama + +Ollama ๆ˜ฏๆœ€ๅฟซ็š„้…็ฝฎๅ’Œ่ฟ่กŒๆœฌๅœฐ่ฏญ่จ€ๆจกๅž‹็š„ๆ–นๆณ•ใ€‚ๆˆ‘ไปฌๆŽจ่ๅฐ่ฏ• Llama 3.1 8b ๏ผŒๅฎƒๆ˜ฏไปคไบบๅฐ่ฑกๆทฑๅˆป็š„๏ผŒๅฎƒ็š„ๅคงๅฐๅ’Œๅœจๅคงๅคšๆ•ฐ็กฌไปถไธŠ่กจ็Žฐ่‰ฏๅฅฝใ€‚ + +1. ไธ‹่ฝฝ Ollama [ๅœจ่ฟ™้‡Œ](https://ollama.ai/) ๏ผˆๅฎƒๅฐ†ๅธฆไฝ ้€š่ฟ‡ๅ…ถไป–็š„ๆญฅ้ชค๏ผ‰ +2. ๆ‰“ๅผ€็ปˆ็ซฏๅนถ่ฟ่กŒ `ollama run llama3.1:8b` +3. ไฟฎๆ”น Continue ้…็ฝฎๆ–‡ไปถๅƒ่ฟ™ๆ ท๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 8b", + "provider": "ollama", + "model": "llama3.1-8b" + } + ] +} +``` + +## Groq + +Groq ๆไพ›ๆœ€ๅฟซ็š„ๅฏ็”จ็š„ๅผ€ๆบ่ฏญ่จ€ๆจกๅž‹ๆŽจ็†๏ผŒๅŒ…ๆ‹ฌๆ•ดไธช Llama 3.1 ๅฎถๆ—ใ€‚ + +1. ่Žทๅ– API key [ๅœจ่ฟ™้‡Œ](https://console.groq.com/keys) +2. ๆ›ดๆ–ฐไฝ ็š„ Continue ้…็ฝฎๆ–‡ไปถๅƒ่ฟ™ๆ ท๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 405b", + "provider": "groq", + "model": "llama3.1-405b", + "apiKey": "" + } + ] +} +``` + +## Together AI + +Together AI ๆไพ›ๅผ€ๆบๆจกๅž‹็š„ๅฟซ้€Ÿๅ’Œๅฏไฟกไปป็š„ๆŽจ็†ใ€‚ไฝ ๅฏไปฅไปฅ่‰ฏๅฅฝ็š„้€Ÿๅบฆ่ฟ่กŒ 405b ๆจกๅž‹ใ€‚ + +1. ๅˆ›ๅปบ่ดฆๅท [ๅœจ่ฟ™้‡Œ](https://api.together.xyz/signup) +2. ๅคๅˆถๅ‡บ็Žฐๅœจๆฌข่ฟŽๅฑๅน•ไธŠไฝ ็š„ API key +3. ๆ›ดๆ–ฐไฝ ็š„ Continue ้…็ฝฎๆ–‡ไปถๅƒ่ฟ™ๆ ท๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 405b", + "provider": "together", + "model": "llama3.1-405b", + "apiKey": "" + } + ] +} +``` + +## Replicate + +Replicate ่ฎฉไฝฟ็”จ API ๆ‰˜็ฎกๅ’Œ่ฟ่กŒๅผ€ๆบ AI ๅ˜ๅพ—็ฎ€ๅ•ใ€‚ + +1. ่Žทๅ–ไฝ ็š„ Replicate API key [ๅœจ่ฟ™้‡Œ](https://replicate.ai/) +2. ไฟฎๆ”นไฝ ็š„ Continue ้…็ฝฎๆ–‡ไปถๅƒ่ฟ™ๆ ท๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Llama 3.1 405b", + "provider": "replicate", + "model": "llama3.1-405b", + "apiKey": "" + } + ] +} +``` + +## SambaNova + +SambaNova Cloud ๆไพ› Llama3.1 70B/405B ๆœๅŠก็š„ไธ–็•Œ่ฎฐๅฝ•ใ€‚ + +1. ๅˆ›ๅปบ่ดฆๅท [ๅœจ่ฟ™้‡Œ](https://cloud.sambanova.ai/) +2. ๅคๅˆถไฝ ็š„ API key +3. ๆ›ดๆ–ฐไฝ ็š„ Continue ้…็ฝฎๆ–‡ไปถๅƒ่ฟ™ๆ ท๏ผš + +```json title="~/.continue/config.json" +{ + "models": [ + { + "title": "SambaNova Llama 3.1 405B", + "provider": "sambanova", + "model": "llama3.1-405b", + "apiKey": "YOUR_API_KEY" + } + ] +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/running-continue-without-internet.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/running-continue-without-internet.md new file mode 100644 index 000000000..146394d76 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/running-continue-without-internet.md @@ -0,0 +1,12 @@ +--- +title: ไธ่”็ฝ‘ไฝฟ็”จ Continue +description: ๅฆ‚ไฝ•ไธ่”็ฝ‘ไฝฟ็”จ Continue +keywords: [ไธ่”็ฝ‘, air-gapped, ๆœฌๅœฐๆจกๅž‹] +--- + +Continue ็”š่‡ณๅฏไปฅ่ฟ่กŒๅœจ air-gapped ่ฎก็ฎ—ๆœบไธŠ๏ผŒๅฆ‚ๆžœไฝ ไฝฟ็”จๆœฌๅœฐๆจกๅž‹ใ€‚ๅช้œ€่ฆๅฐ‘้‡็š„่ฐƒๆ•ดๅฐฑๅฏไปฅๅทฅไฝœใ€‚ + +1. ไปŽ [Open VSX Registry](https://open-vsx.org/extension/Continue/continue) ไธ‹่ฝฝๆœ€ๆ–ฐ็š„ .vsix ๆ–‡ไปถ๏ผŒๅนถ [ๅฎ‰่ฃ…ๅฎƒๅˆฐ VS Code](https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix) ใ€‚ +2. ๆ‰“ๅผ€ `~/.continue/config.json` ๅนถ่ฎพ็ฝฎ `"allowAnonymousTelemetry": false` ใ€‚่ฟ™ๅฐ†ๅœๆญข Continue ๅฐ่ฏ•่ฏทๆฑ‚ PostHog ่Žทๅ– [ๅŒฟๅ้ฅๆต‹](../../telemetry.md) ใ€‚ +3. ่ฟ˜ๅœจ `config.json` ไธญ๏ผŒ่ฎพ็ฝฎ้ป˜่ฎค็š„ๆจกๅž‹ไธบๆœฌๅœฐๆจกๅž‹ใ€‚ไฝ ๅฏไปฅ [ๅœจ่ฟ™้‡Œ](../model-providers/) ็œ‹ๅˆฐๅฏ็”จ็š„้€‰้กนใ€‚ +4. ้‡ๅฏ VS Code ็กฎไฟๅฏน `config.json` ็š„ๅ˜ๆ›ด็”Ÿๆ•ˆใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/set-up-codestral.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/set-up-codestral.md new file mode 100644 index 000000000..583b128a0 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/customize/tutorials/set-up-codestral.md @@ -0,0 +1,69 @@ +--- +title: ๅฆ‚ไฝ•่ฎพ็ฝฎ Codestral +description: ๅฆ‚ไฝ•่ฎพ็ฝฎ Codestral +keywords: [codestral, mistral, ๆจกๅž‹่ฎพ็ฝฎ] +--- + +![mistral x continue](../../../../../../static/img/mistral-x-continue.png) + +**่ฟ™ๆ˜ฏไธ€ไธชๅˆ†ๆญฅๆŒ‡ๅ—๏ผŒๅ…ณไบŽๅฆ‚ไฝ•ๅœจ Continue ่ฎพ็ฝฎ Codestral ๏ผŒไฝฟ็”จ Mistral AI API ๏ผš** + +1. ๅฎ‰่ฃ… Continue VS Code ๆˆ– JetBrains ๆ‰ฉๅฑ•๏ผŒ่ทŸ้š [่ฟ™้‡Œ](../../getting-started/install.md) ็š„ๆŒ‡ไปค + +2. ็‚นๅ‡ป Continue ็ช—ๅฃๅณไธ‹่ง’็š„้ฝฟ่ฝฎๅ›พๆ ‡๏ผŒๆ‰“ๅผ€ `~/.continue/config.json` (MacOS) / `%userprofile%\.continue\config.json` (Windows) + +3. ็™ปๅฝ•ๅนถๅˆ›ๅปบไธ€ไธช API key ๏ผŒๅœจ [่ฟ™้‡Œ](https://console.mistral.ai/codestral) ็š„ Mistral AI's La Plateforme ใ€‚็กฎไฟไฝ ไปŽ "Codestral" ้กต้ข่Žทๅพ—ไธ€ไธช API key ๏ผŒไธ€่ˆฌ็š„ "api.mistral.ai" API ็š„ API key ไธ่ƒฝๅทฅไฝœใ€‚ + +4. ไธบไบ†ไฝฟ็”จ Codestral ไฝœไธบไฝ ็š„ `่‡ชๅŠจ่กฅๅ…จ` ๅ’Œ `่Šๅคฉ` ๆจกๅž‹๏ผŒไฝฟ็”จ Mistral API key ๆ›ฟๆขไธ‹้ข็š„ `[API_KEY]` ๏ผŒๅนถๆŠŠๅฎƒๆทปๅŠ ๅˆฐไฝ ็š„ `config.json` ๆ–‡ไปถ๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "[API_KEY]" + } + ], + "tabAutocompleteModel": { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "[API_KEY]" + } +} +``` + +5. ๅฆ‚ๆžœไฝ ้‡ๅˆฐไปปไฝ• issue ๆˆ–ๆœ‰ไปปไฝ•้—ฎ้ข˜๏ผŒ่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ Discord ๅนถๅœจ [่ฟ™้‡Œ็š„](https://discord.gg/EfJEfdFnDQ) `#help` ้ข‘้“ๅ‘ๅธ– + +## ๆ•…้šœๆŽ’้™ค + +### JetBrains ็š„ไธดๆ—ถๅ˜้€šๆ–นๆณ• + +Mistral AI ๆœ€่ฟ‘ไฟฎๆ”น API ็ซฏ็‚น๏ผŒไฝฟ็”จ `codestral.mistral.ai` ๆ›ฟๆข `api.mistral.ai` ๏ผŒๆˆ‘ไปฌๆ›ดๆ–ฐ็š„ JetBrains ๆ‰ฉๅฑ•ๆญฃๅœจ็ญ‰ๅพ…ๅ•†ๅบ—ๆ‰นๅ‡†ใ€‚ๅœจ่ฟ™ไธชๆœŸ้—ด๏ผŒไฝ ๅฟ…้กปๅœจ config.json ไธญๆŒ‡ๅฎš apiBase ไธบ `https://codestral.mistral.ai/v1` ๏ผŒๅƒ่ฟ™ๆ ท๏ผš + +```json title="config.json" +{ + "models": [ + { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "[API_KEY]", + "apiBase": "https://codestral.mistral.ai/v1/" + } + ], + "tabAutocompleteModel": { + "title": "Codestral", + "provider": "mistral", + "model": "codestral-latest", + "apiKey": "[API_KEY]", + "apiBase": "https://codestral.mistral.ai/v1/" + } +} +``` + +### ๅœจ Discord ๅฏปๆฑ‚ๅธฎๅŠฉ + +่ฏทๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ Discord ๏ผŒๅนถๅœจ [่ฟ™้‡Œ](https://discord.gg/EfJEfdFnDQ) ็š„ `#help` ้ข‘้“ๅ‘ๅธ–๏ผŒๅฆ‚ๆžœไฝ ไฝฟ็”จ Codestral ๆœ‰ไปปไฝ•้—ฎ้ข˜ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/context-selection.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/context-selection.md new file mode 100644 index 000000000..6690976f5 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/context-selection.md @@ -0,0 +1,18 @@ +--- +title: ไธŠไธ‹ๆ–‡้€‰ๆ‹ฉ +sidebar_position: 3 +description: ๅฆ‚ไฝ•้€‰ๆ‹ฉ็ผ–่พ‘็š„ไธŠไธ‹ๆ–‡ +keywords: [็ผ–่พ‘, cmd i, ๅทฅไฝœ] +--- + +## ่พ“ๅ…ฅ + +ไฝ ๆไพ›็š„่พ“ๅ…ฅๅŒ…ๅซๅœจๆ็คบ่ฏไธญใ€‚ + +## ้ซ˜ไบฎไปฃ็  + +ไฝ ้€‰ๆ‹ฉ็š„้ซ˜ไบฎไปฃ็ ๅŒ…ๅซๅœจๆ็คบ่ฏไธญใ€‚่ฟ™ๆ˜ฏๅ”ฏไธ€ๆจกๅž‹ไผšๅฐ่ฏ•็ผ–่พ‘็š„ไปฃ็ ๅ—ใ€‚ + +## ๅฝ“ๅ‰ๆ–‡ไปถ + +ๅŒ…ๅซไฝ ็š„้ซ˜ไบฎไปฃ็ ๅ—็š„ๆ–‡ไปถ็š„ๆ•ดไธชๅ†…ๅฎน้ƒฝไฝœไธบ้ขๅค–็š„ไธŠไธ‹ๆ–‡ใ€‚่ฟ™็ป™ไบ†ๆจกๅž‹ไธ€ไธชๅ…ณไบŽไปฃ็ ็Žฏๅขƒ็š„ๅ…จ้ข็š„็†่งฃใ€‚ๅฆ‚ๆžœๆ–‡ไปถๅคชๅคงไธ่ƒฝๆ”พๅœจไธŠไธ‹ๆ–‡็ช—ๅฃไธญ๏ผŒๆˆ‘ไปฌๅฐ†ๆˆชๆ–ญๆ–‡ไปถๅ†…ๅฎนๆ”พๅ…ฅใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-it-works.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-it-works.md new file mode 100644 index 000000000..06e81fd24 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-it-works.md @@ -0,0 +1,14 @@ +--- +title: ็ผ–่พ‘ๆ˜ฏๅฆ‚ไฝ•ๅทฅไฝœ็š„ +sidebar_position: 4 +description: ็ผ–่พ‘ๆ˜ฏๅฆ‚ไฝ•ๅทฅไฝœ็š„ +keywords: [็ผ–่พ‘, cmd l, ๅทฅไฝœ] +--- + +ไฝฟ็”จ้ซ˜ไบฎไปฃ็ ๏ผŒๅŒ…ๅซไฝ ็š„้ซ˜ไบฎไปฃ็ ็š„ๆ–‡ไปถๅ†…ๅฎน๏ผŒไปฅๅŠไฝ ็š„่พ“ๅ…ฅๆŒ‡ไปค๏ผŒๆˆ‘ไปฌๆ็คบๆจกๅž‹ๆ นๆฎไฝ ็š„ๆŒ‡ไปค็ผ–่พ‘ไปฃ็ ใ€‚ๆฒกๆœ‰ๆ›ดๅคš็š„ไธŠไธ‹ๆ–‡ๆไพ›็ป™ๆจกๅž‹ใ€‚ + +ๆจกๅž‹ๅ“ๅบ”ไผš็›ดๆŽฅๆตๅผๅœฐ่ฟ”ๅ›žๅˆฐไฝ ็š„ไปฃ็ ้ซ˜ไบฎ่Œƒๅ›ดไธญ๏ผŒๆˆ‘ไปฌไฝฟ็”จไธ€ไธช diff ๆ ผๅผๆฅๆ˜พ็คบๅปบ่ฎฎ็š„ๅ˜ๆ›ดใ€‚ + +ๅฆ‚ๆžœไฝ ๆŽฅๅ— diff ๏ผŒๆˆ‘ไปฌ็งป้™คไน‹ๅ‰็š„้ซ˜ไบฎ่กŒ๏ผŒๅฆ‚ๆžœไฝ ๆ‹’็ป diff ๏ผŒๆˆ‘ไปฌ็งป้™คๅปบ่ฎฎ็š„ๅ˜ๆ›ดใ€‚ + +ๅฆ‚ๆžœไฝ ๆƒณๆŸฅ็œ‹ๅœจ็ผ–่พ‘ไธญๅ‘้€็ป™ๆจกๅž‹็š„็กฎๅˆ‡็š„ๆ็คบ่ฏ๏ผŒไฝ ๅฏไปฅ [ๅœจๆ็คบ่ฏๆ—ฅๅฟ—ไธญๆŸฅ็œ‹่ฟ™ไธช](troubleshooting.md#check-the-logs) ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-customize.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-customize.md new file mode 100644 index 000000000..648d1a335 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-customize.md @@ -0,0 +1,16 @@ +--- +title: ๅฆ‚ไฝ•ๅฎšๅˆถ +sidebar_position: 5 +description: ๅฆ‚ไฝ•ๅฎšๅˆถ็ผ–่พ‘ +keywords: [็ผ–่พ‘, cmd i, ๅทฅไฝœ] +--- + +ไฝ ๅฏไปฅ้…็ฝฎ็ผ–่พ‘ไฝฟ็”จๆŒ‡ๅฎš็š„ๆจกๅž‹๏ผŒไฝฟ็”จ `inlineEdit` ๅฑžๆ€งใ€‚ + +```json title="config.json" +"experimental": { + "modelRoles": { + "inlineEdit": "MODEL_TITLE", + } +} +``` diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-use-it.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-use-it.md new file mode 100644 index 000000000..850fdf95e --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/how-to-use-it.md @@ -0,0 +1,37 @@ +--- +title: ็ผ–่พ‘ +sidebar_position: 1 +sidebar_label: ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ +description: ๅฆ‚ไฝ•ไฝฟ็”จ็ผ–่พ‘ +keywords: [็ผ–่พ‘, cmd l, ไฝฟ็”จ] +--- + +![edit](/img/edit.gif) + +## ๅฆ‚ไฝ•ไฝฟ็”จๅฎƒ + +็ผ–่พ‘ๆ˜ฏไธ€็งไธ็”จ็ฆปๅผ€ไฝ ็š„ๅฝ“ๅ‰ๆ–‡ไปถๆฅไฟฎๆ”นไปฃ็ ็š„ๆ–นไพฟ็š„ๆ–นๅผใ€‚้ซ˜ไบฎไธ€ไธชไปฃ็ ๅ—๏ผŒๆ่ฟฐไฝ ็š„ไปฃ็ ๅ˜ๆ›ด๏ผŒไธ€ไธช diff ไผšๆตๅผๅœฐๅ‡บ็Žฐๅœจไฝ ็š„ๆ–‡ไปถ่กŒๅ†…๏ผŒไฝ ๅฏไปฅๆŽฅๅ—ๆˆ–ๆ‹’็ปใ€‚ + +็ผ–่พ‘ๆœ€ๅฅฝ็”จๅœจๅฐ็š„๏ผŒๅฟซ้€Ÿ็š„ๅ˜ๆ›ดไธŠ๏ผŒๆฏ”ๅฆ‚๏ผš + +- ็ผ–ๅ†™ๆณจ้‡Š +- ็”Ÿๆˆๅ•ๅ…ƒๆต‹่ฏ• +- ้‡ๆž„ๅ‡ฝๆ•ฐๆˆ–ๆ–นๆณ• + +## ้ซ˜ไบฎไปฃ็ ๅนถๆฟ€ๆดป + +้ซ˜ไบฎไฝ ๆƒณ่ฆไฟฎๆ”น็š„ไปฃ็ ๅ—๏ผŒๆŒ‰ไธ‹ `cmd/ctrl + i` ๆฅๆฟ€ๆดป็ผ–่พ‘่พ“ๅ…ฅใ€‚ + +## ๆ่ฟฐไปฃ็ ๅ˜ๆ›ด + +ๆ่ฟฐไฝ ๆƒณ่ฆๆจกๅž‹ๅฏนไฝ ็š„้ซ˜ไบฎไปฃ็ ๆ‰€ๅš็š„ๅ˜ๆ›ดใ€‚ๅฏนไบŽ็ผ–่พ‘๏ผŒไธ€ไธชๅฅฝ็š„ๆ็คบ่ฏๅบ”่ฏฅๆ˜ฏ็›ธๅฏน่พƒ็Ÿญไธ”็ฎ€ๆด็š„ใ€‚ๅฏนไบŽ้•ฟ็š„๏ผŒๆ›ดๅคๆ‚็š„ไปปๅŠก๏ผŒๆˆ‘ไปฌๆŽจ่ไฝฟ็”จ [่Šๅคฉ](chat/how-to-use-it.md) ใ€‚ + +## ๆŽฅๅ—ๅ’Œๆ‹’็ปๅ˜ๆ›ด + +ๅปบ่ฎฎ็š„ๅ˜ๆ›ดไฝœไธบ่กŒๅ†… diff ๅ‡บ็Žฐๅœจไฝ ็š„้ซ˜ไบฎๆ–‡ๆœฌไธญใ€‚ + +ไฝ ๅฏไปฅๅฏผ่ˆชๅˆฐๆฏไธชๅปบ่ฎฎๅ˜ๆ›ด๏ผŒๆŽฅๅ—ๆˆ–ๆ‹’็ปๅฎƒไปฌ๏ผŒไฝฟ็”จ `cmd/ctrl + opt + y` (ๆŽฅๅ—) ๆˆ– `cmd/ctrl + opt + n` (ๆ‹’็ป) ใ€‚ + +ไฝ ไนŸๅฏไปฅไธ€ๆฌกๆ€งๆŽฅๅ—ๆˆ–ๆ‹’็ปๆ‰€ๆœ‰ๅ˜ๆ›ด๏ผŒไฝฟ็”จ `cmd/ctrl + shift + enter` (ๆŽฅๅ—) ๆˆ– `cmd/ctrl + shift + delete` (ๆ‹’็ป) ใ€‚ + +ๅฆ‚ๆžœไฝ ๆƒณ่ฆๅฏนไบŽ็›ธๅŒ็š„้ซ˜ไบฎไปฃ็ ๅ—่ฏทๆฑ‚ไธ€ไธชๆ–ฐ็š„ๅปบ่ฎฎ๏ผŒไฝ ๅฏไปฅไฝฟ็”จ `cmd/ctrl + i` ้‡ๆ–ฐๆ็คบๆจกๅž‹ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/model-setup.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/model-setup.md new file mode 100644 index 000000000..f96a8fe6d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/edit/model-setup.md @@ -0,0 +1,10 @@ +--- +title: ๆจกๅž‹่ฎพ็ฝฎ +sidebar_position: 2 +description: ๅฆ‚ไฝ•่ฎพ็ฝฎไธ€ไธช็ผ–่พ‘ๆจกๅž‹ +keywords: [็ผ–่พ‘, cmd l, ๆจกๅž‹] +--- + +้ป˜่ฎคๆƒ…ๅ†ตไธ‹๏ผŒ็ผ–่พ‘ไฝฟ็”จ [ไธŽ่Šๅคฉ็›ธๅŒ็š„ๆจกๅž‹](chat/model-setup.mdx) ๏ผŒๆ‰€ไปฅๅฏนไบŽไปฃ็ ็ผ–่พ‘๏ผŒๆˆ‘ไปฌๆŽจ่็›ธๅŒ็š„ 400B+ ๅ‚ๆ•ฐๆจกๅž‹ๆˆ–่€…้ข†ๅ…ˆ็š„ๆจกๅž‹ไน‹ไธ€ใ€‚ + +ไฝ ๅฏไปฅ้€š่ฟ‡ๆ›ดๆ–ฐไฝ ็š„ [`config.json`](../customize/config.mdx) ไธบ็ผ–่พ‘้…็ฝฎไธ€ไธชไธๅŒ็š„ๆจกๅž‹ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/install.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/install.md new file mode 100644 index 000000000..169b2061c --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/install.md @@ -0,0 +1,33 @@ +--- +title: ๅฎ‰่ฃ… +description: ๅผ€ๅ‘่€…็š„ๅผ€ๆบ AI ไปฃ็ ๅŠฉๆ‰‹ +keywords: [ๅฎ‰่ฃ…, ๅผ€ๅง‹, vs code, jetbrains] +--- + +## VS Code + +1. ็‚นๅ‡ป [Visual Studio ๅธ‚ๅœบไธญ Continue ๆ‰ฉๅฑ•้กต้ข](https://marketplace.visualstudio.com/items?itemName=Continue.continue) ็š„ `ๅฎ‰่ฃ…` ๆŒ‰้’ฎ + +2. ่ฟ™ไผšๆ‰“ๅผ€ VS Code ไธญ็š„ Continue ๆ‰ฉๅฑ•้กต้ข๏ผŒไฝ ้œ€่ฆๅ†ๆฌก็‚นๅ‡ป `ๅฎ‰่ฃ…` + +3. Continue ๆ ‡ๅฟ—ไผšๅ‡บ็Žฐๅœจๅทฆไพง่พนๆ ไธญใ€‚ไธบไบ†่Žทๅพ—ๆ›ดๅฅฝ็š„ไฝ“้ชŒ๏ผŒๅฏไปฅๆŠŠ Continue ็งปๅŠจๅˆฐๅณไพง่พนๆ  + +![move-to-right-sidebar](/img/move-to-right-sidebar.gif) + +:::info[ๆ•…้šœๆŽ’้™ค] +ๅฆ‚ๆžœไฝ ๆœ‰ไปปไฝ•้—ฎ้ข˜๏ผŒๆŸฅ็œ‹ [ๆ•…้šœๆŽ’้™คๆŒ‡ๅ—](troubleshooting.md) ๆˆ–่€…ๅœจ [ๆˆ‘ไปฌ็š„ Discord](https://discord.gg/NWtdYexhMs) ๅฏปๆฑ‚ๅธฎๅŠฉ +::: + +## JetBrains + +1. ๆ‰“ๅผ€ไฝ ็š„ JetBrains IDE ๅนถไฝฟ็”จ `cmd/ctrl + ,` ๆ‰“ๅผ€ **่ฎพ็ฝฎ** + +2. ๅœจไพง่พนๆ ไธญ้€‰ๆ‹ฉ **ๆ’ไปถ** ๅนถๅœจๅธ‚ๅœบไธญๆŸฅๆ‰พ "Continue" + +3. ็‚นๅ‡ป `ๅฎ‰่ฃ…`๏ผŒ ้šๅŽ Continue ๆ ‡ๅฟ—ไผšๅ‡บ็Žฐๅœจๅณไพง่พนๆ  + +![jetbrains-getting-started.png](/img/jetbrains-getting-started.png) + +:::info[ๆ•…้šœๆŽ’้™ค] +ๅฆ‚ๆžœไฝ ๆœ‰ไปปไฝ•้—ฎ้ข˜๏ผŒๆŸฅ็œ‹ [ๆ•…้šœๆŽ’้™คๆŒ‡ๅ—](troubleshooting.md) ๆˆ–่€…ๅœจ [ๆˆ‘ไปฌ็š„ Discord](https://discord.com/invite/EfJEfdFnDQ) ๅฏปๆฑ‚ๅธฎๅŠฉ +::: diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/overview.mdx b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/overview.mdx new file mode 100644 index 000000000..e3ee2af29 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/getting-started/overview.mdx @@ -0,0 +1,58 @@ +--- +title: ๆฆ‚่งˆ +description: ๅผ€ๅง‹ไฝฟ็”จ Continue +keywords: [ๅฟซ้€Ÿๅผ€ๅง‹, ๅผ€ๅง‹, ๆฆ‚่งˆ, ่Šๅคฉ, ่‡ชๅŠจ่กฅๅ…จ, ็ผ–่พ‘, actions] +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import Admonition from "@theme/Admonition"; + +ไธบไบ†ๅฟซ้€Ÿ็†่งฃไฝ ๅฏไปฅๅœจ Continue ๅš็š„ไบ‹๏ผŒๆŸฅ็œ‹ไธ‹้ข็š„ๆฏไธชๆ ‡็ญพ้กตใ€‚ + + + + + [่Šๅคฉ](../chat/how-to-use-it.md#how-to-use-it) ่ฎฉไฝ ๆ–นไพฟๅ‘ LLM ๅฏปๆฑ‚ๅธฎๅŠฉ๏ผŒ่€Œไธ้œ€่ฆ็ฆปๅผ€ IDE + + ![chat](/img/chat.gif) + + + ไบ†่งฃๆ›ดๅคšๅ…ณไบŽ [่Šๅคฉ](../chat/how-to-use-it.md#how-to-use-it) + + + + + + [่‡ชๅŠจ่กฅๅ…จ](../autocomplete/how-to-use-it.md#how-to-use-it) ้š็€ไฝ ็š„่พ“ๅ…ฅๆไพ›่กŒๅ†…ไปฃ็ ๅปบ่ฎฎ + + ![autocomplete](/img/autocomplete.gif) + + + ไบ†่งฃๆ›ดๅคšๅ…ณไบŽ [่‡ชๅŠจ่กฅๅ…จ](../autocomplete/how-to-use-it.md#how-to-use-it) + + + + + + [็ผ–่พ‘](../edit/how-to-use-it.md#how-to-use-it) ๆ˜ฏไธ€็ง็ผ–่พ‘ไปฃ็ ็š„ๆ–นไพฟ็š„ๆ–นๅผ๏ผŒไธ้œ€่ฆ็ฆปๅผ€ไฝ ็š„ๅฝ“ๅ‰ๆ–‡ไปถ + + ![edit](/img/edit.gif) + + + ไบ†่งฃๆ›ดๅคšๅ…ณไบŽ [็ผ–่พ‘](../edit/how-to-use-it.md#how-to-use-it) + + + + + + [Actions](../actions/how-to-use-it.md#how-to-use-it) ๆ˜ฏๅธธ็”จๆƒ…ๅ†ต็š„ๅฟซๆทๆ–นๅผ + + ![actions](/img/actions.gif) + + + ไบ†่งฃๆ›ดๅคšๅ…ณไบŽๅฆ‚ไฝ•ไฝฟ็”จ [Actions](../actions/how-to-use-it.md#how-to-use-it) + + + + diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/introduction.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/introduction.md new file mode 100644 index 000000000..9248b0bb2 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/introduction.md @@ -0,0 +1,25 @@ +--- +title: ็ฎ€ไป‹ +description: ๅผ€ๅ‘่€…็š„ๅผ€ๆบ AI ไปฃ็ ๅŠฉๆ‰‹ +slug: / +keywords: + [ + continue, + AI, + ไปฃ็ ๅŠฉๆ‰‹, + ่‡ชๅŠจ่กฅๅ…จ, + ่Šๅคฉ, + VS Code, + JetBrains, + ็ฎ€ไป‹, + ] +--- + +![Continue Logo](/img/intro.png) + +**Continue ๆ˜ฏ [VS Code](https://marketplace.visualstudio.com/items?itemName=Continue.continue) ๅ’Œ [JetBrains](https://plugins.jetbrains.com/plugin/22707-continue-extension) ไธญ้ข†ๅ…ˆ็š„ๅผ€ๆบ AI ไปฃ็ ๅŠฉๆ‰‹** + +- [่Šๅคฉ](chat/how-to-use-it.md) ๅœจไพง่พนๆ ไธญ็†่งฃๅ’Œ่ฟญไปฃไปฃ็  +- [่‡ชๅŠจ่กฅๅ…จ](autocomplete/how-to-use-it.md) ๅœจไฝ ่พ“ๅ…ฅๆ—ถ่Žทๅ–่กŒๅ†…ไปฃ็ ๅปบ่ฎฎ +- [็ผ–่พ‘](edit/how-to-use-it.md) ๅœจไธ้œ€่ฆ็ฆปๅผ€ๅฝ“ๅ‰ๆ–‡ไปถ็š„ๆƒ…ๅ†ตไธ‹ไฟฎๆ”นไปฃ็  +- [Actions](actions/how-to-use-it.md) ๅฏนไบŽๅธธ็”จๆƒ…ๅ†ตๅปบ็ซ‹ๅฟซๆทๆ–นๅผ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/telemetry.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/telemetry.md new file mode 100644 index 000000000..319c45445 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/telemetry.md @@ -0,0 +1,50 @@ +--- +title: ้ฅๆต‹ +description: ไบ†่งฃ Continue ๅฆ‚ไฝ•ๆ”ถ้›†ๅŒฟๅไฝฟ็”จไฟกๆฏ๏ผŒไปฅๅŠไฝ ๅฆ‚ไฝ•้€‰ๆ‹ฉ้€€ๅ‡บ +keywords: [้ฅๆต‹, ๅŒฟๅ, ไฝฟ็”จไฟกๆฏ, ้€‰ๆ‹ฉ้€€ๅ‡บ] +--- + +## ๆฆ‚่ฟฐ +Continue ๆ”ถ้›†ๅนถๆŠฅๅ‘Š **ๅŒฟๅ** ไฝฟ็”จไฟกๆฏ๏ผŒๆฅๅธฎๅŠฉๆˆ‘ไปฌๆ้ซ˜ไบงๅ“ใ€‚่ฟ™ไธชๆ•ฐๆฎๅ…่ฎธๆˆ‘ไปฌๆœ‰ๆ•ˆๅœฐ็†่งฃ็”จๆˆทไบคไบ’๏ผŒๅนถไผ˜ๅŒ–็”จๆˆทไฝ“้ชŒใ€‚ไฝ ๅฏไปฅๅœจไปปไฝ•ๆ—ถๅ€™้€‰ๆ‹ฉ้€€ๅ‡บ้ฅๆต‹ๆ”ถ้›†๏ผŒๅฆ‚ๆžœไฝ ๅ€พๅ‘ไธŽไธๅˆ†ไบซไฝ ็š„ไฝฟ็”จไฟกๆฏใ€‚ + +ๆˆ‘ไปฌไฝฟ็”จ [Posthog](https://posthog.com/) ๏ผŒไธ€ไธชไบงๅ“ๅˆ†ๆž็š„ๅผ€ๆบๅนณๅฐ๏ผŒๆฅๆ”ถ้›†ๅนถๅญ˜ๅ‚จ่ฟ™ไธชๆ•ฐๆฎใ€‚ไธบไบ†้€ๆ˜Ž๏ผŒไฝ ๅฏไปฅ [ๅœจ่ฟ™้‡Œ](https://github.com/continuedev/continue/blob/main/gui/src/hooks/CustomPostHogProvider.tsx) ๆฃ€ๆŸฅๅฎž็Žฐไปฃ็ ๏ผŒๆˆ–่€…ๆŸฅ็œ‹ๆˆ‘ไปฌ็š„ [ๅฎ˜ๆ–น้š็ง็ญ–็•ฅ](https://continue.dev/privacy) ใ€‚ + +## ่ทŸ่ธช็ญ–็•ฅ + +ๆ‰€ๆœ‰ Continue ๆ”ถ้›†็š„ๆ•ฐๆฎๆ˜ฏๅŒฟๅ็š„๏ผŒๅœจๅ‘้€ๅˆฐ PostHog ไน‹ๅ‰๏ผŒ้™คๅŽปไธชไบบๅฏ่ฏ†ๅˆซไฟกๆฏ (PII) ใ€‚ๆˆ‘ไปฌๆ‰ฟ่ฏบ็ปดๆŠคไฝ ็š„ๆ•ฐๆฎ็š„้š็งๅ’Œๅฎ‰ๅ…จใ€‚ + +## ๆˆ‘ไปฌ่ทŸ่ธชไป€ไนˆ + +ไปฅไธ‹ไฝฟ็”จไฟกๆฏ่ขซๆ”ถ้›†ๅ’ŒๆŠฅๅ‘Š๏ผš + +- **ๅปบ่ฎฎไบคไบ’:** ไฝ ๆ˜ฏๅฆๆŽฅๅ—ๆˆ–ๆ‹’็ปๅปบ่ฎฎ๏ผˆไธๅŒ…ๆ‹ฌๆถ‰ๅŠ็š„ๅฎž้™…ไปฃ็ ๆˆ–ๆ็คบ่ฏ๏ผ‰ใ€‚ +- **ๆจกๅž‹ๅ’Œๅ‘ฝไปคไฟกๆฏ:** ไฝฟ็”จ็š„ๆจกๅž‹ๅ’Œๅ‘ฝไปค็š„ๅ็งฐใ€‚ +- **token ๆŒ‡ๆ ‡:** ็”Ÿๆˆ็š„ token ็š„ๆ•ฐ้‡ใ€‚ +- **็ณป็ปŸไฟกๆฏ:** ไฝ ็š„ๆ“ไฝœ็ณป็ปŸ (OS) ๅ’Œ้›†ๆˆๅผ€ๅ‘็Žฏๅขƒ (IDE) ็š„ๅ็งฐใ€‚ +- **้กต้ขๆต่งˆ้‡:** ไธ€่ˆฌ้กต้ขๆต่งˆ้‡็ปŸ่ฎกใ€‚ + +## ๅฆ‚ไฝ•้€€ๅ‡บ + +ไฝ ๅฏไปฅ้€š่ฟ‡ไฟฎๆ”นไฝไบŽ `~/.continue` ็›ฎๅฝ•ไธญ `config.json` ๆ–‡ไปถ็ฆ็”จๅŒฟๅ้ฅๆต‹ใ€‚่ฟ™ไธชๆ–‡ไปถ้€šๅธธๅŒ…ๅซไปฅไธ‹ๆก็›ฎ๏ผš + +```json title="config.json" +{ + "allowAnonymousTelemetry": true +} +``` + +ไธบไบ†้€€ๅ‡บ๏ผŒไฟฎๆ”น `allowAnonymousTelemetry` ็š„ๅ€ผไธบ `false` ใ€‚ๅฆๅค–๏ผŒไฝ ๅฏไปฅ้€š่ฟ‡ VS Code ่ฎพ็ฝฎ็ฆ็”จ้ฅๆต‹๏ผŒ้€š่ฟ‡ๅ–ๆถˆๅ‹พ้€‰ "Continue: Telemetry Enabled" ้€‰ๆ‹ฉๆก†ใ€‚ + +### ้€š่ฟ‡้…็ฝฎๆ–‡ไปถ็ฆ็”จ้ฅๆต‹็š„ๆญฅ้ชค + +1. ็”จไฝ ็š„ๆ–‡ไปถ็ผ–่พ‘ๅ™จๆ‰“ๅผ€ `~/.continue/config.json` ๆ–‡ไปถใ€‚ +2. ๅฎšไฝๅˆฐ `"allowAnonymousTelemetry"` ่ฎพ็ฝฎใ€‚ +3. ๅฐ†ๅ€ผไปŽ `true` ไฟฎๆ”นไธบ `false` ใ€‚ +4. ไฟๅญ˜ๆ–‡ไปถใ€‚ + +### ้€š่ฟ‡ VS Code ่ฎพ็ฝฎ็ฆ็”จ้ฅๆต‹ + +1. ๆ‰“ๅผ€ VS Code ใ€‚ +2. ๅฏผ่ˆชๅˆฐ `File` > `Preferences` > `Settings` (ๆˆ–ๅœจ Windows/Linux ไธŠไฝฟ็”จๅฟซๆท้”ฎ `Ctrl + ,` ๆˆ–ๅœจ macOS ไธŠไฝฟ็”จ `Cmd + ,` )ใ€‚ +3. ๅœจๆœ็ดขๆ ไธญ๏ผŒ่พ“ๅ…ฅ "Continue: Telemetry Enabled" ใ€‚ +4. ๅ–ๆถˆๅ‹พ้€‰ "Continue: Telemetry Enabled" ้€‰ๆ‹ฉๆก†ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/troubleshooting.md b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/troubleshooting.md new file mode 100644 index 000000000..9f1ceab6a --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-plugin-content-docs/current/troubleshooting.md @@ -0,0 +1,131 @@ +--- +title: ๆ•…้šœๆŽ’้™ค +description: ๆ•…้šœๆŽ’้™ค๏ผŒๅœจ็ญ‰ๅพ… beta / alpha ๆต‹่ฏ•ๅธฎๅŠฉๆ—ถ +keywords: [้‡ๆ–ฐๅŠ ่ฝฝ, ๅˆ ้™ค, ๆ‰‹ๅŠจ, ๆ—ฅๅฟ—, ๆœๅŠกๅ™จ, ๆŽงๅˆถๅฐ] +--- + +Continue VS Code ๆ‰ฉๅฑ•็Žฐๅœจๆ˜ฏ beta ๏ผŒ JetBrains ๆ‰ฉๅฑ•็Žฐๅœจๆ˜ฏ Alpha ใ€‚ๅฆ‚ๆžœไฝ ๆœ‰้—ฎ้ข˜๏ผŒ่ฏท่ทŸ้šไธ‹้ข็š„ๆญฅ้ชคใ€‚ + +1. [ๆฃ€ๆŸฅๆ—ฅๅฟ—](#check-the-logs) +2. [ๅฐ่ฏ•ๆœ€ๆ–ฐ็š„้ข„่งˆ็‰ˆ](#download-the-latest-pre-release) +3. [ไธ‹่ฝฝ่พƒ่€็š„็‰ˆๆœฌ](#download-an-older-version) +4. [่งฃๆžๅฟซไปถ้”ฎ้—ฎ้ข˜](#keyboard-shortcuts-not-resolving) +5. [ๆฃ€ๆŸฅๅธธ่ง้—ฎ้ข˜็š„ FAQ](#faqs) + +## ๆฃ€ๆŸฅๆ—ฅๅฟ— + +่งฃๅ†ณๅพˆๅคš้—ฎ้ข˜๏ผŒ็ฌฌไธ€ๆญฅๆ˜ฏ้˜…่ฏปๆ—ฅๅฟ—ๆ‰พๅˆฐ็›ธๅ…ณ็š„้”™่ฏฏไฟกๆฏใ€‚่ฆๅš่ฟ™ไธช๏ผŒ่ทŸ้šไธ‹้ข็š„ๆญฅ้ชค๏ผš + +### VS Code + +#### ๆŽงๅˆถๅฐๆ—ฅๅฟ— + +:::info +ไธบไบ†ๆŸฅ็œ‹่ฐƒ่ฏ•ๆ—ฅๅฟ—๏ผŒๅฎƒๅŒ…ๅซ้ขๅค–็š„ไฟกๆฏ๏ผŒ็‚นๅ‡ปๆœ€ไธŠ้ขๆ˜ฏ "Default levels" ็š„ไธ‹ๆ‹‰ๆก†ๅนถ้€‰ๆ‹ฉ "Verbose" ใ€‚ +::: + +1. `cmd+shift+p` (MacOS) / `ctrl+shift+p` (Windows) +2. ๆŸฅๆ‰พ๏ผŒ็„ถๅŽ้€‰ๆ‹ฉ "Developer: Toggle Developer Tools" +3. ่ฟ™ๅฐ†ๆ‰“ๅผ€ [Chrome DevTools window](https://developer.chrome.com/docs/devtools/) +4. ้€‰ๆ‹ฉ `Console` ๆ ‡็ญพ +5. ๆŸฅ็œ‹ๆŽงๅˆถๅฐๆ—ฅๅฟ— + +#### LLM ๆ็คบ่ฏๆ—ฅๅฟ— + +ๅฆ‚ๆžœไฝ ไปŽ LLM ่Žทๅพ—็š„ๅ“ๅบ”็œ‹่ตทๆฅๆ˜ฏไธๅˆ็†็š„๏ผŒไฝ ๅฏไปฅ + +1. ๆ‰“ๅผ€ "Output" ้ขๆฟ (็ปˆ็ซฏ็š„ไธ‹ไธ€ไธช) +2. ๅœจไธ‹ๆ‹‰ๆก†ไธญ๏ผŒ้€‰ๆ‹ฉ "Continue - LLM Prompts/Completions" +3. ๆŸฅ็œ‹ๅ‘้€็ป™ LLM ๏ผŒ่กฅๅ…จๆ‰€ๆŽฅๅ—็š„็กฎๅˆ‡็š„ๆ็คบ่ฏ + +### JetBrains + +ๆ‰“ๅผ€ `~/.continue/logs/core.log` ใ€‚ๆœ€่ฟ‘็š„ๆ—ฅๅฟ—ๅฏไปฅๅœจๆ–‡ไปถ็š„ๅบ•้ƒจๆ‰พๅˆฐใ€‚ + +## ไธ‹่ฝฝๆœ€ๆ–ฐ็š„้ข„่งˆ็‰ˆ + +### VS Code + +ๆˆ‘ไปฌไธๆ–ญๅœฐไฟฎๅคๅ’Œๆ”น่ฟ› Continue ๏ผŒไฝ†ๆ˜ฏๆœ€ๆ–ฐ็š„ไฟฎๆ”นๅœ็•™ๅœจ "้ข„่งˆ" ็‰ˆๅคงๆฆ‚ไธ€ๅ‘จ๏ผŒ่ฎฉๆˆ‘ไปฌๅฏไปฅๆต‹่ฏ•ๅฎƒไปฌ็š„็จณๅฎšๆ€งใ€‚ๅฆ‚ๆžœไฝ ้‡ๅˆฐ้—ฎ้ข˜๏ผŒไฝ ๅฏไปฅๅฐ่ฏ•้ข„่งˆ็‰ˆ๏ผŒ้€š่ฟ‡ๅŽป VS Code ็š„ Continue ๆ‰ฉๅฑ•้กต้ข๏ผŒๅนถ้€‰ๆ‹ฉ "ๅˆ‡ๆขๅˆฐ้ข„่งˆ็‰ˆ" ๏ผŒๅƒไธ‹้ขๆ˜พ็คบ็š„่ฟ™ๆ ทใ€‚ + +![Pre-Release](../../../../static/img/prerelease.png) + +### JetBrains + +ๅœจ JetBrains ไธŠ๏ผŒ "้ข„่งˆ็‰ˆ" ๅ‡บ็Žฐๅœจไป–ไปฌ็š„ๆŠขๅ…ˆไฝ“้ชŒ่ฎกๅˆ’ (EAP) ้ข‘้“ใ€‚่ฆไธ‹่ฝฝๆœ€ๆ–ฐ็š„ EAP ็‰ˆๆœฌ๏ผŒๅฏ็”จ EAP ้ข‘้“๏ผš + +1. ๆ‰“ๅผ€ JetBrains ่ฎพ็ฝฎ (`cmd/ctrl + ,`) ๅนถๅฏผ่ˆชๅˆฐ "ๆ’ไปถ" +2. ็‚นๅ‡ป้กถ้ƒจ็š„้ฝฟ่ฝฎๅ›พๆ ‡ +3. ้€‰ๆ‹ฉ "็ฎก็†ๆ’ไปถไป“ๅบ“..." +4. ๆทปๅŠ  "[https://plugins.jetbrains.com/plugins/eap/list](https://plugins.jetbrains.com/plugins/eap/list)" ๅˆฐๅˆ—่กจไธญ +5. ไฝ ็Žฐๅœจๆ€ปๆ˜ฏๅฏไปฅๅœจๅธ‚ๅœบไธ‹่ฝฝๆœ€ๆ–ฐ็š„ EAP ็‰ˆๆœฌ + +## ไธ‹่ฝฝไธ€ไธช่พƒ่€็š„็‰ˆๆœฌ + +ๅฆ‚ๆžœไฝ ๅฐ่ฏ•ไบ†ๆ‰€ๆœ‰ไธœ่ฅฟ๏ผŒๆŠฅๅ‘Šไธ€ไธช้”™่ฏฏ๏ผŒ็Ÿฅ้“ไธ€ไธชไน‹ๅ‰็š„็‰ˆๆœฌๅฏนไฝ ๆœ‰ๆ•ˆ๏ผŒๅนถ็ญ‰ๅพ…ๅ›žๅค๏ผŒไฝ ๅฏไปฅๅฐ่ฏ•ไธ‹่ฝฝไธ€ไธชๆ‰ฉๅฑ•็š„ๆฏ”่พƒ่€็š„็‰ˆๆœฌใ€‚ + +ๅฏนไบŽ VS Code ๏ผŒๆ‰€ๆœ‰็‰ˆๆœฌ้ƒฝๆ‰˜็ฎกๅœจ [่ฟ™้‡Œ](https://open-vsx.org/extension/Continue/continue) ็š„ Open VSX Registry ใ€‚ไธ€ๆ—ฆไฝ ไธ‹่ฝฝไบ†ๆ‰ฉๅฑ•๏ผŒๅฎƒๆ˜ฏไธ€ไธช .vsix ๆ–‡ไปถ๏ผŒไฝ ๅฏไปฅ้€š่ฟ‡ [ๅœจ่ฟ™้‡Œ](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix) ็š„ไปฅไธ‹ๆŒ‡ไปคๆ‰‹ๅŠจๅฎ‰่ฃ…ๅฎƒใ€‚ + +ไฝ ๅฏไปฅๅœจไป–ไปฌ็š„ [ๅธ‚ๅœบ](https://plugins.jetbrains.com/plugin/22707-continue) ไธญๆ‰พๅˆฐ่พƒ่€็‰ˆๆœฌ็š„ JetBrains ๆ‰ฉๅฑ•๏ผŒ่ฟ™ๅฐ†ๅ…่ฎธไฝ ไปŽ็ฃ็›˜ไธŠๅฎ‰่ฃ…ใ€‚ + +## ๅฟซๆท้”ฎๆ— ๆณ•่งฃๆž + +ๅฆ‚ๆžœไฝ ็š„ๅฟซๆท้”ฎๆ— ๆณ•่งฃๆž๏ผŒไฝ ๅฏ่ƒฝๆœ‰ๅ…ถไป–ๅ‘ฝไปคไผ˜ๅ…ˆไบŽ Continue ๅฟซๆท้”ฎใ€‚ไฝ ๅฏไปฅ็œ‹็œ‹ๆ˜ฏๅฆๆ˜ฏ่ฟ™็งๆƒ…ๅ†ต๏ผŒๅœจไฝ ็š„ IDE ็š„้…็ฝฎไธญไฟฎๆ”นไฝ ็š„ๅฟซๆท้”ฎ็ป‘ๅฎšใ€‚ + +- [VSCode ๅฟซๆท้”ฎๆ–‡ๆกฃ](https://code.visualstudio.com/docs/getstarted/keybindings) +- [IntelliJ ๅฟซๆท้”ฎๆ–‡ๆกฃ](https://www.jetbrains.com/help/idea/configuring-keyboard-and-mouse-shortcuts.html) + +## ๅธธ่ง้—ฎ้ข˜ + +### ็ฝ‘็ปœ้—ฎ้ข˜ + +#### ้…็ฝฎ่ฏไนฆ + +ๅฆ‚ๆžœไฝ ็œ‹ๅˆฐ `fetch failed` ้”™่ฏฏ๏ผŒๅนถไธ”ไฝ ็š„็ฝ‘็ปœ้œ€่ฆ่‡ชๅฎšไน‰่ฏไนฆ๏ผŒไฝ ้œ€่ฆๅœจ `config.json` ้…็ฝฎๅฎƒไปฌใ€‚ๅœจ `"models"` ๅˆ—่กจ็š„ๆฏไธชๅฏน่ฑกไธญ๏ผŒๆทปๅŠ  `requestOptions.caBundlePath` ๏ผŒๅƒ่ฟ™ๆ ท๏ผš + +```json +{ + "models": [ + { + "title": "My Model", + ... + "requestOptions": { + "caBundlePath": "/path/to/cert.pem" + } + } + ], + ... +} +``` + +ไฝ ๅฏ่ƒฝไนŸ้œ€่ฆไธบๅคšไธช่ฏไนฆ่ฎพ็ฝฎ `requestOptions.caBundlePath` ๅˆฐ่ทฏๅพ„ๅˆ—่กจใ€‚ + +#### VS Code ไปฃ็†่ฎพ็ฝฎ + +ๅฆ‚ๆžœไฝ ไฝฟ็”จ VS Code ๏ผŒ้œ€่ฆ้€š่ฟ‡ไปฃ็†่ฟ›่กŒ่ฏทๆฑ‚๏ผŒไฝ ๅฏ่ƒฝๅทฒ็ป้€š่ฟ‡ VS Code ็š„ [Proxy Server Support](https://code.visualstudio.com/docs/setup/network#_proxy-server-support) ่ฎพ็ฝฎใ€‚ไธบไบ†ๆฃ€ๆŸฅ่ฟ™ไธชๆ˜ฏๅฆๅฏ็”จ๏ผŒไฝฟ็”จ `cmd/ctrl+,` ๆ‰“ๅผ€่ฎพ็ฝฎๅนถๆŸฅๆ‰พ "Proxy Support" ๏ผŒ้™ค้žๅฎƒ่ฎพ็ฝฎไธบ "off" ๏ผŒ้‚ฃไนˆ VS Code ๅฐ†ไผš่ดŸ่ดฃๅฏนไปฃ็†่ฟ›่กŒ่ฏทๆฑ‚ใ€‚ + +#### code-server + +Continue ๅฏไปฅๅœจ [code-server](https://coder.com/) ไธญไฝฟ็”จ๏ผŒไฝ†ๆ˜ฏๅฆ‚ๆžœไฝ ่ฟ่กŒ๏ผŒๆ—ฅๅฟ—ไธญ้”™่ฏฏๅŒ…ๅซ "This is likely because the editor is not running in a secure context" ๏ผŒ่ฏทๆŸฅ็œ‹ [ไป–ไปฌ็š„ๅ…ณไบŽๅฎ‰ๅ…จๆšด้œฒ code-server ็š„ๆ–‡ๆกฃ](https://coder.com/docs/code-server/latest/guide#expose-code-server) ใ€‚ + +### ๆˆ‘ๅฎ‰่ฃ…ไบ† Continue ๏ผŒไฝ†ๆ˜ฏๆฒกๆœ‰็œ‹ๅˆฐไพง่พนๆ ็ช—ๅฃ + +้ป˜่ฎคๆƒ…ๅ†ตไธ‹๏ผŒ VS Code ไธญ็š„ Continue ็ช—ๅฃๅœจๅทฆ่พน๏ผŒไฝ†ๆ˜ฏๅฎƒไนŸๅฏไปฅๆ‹–ๅŠจๅˆฐๅณ่พน๏ผŒ่ฟ™ๅœจๆˆ‘ไปฌ็š„ๅ…ฅ้—จๆ•™็จ‹ไธญๆ˜ฏๆŽจ่็š„ใ€‚ๅœจไฝ ๅทฒ็ปๅฎ‰่ฃ… Continue ๅนถๅฐ†ๅฎƒ็งปๅŠจๅˆฐๅณ่พน็š„ๆƒ…ๅ†ตไธ‹๏ผŒๅฎƒๅฏ่ƒฝไป็„ถๅœจ้‚ฃ้‡Œใ€‚ไฝ ๅฏไปฅๆ˜พ็คบ Continue ๏ผŒ้€š่ฟ‡ไฝฟ็”จ `cmd/ctrl+L` ๆˆ–็‚นๅ‡ป VS Code ๅณไธŠๆ–น็š„ๆŒ‰้’ฎๆ‰“ๅผ€ๅณไพง่พนๆ ใ€‚ + +### ๆˆ‘ๅพ—ๅˆฐไธ€ไธช OpenAI ็š„ 404 ้”™่ฏฏ + +ๅฆ‚ๆžœไฝ ่พ“ๅ…ฅไธ€ไธชๆœ‰ๆ•ˆ็š„ API key ๅ’Œๆจกๅž‹๏ผŒไฝ†ๆ˜ฏไป็„ถๅพ—ๅˆฐ OpenAI ็š„ 404 ้”™่ฏฏ๏ผŒ่ฟ™ๅฏ่ƒฝๆ˜ฏๅ› ไธบไฝ ้œ€่ฆๆทปๅŠ ไฟก็”จๅกๅˆฐไฝ ็š„่ดฆๅ•่ดฆๆˆทใ€‚ไฝ ๅฏไปฅๅœจ [่ดฆๅ•ๆŽงๅˆถๅฐ](https://platform.openai.com/settings/organization/billing/overview)่ฟ™ๆ ทๅšใ€‚ๅฆ‚ๆžœไฝ ๅชๆƒณ่ฆๆฃ€ๆŸฅ่ฟ™็กฎๅฎžๆ˜ฏ้”™่ฏฏ็š„ๅŽŸๅ› ๏ผŒไฝ ๅฏไปฅๅฐ่ฏ•ๆทปๅŠ  1 ็พŽๅ…ƒๅˆฐไฝ ็š„่ดฆๆˆท๏ผŒๅ†ๆฃ€ๆŸฅ้”™่ฏฏๆ˜ฏๅฆไป็„ถๅญ˜ๅœจใ€‚ + +### ็ดขๅผ•้—ฎ้ข˜ + +ๅฆ‚ๆžœไฝ ๆœ‰ๆŒ็ปญ็š„็ดขๅผ•้—ฎ้ข˜๏ผŒๆˆ‘ไปฌ็š„ๆŽจ่ๆ˜ฏ้‡ๆ–ฐๆž„ๅปบไฝ ็š„็ดขๅผ•ใ€‚ๆณจๆ„๏ผŒๅฏนไบŽๅคง็š„ไปฃ็ ๅบ“๏ผŒ่ฟ™ๅฏ่ƒฝ้œ€่ฆไธ€ไบ›ๆ—ถ้—ดใ€‚ + +่ฟ™ๅฏไปฅ้€š่ฟ‡ไปฅไธ‹ๅ‘ฝไปคๅฎž็Žฐ๏ผš `Continue: Rebuild codebase index` ใ€‚ + +### Android Studio - "Nothing to show" ๅœจ่Šๅคฉไธญ + +่ฟ™ๅฏไปฅไฟฎๅค๏ผŒ้€š่ฟ‡้€‰ๆ‹ฉ `Actions > Choose Boot runtime for the IDE` ๏ผŒ็„ถๅŽ้€‰ๆ‹ฉๆœ€ๆ–ฐ็š„็‰ˆๆœฌ๏ผŒ็„ถๅŽ้‡ๅฏ Android Studio ใ€‚[ๆŸฅ็œ‹่ฟ™ไธช็บฟ็ดข](https://github.com/continuedev/continue/issues/2280#issuecomment-2365231567) ่Žทๅพ—่ฏฆๆƒ…ใ€‚ + +## ไป็„ถๆœ‰้—ฎ้ข˜๏ผŸ + +ไฝ ่ฟ˜ๅฏไปฅ [ๅœจ่ฟ™้‡Œ](https://discord.gg/vapESyrFmJ) ๅŠ ๅ…ฅๆˆ‘ไปฌ็š„ Discord ็คพๅŒบ๏ผŒ่Žทๅพ—ๆ›ดๅคš็š„ๆ”ฏๆŒๅ’Œ่ฎจ่ฎบใ€‚ๅฆๅค–๏ผŒไฝ ๅฏไปฅ [ๅœจ่ฟ™้‡Œ](https://github.com/continuedev/continue/issues/new?assignees=&labels=bug&projects=&template=bug-report-%F0%9F%90%9B.md&title=) ๅˆ›ๅปบไธ€ไธช GitHub issue ๏ผŒๆไพ›ไฝ ็š„้—ฎ้ข˜็š„่ฏฆๆƒ…๏ผŒๆˆ‘ไปฌๅฐ†่ƒฝๆ›ดๅฟซ็š„ๅธฎๅŠฉไฝ ใ€‚ diff --git a/docs/i18n/zh-CN/docusaurus-theme-classic/footer.json b/docs/i18n/zh-CN/docusaurus-theme-classic/footer.json new file mode 100644 index 000000000..381e52193 --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-theme-classic/footer.json @@ -0,0 +1,42 @@ +{ + "link.title.Extensions": { + "message": "ๆ‰ฉๅฑ•", + "description": "The title of the footer links column with title=Extensions in the footer" + }, + "link.title.Community": { + "message": "็คพๅŒบ", + "description": "The title of the footer links column with title=Community in the footer" + }, + "link.title.Follow Us": { + "message": "ๅ…ณๆณจๆˆ‘ไปฌ", + "description": "The title of the footer links column with title=Follow Us in the footer" + }, + "link.item.label.VS Code": { + "message": "VS Code", + "description": "The label of footer link with label=VS Code linking to https://marketplace.visualstudio.com/items?itemName=Continue.continue" + }, + "link.item.label.JetBrains": { + "message": "JetBrains", + "description": "The label of footer link with label=JetBrains linking to https://plugins.jetbrains.com/plugin/22707-continue-extension" + }, + "link.item.label.Discord": { + "message": "Discord", + "description": "The label of footer link with label=Discord linking to https://discord.gg/vapESyrFmJ" + }, + "link.item.label.GitHub": { + "message": "GitHub", + "description": "The label of footer link with label=GitHub linking to https://github.com/continuedev/continue" + }, + "link.item.label.Twitter": { + "message": "Twitter", + "description": "The label of footer link with label=Twitter linking to https://twitter.com/continuedev" + }, + "link.item.label.LinkedIn": { + "message": "LinkedIn", + "description": "The label of footer link with label=LinkedIn linking to https://linkedin.com/company/continuedev" + }, + "copyright": { + "message": "Copyright ยฉ 2024 Continue Dev, Inc.", + "description": "The footer copyright" + } +} diff --git a/docs/i18n/zh-CN/docusaurus-theme-classic/navbar.json b/docs/i18n/zh-CN/docusaurus-theme-classic/navbar.json new file mode 100644 index 000000000..872b8559d --- /dev/null +++ b/docs/i18n/zh-CN/docusaurus-theme-classic/navbar.json @@ -0,0 +1,26 @@ +{ + "title": { + "message": "Continue", + "description": "The title in the navbar" + }, + "logo.alt": { + "message": "Continue Logo", + "description": "The alt text of navbar logo" + }, + "item.label.Docs": { + "message": "ๆ–‡ๆกฃ", + "description": "Navbar item with label Docs" + }, + "item.label.Customize": { + "message": "ๅฎšๅˆถ", + "description": "Navbar item with label Customize" + }, + "item.label.GitHub": { + "message": "GitHub", + "description": "Navbar item with label GitHub" + }, + "item.label.Discord": { + "message": "Discord", + "description": "Navbar item with label Discord" + } +} diff --git a/docs/package-lock.json b/docs/package-lock.json index 756266105..c2485bdf7 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -5229,9 +5229,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", diff --git a/extensions/intellij/build.gradle.kts b/extensions/intellij/build.gradle.kts index 4c6aba783..afe24b719 100644 --- a/extensions/intellij/build.gradle.kts +++ b/extensions/intellij/build.gradle.kts @@ -25,7 +25,7 @@ repositories { mavenCentral() } // https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog dependencies { // implementation(libs.annotations) - implementation("com.squareup.okhttp3:okhttp:4.9.2") { + implementation("com.squareup.okhttp3:okhttp:4.12.0") { exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib") } implementation("org.jetbrains.kotlin:kotlin-stdlib:1.4.32") diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 5dba42f8e..be8b0febb 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension pluginName=continue-intellij-extension pluginRepositoryUrl=https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion=0.0.81 +pluginVersion=0.0.82 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild=223 # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginDisposable.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginDisposable.kt new file mode 100644 index 000000000..e8d3d0788 --- /dev/null +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginDisposable.kt @@ -0,0 +1,32 @@ +package com.github.continuedev.continueintellijextension.activities + +import com.intellij.openapi.Disposable +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.components.Service +import com.intellij.openapi.project.Project + +/** + * The service is a parent disposable that represents the entire plugin lifecycle + * and is intended to be used instead of the project/application as a parent disposable, + * ensures that disposables registered using it as parents will be processed when the plugin is unloaded to avoid memory leaks. + * + * @author lk + */ +@Service(Service.Level.APP, Service.Level.PROJECT) +class ContinuePluginDisposable : Disposable { + + override fun dispose() { + } + + companion object { + + fun getInstance(): ContinuePluginDisposable { + return ApplicationManager.getApplication().getService(ContinuePluginDisposable::class.java) + } + + fun getInstance(project: Project): ContinuePluginDisposable { + return project.getService(ContinuePluginDisposable::class.java) + } + + } +} \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt index 509bc44ce..eecbc958c 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/activities/ContinuePluginStartupActivity.kt @@ -70,8 +70,7 @@ private fun getTutorialFileName(): String { } } -class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { - private val coroutineScope = CoroutineScope(Dispatchers.IO) +class ContinuePluginStartupActivity : StartupActivity, DumbAware { override fun runActivity(project: Project) { removeShortcutFromAction(getPlatformSpecificKeyStroke("J")) @@ -110,6 +109,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { } private fun initializePlugin(project: Project) { + val coroutineScope = CoroutineScope(Dispatchers.IO) val continuePluginService = ServiceManager.getService( project, ContinuePluginService::class.java @@ -169,8 +169,8 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { // Create a data map if there are any paths to re-index if (allPaths.isNotEmpty()) { - val data = mapOf("dirs" to allPaths) - continuePluginService.coreMessenger?.request("index/forceReIndex", data, null) { _ -> } + val data = mapOf("files" to allPaths) + continuePluginService.coreMessenger?.request("index/forceReIndexFiles", data, null) { _ -> } } } }) @@ -225,16 +225,11 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware { EditorFactory.getInstance().eventMulticaster.addSelectionListener( listener, - this@ContinuePluginStartupActivity + ContinuePluginDisposable.getInstance(project) ) val coreMessengerManager = CoreMessengerManager(project, ideProtocolClient, coroutineScope) continuePluginService.coreMessengerManager = coreMessengerManager } } - - override fun dispose() { - // Cleanup resources here - coroutineScope.cancel() - } } \ No newline at end of file diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteSpinnerWidgetFactory.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteSpinnerWidgetFactory.kt index 299614665..98be79f74 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteSpinnerWidgetFactory.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/autocomplete/AutocompleteSpinnerWidgetFactory.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.autocomplete +import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings import com.intellij.openapi.Disposable import com.intellij.openapi.components.service @@ -35,7 +36,7 @@ class AutocompleteSpinnerWidget(project: Project) : EditorBasedWidget(project), ) init { - Disposer.register(project, this) + Disposer.register(ContinuePluginDisposable.getInstance(project), this) updateIcon() } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt index aaa6ce28d..178ae4059 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/CoreMessenger.kt @@ -19,7 +19,7 @@ class CoreMessenger( private val project: Project, continueCorePath: String, private val ideProtocolClient: IdeProtocolClient, - coroutineScope: CoroutineScope + val coroutineScope: CoroutineScope ) { private var writer: Writer? = null private var reader: BufferedReader? = null @@ -232,4 +232,11 @@ class CoreMessenger( } } } + + fun killSubProcess() { + process?.isAlive?.let { + exitCallbacks.clear() + process?.destroy() + } + } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt index b773026bd..c48c8e58b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/continue/IdeProtocolClient.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.`continue` +import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable import com.github.continuedev.continueintellijextension.auth.AuthListener import com.github.continuedev.continueintellijextension.auth.ContinueAuthService import com.github.continuedev.continueintellijextension.constants.getConfigJsPath @@ -105,7 +106,7 @@ class AsyncFileSaveListener(private val ideProtocolClient: IdeProtocolClient) : for (event in events) { if (event.path.endsWith(".continue/config.json") || event.path.endsWith(".continue/config.ts") || event.path.endsWith( ".continue\\config.json" - ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") + ) || event.path.endsWith(".continue\\config.ts") || event.path.endsWith(".continuerc.json") || event.path.endsWith(".continuerc.json") ) { return object : AsyncFileListener.ChangeApplier { override fun afterVfsChange() { @@ -132,9 +133,9 @@ class IdeProtocolClient( initIdeProtocol() // Setup config.json / config.ts save listeners - VirtualFileManager.getInstance().addAsyncFileListener(AsyncFileSaveListener(this), object : Disposable { - override fun dispose() {} - }) + VirtualFileManager.getInstance().addAsyncFileListener( + AsyncFileSaveListener(this), ContinuePluginDisposable.getInstance(project) + ) val myPluginId = "com.github.continuedev.continueintellijextension" val pluginDescriptor = diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt index 0a6b33496..3f25b87cb 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/DiffStreamHandler.kt @@ -109,14 +109,14 @@ class DiffStreamHandler( } updateProgressHighlighters(type) - - // Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where - // we reach EOF while in a diff block, since we won't encounter a "same" line. - if (curLine.index >= editor.document.lineCount - 1) { - curLine.diffBlock?.onLastDiffLine() - } } catch (e: Exception) { - println("Error handling diff line: ${curLine.index}, $type, $text, ${e.message}") + println( + "Error handling diff line - " + + "Line index: ${curLine.index}, " + + "Line type: $type, " + + "Line text: $text, " + + "Error message: ${e.message}" + ) } } @@ -139,7 +139,7 @@ class DiffStreamHandler( val diffBlock = VerticalDiffBlock( editor, project, curLine.index, ::handleDiffBlockAcceptOrReject ) - + diffBlocks.add(diffBlock) return diffBlock @@ -251,9 +251,12 @@ class DiffStreamHandler( } private fun handleFinishedResponse() { - onFinish() - ApplicationManager.getApplication().invokeLater { + // Since we only call onLastDiffLine() when we reach a "same" line, we need to handle the case where + // the last line in the diff stream is in the middle of a diff block. + curLine.diffBlock?.onLastDiffLine() + + onFinish() cleanupProgressHighlighters() } } @@ -267,9 +270,12 @@ class DiffStreamHandler( private fun handleDiffLineResponse(parsed: Map<*, *>) { val data = parsed["content"] as Map<*, *> val diffLineType = getDiffLineType(data["type"] as String) + val lineText = data["line"] as String - WriteCommandAction.runWriteCommandAction(project) { - handleDiffLine(diffLineType, data["line"] as String) + ApplicationManager.getApplication().invokeLater { + WriteCommandAction.runWriteCommandAction(project) { + handleDiffLine(diffLineType, lineText) + } } } diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt index bd1ac8072..714cd6417 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/InlineEditAction.kt @@ -40,6 +40,8 @@ import org.jdesktop.swingx.JXTextArea const val MAIN_FONT_SIZE = 13 +const val DOWN_ARROW = " โ–พ" + fun makeTextArea(): JTextArea { val textArea = CustomTextArea(1, 40).apply { @@ -48,7 +50,7 @@ fun makeTextArea(): JTextArea { isOpaque = false background = GetTheme().getSecondaryDark() maximumSize = Dimension(400, Short.MAX_VALUE.toInt()) - margin = JBUI.insets(6, 8, 6, 4) + margin = JBUI.insets(6, 8, 2, 4) font = UIUtil.getFontWithFallback("Arial", Font.PLAIN, MAIN_FONT_SIZE) preferredSize = Dimension(400, 75) } @@ -206,7 +208,7 @@ fun openInlineEdit(project: Project?, editor: Editor) { val comboBoxRef = Ref>() fun onEnter() { - val selectedModelStrippedOfCaret = (comboBoxRef.get().selectedItem as String).removeSuffix(" โ–พ") + val selectedModelStrippedOfCaret = (comboBoxRef.get().selectedItem as String).removeSuffix(DOWN_ARROW) customPanelRef.get().enter() diffStreamHandler.streamDiffLinesToEditor( textArea.text, prefix, highlighted, suffix, selectedModelStrippedOfCaret @@ -425,7 +427,7 @@ class CustomPanel( } selectedIndex = - continueSettingsService.continueState.lastSelectedInlineEditModel?.let { + if(itemCount == 0) -1 else continueSettingsService.continueState.lastSelectedInlineEditModel?.let { if (modelTitles.isEmpty()) -1 else { val index = modelTitles.indexOf(it) @@ -435,7 +437,7 @@ class CustomPanel( addActionListener { continueSettingsService.continueState.lastSelectedInlineEditModel = - selectedItem as String + (selectedItem as String).removeSuffix(DOWN_ARROW) } } @@ -711,7 +713,7 @@ class TransparentArrowButtonUI : BasicComboBoxUI() { override fun getSelectedItem(): Any? { val item = originalModel.selectedItem - return "$item โ–พ" + return "$item$DOWN_ARROW" } override fun addListDataListener(l: ListDataListener?) { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/ToolTipComponent.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/ToolTipComponent.kt index 30535c4d6..7890ebdba 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/ToolTipComponent.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/ToolTipComponent.kt @@ -88,8 +88,8 @@ class ToolTipComponent(editor: Editor, x: Int, y: Int) : val componentHorizontalPadding = 4 val buttonMargin = 4 - addToChatButton = StyledButton("Chat (${cmdCtrlChar}J)") - editButton = StyledButton("Edit (${cmdCtrlChar}I)") + addToChatButton = StyledButton("Chat (${cmdCtrlChar}+J)") + editButton = StyledButton("Edit (${cmdCtrlChar}+I)") addToChatButton.addActionListener { e: ActionEvent? -> focusContinueInput(editor.project) diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt index 2990b72e8..a84bf7f9b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/editor/VerticalDiffBlock.kt @@ -29,6 +29,7 @@ class VerticalDiffBlock( private val rejectButton: JButton private var deletionInlay: Disposable? = null private var textArea: JTextArea? = null // Used for calculation of the text area height when rendering buttons + private var hasRenderedDiffBlock: Boolean = false private val editorComponentInlaysManager = EditorComponentInlaysManager.from(editor, false) private val greenKey = createTextAttributesKey("CONTINUE_DIFF_NEW_LINE", 0x3000FF00, editor) @@ -81,11 +82,19 @@ class VerticalDiffBlock( } fun onLastDiffLine() { + // Handles the case where we are invoking one last time on last line of diff stream, but the block has + // already been rendered + if (hasRenderedDiffBlock) { + return + } + if (deletedLines.size > 0) { renderDeletedLinesInlay() } renderButtons() + + hasRenderedDiffBlock = true } fun handleReject() { diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt index 7318d2731..87b08f829 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/services/ContinuePluginService.kt @@ -34,6 +34,10 @@ class ContinuePluginService(project: Project) : Disposable, DumbAware { override fun dispose() { coroutineScope.cancel() + coreMessenger?.coroutineScope?.let { + it.cancel() + coreMessenger?.killSubProcess() + } } fun sendToWebview( diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt index 7891a02dc..fc51a392e 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/toolWindow/ContinueBrowser.kt @@ -1,5 +1,6 @@ package com.github.continuedev.continueintellijextension.toolWindow +import com.github.continuedev.continueintellijextension.activities.ContinuePluginDisposable import com.github.continuedev.continueintellijextension.activities.showTutorial import com.github.continuedev.continueintellijextension.constants.MessageTypes import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath @@ -18,8 +19,6 @@ import kotlinx.coroutines.* import org.cef.CefApp import org.cef.browser.CefBrowser import org.cef.handler.CefLoadHandlerAdapter -import com.intellij.openapi.application.ApplicationInfo -import com.intellij.openapi.util.SystemInfo class ContinueBrowser(val project: Project, url: String) { private val coroutineScope = CoroutineScope( @@ -60,6 +59,7 @@ class ContinueBrowser(val project: Project, url: String) { "stats/getTokensPerModel", "index/setPaused", "index/forceReIndex", + "index/forceReIndexFiles", "index/indexingProgressBarInitialized", "completeOnboarding", "addAutocompleteModel", @@ -79,8 +79,8 @@ class ContinueBrowser(val project: Project, url: String) { val browser: JBCefBrowser init { - val enableOSR = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR - this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(enableOSR).build() + val isOSREnabled = ServiceManager.getService(ContinueExtensionSettings::class.java).continueState.enableOSR + this.browser = JBCefBrowser.createBuilder().setOffScreenRendering(isOSREnabled).build() browser.jbCefClient.setProperty( @@ -90,7 +90,7 @@ class ContinueBrowser(val project: Project, url: String) { registerAppSchemeHandler() browser.loadURL(url); - Disposer.register(project, browser) + Disposer.register(ContinuePluginDisposable.getInstance(project), browser) // Listen for events sent from browser val myJSQueryOpenInBrowser = JBCefJSQuery.create((browser as JBCefBrowserBase?)!!) @@ -136,6 +136,10 @@ class ContinueBrowser(val project: Project, url: String) { heightChangeListeners.forEach { it(height) } } + "jetbrains/isOSREnabled" -> { + sendToWebview( "jetbrains/isOSREnabled", isOSREnabled) + } + "onLoad" -> { coroutineScope.launch { // Set the colors to match Intellij theme diff --git a/extensions/vscode/CHANGELOG.md b/extensions/vscode/CHANGELOG.md index 88925e7f4..8dac5cd8c 100644 --- a/extensions/vscode/CHANGELOG.md +++ b/extensions/vscode/CHANGELOG.md @@ -7,8 +7,6 @@ and is generated by [Changie](https://github.com/miniscruff/changie). Pre-release Changes ### Added -* New Edit mode in sidebar (cmd/ctrl+I) -* Significantly faster and more accurate docs crawler by default * OpenAI predicted outputs support * Improve codebase retrieval with BM25 * Support for Grok from xAI @@ -19,12 +17,19 @@ Pre-release Changes * Improved reference for config.json * New @web context provider * Updates for llama3.2 +* .continuerules file to set system prompt +* .prompt files v2 ### Changed * Improved @docs crawler * Many improvements to make autocomplete more eager ### Fixed * Brought back the Apply button for all code blocks +## 0.8.56 - 2024-11-08 +### Added +* New Edit mode in sidebar (cmd/ctrl+I) +* Significantly faster and more accurate docs crawler by default + ## 0.8.55 - 2024-10-25 ### Added * Web context provider diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index a0535391f..21fe76ccf 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -205,7 +205,8 @@ "nebius", "vertexai", "xAI", - "kindo" + "kindo", + "moonshot" ], "markdownEnumDescriptions": [ "### OpenAI\nUse gpt-4, gpt-3.5-turbo, or any other OpenAI model. See [here](https://openai.com/product#made-for-developers) to obtain an API key.\n\n> [Reference](https://docs.continue.dev/reference/Model%20Providers/openai)", @@ -242,7 +243,8 @@ "### Cerebras\nCerebras Inference uses specialized silicon to provides superfast inference. To get started, get your API keys from [their console](https://cloud.cerebras.ai/).", "### Ask Sage\nAsk Sage is an agnostic hosted service that provides language models. To get started with Ask Sage:\n1. Obtain an API key from your account. For more information, visit [Ask Sage](https://docs.asksage.ai/).\n2. Paste the API key below.\n3. Select a model preset.\n> [Reference](https://docs.asksage.ai/)", "### xAI offers a world class developer tool set to build scalable applications powered by Grok. To get started, obtain an API key from [the x Console](https://console.x.ai/), and see the [docs](https://docs.x.ai/docs/)", - "### Secure AI management software that helps enterprises adopt and manage AI across their workforce. To get started, obtain an API key from [the Kindo console](https://app.kindo.ai/settings/api), and see the [website](https://app.kindo.ai//)" + "### Secure AI management software that helps enterprises adopt and manage AI across their workforce. To get started, obtain an API key from [the Kindo console](https://app.kindo.ai/settings/api), and see the [website](https://app.kindo.ai//)", + "### Moonshot\nTo get started with Moonshot AI, obtain your API key from [Moonshot AI](https://platform.moonshot.cn/). Moonshot AI provides high-quality large language models with competitive pricing.\n> [Reference](https://platform.moonshot.cn/docs/api)" ], "type": "string" }, @@ -769,9 +771,11 @@ "starcoder-1b", "starcoder-3b", "starcoder2-3b", - "mistral-tiny", - "mistral-small", - "mistral-medium", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b", "AUTODETECT" ] }, @@ -1028,7 +1032,12 @@ "stable-code-3b", "starcoder-1b", "starcoder-3b", - "starcoder2-3b" + "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b" ] }, { @@ -1081,6 +1090,11 @@ "starcoder-1b", "starcoder-3b", "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b", "AUTODETECT" ] }, @@ -1132,6 +1146,35 @@ "required": ["projectId", "region"] } }, + { + "if": { + "properties": { + "provider": { + "enum": ["moonshot"] + } + }, + "required": ["provider"] + }, + "then": { + "properties": { + "model": { + "anyOf": [ + { + "enum": [ + "moonshot-v1-8k", + "moonshot-v1-32k", + "moonshot-v1-128k", + "AUTODETECT" + ] + }, + { + "type": "string" + } + ] + } + } + } + }, { "if": { "properties": { @@ -1400,7 +1443,12 @@ "stable-code-3b", "starcoder-1b", "starcoder-3b", - "starcoder2-3b" + "starcoder2-3b", + "qwen2.5-coder:1.5b", + "qwen2.5-coder:3b", + "qwen2.5-coder:7b", + "qwen2.5-coder:14b", + "qwen2.5-coder:32b" ] }, { @@ -2710,8 +2758,8 @@ }, "tabAutocompleteModel": { "title": "Tab Autocomplete Model", - "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using starcoder2:3b on a local Ollama instance.\n\n*IMPORTANT*:\n\nIf you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", - "x-intellij-html-description": "The model used for tab autocompletion. If undefined, Continue will default to using starcoder2:3b on a local Ollama instance.

IMPORTANT:

If you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", + "markdownDescription": "The model used for tab autocompletion. If undefined, Continue will default to using qwen2.5-coder:1.5b on a local Ollama instance.\n\n*IMPORTANT*:\n\nIf you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", + "x-intellij-html-description": "The model used for tab autocompletion. If undefined, Continue will default to using qwen2.5-coder:1.5b on a local Ollama instance.

IMPORTANT:

If you use a custom model, ensure that it is one trained for fill-in-the-middle completions. An instruct model is typically not well-suited to autocomplete and you may receive unsatisfactory completions.", "default": { "title": "Tab Autocomplete Model", "provider": "ollama", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 3f6ace66f..3dc6757e7 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.226", + "version": "0.9.231", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.226", + "version": "0.9.231", "license": "Apache-2.0", "dependencies": { "@electron/rebuild": "^3.2.10", diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index eeb7124ab..186d18219 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "0.9.227", + "version": "0.9.231", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" @@ -331,12 +331,14 @@ { "command": "continue.acceptDiff", "mac": "shift+cmd+enter", - "key": "shift+ctrl+enter" + "key": "shift+ctrl+enter", + "when": "continue.diffVisible" }, { "command": "continue.rejectDiff", "mac": "shift+cmd+backspace", - "key": "shift+ctrl+backspace" + "key": "shift+ctrl+backspace", + "when": "continue.diffVisible" }, { "command": "continue.rejectDiff", diff --git a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts index a7018196c..8c8c399a7 100644 --- a/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts +++ b/extensions/vscode/src/ContinueGUIWebviewViewProvider.ts @@ -15,6 +15,10 @@ export class ContinueGUIWebviewViewProvider public static readonly viewType = "continue.continueGUIView"; public webviewProtocol: VsCodeWebviewProtocol; + public get isReady(): boolean { + return !!this.webview; + } + private updateDebugLogsStatus() { const settings = vscode.workspace.getConfiguration(EXTENSION_NAME); this.enableDebugLogs = settings.get("enableDebugLogs", false); diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 980eb7ab4..217f33e6d 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -489,11 +489,13 @@ class VsCodeIde implements IDE { } async getCurrentFile() { - if (!vscode.window.activeTextEditor) {return undefined;} + if (!vscode.window.activeTextEditor) { + return undefined; + } return { isUntitled: vscode.window.activeTextEditor.document.isUntitled, path: vscode.window.activeTextEditor.document.uri.fsPath, - contents: vscode.window.activeTextEditor.document.getText() + contents: vscode.window.activeTextEditor.document.getText(), }; } @@ -629,4 +631,3 @@ class VsCodeIde implements IDE { } export { VsCodeIde }; - diff --git a/extensions/vscode/src/autocomplete/completionProvider.ts b/extensions/vscode/src/autocomplete/completionProvider.ts index b6b04297f..0df8e58b1 100644 --- a/extensions/vscode/src/autocomplete/completionProvider.ts +++ b/extensions/vscode/src/autocomplete/completionProvider.ts @@ -41,7 +41,9 @@ export class ContinueCompletionProvider showFreeTrialLoginMessage( e.message, this.configHandler.reloadConfig.bind(this.configHandler), - () => this.webviewProtocol.request("openOnboardingCard", undefined), + () => { + void this.webviewProtocol.request("openOnboardingCard", undefined) + }, ); return; } diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 197a2c111..52d24969e 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -258,7 +258,7 @@ const commandsMap: ( const modelTitle = getModelByRole(config, "inlineEdit")?.title ?? defaultModelTitle; - sidebar.webviewProtocol.request("incrementFtc", undefined); + void sidebar.webviewProtocol.request("incrementFtc", undefined); await verticalDiffManager.streamEdit( config.experimental?.contextMenuPrompts?.[promptName] ?? fallbackPrompt, @@ -271,7 +271,10 @@ const commandsMap: ( } return { - "continue.acceptDiff": async (newFilepath?: string | vscode.Uri) => { + "continue.acceptDiff": async ( + newFilepath?: string | vscode.Uri, + streamId?: string, + ) => { captureCommandTelemetry("acceptDiff"); let fullPath = newFilepath; @@ -287,11 +290,26 @@ const commandsMap: ( verticalDiffManager.clearForFilepath(fullPath, true); await diffManager.acceptDiff(fullPath); - await sidebar.webviewProtocol.request("setEditStatus", { + void sidebar.webviewProtocol.request("setEditStatus", { status: "done", }); + + if (streamId && fullPath) { + const fileContent = await ide.readFile(fullPath); + + await sidebar.webviewProtocol.request("updateApplyState", { + fileContent, + filepath: fullPath, + streamId: streamId, + status: "closed", + numDiffs: 0, + }); + } }, - "continue.rejectDiff": async (newFilepath?: string | vscode.Uri) => { + "continue.rejectDiff": async ( + newFilepath?: string | vscode.Uri, + streamId?: string, + ) => { captureCommandTelemetry("rejectDiff"); let fullPath = newFilepath; @@ -306,9 +324,21 @@ const commandsMap: ( verticalDiffManager.clearForFilepath(fullPath, false); await diffManager.rejectDiff(fullPath); - await sidebar.webviewProtocol.request("setEditStatus", { + void sidebar.webviewProtocol.request("setEditStatus", { status: "done", }); + + if (streamId && fullPath) { + const fileContent = await ide.readFile(fullPath); + + await sidebar.webviewProtocol.request("updateApplyState", { + fileContent, + filepath: fullPath, + streamId: streamId, + status: "closed", + numDiffs: 0, + }); + } }, "continue.acceptVerticalDiffBlock": (filepath?: string, index?: number) => { captureCommandTelemetry("acceptVerticalDiffBlock"); @@ -366,6 +396,14 @@ const commandsMap: ( core.invoke("context/indexDocs", { reIndex: true }); }, "continue.focusContinueInput": async () => { + // This is a temporary fixโ€”sidebar.webviewProtocol.request is blocking + // when the GUI hasn't yet been setup and we should instead be + // immediately throwing an error, or returning a Result object + if (!sidebar.isReady) { + focusGUI(); + return; + } + const historyLength = await sidebar.webviewProtocol.request( "getWebviewHistoryLength", undefined, @@ -379,15 +417,23 @@ const commandsMap: ( if (historyLength === 0) { hideGUI(); } else { - sidebar.webviewProtocol?.request("focusContinueInput", undefined); + void sidebar.webviewProtocol?.request("focusContinueInput", undefined); } } else { focusGUI(); sidebar.webviewProtocol?.request("focusContinueInput", undefined); - await addHighlightedCodeToContext(sidebar.webviewProtocol); + void addHighlightedCodeToContext(sidebar.webviewProtocol); } }, "continue.focusContinueInputWithoutClear": async () => { + // This is a temporary fixโ€”sidebar.webviewProtocol.request is blocking + // when the GUI hasn't yet been setup and we should instead be + // immediately throwing an error, or returning a Result object + if (!sidebar.isReady) { + focusGUI(); + return; + } + const isContinueInputFocused = await sidebar.webviewProtocol.request( "isContinueInputFocused", undefined, @@ -403,7 +449,7 @@ const commandsMap: ( undefined, ); - await addHighlightedCodeToContext(sidebar.webviewProtocol); + void addHighlightedCodeToContext(sidebar.webviewProtocol); } }, "continue.edit": async () => { @@ -580,10 +626,10 @@ const commandsMap: ( prompt: "Enter the Session ID", }); } - sidebar.webviewProtocol?.request("focusContinueSessionId", { sessionId }); + void sidebar.webviewProtocol?.request("focusContinueSessionId", { sessionId }); }, "continue.applyCodeFromChat": () => { - sidebar.webviewProtocol.request("applyCodeFromChat", undefined); + void sidebar.webviewProtocol.request("applyCodeFromChat", undefined); }, "continue.toggleFullScreen": () => { focusGUI(); diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 1ec5a60b6..3286749a6 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -18,6 +18,7 @@ export interface VerticalDiffHandlerOptions { onStatusUpdate: ( status?: ApplyState["status"], numDiffs?: ApplyState["numDiffs"], + fileContent?: ApplyState["fileContent"], ) => void; } @@ -25,9 +26,12 @@ export class VerticalDiffHandler implements vscode.Disposable { private currentLineIndex: number; private cancelled = false; private newLinesAdded = 0; - private get diffBlocks() { - return this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + private deletionBuffer: string[] = []; + private redDecorationManager: DecorationTypeRangeManager; + private get filepath() { + return this.editor.document.uri.fsPath; } + public insertedInCurrentBlock = 0; public get range(): vscode.Range { const startLine = Math.min(this.startLine, this.endLine); const endLine = Math.max(this.startLine, this.endLine); @@ -77,14 +81,6 @@ export class VerticalDiffHandler implements vscode.Disposable { this.disposables.push(disposable); } - private get filepath() { - return this.editor.document.uri.fsPath; - } - - private deletionBuffer: string[] = []; - private redDecorationManager: DecorationTypeRangeManager; - insertedInCurrentBlock = 0; - private async insertDeletionBuffer() { // Don't remove trailing whitespace line const totalDeletedContent = this.deletionBuffer.join("\n"); @@ -98,13 +94,15 @@ export class VerticalDiffHandler implements vscode.Disposable { } if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) { - this.diffBlocks.push({ + const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + + blocks.push({ start: this.currentLineIndex - this.insertedInCurrentBlock, numRed: this.deletionBuffer.length, numGreen: this.insertedInCurrentBlock, }); - this.editorToVerticalDiffCodeLens.set(this.filepath, this.diffBlocks); + this.editorToVerticalDiffCodeLens.set(this.filepath, blocks); } if (this.deletionBuffer.length === 0) { @@ -271,7 +269,11 @@ export class VerticalDiffHandler implements vscode.Disposable { }, ); - this.options.onStatusUpdate("closed", this.diffBlocks.length); + this.options.onStatusUpdate( + "closed", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + this.editor.document.getText(), + ); this.cancelled = true; this.refreshCodeLens(); @@ -359,7 +361,11 @@ export class VerticalDiffHandler implements vscode.Disposable { this.refreshCodeLens(); - this.options.onStatusUpdate("done", this.diffBlocks.length); + this.options.onStatusUpdate( + "done", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + this.editor.document.getText(), + ); // Reject on user typing // const listener = vscode.workspace.onDidChangeTextDocument((e) => { @@ -409,8 +415,15 @@ export class VerticalDiffHandler implements vscode.Disposable { // Shift the codelens objects this.shiftCodeLensObjects(startLine, offset); - const status = this.diffBlocks.length === 0 ? "closed" : undefined; - this.options.onStatusUpdate(status, this.diffBlocks.length); + const numDiffs = + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0; + + const status = numDiffs === 0 ? "closed" : undefined; + this.options.onStatusUpdate( + status, + numDiffs, + this.editor.document.getText(), + ); } private shiftCodeLensObjects(startLine: number, offset: number) { @@ -450,6 +463,7 @@ export class VerticalDiffHandler implements vscode.Disposable { } public hasDiffForCurrentFile(): boolean { - return this.diffBlocks.length > 0; + const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath); + return diffBlocks !== undefined && diffBlocks.length > 0; } } diff --git a/extensions/vscode/src/diff/vertical/manager.ts b/extensions/vscode/src/diff/vertical/manager.ts index 56be062ae..3342c5341 100644 --- a/extensions/vscode/src/diff/vertical/manager.ts +++ b/extensions/vscode/src/diff/vertical/manager.ts @@ -180,6 +180,8 @@ export class VerticalDiffManager { // Re-enable listener for user changes to file this.enableDocumentChangeListener(); } + + this.refreshCodeLens(); } async streamDiffLines( @@ -215,11 +217,13 @@ export class VerticalDiffManager { endLine, { instant, - onStatusUpdate: (status, numDiffs) => - this.webviewProtocol.request("updateApplyState", { + onStatusUpdate: (status, numDiffs, fileContent) => + void this.webviewProtocol.request("updateApplyState", { streamId, status, numDiffs, + fileContent, + filepath, }), }, ); @@ -267,13 +271,13 @@ export class VerticalDiffManager { onlyOneInsertion?: boolean, quickEdit?: string, range?: vscode.Range, - ) { + ): Promise { vscode.commands.executeCommand("setContext", "continue.diffVisible", true); let editor = vscode.window.activeTextEditor; if (!editor) { - return; + return undefined; } const filepath = editor.document.uri.fsPath; @@ -334,19 +338,21 @@ export class VerticalDiffManager { endLine, { input, - onStatusUpdate: (status, numDiffs) => + onStatusUpdate: (status, numDiffs, fileContent) => streamId && - this.webviewProtocol.request("updateApplyState", { + void this.webviewProtocol.request("updateApplyState", { streamId, status, numDiffs, + fileContent, + filepath, }), }, ); if (!diffHandler) { console.warn("Issue occured while creating new vertical diff handler"); - return; + return undefined; } let selectedRange = diffHandler.range; @@ -396,8 +402,10 @@ export class VerticalDiffManager { this.editDecorationManager.clear(); try { - this.logDiffs = await diffHandler.run( - streamDiffLines( + const streamedLines: string[] = []; + + async function* recordedStream() { + const stream = streamDiffLines( prefix, rangeContent, suffix, @@ -405,14 +413,26 @@ export class VerticalDiffManager { input, getMarkdownLanguageTagForFile(filepath), onlyOneInsertion, - ), - ); + ); + + for await (const line of stream) { + if (line.type === "new" || line.type === "same") { + streamedLines.push(line.line); + } + yield line; + } + } + + this.logDiffs = await diffHandler.run(recordedStream()); // enable a listener for user edits to file while diff is open this.enableDocumentChangeListener(); + + return `${prefix}${streamedLines.join("\n")}${suffix}`; } catch (e) { this.disableDocumentChangeListener(); vscode.window.showErrorMessage(`Error streaming diff: ${e}`); + return undefined; } finally { vscode.commands.executeCommand( "setContext", diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index f8bc7c556..1eb619aa8 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -37,6 +37,7 @@ import { VsCodeIde } from "../VsCodeIde"; import { VsCodeMessenger } from "./VsCodeMessenger"; +import { SYSTEM_PROMPT_DOT_FILE } from "core/config/getSystemPromptDotFile"; import type { VsCodeWebviewProtocol } from "../webviewProtocol"; export class VsCodeExtension { @@ -284,7 +285,8 @@ export class VsCodeExtension { if ( filepath.endsWith(".continuerc.json") || - filepath.endsWith(".prompt") + filepath.endsWith(".prompt") || + filepath.endsWith(SYSTEM_PROMPT_DOT_FILE) ) { this.configHandler.reloadConfig(); } else if ( @@ -295,15 +297,21 @@ export class VsCodeExtension { this.core.invoke("index/forceReIndex", undefined); } else { // Reindex the file - this.core.invoke("index/forceReIndex", { - dirs: [filepath] + this.core.invoke("index/forceReIndexFiles", { + files: [filepath], }); } }); vscode.workspace.onDidDeleteFiles(async (event) => { - this.core.invoke("index/forceReIndex", { - dirs: event.files.map((file) => file.fsPath.split("/").slice(0, -1).join("/")) + this.core.invoke("index/forceReIndexFiles", { + files: event.files.map((file) => file.fsPath), + }); + }); + + vscode.workspace.onDidCreateFiles(async (event) => { + this.core.invoke("index/forceReIndexFiles", { + files: event.files.map((file) => file.fsPath), }); }); @@ -314,14 +322,14 @@ export class VsCodeExtension { } else if (e.provider.id === controlPlaneEnv.AUTH_TYPE) { const sessionInfo = await getControlPlaneSessionInfo(true); this.webviewProtocolPromise.then(async (webviewProtocol) => { - webviewProtocol.request("didChangeControlPlaneSessionInfo", { + void webviewProtocol.request("didChangeControlPlaneSessionInfo", { sessionInfo, }); // To make sure continue-proxy models and anything else requiring it get updated access token this.configHandler.reloadConfig(); }); - this.core.invoke("didChangeControlPlaneSessionInfo", { sessionInfo }); + void this.core.invoke("didChangeControlPlaneSessionInfo", { sessionInfo }); } }); @@ -352,7 +360,8 @@ export class VsCodeExtension { // Register a content provider for the readonly virtual documents const documentContentProvider = new (class - implements vscode.TextDocumentContentProvider { + implements vscode.TextDocumentContentProvider + { // emitter and its event onDidChangeEmitter = new vscode.EventEmitter(); onDidChange = this.onDidChangeEmitter.event; @@ -369,14 +378,14 @@ export class VsCodeExtension { ); this.ide.onDidChangeActiveTextEditor((filepath) => { - this.core.invoke("didChangeActiveTextEditor", { filepath }); + void this.core.invoke("didChangeActiveTextEditor", { filepath }); }); vscode.workspace.onDidChangeConfiguration(async (event) => { if (event.affectsConfiguration(EXTENSION_NAME)) { const settings = this.ide.getIdeSettingsSync(); const webviewProtocol = await this.webviewProtocolPromise; - webviewProtocol.request("didChangeIdeSettings", { + void webviewProtocol.request("didChangeIdeSettings", { settings, }); } diff --git a/extensions/vscode/src/extension/VsCodeMessenger.ts b/extensions/vscode/src/extension/VsCodeMessenger.ts index 96ab1fa1a..3b5baad5f 100644 --- a/extensions/vscode/src/extension/VsCodeMessenger.ts +++ b/extensions/vscode/src/extension/VsCodeMessenger.ts @@ -48,7 +48,7 @@ export class VsCodeMessenger { message: Message, ) => Promise | FromWebviewProtocol[T][1], ): void { - this.webviewProtocol.on(messageType, handler); + void this.webviewProtocol.on(messageType, handler); } onCore( @@ -152,15 +152,35 @@ export class VsCodeMessenger { ); }); - webviewProtocol.on("acceptDiff", async ({ data: { filepath } }) => { - await vscode.commands.executeCommand("continue.acceptDiff", filepath); - }); + webviewProtocol.on( + "acceptDiff", + async ({ data: { filepath, streamId } }) => { + await vscode.commands.executeCommand( + "continue.acceptDiff", + filepath, + streamId, + ); + }, + ); - webviewProtocol.on("rejectDiff", async ({ data: { filepath } }) => { - await vscode.commands.executeCommand("continue.rejectDiff", filepath); - }); + webviewProtocol.on( + "rejectDiff", + async ({ data: { filepath, streamId } }) => { + await vscode.commands.executeCommand( + "continue.rejectDiff", + filepath, + streamId, + ); + }, + ); this.onWebview("applyToFile", async ({ data }) => { + webviewProtocol.request("updateApplyState", { + streamId: data.streamId, + status: "streaming", + fileContent: data.text, + }); + let filepath = data.filepath; // If there is a filepath, verify it exists and then open the file @@ -173,18 +193,10 @@ export class VsCodeMessenger { const fileExists = await this.ide.fileExists(fullPath); - // If it's a new file, no need to apply, just write directly + // If there is no existing file at the path, create it if (!fileExists) { - await this.ide.writeFile(fullPath, data.text); + await this.ide.writeFile(fullPath, ""); await this.ide.openFile(fullPath); - - await webviewProtocol.request("updateApplyState", { - streamId: data.streamId, - status: "done", - numDiffs: 0, - }); - - return; } await this.ide.openFile(fullPath); @@ -203,11 +215,14 @@ export class VsCodeMessenger { editor.edit((builder) => builder.insert(new vscode.Position(0, 0), data.text), ); - await webviewProtocol.request("updateApplyState", { + + void webviewProtocol.request("updateApplyState", { streamId: data.streamId, - status: "done", + status: "closed", numDiffs: 0, + fileContent: data.text, }); + return; } @@ -295,6 +310,37 @@ export class VsCodeMessenger { this.onWebview("openUrl", (msg) => { vscode.env.openExternal(vscode.Uri.parse(msg.data)); }); + + this.onWebview( + "overwriteFile", + async ({ data: { prevFileContent, filepath } }) => { + if (prevFileContent === null) { + // TODO: Delete the file + return; + } + + await this.ide.openFile(filepath); + + // Get active text editor + const editor = vscode.window.activeTextEditor; + + if (!editor) { + vscode.window.showErrorMessage("No active editor to apply edits to"); + return; + } + + editor.edit((builder) => + builder.replace( + new vscode.Range( + editor.document.positionAt(0), + editor.document.positionAt(editor.document.getText().length), + ), + prevFileContent, + ), + ); + }, + ); + this.onWebview("insertAtCursor", async (msg) => { const editor = vscode.window.activeTextEditor; if (editor === undefined || !editor.selection) { @@ -316,7 +362,7 @@ export class VsCodeMessenger { "getDefaultModelTitle", undefined, ); - await verticalDiffManager.streamEdit( + const fileAfterEdit = await verticalDiffManager.streamEdit( stripImages(prompt), modelTitle, "edit", @@ -328,8 +374,9 @@ export class VsCodeMessenger { ), ); - this.webviewProtocol.request("setEditStatus", { + void this.webviewProtocol.request("setEditStatus", { status: "accepting", + fileAfterEdit, }); }); this.onWebview("edit/acceptReject", async (msg) => { diff --git a/extensions/vscode/src/lang-server/promptFileCompletions.ts b/extensions/vscode/src/lang-server/promptFileCompletions.ts index 4dfd1a9ef..ef873b44d 100644 --- a/extensions/vscode/src/lang-server/promptFileCompletions.ts +++ b/extensions/vscode/src/lang-server/promptFileCompletions.ts @@ -141,6 +141,12 @@ class YamlKeysCompletionItemProvider implements vscode.CompletionItemProvider { const lineText = document.lineAt(position).text; const textBeforeCursor = lineText.substring(0, position.character); + // 0. If no delimiter in the file, return no completions + const fullContent = document.getText(); + if (!fullContent.includes("---")) { + return undefined; + } + // 1. Check if the cursor is in YAML section (before --- delimiter) const beforeDelimiter = isCursorBeforeDelimiter(document, position); @@ -160,7 +166,7 @@ class YamlKeysCompletionItemProvider implements vscode.CompletionItemProvider { vscode.CompletionItemKind.Property, ); item.documentation = new vscode.MarkdownString(key.description); - item.insertText = key + ": "; + item.insertText = key.key + ": "; return item; }); diff --git a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts index 355c02de6..4b59dcbda 100644 --- a/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts +++ b/extensions/vscode/src/quickEdit/QuickEditQuickPick.ts @@ -329,7 +329,7 @@ export class QuickEdit { prompt = this.contextProviderStr + prompt; } - this.webviewProtocol.request("incrementFtc", undefined); + void this.webviewProtocol.request("incrementFtc", undefined); await this.verticalDiffManager.streamEdit( prompt, diff --git a/extensions/vscode/src/util/loadAutocompleteModel.ts b/extensions/vscode/src/util/loadAutocompleteModel.ts index f4f4c87b3..b4aa9289b 100644 --- a/extensions/vscode/src/util/loadAutocompleteModel.ts +++ b/extensions/vscode/src/util/loadAutocompleteModel.ts @@ -6,7 +6,7 @@ import type { ILLM } from "core"; export class TabAutocompleteModel { private _llm: ILLM | undefined; - private defaultTag = "starcoder2:3b"; + private defaultTag = "qwen2.5-coder:1.5b"; private globalContext: GlobalContext = new GlobalContext(); constructor(private configHandler: ConfigHandler) {} diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/typescript.scm b/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/typescript.scm deleted file mode 100644 index bf38152b7..000000000 --- a/extensions/vscode/tree-sitter/root-path-context-queries/class_declaration/typescript.scm +++ /dev/null @@ -1,19 +0,0 @@ -( - (class_declaration - (class_heritage - (extends_clause - (identifier) @base-class - ) - ) - ) -) - -( - (class_declaration - (class_heritage - (implements_clause - (type_identifier) @interface - ) - ) - ) -) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/cpp.scm b/extensions/vscode/tree-sitter/root-path-context-queries/cpp/function_definition.scm similarity index 100% rename from extensions/vscode/tree-sitter/root-path-context-queries/function_definition/cpp.scm rename to extensions/vscode/tree-sitter/root-path-context-queries/cpp/function_definition.scm diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm b/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm deleted file mode 100644 index ab10968a3..000000000 --- a/extensions/vscode/tree-sitter/root-path-context-queries/function_declaration/typescript.scm +++ /dev/null @@ -1,10 +0,0 @@ -( - (function_declaration - (formal_parameters - (_ - (type_annotation) @param_type - ) - ) - (type_annotation) @return_type - ) -) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/python.scm b/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/python.scm deleted file mode 100644 index 864666a4a..000000000 --- a/extensions/vscode/tree-sitter/root-path-context-queries/function_definition/python.scm +++ /dev/null @@ -1,17 +0,0 @@ -( - (function_definition - (parameters - (_ - (type) @a - (#not-match? @a "^(str|int|float|bool|list|dict|tuple)$") - ) - ) - ) -) - -( - (function_definition - (type) @b - (#not-match? @b "^(str|int|float|bool|list|dict|tuple)$") - ) -) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/go/function_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/go/function_declaration.scm new file mode 100644 index 000000000..482f50841 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/go/function_declaration.scm @@ -0,0 +1,12 @@ +( + (function_declaration + (parameter_list + (parameter_declaration + type: (_) @param_type + )* + ) + ; Optional return type node before the block + ([_] @return_type)? + (block) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/method_declaration/java.scm b/extensions/vscode/tree-sitter/root-path-context-queries/java/method_declaration.scm similarity index 100% rename from extensions/vscode/tree-sitter/root-path-context-queries/method_declaration/java.scm rename to extensions/vscode/tree-sitter/root-path-context-queries/java/method_declaration.scm diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm b/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm deleted file mode 100644 index 727db5090..000000000 --- a/extensions/vscode/tree-sitter/root-path-context-queries/method_definition/typescript.scm +++ /dev/null @@ -1,10 +0,0 @@ -( - (method_definition - (formal_parameters - (_ - (type_annotation) @param_type - ) - ) - (type_annotation) @return_type - ) -) diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/php/class_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/php/class_declaration.scm new file mode 100644 index 000000000..5e9a9c13e --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/php/class_declaration.scm @@ -0,0 +1,13 @@ +( + (class_declaration + (base_clause + (name) @superclass) + ) +) + +( + (class_declaration + (class_interface_clause + (name) @interface) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/php/function_definition.scm b/extensions/vscode/tree-sitter/root-path-context-queries/php/function_definition.scm new file mode 100644 index 000000000..3f9303ae1 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/php/function_definition.scm @@ -0,0 +1,10 @@ +( + (function_definition + parameters: (formal_parameters + (simple_parameter + type: (named_type) @param_type + )* + ) + return_type: (named_type) @return_type + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/php/method_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/php/method_declaration.scm new file mode 100644 index 000000000..825324e01 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/php/method_declaration.scm @@ -0,0 +1,10 @@ +( + (method_declaration + (formal_parameters + (simple_parameter + type: (named_type) @param_type + )* + ) + return_type: (named_type) @return_type + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/python/class_definition.scm b/extensions/vscode/tree-sitter/root-path-context-queries/python/class_definition.scm new file mode 100644 index 000000000..61fdb29ec --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/python/class_definition.scm @@ -0,0 +1,24 @@ +; Match superclass identifiers in a simple inheritance +(class_definition + superclasses: (argument_list + (identifier) @catch) + (#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; Match the value of a keyword argument in class inheritance +(class_definition + superclasses: (argument_list + (keyword_argument + (_) + (identifier) @catch)) + (#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; Match identifiers within subscripts in class inheritance +(class_definition + superclasses: (argument_list + (subscript + (identifier) @catch + )) + (#not-match? @catch "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/python/function_definition.scm b/extensions/vscode/tree-sitter/root-path-context-queries/python/function_definition.scm new file mode 100644 index 000000000..535882bfa --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/python/function_definition.scm @@ -0,0 +1,60 @@ +; When the type is a simple identifier: +(function_definition + parameters: (parameters + (typed_parameter + type: (type + (identifier) @type_identifier))) + + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; When the type is a generic type with one identifier +(function_definition + parameters: (parameters + (typed_parameter + type: (type + (generic_type + (identifier) @type_identifier)))) + + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; When the generic type has type parameters with one identifier +(function_definition + parameters: (parameters + (typed_parameter + type: (type + (generic_type + (identifier) + (type_parameter + (type + (identifier) @type_identifier)))))) + + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; When the return type is a simple identifier +(function_definition + return_type: (type + (identifier) @type_identifier) + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; When the return type is a generic type with one identifier +(function_definition + return_type: (type + (generic_type + (identifier) @type_identifier)) + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) + +; When the generic type has type parameters with one identifier +(function_definition + return_type: (type + (generic_type + (identifier) + (type_parameter + (type + (identifier) @type_identifier)))) + (#not-match? @type_identifier "^(str|int|float|bool|list|dict|tuple|set|frozenset|complex|bytes|bytearray|memoryview|range|slice|object|type|NoneType|List|Dict|Tuple|Set|FrozenSet|Union|Optional|Any|Callable|Iterable|Iterator|Generator|Coroutine|AsyncIterable|AsyncIterator|Awaitable|ContextManager|Pattern|Match|TypeVar|Generic|Sequence|Mapping|MutableMapping|MutableSequence|ByteString|Reversible|Sized|Container|Collection|AbstractSet|MutableSet|KeysView|ItemsView|ValuesView|Hashable|Sized|SupportsInt|SupportsFloat|SupportsComplex|SupportsBytes|SupportsAbs|SupportsRound|ChainMap|Counter|OrderedDict|defaultdict|deque|namedtuple|TypedDict)$") +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/typescript/arrow_function.scm b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/arrow_function.scm new file mode 100644 index 000000000..159ff63f6 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/arrow_function.scm @@ -0,0 +1,77 @@ +; Pattern for return type with direct type_identifier +( + (arrow_function + (type_annotation + (type_identifier) @return_type + ) + ) +) + +; Pattern for return type with one level of nesting +( + (arrow_function + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) +) + +; Pattern for return type with two levels of nesting +( + (arrow_function + (type_annotation + (_ + (_ + (type_identifier) @return_type + ) + ) + ) + ) +) + +; Pattern for parameters with direct type_identifier +( + (arrow_function + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with one level of nesting +( + (arrow_function + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) +) + +; Pattern for parameters with two levels of nesting +( + (arrow_function + (formal_parameters + (_ + (type_annotation + (_ + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/typescript/class_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/class_declaration.scm new file mode 100644 index 000000000..d164b05a8 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/class_declaration.scm @@ -0,0 +1,45 @@ +; Match a class declaration that extends a base class +; Returns: +; @base-class: The identifier of the base class being extended +; @generic_argument: The type identifier of the generic argument, if present +(class_declaration + (class_heritage + (extends_clause + (identifier) @base-class + (type_arguments + (type_identifier) @generic_argument + )? + ) + ) +) + +; Match a class declaration that implements an interface +; Returns: +; @interface: The type identifier of the interface being implemented +( + (class_declaration + (class_heritage + (implements_clause + (type_identifier) @interface + ) + ) + ) +) + +; Match a class declaration that implements a generic interface +; Returns: +; @interface: The type identifier of the generic interface being implemented +; @generic_argument: The type identifier of the generic argument +( + class_declaration + (class_heritage + (implements_clause + (generic_type + (type_identifier) @interface + (type_arguments + (type_identifier) @generic_argument + ) + ) + ) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/typescript/function_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/function_declaration.scm new file mode 100644 index 000000000..52b62f9bd --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/function_declaration.scm @@ -0,0 +1,77 @@ +; Pattern for return type with direct type_identifier +( + (function_declaration + (type_annotation + (type_identifier) @return_type + ) + ) +) + +; Pattern for return type with one level of nesting +( + (function_declaration + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) +) + +; Pattern for return type with two levels of nesting +( + (function_declaration + (type_annotation + (_ + (_ + (type_identifier) @return_type + ) + ) + ) + ) +) + +; Pattern for parameters with direct type_identifier +( + (function_declaration + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with one level of nesting +( + (function_declaration + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) +) + +; Pattern for parameters with two levels of nesting +( + (function_declaration + (formal_parameters + (_ + (type_annotation + (_ + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/typescript/generator_function_declaration.scm b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/generator_function_declaration.scm new file mode 100644 index 000000000..b6417f45c --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/generator_function_declaration.scm @@ -0,0 +1,77 @@ +; Pattern for return type with direct type_identifier +( + (generator_function_declaration + (type_annotation + (type_identifier) @return_type + ) + ) +) + +; Pattern for return type with one level of nesting +( + (generator_function_declaration + (type_annotation + (_ + (type_identifier) @return_type + ) + ) + ) +) + +; Pattern for return type with two levels of nesting +( + (generator_function_declaration + (type_annotation + (_ + (_ + (type_identifier) @return_type + ) + ) + ) + ) +) + +; Pattern for parameters with direct type_identifier +( + (generator_function_declaration + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with one level of nesting +( + (generator_function_declaration + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) +) + +; Pattern for parameters with two levels of nesting +( + (generator_function_declaration + (formal_parameters + (_ + (type_annotation + (_ + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/extensions/vscode/tree-sitter/root-path-context-queries/typescript/method_definition.scm b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/method_definition.scm new file mode 100644 index 000000000..d5d4c3724 --- /dev/null +++ b/extensions/vscode/tree-sitter/root-path-context-queries/typescript/method_definition.scm @@ -0,0 +1,77 @@ +; Pattern for return type with direct type_identifier +( + (method_definition + (type_annotation + (type_identifier) @return_type + ) + ) +) + +; Pattern for return type with one level of nesting +( + (method_definition + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) +) + +; Pattern for return type with two levels of nesting +( + (method_definition + (type_annotation + (_ + (_ + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with direct type_identifier +( + (method_definition + (formal_parameters + (_ + (type_annotation + (type_identifier) @param_type + ) + ) + ) + ) +) + +; Pattern for parameters with one level of nesting +( + (method_definition + (formal_parameters + (_ + (type_annotation + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) +) + +; Pattern for parameters with two levels of nesting +( + (method_definition + (formal_parameters + (_ + (type_annotation + (_ + (_ + (type_identifier) @param_type + ) + ) + ) + ) + ) + ) +) \ No newline at end of file diff --git a/gui/public/logos/moonshot.png b/gui/public/logos/moonshot.png new file mode 100644 index 000000000..f51df62eb Binary files /dev/null and b/gui/public/logos/moonshot.png differ diff --git a/gui/src/components/History/index.tsx b/gui/src/components/History/index.tsx index 7ed525626..4aee636bd 100644 --- a/gui/src/components/History/index.tsx +++ b/gui/src/components/History/index.tsx @@ -46,13 +46,20 @@ export function History() { const fetchSessions = async () => { const sessions = await getHistory(); setSessions(sessions); - minisearch.addAll( - sessions.map((session) => ({ - title: session.title, - sessionId: session.sessionId, - id: session.sessionId, - })), - ); + + try { + // Consider adding just last session to existing instead of clearing/adding all + minisearch.removeAll(); + minisearch.addAll( + sessions.map((session) => ({ + title: session.title, + sessionId: session.sessionId, + id: session.sessionId, + })), + ); + } catch (e) { + console.log("error adding sessions to minisearch", e); + } }; fetchSessions(); }, [lastSessionId]); diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 0ab40cb03..5879bd2e0 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -12,7 +12,11 @@ import { setEditStatus, startEditMode, } from "../redux/slices/editModeState"; -import { setShowDialog, updateApplyState } from "../redux/slices/uiStateSlice"; +import { setShowDialog } from "../redux/slices/uiStateSlice"; +import { + updateApplyState, + updateCurCheckpoint, +} from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; import { getFontSize, isMetaEquivalentKeyPressed } from "../util"; import { getLocalStorage, setLocalStorage } from "../util/localStorage"; @@ -158,6 +162,12 @@ const Layout = () => { useWebviewListener( "updateApplyState", async (state) => { + dispatch( + updateCurCheckpoint({ + filepath: state.filepath, + content: state.fileContent, + }), + ); dispatch(updateApplyState(state)); }, [], @@ -188,8 +198,8 @@ const Layout = () => { [navigate], ); - useWebviewListener("setEditStatus", async ({ status }) => { - dispatch(setEditStatus(status)); + useWebviewListener("setEditStatus", async ({ status, fileAfterEdit }) => { + dispatch(setEditStatus({ status, fileAfterEdit })); }); useWebviewListener("exitEditMode", async () => { diff --git a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx index e798bf18a..2113be710 100644 --- a/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx +++ b/gui/src/components/OnboardingCard/components/QuickStartSubmitButton.tsx @@ -41,7 +41,7 @@ function QuickstartSubmitButton() { force: true, }); - if (result.status === "success" && typeof result.content === "string") { + if (result.status === "success") { onComplete(); } else { ideMessenger.post("showToast", [ diff --git a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx index 2e4175083..d16587427 100644 --- a/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx +++ b/gui/src/components/OnboardingCard/tabs/OnboardingLocalTab.tsx @@ -57,11 +57,11 @@ function OnboardingLocalTab() { useEffect(() => { const fetchDownloadedModels = async () => { try { - const result = (await ideMessenger.request("llm/listModels", { + const result = await ideMessenger.request("llm/listModels", { title: ONBOARDING_LOCAL_MODEL_TITLE, - })) as any; + }) - if (result.status === "success" && Array.isArray(result.content)) { + if (result.status === "success") { setDownloadedOllamaModels(result.content); setIsOllamaConnected(true); } else { diff --git a/gui/src/components/ProfileSwitcher.tsx b/gui/src/components/ProfileSwitcher.tsx index 4fe8bd72d..601de6782 100644 --- a/gui/src/components/ProfileSwitcher.tsx +++ b/gui/src/components/ProfileSwitcher.tsx @@ -193,7 +193,7 @@ function ProfileSwitcher() { { - ideMessenger.request("didChangeSelectedProfile", { id }); + ideMessenger.post("didChangeSelectedProfile", { id }); }} >
diff --git a/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx b/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx new file mode 100644 index 000000000..a1e7b28f6 --- /dev/null +++ b/gui/src/components/StepContainer/AcceptRejectAllButtons.tsx @@ -0,0 +1,46 @@ +import { useContext } from "react"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import { ApplyState } from "core/protocol/ideWebview"; + +export interface AcceptRejectAllButtonsProps { + pendingApplyStates: ApplyState[]; +} + +export default function AcceptRejectAllButtons({ + pendingApplyStates, +}: AcceptRejectAllButtonsProps) { + const ideMessenger = useContext(IdeMessengerContext); + + async function handleAcceptOrReject(status: "acceptDiff" | "rejectDiff") { + for (const { filepath, streamId } of pendingApplyStates) { + ideMessenger.post(status, { + filepath, + streamId, + }); + } + } + + return ( +
+ + +
+ ); +} diff --git a/gui/src/components/StepContainer/FeedbackButtons.tsx b/gui/src/components/StepContainer/FeedbackButtons.tsx new file mode 100644 index 000000000..55e870991 --- /dev/null +++ b/gui/src/components/StepContainer/FeedbackButtons.tsx @@ -0,0 +1,55 @@ +import { + HandThumbUpIcon, + HandThumbDownIcon, +} from "@heroicons/react/24/outline"; +import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; +import { ChatHistoryItem } from "core"; +import { useState, useContext } from "react"; +import { useSelector } from "react-redux"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { RootState } from "../../redux/store"; + +export interface FeedbackButtonsProps { + item: ChatHistoryItem; +} + +export default function FeedbackButtons({ item }: FeedbackButtonsProps) { + const [feedback, setFeedback] = useState(undefined); + const ideMessenger = useContext(IdeMessengerContext); + const sessionId = useSelector((store: RootState) => store.state.sessionId); + + const sendFeedback = (feedback: boolean) => { + setFeedback(feedback); + if (item.promptLogs?.length) { + for (const promptLog of item.promptLogs) { + ideMessenger.post("devdata/log", { + tableName: "chat", + data: { ...promptLog, feedback, sessionId }, + }); + } + } + }; + + return ( + <> + sendFeedback(true)} + > + + + sendFeedback(false)} + > + + {" "} + + ); +} diff --git a/gui/src/components/StepContainer/MultifileEditActions.tsx b/gui/src/components/StepContainer/MultifileEditActions.tsx new file mode 100644 index 000000000..5fb7122df --- /dev/null +++ b/gui/src/components/StepContainer/MultifileEditActions.tsx @@ -0,0 +1,65 @@ +import { useSelector } from "react-redux"; +import { RootState } from "../../redux/store"; +import AcceptRejectAllButtons from "./AcceptRejectAllButtons"; +import FeedbackButtons from "./FeedbackButtons"; +import UndoAndRedoButtons from "./UndoAndRedoButtons"; +import { ChatHistoryItem } from "core"; +import { stripImages } from "core/llm/images"; +import { CopyIconButton } from "../gui/CopyIconButton"; + +export interface MultifileEditActionsProps { + index: number; + item: ChatHistoryItem; +} + +export default function MultifileEditActions({ + index, + item, +}: MultifileEditActionsProps) { + const curCheckpointIndex = useSelector( + (store: RootState) => store.state.curCheckpointIndex, + ); + + const applyStates = useSelector( + (state: RootState) => state.state.applyStates, + ); + + const pendingApplyStates = applyStates.filter( + (state) => state.status === "done", + ); + + const hasClosedAllStreams = applyStates.every( + (state) => state.status === "closed", + ); + + const isCurCheckpoint = Math.floor(index / 2) === curCheckpointIndex; + const hasPendingApplies = pendingApplyStates.length > 0; + + return ( +
+
+ + {isCurCheckpoint && ( +
+ {hasPendingApplies && ( + + )} + {hasClosedAllStreams && } +
+ )} + +
+ + + +
+
+ ); +} diff --git a/gui/src/components/StepContainer/ResponseActions.tsx b/gui/src/components/StepContainer/ResponseActions.tsx new file mode 100644 index 000000000..66d62575c --- /dev/null +++ b/gui/src/components/StepContainer/ResponseActions.tsx @@ -0,0 +1,65 @@ +import { BarsArrowDownIcon, TrashIcon } from "@heroicons/react/24/outline"; +import { stripImages } from "core/llm/images"; +import { CopyIconButton } from "../gui/CopyIconButton"; +import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; +import { useSelector } from "react-redux"; +import { RootState } from "../../redux/store"; +import { ChatHistoryItem } from "core"; +import FeedbackButtons from "./FeedbackButtons"; +import MultifileEditActions from "./MultifileEditActions"; + +export interface ResponseActionsProps { + isTruncated: boolean; + onContinueGeneration: () => void; + index: number; + onDelete: () => void; + item: ChatHistoryItem; +} + +export default function ResponseActions({ + onContinueGeneration, + index, + item, + isTruncated, + onDelete, +}: ResponseActionsProps) { + const isInMultifileEdit = useSelector( + (store: RootState) => store.state.isMultifileEdit, + ); + + // Only render delete button if there is more than one message + const shouldRenderDelete = index !== 1; + + if (isInMultifileEdit) { + return ; + } + + return ( +
+ {isTruncated && ( + + + + )} + + {shouldRenderDelete && ( + + + + )} + + + + +
+ ); +} diff --git a/gui/src/components/StepContainer/StepContainer.tsx b/gui/src/components/StepContainer/StepContainer.tsx new file mode 100644 index 000000000..f5673e4e8 --- /dev/null +++ b/gui/src/components/StepContainer/StepContainer.tsx @@ -0,0 +1,115 @@ +import { ChatHistoryItem } from "core"; +import { stripImages } from "core/llm/images"; +import { useEffect, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import styled from "styled-components"; +import { vscBackground } from ".."; +import useUIConfig from "../../hooks/useUIConfig"; +import { RootState } from "../../redux/store"; +import { getFontSize } from "../../util"; +import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; +import ResponseActions from "./ResponseActions"; +import { deleteMessage } from "../../redux/slices/stateSlice"; + +interface StepContainerProps { + item: ChatHistoryItem; + index: number; + isLast: boolean; +} + +const ContentDiv = styled.div<{ fontSize?: number }>` + padding-top: 4px; + background-color: ${vscBackground}; + font-size: ${getFontSize()}px; + overflow: hidden; +`; + +export default function StepContainer(props: StepContainerProps) { + const dispatch = useDispatch(); + const [isTruncated, setIsTruncated] = useState(false); + const active = useSelector((store: RootState) => store.state.active); + const curCheckpointIndex = useSelector( + (store: RootState) => store.state.curCheckpointIndex, + ); + const isMultifileEdit = useSelector( + (store: RootState) => store.state.isMultifileEdit, + ); + const uiConfig = useUIConfig(); + const shouldHideActions = active && props.isLast; + const isStepAheadOfCurCheckpoint = + isMultifileEdit && Math.floor(props.index / 2) > curCheckpointIndex; + + useEffect(() => { + if (!active) { + const content = stripImages(props.item.message.content).trim(); + const endingPunctuation = [".", "?", "!", "```"]; + + // If not ending in punctuation or emoji, we assume the response got truncated + if ( + !( + endingPunctuation.some((p) => content.endsWith(p)) || + /\p{Emoji}/u.test(content.slice(-2)) + ) + ) { + setIsTruncated(true); + } else { + setIsTruncated(false); + } + } + }, [props.item.message.content, active]); + + function onDelete() { + dispatch(deleteMessage(props.index)); + } + + function onContinueGeneration() { + window.postMessage( + { + messageType: "userInput", + data: { + input: "Continue your response exactly where you left off:", + }, + }, + "*", + ); + } + + return ( +
+ + {uiConfig?.displayRawMarkdown ? ( +
+            {stripImages(props.item.message.content)}
+          
+ ) : ( + + )} +
+ {/* We want to occupy space in the DOM regardless of whether the actions are visible to avoid jank on */} +
+ {!shouldHideActions && ( + + )} +
+
+ ); +} diff --git a/gui/src/components/StepContainer/UndoAndRedoButtons.tsx b/gui/src/components/StepContainer/UndoAndRedoButtons.tsx new file mode 100644 index 000000000..2ee69a11a --- /dev/null +++ b/gui/src/components/StepContainer/UndoAndRedoButtons.tsx @@ -0,0 +1,61 @@ +import { useDispatch, useSelector } from "react-redux"; +import { RootState } from "../../redux/store"; +import { + ArrowUturnLeftIcon, + ArrowUturnRightIcon, +} from "@heroicons/react/24/outline"; +import { setCurCheckpointIndex } from "../../redux/slices/stateSlice"; +import { useContext } from "react"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; + +export default function UndoAndRedoButtons() { + const dispatch = useDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + + const checkpoints = useSelector( + (store: RootState) => store.state.checkpoints, + ); + + const curCheckpointIndex = useSelector( + (store: RootState) => store.state.curCheckpointIndex, + ); + + const shouldRenderRedo = curCheckpointIndex !== checkpoints.length - 1; + + async function handleUndoOrRedo(type: "undo" | "redo") { + const checkpointIndex = Math.max( + 0, + type === "undo" ? curCheckpointIndex - 1 : curCheckpointIndex + 1, + ); + + const checkpoint = checkpoints[checkpointIndex]; + + for (const [filepath, prevFileContent] of Object.entries(checkpoint)) { + ideMessenger.post("overwriteFile", { filepath, prevFileContent }); + } + + dispatch(setCurCheckpointIndex(checkpointIndex)); + } + + return ( +
+ + + {shouldRenderRedo && ( + + )} +
+ ); +} diff --git a/gui/src/components/StepContainer/index.ts b/gui/src/components/StepContainer/index.ts new file mode 100644 index 000000000..41d4fa945 --- /dev/null +++ b/gui/src/components/StepContainer/index.ts @@ -0,0 +1 @@ +export { default } from "./StepContainer"; diff --git a/gui/src/components/find/FindWidget.tsx b/gui/src/components/find/FindWidget.tsx index 3089803da..60a9bf2a9 100644 --- a/gui/src/components/find/FindWidget.tsx +++ b/gui/src/components/find/FindWidget.tsx @@ -1,19 +1,19 @@ -import { - useRef, - useEffect, - useState, - RefObject, - useCallback, - useMemo, -} from "react"; -import { RootState } from "../../redux/store"; -import { useSelector } from "react-redux"; -import { HeaderButton, Input } from ".."; import { ArrowDownIcon, ArrowUpIcon, XMarkIcon, } from "@heroicons/react/24/outline"; +import { + RefObject, + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from "react"; +import { useSelector } from "react-redux"; +import { HeaderButton, Input } from ".."; +import { RootState } from "../../redux/store"; import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; interface SearchMatch { @@ -119,7 +119,7 @@ export const useFindWidget = (searchRef: RefObject) => { // Handle keyboard shortcuts for navigation useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { - if (event.metaKey && event.key.toLowerCase() === "f") { + if (event.metaKey && event.key.toLowerCase() === "f" && !event.shiftKey) { event.preventDefault(); event.stopPropagation(); openWidget(); @@ -389,7 +389,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); previousMatch(); }} - className="h-4 w-4 focus:ring focus:ring-1" + className="h-4 w-4 focus:ring" disabled={matches.length < 2 || active} > @@ -401,7 +401,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); nextMatch(); }} - className="h-4 w-4 focus:ring focus:ring-1" + className="h-4 w-4 focus:ring" disabled={matches.length < 2 || active} > @@ -420,7 +420,7 @@ export const useFindWidget = (searchRef: RefObject) => { e.stopPropagation(); setCaseSensitive((curr) => !curr); }} - className="h-5 w-6 rounded-full border text-xs focus:outline-none focus:ring focus:ring-1" + className="h-5 w-6 rounded-full border text-xs focus:outline-none focus:ring" > Aa @@ -428,7 +428,7 @@ export const useFindWidget = (searchRef: RefObject) => { setOpen(false)} - className="focus:ring focus:ring-1" + className="focus:ring" > diff --git a/gui/src/components/gui/StepContainer.tsx b/gui/src/components/gui/StepContainer.tsx deleted file mode 100644 index 1eba7ee91..000000000 --- a/gui/src/components/gui/StepContainer.tsx +++ /dev/null @@ -1,169 +0,0 @@ -import { - BarsArrowDownIcon, - HandThumbDownIcon, - HandThumbUpIcon, - TrashIcon, -} from "@heroicons/react/24/outline"; -import { ChatHistoryItem } from "core"; -import { stripImages } from "core/llm/images"; -import { useContext, useEffect, useState } from "react"; -import { useSelector } from "react-redux"; -import styled from "styled-components"; -import { vscBackground, vscInputBackground } from ".."; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import useUIConfig from "../../hooks/useUIConfig"; -import { RootState } from "../../redux/store"; -import { getFontSize } from "../../util"; -import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview"; -import { CopyIconButton } from "./CopyIconButton"; -import HeaderButtonWithToolTip from "./HeaderButtonWithToolTip"; - -interface StepContainerProps { - item: ChatHistoryItem; - onReverse: () => void; - onUserInput: (input: string) => void; - onRetry: () => void; - onContinueGeneration: () => void; - onDelete: () => void; - open: boolean; - isFirst: boolean; - isLast: boolean; - index: number; - modelTitle?: string; -} - -const ContentDiv = styled.div<{ isUserInput: boolean; fontSize?: number }>` - padding-top: 4px; - background-color: ${(props) => - props.isUserInput ? vscInputBackground : vscBackground}; - font-size: ${(props) => props.fontSize || getFontSize()}px; - overflow: hidden; -`; - -function StepContainer(props: StepContainerProps) { - const active = useSelector((store: RootState) => store.state.active); - const [truncatedEarly, setTruncatedEarly] = useState(false); - const ideMessenger = useContext(IdeMessengerContext); - const [feedback, setFeedback] = useState(undefined); - const sessionId = useSelector((store: RootState) => store.state.sessionId); - - const isUserInput = props.item.message.role === "user"; - const uiConfig = useUIConfig(); - const shouldRenderActions = !active || !props.isLast; - - useEffect(() => { - if (!active) { - const content = stripImages(props.item.message.content).trim(); - const endingPunctuation = [".", "?", "!", "```"]; - - // If not ending in punctuation or emoji, we assume the response got truncated - if ( - !( - endingPunctuation.some((p) => content.endsWith(p)) || - /\p{Emoji}/u.test(content.slice(-2)) - ) - ) { - setTruncatedEarly(true); - } else { - setTruncatedEarly(false); - } - } - }, [props.item.message.content, active]); - - const sendFeedback = (feedback: boolean) => { - setFeedback(feedback); - if (props.item.promptLogs?.length) { - for (const promptLog of props.item.promptLogs) { - ideMessenger.post("devdata/log", { - tableName: "chat", - data: { ...promptLog, feedback, sessionId }, - }); - } - } - }; - - return ( -
- -
- {truncatedEarly && ( - - - - )} - - {props.index !== 1 && ( - - - - )} - - - - sendFeedback(true)} - > - - - - sendFeedback(false)} - > - - -
-
- ); -} - -export default StepContainer; diff --git a/gui/src/components/index.ts b/gui/src/components/index.ts index 7a04bf43a..3a384c995 100644 --- a/gui/src/components/index.ts +++ b/gui/src/components/index.ts @@ -109,7 +109,6 @@ export function parseColorForHex(colorVar: string): string { colorVar, ); if (value.startsWith("#")) { - console.log("OAIJFIOJOOJOIO", colorVar, value, value.slice(0, 7)); return value.slice(0, 7); } diff --git a/gui/src/components/mainInput/AcceptRejectAllButtons.tsx b/gui/src/components/mainInput/AcceptRejectAllButtons.tsx deleted file mode 100644 index aff8355e0..000000000 --- a/gui/src/components/mainInput/AcceptRejectAllButtons.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { useContext } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { RootState } from "../../redux/store"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { updateApplyState } from "../../redux/slices/uiStateSlice"; -import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; -export default function AcceptRejectAllButtons() { - const dispatch = useDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - - const applyStates = useSelector( - (state: RootState) => state.uiState.applyStates, - ); - - const pendingApplyStates = applyStates.filter( - (state) => state.status === "done", - ); - - const handleAcceptAll = async () => { - for (const applyState of pendingApplyStates) { - ideMessenger.post("acceptDiff", { filepath: applyState.filepath }); - dispatch( - updateApplyState({ - streamId: applyState.streamId, - status: "closed", - }), - ); - } - }; - - const handleRejectAll = async () => { - for (const applyState of pendingApplyStates) { - ideMessenger.post("rejectDiff", { filepath: applyState.filepath }); - dispatch( - updateApplyState({ - streamId: applyState.streamId, - status: "closed", - }), - ); - } - }; - - return ( -
- - -
- ); -} diff --git a/gui/src/components/mainInput/CodeBlockComponent.tsx b/gui/src/components/mainInput/CodeBlockComponent.tsx index 217fcc293..20d700c63 100644 --- a/gui/src/components/mainInput/CodeBlockComponent.tsx +++ b/gui/src/components/mainInput/CodeBlockComponent.tsx @@ -1,28 +1,25 @@ import { NodeViewWrapper } from "@tiptap/react"; import { ContextItemWithId } from "core"; -import { useDispatch, useSelector } from "react-redux"; import { vscBadgeBackground } from ".."; -import { RootState } from "../../redux/store"; import CodeSnippetPreview from "../markdown/CodeSnippetPreview"; +import { useSelector } from "react-redux"; +import { RootState } from "../../redux/store"; -export const CodeBlockComponent = ({ - node, - deleteNode, - selected, - editor, - updateAttributes, -}: any) => { - const dispatch = useDispatch(); +export const CodeBlockComponent = (props: any) => { + const { node, deleteNode, selected, editor, updateAttributes } = props; const item: ContextItemWithId = node.attrs.item; + // const contextItems = useSelector( + // (store: RootState) => + // store.state.history[store.state.history.length - 1].contextItems, + // ); + // const isFirstContextItem = item.id === contextItems[0]?.id; + const isFirstContextItem = false; - const contextItems = useSelector( - (state: RootState) => state.state.contextItems, - ); return ( (null); - const isInMultifileEdit = useSelector( - (state: RootState) => state.state.isInMultifileEdit, - ); - - const shouldShowAcceptRejectButtons = - props.isMainInput && isInMultifileEdit && !active; - useWebviewListener( "newSessionWithPrompt", async (data) => { @@ -118,8 +110,6 @@ function ContinueInputBox(props: ContinueInputBoxProps) { return (
- {shouldShowAcceptRejectButtons && } -
` - padding: 4px 0; + padding-top: 4px; justify-content: space-between; gap: 1px; background-color: ${vscInputBackground}; @@ -103,7 +103,7 @@ function InputToolbar(props: InputToolbarProps) { isHidden={props.hidden} onClick={props.onClick} id="input-toolbar" - className="flex find-widget-skip" + className="find-widget-skip flex" >
diff --git a/gui/src/components/mainInput/MentionList.tsx b/gui/src/components/mainInput/MentionList.tsx index 1faee50d4..49e3196de 100644 --- a/gui/src/components/mainInput/MentionList.tsx +++ b/gui/src/components/mainInput/MentionList.tsx @@ -215,7 +215,7 @@ const MentionList = forwardRef((props: MentionListProps, ref) => { title: "New .prompt file", type: "action", action: () => { - ideMessenger.request("config/newPromptFile", undefined); + ideMessenger.post("config/newPromptFile", undefined); const { tr } = props.editor.view.state; const text = tr.doc.textBetween(0, tr.selection.from); const start = text.lastIndexOf("@"); diff --git a/gui/src/components/mainInput/TipTapEditor.tsx b/gui/src/components/mainInput/TipTapEditor.tsx index c2646415e..6da867b40 100644 --- a/gui/src/components/mainInput/TipTapEditor.tsx +++ b/gui/src/components/mainInput/TipTapEditor.tsx @@ -60,10 +60,11 @@ import { getSlashCommandDropdownOptions, } from "./getSuggestion"; import { - handleJetBrainsMetaKeyPress, - handleMetaKeyPress, -} from "./handleMetaKeyPress"; + handleJetBrainsOSRMetaKeyIssues, + handleVSCMetaKeyIssues, +} from "./handleMetaKeyIssues"; import { ComboBoxItem } from "./types"; +import useIsOSREnabled from "../../hooks/useIsOSREnabled"; const InputBoxDiv = styled.div<{ border?: string }>` resize: none; @@ -181,6 +182,8 @@ function TipTapEditor(props: TipTapEditorProps) { const inSubmenuRef = useRef(undefined); const inDropdownRef = useRef(false); + const isOSREnabled = useIsOSREnabled(); + const enterSubmenu = async (editor: Editor, providerId: string) => { const contents = editor.getText(); const indexOfAt = contents.lastIndexOf("@"); @@ -222,10 +225,6 @@ function TipTapEditor(props: TipTapEditorProps) { inDropdownRef.current = true; }; - const contextItems = useSelector( - (store: RootState) => store.state.contextItems, - ); - const defaultModel = useSelector(defaultModelSelector); const defaultModelRef = useUpdatingRef(defaultModel); @@ -495,19 +494,7 @@ function TipTapEditor(props: TipTapEditorProps) { content: props.editorState || mainEditorContent || "", onFocus: () => setIsEditorFocused(true), onBlur: () => setIsEditorFocused(false), - onUpdate: ({ editor, transaction }) => { - // If /edit is typed and no context items are selected, select the first - - if (contextItems.length > 0) { - return; - } - - const json = editor.getJSON(); - let codeBlock = json.content?.find((el) => el.type === "codeBlock"); - if (!codeBlock) { - return; - } - }, + // onUpdate editable: !active || props.isMainInput, }); @@ -551,17 +538,14 @@ function TipTapEditor(props: TipTapEditorProps) { * with those key actions. */ const handleKeyDown = async (e: KeyboardEvent) => { - if (!editorFocusedRef?.current) return; - setActiveKey(e.key); - // Handle meta key issues - if (isMetaEquivalentKeyPressed(e)) { - if (isJetBrains()) { - handleJetBrainsMetaKeyPress(e, editor); - } + if (!editorFocusedRef?.current || !isMetaEquivalentKeyPressed(e)) return; - await handleMetaKeyPress(e, editor); + if (isOSREnabled) { + handleJetBrainsOSRMetaKeyIssues(e, editor); + } else { + await handleVSCMetaKeyIssues(e, editor); } }; diff --git a/gui/src/components/mainInput/TutorialCard.tsx b/gui/src/components/mainInput/TutorialCard.tsx index 3a424e257..4e07ead6d 100644 --- a/gui/src/components/mainInput/TutorialCard.tsx +++ b/gui/src/components/mainInput/TutorialCard.tsx @@ -57,7 +57,7 @@ export function TutorialCard({ onClose }: TutorialCardProps) { - ideMessenger.request( + ideMessenger.post( "vscode/openMoveRightMarkdown", undefined, ) diff --git a/gui/src/components/mainInput/getSuggestion.ts b/gui/src/components/mainInput/getSuggestion.ts index 7711562ae..b52328148 100644 --- a/gui/src/components/mainInput/getSuggestion.ts +++ b/gui/src/components/mainInput/getSuggestion.ts @@ -89,7 +89,7 @@ function getSubActionsForSubmenuItem( label: "Open in new tab", icon: "trash", action: () => { - ideMessenger.request("context/removeDocs", { startUrl: item.id }); + ideMessenger.post("context/removeDocs", { startUrl: item.id }); }, }, ]; @@ -166,7 +166,7 @@ export function getContextProviderDropdownOptions( title: "Add more context providers", type: "action", action: () => { - ideMessenger.request( + ideMessenger.post( "openUrl", "https://docs.continue.dev/customization/context-providers#built-in-context-providers", ); @@ -196,7 +196,7 @@ export function getSlashCommandDropdownOptions( // id: "createPromptFile", // label: "Create Prompt File", // action: () => { - // ideMessenger.request("config/newPromptFile", undefined); + // ideMessenger.post("config/newPromptFile", undefined); // }, // name: "Create Prompt File", // }, diff --git a/gui/src/components/mainInput/handleMetaKeyPress.ts b/gui/src/components/mainInput/handleMetaKeyIssues.ts similarity index 74% rename from gui/src/components/mainInput/handleMetaKeyPress.ts rename to gui/src/components/mainInput/handleMetaKeyIssues.ts index fd122350f..35fd847c9 100644 --- a/gui/src/components/mainInput/handleMetaKeyPress.ts +++ b/gui/src/components/mainInput/handleMetaKeyIssues.ts @@ -1,41 +1,26 @@ +import { Editor } from "@tiptap/react"; import { KeyboardEvent } from "react"; import { isWebEnvironment } from "../../util"; -import { Editor } from "@tiptap/react"; const isWebEnv = isWebEnvironment(); -export const handleJetBrainsMetaKeyPress = ( +/** + * This handles various keypress issues when OSR is enabled + */ +export const handleJetBrainsOSRMetaKeyIssues = ( e: KeyboardEvent, editor: Editor, ) => { const selection = window.getSelection(); + const alter = e.shiftKey ? "extend" : "move"; const handlers: Record void> = { Backspace: () => handleJetBrainsMetaBackspace(editor), - ArrowLeft: () => - selection.modify( - e.shiftKey ? "extend" : "move", - "backward", - "lineboundary", - ), - ArrowRight: () => - selection.modify( - e.shiftKey ? "extend" : "move", - "forward", - "lineboundary", - ), - ArrowDown: () => - selection.modify( - e.shiftKey ? "extend" : "move", - "forward", - "documentboundary", - ), + ArrowLeft: () => selection.modify(alter, "backward", "lineboundary"), + ArrowRight: () => selection.modify(alter, "forward", "lineboundary"), + ArrowDown: () => selection.modify(alter, "forward", "documentboundary"), ArrowUp: () => { - selection.modify( - e.shiftKey ? "extend" : "move", - "backward", - "documentboundary", - ); + selection.modify(alter, "backward", "documentboundary"); }, }; @@ -46,7 +31,13 @@ export const handleJetBrainsMetaKeyPress = ( } }; -export const handleMetaKeyPress = async (e: KeyboardEvent, editor: Editor) => { +/** + * This handles reported issues with cut/copy/paste in .ipynb files in VSC + */ +export const handleVSCMetaKeyIssues = async ( + e: KeyboardEvent, + editor: Editor, +) => { const text = editor.state.doc.textBetween( editor.state.selection.from, editor.state.selection.to, diff --git a/gui/src/components/markdown/CodeSnippetPreview.tsx b/gui/src/components/markdown/CodeSnippetPreview.tsx index 639e14cc8..39c09cfb6 100644 --- a/gui/src/components/markdown/CodeSnippetPreview.tsx +++ b/gui/src/components/markdown/CodeSnippetPreview.tsx @@ -124,6 +124,7 @@ function CodeSnippetPreview(props: CodeSnippetPreviewProps) { source={`${fence}${getMarkdownLanguageTagForFile( props.item.description.split(" ")[0], )} ${props.item.description}\n${content}\n${fence}`} + contextItems={[props.item]} />
diff --git a/gui/src/components/markdown/StepContainerPreActionButtons.tsx b/gui/src/components/markdown/StepContainerPreActionButtons.tsx index e14cd7b09..21fafc2f5 100644 --- a/gui/src/components/markdown/StepContainerPreActionButtons.tsx +++ b/gui/src/components/markdown/StepContainerPreActionButtons.tsx @@ -13,10 +13,10 @@ import HeaderButtonWithToolTip from "../gui/HeaderButtonWithToolTip"; import { CopyIconButton } from "../gui/CopyIconButton"; import useUIConfig from "../../hooks/useUIConfig"; import { v4 as uuidv4 } from "uuid"; -import { useApplyCodeBlock } from "./utils/useApplyCodeBlock"; import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useSelector } from "react-redux"; import { RootState } from "../../redux/store"; +import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; const TopDiv = styled.div` outline: 0.5px solid rgba(153, 153, 152); @@ -66,12 +66,8 @@ export default function StepContainerPreActionButtons({ const uiConfig = useUIConfig(); const streamIdRef = useRef(null); const nextCodeBlockIndex = useSelector( - (state: RootState) => state.uiState.nextCodeBlockToApplyIndex, + (state: RootState) => state.state.nextCodeBlockToApplyIndex, ); - const onClickApply = useApplyCodeBlock({ - codeBlockContent, - streamId: streamIdRef.current, - }); const isBottomToolbarPosition = uiConfig?.codeBlockToolbarPosition == "bottom"; @@ -83,10 +79,19 @@ export default function StepContainerPreActionButtons({ streamIdRef.current = uuidv4(); } + const defaultModel = useSelector(defaultModelSelector); + function onClickApply() { + ideMessenger.post("applyToFile", { + streamId: streamIdRef.current, + text: codeBlockContent, + curSelectedModelTitle: defaultModel.title, + }); + } + // Handle apply keyboard shortcut useWebviewListener( "applyCodeFromChat", - onClickApply, + async () => onClickApply(), [isNextCodeBlock, codeBlockContent], !isNextCodeBlock, ); diff --git a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx index 9d4f965f7..286277d4f 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/ApplyActions.tsx @@ -33,16 +33,17 @@ export default function ApplyActions(props: ApplyActionsProps) { ); case "done": return ( -
- - {`${props.applyState.numDiffs === 1 ? "1 diff" : `${props.applyState.numDiffs} diffs`} remaining`} +
+ + {`${props.applyState.numDiffs === 1 ? "1 diff" : `${props.applyState.numDiffs} diffs`}`} + {` remaining`} - + - Applied - + + Applied + ); } diff --git a/gui/src/components/markdown/StepContainerPreToolbar/CopyButton.tsx b/gui/src/components/markdown/StepContainerPreToolbar/CopyButton.tsx index 99dfddfaa..195615380 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/CopyButton.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/CopyButton.tsx @@ -15,18 +15,18 @@ export default function CopyButton({ text }: CopyButtonProps) { onClick={copyText} >
{copied ? ( <> - Copied + Copied ) : ( <> - Copy + Copy )}
diff --git a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx index c95e7962d..6d8fc8d74 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/FileInfo.tsx @@ -12,7 +12,6 @@ export interface FileInfoProps { const FileInfo = ({ filepath, range }: FileInfoProps) => { const ideMessenger = useContext(IdeMessengerContext); - // TODO: Need to turn into relative or fq path function onClickFileName() { ideMessenger.post("showFile", { filepath, @@ -20,13 +19,13 @@ const FileInfo = ({ filepath, range }: FileInfoProps) => { } return ( -
+
- + {getBasename(filepath)} {range && ` ${range}`} diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index ac13c6d54..fbc43e5d2 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -1,21 +1,20 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline"; import { debounce } from "lodash"; import { useContext, useEffect, useRef, useState } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import styled, { keyframes } from "styled-components"; +import { useSelector } from "react-redux"; +import styled, { css, keyframes } from "styled-components"; import { v4 as uuidv4 } from "uuid"; import { defaultBorderRadius, lightGray, vscEditorBackground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useWebviewListener } from "../../../hooks/useWebviewListener"; -import { updateApplyState } from "../../../redux/slices/uiStateSlice"; import { RootState } from "../../../redux/store"; import { getFontSize } from "../../../util"; import { childrenToText } from "../utils"; -import { useApplyCodeBlock } from "../utils/useApplyCodeBlock"; import ApplyActions from "./ApplyActions"; import CopyButton from "./CopyButton"; import FileInfo from "./FileInfo"; import GeneratingCodeLoader from "./GeneratingCodeLoader"; +import { defaultModelSelector } from "../../../redux/selectors/modelSelectors"; const fadeInAnimation = keyframes` from { @@ -26,13 +25,19 @@ const fadeInAnimation = keyframes` } `; -const TopDiv = styled.div` +const TopDiv = styled.div<{ active?: boolean }>` outline: 1px solid rgba(153, 153, 152); outline-offset: -0.5px; border-radius: ${defaultBorderRadius}; margin-bottom: 8px !important; background-color: ${vscEditorBackground}; - animation: ${fadeInAnimation} 300ms ease-out forwards; + min-width: 0; + ${(props) => + props.active + ? "animation: none;" + : css` + animation: ${fadeInAnimation} 300ms ease-out forwards; + `} `; const ToolbarDiv = styled.div<{ isExpanded: boolean }>` @@ -60,27 +65,23 @@ export interface StepContainerPreToolbarProps { export default function StepContainerPreToolbar( props: StepContainerPreToolbarProps, ) { - const dispatch = useDispatch(); const ideMessenger = useContext(IdeMessengerContext); - const streamIdRef = useRef(null); + const streamIdRef = useRef(uuidv4()); const wasGeneratingRef = useRef(props.isGeneratingCodeBlock); const isMultifileEdit = useSelector( - (state: RootState) => state.state.isInMultifileEdit, + (state: RootState) => state.state.isMultifileEdit, ); + const active = useSelector((state: RootState) => state.state.active); const [isExpanded, setIsExpanded] = useState(isMultifileEdit ? false : true); const [codeBlockContent, setCodeBlockContent] = useState(""); const isChatActive = useSelector((state: RootState) => state.state.active); - const onClickApply = useApplyCodeBlock({ - streamId: streamIdRef.current, - filepath: props.filepath, - codeBlockContent: props.codeBlockContent, - }); + const nextCodeBlockIndex = useSelector( - (state: RootState) => state.uiState.nextCodeBlockToApplyIndex, + (state: RootState) => state.state.nextCodeBlockToApplyIndex, ); const applyState = useSelector((store: RootState) => - store.uiState.applyStates.find( + store.state.applyStates.find( (state) => state.streamId === streamIdRef.current, ), ); @@ -97,14 +98,20 @@ export default function StepContainerPreToolbar( const isNextCodeBlock = nextCodeBlockIndex === props.codeBlockIndex; const hasFileExtension = /\.[0-9a-z]+$/i.test(props.filepath); - if (streamIdRef.current === null) { - streamIdRef.current = uuidv4(); + const defaultModel = useSelector(defaultModelSelector); + function onClickApply() { + ideMessenger.post("applyToFile", { + streamId: streamIdRef.current, + filepath: props.filepath, + text: codeBlockContent, + curSelectedModelTitle: defaultModel.title, + }); } // Handle apply keyboard shortcut useWebviewListener( "applyCodeFromChat", - onClickApply, + async () => onClickApply(), [isNextCodeBlock, codeBlockContent], !isNextCodeBlock, ); @@ -138,23 +145,17 @@ export default function StepContainerPreToolbar( }, [isGeneratingCodeBlock]); function onClickAcceptApply() { - ideMessenger.post("acceptDiff", { filepath: props.filepath }); - dispatch( - updateApplyState({ - streamId: streamIdRef.current, - status: "closed", - }), - ); + ideMessenger.post("acceptDiff", { + filepath: props.filepath, + streamId: streamIdRef.current, + }); } function onClickRejectApply() { - ideMessenger.post("rejectDiff", { filepath: props.filepath }); - dispatch( - updateApplyState({ - streamId: streamIdRef.current, - status: "closed", - }), - ); + ideMessenger.post("rejectDiff", { + filepath: props.filepath, + streamId: streamIdRef.current, + }); } function onClickExpand() { @@ -168,19 +169,21 @@ export default function StepContainerPreToolbar( } return ( - + -
+
- +
+ +
-
+
{isGeneratingCodeBlock && ( processCodeBlocks], rehypePlugins: [ @@ -238,13 +236,14 @@ const StyledMarkdownPreview = memo(function StyledMarkdownPreview( code: ({ node, ...codeProps }) => { const content = getCodeChildrenContent(codeProps.children); - const ctxItem = contextItems.find((ctxItem) => - ctxItem.uri?.value.includes(content), - ); - - if (ctxItem) { - const rif = ctxItemToRifWithContents(ctxItem); - return ; + if (props.contextItems) { + const ctxItem = props.contextItems.find((ctxItem) => + ctxItem.uri?.value.includes(content), + ); + if (ctxItem) { + const rif = ctxItemToRifWithContents(ctxItem); + return ; + } } return {codeProps.children}; diff --git a/gui/src/components/markdown/utils/index.ts b/gui/src/components/markdown/utils.ts similarity index 100% rename from gui/src/components/markdown/utils/index.ts rename to gui/src/components/markdown/utils.ts diff --git a/gui/src/components/markdown/utils/useApplyCodeBlock.ts b/gui/src/components/markdown/utils/useApplyCodeBlock.ts deleted file mode 100644 index cb016e1d8..000000000 --- a/gui/src/components/markdown/utils/useApplyCodeBlock.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { useContext } from "react"; -import { useDispatch, useSelector } from "react-redux"; -import { IdeMessengerContext } from "../../../context/IdeMessenger"; -import { - incrementNextCodeBlockToApplyIndex, - updateApplyState, -} from "../../../redux/slices/uiStateSlice"; -import { defaultModelSelector } from "../../../redux/selectors/modelSelectors"; - -export interface useApplyCodeBlock { - streamId: string; - filepath?: string; - codeBlockContent: string; -} - -export function useApplyCodeBlock({ - streamId, - filepath, - codeBlockContent, -}: useApplyCodeBlock) { - const dispatch = useDispatch(); - const ideMessenger = useContext(IdeMessengerContext); - const defaultModel = useSelector(defaultModelSelector); - - const applyCodeBlock = async () => { - dispatch( - updateApplyState({ - streamId, - filepath, - status: "streaming", - }), - ); - - await ideMessenger.request("applyToFile", { - text: codeBlockContent, - streamId, - curSelectedModelTitle: defaultModel.title, - filepath, - }); - - dispatch(incrementNextCodeBlockToApplyIndex({})); - }; - - return applyCodeBlock; -} diff --git a/gui/src/editorInset/EditorInset.tsx b/gui/src/editorInset/EditorInset.tsx index 4b7b55ab8..7e8e5fde1 100644 --- a/gui/src/editorInset/EditorInset.tsx +++ b/gui/src/editorInset/EditorInset.tsx @@ -35,7 +35,7 @@ function EditorInset() { if (!elementRef.current) return; console.log("Height: ", elementRef.current.clientHeight); - ideMessenger.request("jetbrains/editorInsetHeight", { + ideMessenger.post("jetbrains/editorInsetHeight", { height: elementRef.current.clientHeight, }); }); diff --git a/gui/src/hooks/useAuth.tsx b/gui/src/hooks/useAuth.tsx index 49961df8b..994c8c1e7 100644 --- a/gui/src/hooks/useAuth.tsx +++ b/gui/src/hooks/useAuth.tsx @@ -68,7 +68,7 @@ export function useAuth(): { confirmText="Yes, log out" text={"Are you sure you want to log out of Continue?"} onConfirm={() => { - ideMessenger.request("logoutOfControlPlane", undefined); + ideMessenger.post("logoutOfControlPlane", undefined); }} />, ), diff --git a/gui/src/hooks/useChatHandler.ts b/gui/src/hooks/useChatHandler.ts index 2e35acc53..ce599454d 100644 --- a/gui/src/hooks/useChatHandler.ts +++ b/gui/src/hooks/useChatHandler.ts @@ -23,18 +23,18 @@ import resolveEditorContent, { import { IIdeMessenger } from "../context/IdeMessenger"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; import { - addContextItems, addPromptCompletionPair, clearLastResponse, initNewActiveMessage, resubmitAtIndex, + setCurCheckpointIndex, setInactive, setIsGatheringContext, setIsInMultifileEdit, setMessageAtIndex, streamUpdate, } from "../redux/slices/stateSlice"; -import { resetNextCodeBlockToApplyIndex } from "../redux/slices/uiStateSlice"; +import { resetNextCodeBlockToApplyIndex } from "../redux/slices/stateSlice"; import { RootState } from "../redux/store"; import useHistory from "./useHistory"; @@ -50,10 +50,6 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { (store: RootState) => store.state.config.slashCommands || [], ); - const contextItems = useSelector( - (state: RootState) => state.state.contextItems, - ); - const history = useSelector((store: RootState) => store.state.history); const active = useSelector((store: RootState) => store.state.active); const activeRef = useRef(active); @@ -195,6 +191,10 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { // Reset current code block index dispatch(resetNextCodeBlockToApplyIndex()); + if (index) { + dispatch(setCurCheckpointIndex(Math.floor(index / 2))); + } + const shouldGatherContext = modifiers.useCodebase || hasSlashCommandOrContextProvider(editorState); @@ -226,26 +226,33 @@ function useChatHandler(dispatch: Dispatch, ideMessenger: IIdeMessenger) { .slice(0, 1000) .join("\n"); } - selectedContextItems.unshift({ - content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath( - currentFile.path, - await ideMessenger.ide.getWorkspaceDirs(), - )}\n${currentFileContents}\n\`\`\``, - name: `Active file: ${getBasename(currentFile.path)}`, - description: currentFile.path, - id: { - itemId: currentFile.path, - providerTitle: "file", - }, - uri: { - type: "file", - value: currentFile.path, - }, - }); + if ( + !selectedContextItems.find( + (item) => item.uri?.value === currentFile.path, + ) + ) { + // don't add the file if it's already in the context items + selectedContextItems.unshift({ + content: `The following file is currently open. Don't reference it if it's not relevant to the user's message.\n\n\`\`\`${getRelativePath( + currentFile.path, + await ideMessenger.ide.getWorkspaceDirs(), + )}\n${currentFileContents}\n\`\`\``, + name: `Active file: ${getBasename(currentFile.path)}`, + description: currentFile.path, + id: { + itemId: currentFile.path, + providerTitle: "file", + }, + uri: { + type: "file", + value: currentFile.path, + }, + }); + } } } - dispatch(addContextItems(contextItems)); + // dispatch(addContextItems(contextItems)); const message: ChatMessage = { role: "user", diff --git a/gui/src/hooks/useCopy.tsx b/gui/src/hooks/useCopy.tsx index e8d880828..4daa0b933 100644 --- a/gui/src/hooks/useCopy.tsx +++ b/gui/src/hooks/useCopy.tsx @@ -9,7 +9,7 @@ export default function useCopy(text: string | (() => string)) { const copyText = useCallback(() => { const textVal = typeof text === "string" ? text : text(); if (isJetBrains()) { - ideMessenger.request("copyText", { text: textVal }); + ideMessenger.post("copyText", { text: textVal }); } else { navigator.clipboard.writeText(textVal); } diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index 1d8963b5e..f159ffea3 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -94,6 +94,7 @@ function useHistory(dispatch: Dispatch) { title: title, sessionId: stateCopy.sessionId, workspaceDirectory: window.workspacePaths?.[0] || "", + checkpoints: stateCopy.checkpoints, }; return await ideMessenger.request("history/save", sessionInfo); @@ -121,9 +122,9 @@ function useHistory(dispatch: Dispatch) { if (result.status === "error") { throw new Error(result.error); } - const json = result.content; - dispatch(newSession(json)); - return json; + const persistedSessionInfo = result.content; + dispatch(newSession(persistedSessionInfo)); + return persistedSessionInfo; } async function loadLastSession(): Promise { diff --git a/gui/src/hooks/useIsOSREnabled.ts b/gui/src/hooks/useIsOSREnabled.ts new file mode 100644 index 000000000..10ad04756 --- /dev/null +++ b/gui/src/hooks/useIsOSREnabled.ts @@ -0,0 +1,21 @@ +import { useState, useEffect, useContext } from "react"; +import { isJetBrains } from "../util"; +import { useWebviewListener } from "./useWebviewListener"; +import { IdeMessengerContext } from "../context/IdeMessenger"; + +export default function useIsOSREnabled() { + const [isOSREnabled, setIsOSREnabled] = useState(false); + const ideMessenger = useContext(IdeMessengerContext); + + useWebviewListener("jetbrains/isOSREnabled", async (isOSREnabled) => { + setIsOSREnabled(isOSREnabled); + }); + + useEffect(() => { + if (isJetBrains()) { + ideMessenger.post("jetbrains/isOSREnabled", undefined); + } + }, []); + + return isOSREnabled; +} diff --git a/gui/src/hooks/useSetup.ts b/gui/src/hooks/useSetup.ts index 2fed805da..2d98b1011 100644 --- a/gui/src/hooks/useSetup.ts +++ b/gui/src/hooks/useSetup.ts @@ -1,5 +1,5 @@ import { Dispatch } from "@reduxjs/toolkit"; -import { useContext, useEffect, useState } from "react"; +import { useCallback, useContext, useEffect, useRef, useState } from "react"; import { useSelector } from "react-redux"; import { VSC_THEME_COLOR_VARS } from "../components"; import { IdeMessengerContext } from "../context/IdeMessenger"; @@ -21,11 +21,10 @@ import useChatHandler from "./useChatHandler"; import { useWebviewListener } from "./useWebviewListener"; function useSetup(dispatch: Dispatch) { - const [configLoaded, setConfigLoaded] = useState(false); - const ideMessenger = useContext(IdeMessengerContext); - const loadConfig = async () => { + const initialConfigLoad = useRef(false); + const loadConfig = useCallback(async () => { const result = await ideMessenger.request( "config/getSerializedProfileInfo", undefined, @@ -36,7 +35,7 @@ function useSetup(dispatch: Dispatch) { const { config, profileId } = result.content; dispatch(setConfig(config)); dispatch(setSelectedProfileId(profileId)); - setConfigLoaded(true); + initialConfigLoad.current = true; setLocalStorage("disableIndexing", config.disableIndexing || false); // Perform any actions needed with the config @@ -44,13 +43,13 @@ function useSetup(dispatch: Dispatch) { setLocalStorage("fontSize", config.ui.fontSize); document.body.style.fontSize = `${config.ui.fontSize}px`; } - }; + }, [dispatch, ideMessenger, initialConfigLoad]); // Load config from the IDE useEffect(() => { loadConfig(); const interval = setInterval(() => { - if (configLoaded) { + if (initialConfigLoad.current) { clearInterval(interval); return; } @@ -58,7 +57,7 @@ function useSetup(dispatch: Dispatch) { }, 2_000); return () => clearInterval(interval); - }, [configLoaded]); + }, [initialConfigLoad, loadConfig]); useEffect(() => { // Override persisted state @@ -112,7 +111,7 @@ function useSetup(dispatch: Dispatch) { }); const debouncedIndexDocs = debounce(() => { - ideMessenger.request("context/indexDocs", { reIndex: false }); + ideMessenger.post("context/indexDocs", { reIndex: false }); }, 1000); useWebviewListener("configUpdate", async () => { diff --git a/gui/src/hooks/useSubmenuContextProviders.tsx b/gui/src/hooks/useSubmenuContextProviders.tsx index fc0b0c71a..29abfc1c9 100644 --- a/gui/src/hooks/useSubmenuContextProviders.tsx +++ b/gui/src/hooks/useSubmenuContextProviders.tsx @@ -233,12 +233,12 @@ function useSubmenuContextProviders() { storeFields: ["id", "title", "description"], }); - const result = (await ideMessenger.request( + const result = await ideMessenger.request( "context/loadSubmenuItems", { title: description.title, }, - )) as WebviewMessengerResult<"context/loadSubmenuItems">; + ) if (result.status === "error") { console.error( diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 67c3547a7..5e55c5c64 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -169,6 +169,55 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["deepseek"], isOpenSource: false, }, + deepseekCoder2Lite: { + title: "DeepSeek Coder 2 Lite", + description: + "DeepSeek-Coder-V2-Lite-Instruct is an open-source code language model that supports 338 programming languages and offers a context length of up to 128,000 tokens.", + params: { + title: "DeepSeek-2-lite", + model: "deepseek-2-lite", + contextLength: 128_000, + }, + icon: "deepseek.png", + providerOptions: ["nebius"], + isOpenSource: true, + }, + moonshotChat: { + title: "Moonshot Chat", + description: "Moonshot AI provides high-performance large language models", + refUrl: "https://platform.moonshot.cn/", + params: { + title: "Moonshot-v1-8k", + model: "moonshot-v1-8k", + contextLength: 8192, + }, + icon: "moonshot.png", + dimensions: [ + { + name: "Context Window", + description: "The size of the model's context window", + options: { + "8K": { + model: "moonshot-v1-8k", + title: "Moonshot-v1-8k", + contextLength: 8192, + }, + "32K": { + model: "moonshot-v1-32k", + title: "Moonshot-v1-32k", + contextLength: 32768, + }, + "128K": { + model: "moonshot-v1-128k", + title: "Moonshot-v1-128k", + contextLength: 131072, + }, + }, + }, + ], + providerOptions: ["moonshot"], + isOpenSource: false, + }, mistralOs: { title: "Mistral", description: @@ -359,6 +408,18 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["groq"], isOpenSource: false, }, + llama3170bNemotron: { + title: "Llama 3.1 Nemotron 70B", + description: + "Llama-3.1-Nemotron-70B-Instruct is a large language model customized by NVIDIA to improve the helpfulness of LLM generated responses to user queries.", + params: { + title: "Llama 3.1 Nemotron 70B", + model: "llama3.1-70b-nemotron", + contextLength: 128_000, + }, + icon: "meta.png", + isOpenSource: true, + }, llama321bChat: { title: "Llama3.2 1b Chat", description: @@ -628,6 +689,18 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["mistral", "askSage"], isOpenSource: false, }, + mistralNemo: { + title: "Mistral Nemo", + description: + "Mistral Nemo Instruct is a large language model developed by Mistral AI and NVIDIA.", + params: { + title: "Mistral Nemo", + model: "mistral-nemo", + contextLength: 128_000, + }, + icon: "mistral.png", + isOpenSource: true, + }, geminiPro: { title: "Gemini Pro", description: "A highly capable model created by Google DeepMind", @@ -979,7 +1052,6 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["vertexai"], isOpenSource: false, }, - gpt4gov: { title: "GPT-4 gov", description: @@ -1048,6 +1120,61 @@ export const models: { [key: string]: ModelPackage } = { providerOptions: ["xAI"], isOpenSource: false, }, + gemma2_2b: { + title: "Gemma 2 2b IT", + description: + "Gemma 2 IT instruction-tuned language model developed by Google, designed for tasks like question answering, summarization, and reasoning.", + params: { + title: "Gemma 2 2b IT", + model: "gemma2-2b-it", + contextLength: 4000, + }, + isOpenSource: true, + }, + gemma2_9b: { + title: "Gemma 2 9b IT", + description: + "Gemma 2 IT instruction-tuned language model developed by Google, designed for tasks like question answering, summarization, and reasoning.", + params: { + title: "Gemma 2 9b IT", + model: "gemma2-9b-it", + contextLength: 8000, + }, + isOpenSource: true, + }, + phi3mini: { + title: "Microsoft Phi 3 mini", + description: + "Phi 3 Mini is a 3.8-billion-parameter language model developed by Microsoft.", + params: { + title: "Microsoft Phi 3 mini", + model: "phi-3-mini", + contextLength: 4000, + }, + isOpenSource: true, + }, + phi3medium: { + title: "Microsoft Phi 3 medium", + description: + "Phi 3 Medium is a 14-billion-parameter language model developed by Microsoft.", + params: { + title: "Microsoft Phi 3 medium", + model: "phi-3-medium", + contextLength: 128_000, + }, + isOpenSource: true, + }, + olmo7b: { + title: "OLMo 7b", + description: + "OLMo 7B Instruct HF is a 7-billion-parameter language model by the Allen Institute for AI, fine-tuned for question answering tasks.", + params: { + title: "OLMo 7b", + model: "olmo-7b", + contextLength: 2000, + }, + isOpenSource: true, + }, AUTODETECT: { title: "Autodetect", description: diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index 39613731b..3100f1ddc 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -116,6 +116,29 @@ export const providers: Partial> = { ], apiKeyUrl: "https://console.anthropic.com/account/keys", }, + moonshot: { + title: "Moonshot", + provider: "moonshot", + description: "Use the Moonshot API for LLMs", + longDescription: `[Visit our documentation](https://docs.continue.dev/reference/Model%20Providers/moonshot) for information on obtaining an API key.`, + icon: "moonshot.png", + tags: [ModelProviderTags.RequiresApiKey], + refPage: "moonshot", + apiKeyUrl: "https://docs.moonshot.cn/docs/getting-started", + packages: [ + models.moonshotChat, + ], + collectInputFor: [ + { + inputType: "text", + key: "apiKey", + label: "API Key", + placeholder: "Enter your Moonshot API key", + required: true, + }, + ...completionParamsInputsConfigs, + ], + }, azure: { title: "Azure OpenAI", provider: "azure", @@ -744,7 +767,22 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo ], icon: "nebius.png", tags: [ModelProviderTags.RequiresApiKey, ModelProviderTags.OpenSource], - packages: [models.llama31Chat, models.Qwen2Coder, models.mistralOs], + packages: [ + models.llama318bChat, + models.llama3170bChat, + models.llama31405bChat, + models.llama3170bNemotron, + models.mistral8x7b, + models.mistral8x22b, + models.mistralNemo, + models.phi3mini, + models.phi3medium, + models.gemma2_2b, + models.gemma2_9b, + models.Qwen2Coder, + models.deepseekCoder2Lite, + models.olmo7b, + ], apiKeyUrl: "https://studio.nebius.ai/settings/api-keys", }, }; diff --git a/gui/src/pages/edit/EditInputHeader.tsx b/gui/src/pages/edit/EditInputHeader.tsx new file mode 100644 index 000000000..00695e66b --- /dev/null +++ b/gui/src/pages/edit/EditInputHeader.tsx @@ -0,0 +1,114 @@ +import { CheckIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import { getBasename } from "core/util"; +import { useContext, useState } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import FileIcon from "../../components/FileIcon"; +import HeaderButtonWithToolTip from "../../components/gui/HeaderButtonWithToolTip"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { setEditDone, setEditStatus } from "../../redux/slices/editModeState"; +import { RootState } from "../../redux/store"; + +interface EditInputHeaderParams {} + +/** + * @description This is a class that represents an edit input header. + */ +export function EditInputHeader(editInputHeaderParams: EditInputHeaderParams) { + const dispatch = useDispatch(); + const ideMessenger = useContext(IdeMessengerContext); + const editModeState = useSelector((state: RootState) => state.editModeState); + + const [showCode, setShowCode] = useState(false); + + function onClick() { + ideMessenger.ide.showLines( + editModeState.highlightedCode.filepath, + editModeState.highlightedCode.range.start.line, + editModeState.highlightedCode.range.end.line, + ); + setShowCode(!showCode); + } + + async function showFullDiff() { + await ideMessenger.ide.showDiff( + editModeState.highlightedCode.filepath, + editModeState.fileAfterEdit, + 0, + ); + dispatch(setEditStatus({ status: "accepting:full-diff" })); + } + + return ( + <> +
+
+
+ + {getBasename(editModeState.highlightedCode.filepath)} ( + {editModeState.highlightedCode.range.start.line}- + {editModeState.highlightedCode.range.end.line}) +
+ {editModeState.editStatus === "accepting" || + editModeState.editStatus === "accepting:full-diff" ? ( +
+ {/* {editModeState.editStatus === "accepting" ? ( + <> + + + + + N diffs remaining + + + ) : ( +
hi
+ )} */} + +
+ + { + ideMessenger.post("edit/acceptReject", { + accept: false, + onlyFirst: false, + filepath: editModeState.highlightedCode.filepath, + }); + dispatch(setEditDone()); + }} + > + + + { + ideMessenger.post("edit/acceptReject", { + accept: true, + onlyFirst: false, + filepath: editModeState.highlightedCode.filepath, + }); + dispatch(setEditDone()); + }} + > + +
+
+ ) : null} +
+
+ + ); +} diff --git a/gui/src/pages/edit.tsx b/gui/src/pages/edit/index.tsx similarity index 52% rename from gui/src/pages/edit.tsx rename to gui/src/pages/edit/index.tsx index b2a7e4e77..c601c9650 100644 --- a/gui/src/pages/edit.tsx +++ b/gui/src/pages/edit/index.tsx @@ -1,28 +1,23 @@ import { ArrowLeftIcon } from "@heroicons/react/24/outline"; import { Editor, JSONContent } from "@tiptap/core"; import { InputModifiers } from "core"; -import { getBasename } from "core/util"; -import { usePostHog } from "posthog-js/react"; -import { useContext, useEffect, useState } from "react"; +import { stripImages } from "core/llm/images"; +import { useContext, useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { useNavigate } from "react-router-dom"; import styled from "styled-components"; import { defaultBorderRadius, lightGray, - parseColorForHex, - VSC_DIFF_INSERTED_LINE_BACKGROUND_VAR, - VSC_DIFF_REMOVED_LINE_BACKGROUND_VAR, vscForeground, -} from "../components"; -import FileIcon from "../components/FileIcon"; -import { NewSessionButton } from "../components/mainInput/NewSessionButton"; -import resolveEditorContent from "../components/mainInput/resolveInput"; -import TipTapEditor from "../components/mainInput/TipTapEditor"; -import { IdeMessengerContext } from "../context/IdeMessenger"; -import { setEditDone, submitEdit } from "../redux/slices/editModeState"; -import { RootState } from "../redux/store"; -import { getMetaKeyLabel } from "../util"; +} from "../../components"; +import { NewSessionButton } from "../../components/mainInput/NewSessionButton"; +import resolveEditorContent from "../../components/mainInput/resolveInput"; +import TipTapEditor from "../../components/mainInput/TipTapEditor"; +import { IdeMessengerContext } from "../../context/IdeMessenger"; +import { setEditDone, submitEdit } from "../../redux/slices/editModeState"; +import { RootState } from "../../redux/store"; +import { EditInputHeader } from "./EditInputHeader"; const TopDiv = styled.div` overflow-y: auto; @@ -33,6 +28,13 @@ const TopDiv = styled.div` } `; +const ToolbarDiv = styled.div` + padding: 8px; + border-bottom: 1px solid ${lightGray}; + border-radius: ${defaultBorderRadius}; + display: flex; +`; + const AcceptRejectButton = styled.div<{ backgroundColor: string; disabled: boolean; @@ -71,10 +73,19 @@ const EditHistoryDiv = styled.div` } `; -const EDIT_ALLOWS_CONTEXT_PROVIDERS = ["file", "code"]; +const EDIT_DISALLOWED_CONTEXT_PROVIDERS = [ + "codebase", + "tree", + "open", + "web", + "diff", + "folder", + "search", + "debugger", + "repo-map", +]; function Edit() { - const posthog = usePostHog(); const dispatch = useDispatch(); const navigate = useNavigate(); const ideMessenger = useContext(IdeMessengerContext); @@ -84,19 +95,17 @@ function Edit() { ); useEffect(() => {}, []); - const [showCode, setShowCode] = useState(false); - // Reusing the applyState logic which was just the fastest way to get this working useEffect(() => { if (editModeState.editStatus === "done") { - ideMessenger.request("edit/escape", undefined); + ideMessenger.post("edit/escape", undefined); navigate("/"); } }, [editModeState.editStatus]); const applyState = useSelector( (store: RootState) => - store.uiState.applyStates.find((state) => state.streamId === "edit") + store.state.applyStates.find((state) => state.streamId === "edit") ?.status ?? "closed", ); @@ -126,35 +135,7 @@ function Edit() {
-
{ - ideMessenger.ide.showLines( - editModeState.highlightedCode.filepath, - editModeState.highlightedCode.range.start.line, - editModeState.highlightedCode.range.end.line, - ); - setShowCode(!showCode); - }} - > - - {getBasename(editModeState.highlightedCode.filepath)} ( - {editModeState.highlightedCode.range.start.line}- - {editModeState.highlightedCode.range.end.line}) -
-
- } + header={} toolbarOptions={{ hideAddContext: true, hideImageUpload: true, @@ -168,13 +149,13 @@ function Edit() { }} placeholder={ ["streaming", "accepting"].includes(editModeState.editStatus) - ? "Enter instructions for edit" - : "Enter instructions for edit" + ? "Describe how to modify code" + : "Describe how to modify code" } border={`1px solid #aa0`} availableContextProviders={availableContextProviders.filter( (provider) => - EDIT_ALLOWS_CONTEXT_PROVIDERS.includes(provider.title), + !EDIT_DISALLOWED_CONTEXT_PROVIDERS.includes(provider.title), )} historyKey="edit" availableSlashCommands={[]} @@ -184,16 +165,22 @@ function Edit() { modifiers: InputModifiers, editor: Editor, ): Promise { - const [_, __, prompt] = await resolveEditorContent( - editorState, - { - noContext: true, - useCodebase: false, - }, - ideMessenger, - [], - ); - ideMessenger.request("edit/sendPrompt", { + const [contextItems, __, userInstructions] = + await resolveEditorContent( + editorState, + { + noContext: true, + useCodebase: false, + }, + ideMessenger, + [], + ); + + const prompt = [ + ...contextItems.map((item) => item.content), + stripImages(userInstructions), + ].join("\n\n"); + ideMessenger.post("edit/sendPrompt", { prompt, range: editModeState.highlightedCode, }); @@ -206,43 +193,6 @@ function Edit() {
- {["accepting", "streaming"].includes(editModeState.editStatus) && ( -
- { - ideMessenger.request("edit/acceptReject", { - accept: false, - onlyFirst: false, - filepath: editModeState.highlightedCode.filepath, - }); - dispatch(setEditDone()); - }} - > - {getMetaKeyLabel()}โ‡งโŒซ Reject all - - { - ideMessenger.request("edit/acceptReject", { - accept: true, - onlyFirst: false, - filepath: editModeState.highlightedCode.filepath, - }); - dispatch(setEditDone()); - }} - > - {getMetaKeyLabel()}โ‡งโŽ Accept all - -
- )} -
{ diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 4e3e82fc2..345fe6f37 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -25,11 +25,9 @@ import { vscBackground, } from "../../components"; import { ChatScrollAnchor } from "../../components/ChatScrollAnchor"; -import { useFindWidget } from "../../components/find/FindWidget"; -import StepContainer from "../../components/gui/StepContainer"; +import StepContainer from "../../components/StepContainer"; import TimelineItem from "../../components/gui/TimelineItem"; import ContinueInputBox from "../../components/mainInput/ContinueInputBox"; -import { defaultInputModifiers } from "../../components/mainInput/inputModifiers"; import { NewSessionButton } from "../../components/mainInput/NewSessionButton"; import { TutorialCard } from "../../components/mainInput/TutorialCard"; import { @@ -44,7 +42,6 @@ import { useWebviewListener } from "../../hooks/useWebviewListener"; import { defaultModelSelector } from "../../redux/selectors/modelSelectors"; import { clearLastResponse, - deleteMessage, newSession, setInactive, } from "../../redux/slices/stateSlice"; @@ -62,6 +59,7 @@ import { } from "../../util"; import { FREE_TRIAL_LIMIT_REQUESTS } from "../../util/freeTrial"; import { getLocalStorage, setLocalStorage } from "../../util/localStorage"; +import { useFindWidget } from "../../components/find/FindWidget"; const StopButton = styled.div` background-color: ${vscBackground}; @@ -159,11 +157,11 @@ export function Chat() { if (active) snapToBottom(); }, [active, snapToBottom]); - useEffect(() => { - setTimeout(() => { - smoothScrollToBottom(); - }, 400); - }, [smoothScrollToBottom, state.sessionId]); + // useEffect(() => { + // setTimeout(() => { + // smoothScrollToBottom(); + // }, 400); + // }, [smoothScrollToBottom, state.sessionId]); useEffect(() => { // Cmd + Backspace to delete current step @@ -290,7 +288,7 @@ export function Chat() { setLocalStorage("mainTextEntryCounter", 1); } }, - [state.history, state.contextItems, defaultModel, state, streamResponse], + [state.history, defaultModel, state, streamResponse], ); useWebviewListener( @@ -311,7 +309,8 @@ export function Chat() { [state.history], ); - const showScrollbar = state.config.ui?.showChatScrollbar || false; + const showScrollbar = + state.config.ui?.showChatScrollbar || window.innerHeight > 5000; return ( <> @@ -369,41 +368,7 @@ export function Chat() { {}} item={item} - onReverse={() => {}} - onRetry={() => { - streamResponse( - state.history[index - 1].editorState, - state.history[index - 1].modifiers ?? - defaultInputModifiers, - ideMessenger, - index - 1, - ); - }} - onContinueGeneration={() => { - window.postMessage( - { - messageType: "userInput", - data: { - input: - "Continue your response exactly where you left off:", - }, - }, - "*", - ); - }} - onDelete={() => { - dispatch(deleteMessage(index)); - }} - modelTitle={item.promptLogs?.[0]?.modelTitle ?? ""} />
diff --git a/gui/src/redux/slices/editModeState.ts b/gui/src/redux/slices/editModeState.ts index 4c5defeef..38091ccbf 100644 --- a/gui/src/redux/slices/editModeState.ts +++ b/gui/src/redux/slices/editModeState.ts @@ -1,12 +1,13 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { MessageContent } from "core"; import { RangeInFileWithContents } from "core/commands/util"; -import { EditModeArgs } from "core/protocol/ideWebview"; -type EditStatus = "not-started" | "streaming" | "accepting" | "done"; +import { EditModeArgs, EditStatus } from "core/protocol/ideWebview"; + interface EditModeState { highlightedCode?: RangeInFileWithContents; editStatus: EditStatus; previousInputs: MessageContent[]; + fileAfterEdit?: string; } const initialState: EditModeState = { @@ -22,22 +23,47 @@ export const editModeStateSlice = createSlice({ state.highlightedCode = payload.highlightedCode; state.editStatus = "not-started"; state.previousInputs = []; + state.fileAfterEdit = undefined; }, submitEdit: (state, { payload }: PayloadAction) => { state.previousInputs.push(payload); state.editStatus = "streaming"; }, - setEditStatus: (state, { payload }: PayloadAction) => { + setEditStatus: ( + state, + { + payload, + }: PayloadAction<{ status: EditStatus; fileAfterEdit?: string }>, + ) => { // Only allow valid transitions const currentStatus = state.editStatus; - if (currentStatus === "not-started" && payload === "streaming") { - state.editStatus = payload; - } else if (currentStatus === "streaming" && payload === "accepting") { - state.editStatus = payload; - } else if (currentStatus === "accepting" && payload === "done") { - state.editStatus = payload; - } else if (currentStatus === "done" && payload === "not-started") { - state.editStatus = payload; + if (currentStatus === "not-started" && payload.status === "streaming") { + state.editStatus = payload.status; + } else if ( + currentStatus === "streaming" && + payload.status === "accepting" + ) { + state.editStatus = payload.status; + state.fileAfterEdit = payload.fileAfterEdit; + } else if (currentStatus === "accepting" && payload.status === "done") { + state.editStatus = payload.status; + } else if ( + currentStatus === "accepting:full-diff" && + payload.status === "done" + ) { + state.editStatus = payload.status; + } else if ( + currentStatus === "accepting" && + payload.status === "accepting:full-diff" + ) { + state.editStatus = payload.status; + } else if ( + currentStatus === "accepting:full-diff" && + payload.status === "accepting" + ) { + state.editStatus = payload.status; + } else if (currentStatus === "done" && payload.status === "not-started") { + state.editStatus = payload.status; } }, addPreviousInput: (state, { payload }: PayloadAction) => { diff --git a/gui/src/redux/slices/stateSlice.ts b/gui/src/redux/slices/stateSlice.ts index e3ce22eb6..2d5cb1267 100644 --- a/gui/src/redux/slices/stateSlice.ts +++ b/gui/src/redux/slices/stateSlice.ts @@ -3,6 +3,7 @@ import { JSONContent } from "@tiptap/react"; import { ChatHistoryItem, ChatMessage, + Checkpoint, ContextItemId, ContextItemWithId, PersistedSessionInfo, @@ -14,26 +15,15 @@ import { stripImages } from "core/llm/images"; import { createSelector } from "reselect"; import { v4 as uuidv4, v4 } from "uuid"; import { RootState } from "../store"; - -export const memoizedContextItemsSelector = createSelector( - [(state: RootState) => state.state.history], - (history) => { - return history.reduce((acc, item) => { - acc.push(...item.contextItems); - return acc; - }, []); - }, -); +import { ApplyState } from "core/protocol/ideWebview"; // We need this to handle reorderings (e.g. a mid-array deletion) of the messages array. // The proper fix is adding a UUID to all chat messages, but this is the temp workaround. type ChatHistoryItemWithMessageId = ChatHistoryItem & { message: ChatMessage & { id: string }; }; - type State = { history: ChatHistoryItemWithMessageId[]; - contextItems: ContextItemWithId[]; ttsActive: boolean; active: boolean; isGatheringContext: boolean; @@ -44,12 +34,15 @@ type State = { mainEditorContent?: JSONContent; selectedProfileId: string; configError: ConfigValidationError[] | undefined; - isInMultifileEdit: boolean; + checkpoints: Checkpoint[]; + curCheckpointIndex: number; + isMultifileEdit: boolean; + applyStates: ApplyState[]; + nextCodeBlockToApplyIndex: number; }; const initialState: State = { history: [], - contextItems: [], ttsActive: false, active: false, isGatheringContext: false, @@ -72,7 +65,11 @@ const initialState: State = { sessionId: v4(), defaultModelTitle: "GPT-4", selectedProfileId: "local", - isInMultifileEdit: false, + checkpoints: [], + isMultifileEdit: false, + curCheckpointIndex: 0, + nextCodeBlockToApplyIndex: 0, + applyStates: [], }; export const stateSlice = createSlice({ @@ -143,9 +140,6 @@ export const stateSlice = createSlice({ state.history[index].contextItems = contextItems; } }, - addContextItems: (state, action: PayloadAction) => { - state.contextItems = state.contextItems.concat(action.payload); - }, resubmitAtIndex: ( state, { @@ -173,7 +167,6 @@ export const stateSlice = createSlice({ }); // https://github.com/continuedev/continue/pull/1021 - // state.contextItems = []; state.active = true; }, deleteMessage: (state, action: PayloadAction) => { @@ -190,7 +183,7 @@ export const stateSlice = createSlice({ ) => { state.history.push({ message: { role: "user", content: "", id: uuidv4() }, - contextItems: state.contextItems, + contextItems: [], editorState: payload.editorState, }); state.history.push({ @@ -201,9 +194,9 @@ export const stateSlice = createSlice({ }, contextItems: [], }); - // https://github.com/continuedev/continue/pull/1021 - // state.contextItems = []; + state.active = true; + state.curCheckpointIndex = state.curCheckpointIndex + 1; }, setMessageAtIndex: ( state, @@ -270,32 +263,15 @@ export const stateSlice = createSlice({ state.history = payload.history as any; state.title = payload.title; state.sessionId = payload.sessionId; + state.checkpoints = payload.checkpoints; + state.curCheckpointIndex = 0; } else { state.history = []; - state.contextItems = []; state.active = false; state.title = "New Session"; state.sessionId = v4(); - state.isInMultifileEdit = false; - } - }, - deleteContextWithIds: ( - state, - { - payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, - ) => { - const getKey = (id: ContextItemId) => `${id.providerTitle}-${id.itemId}`; - const ids = new Set(payload.ids.map(getKey)); - - if (payload.index === undefined) { - state.contextItems = state.contextItems.filter( - (item) => !ids.has(getKey(item.id)), - ); - } else { - state.history[payload.index].contextItems = state.history[ - payload.index - ].contextItems.filter((item) => !ids.has(getKey(item.id))); + state.checkpoints = []; + state.curCheckpointIndex = 0; } }, addHighlightedCode: ( @@ -304,46 +280,15 @@ export const stateSlice = createSlice({ payload, }: PayloadAction<{ rangeInFileWithContents: any; edit: boolean }>, ) => { - let contextItems = [...state.contextItems].map((item) => { + let contextItems = + state.history[state.history.length - 1].contextItems ?? []; + contextItems = contextItems.map((item) => { return { ...item, editing: false }; }); const base = payload.rangeInFileWithContents.filepath .split(/[\\/]/) .pop(); - // Merge if there is overlap - for (let i = 0; i < contextItems.length; i++) { - const item = contextItems[i]; - if (item.description === payload.rangeInFileWithContents.filepath) { - let newStart = payload.rangeInFileWithContents.range.start.line; - let newEnd = payload.rangeInFileWithContents.range.end.line; - let [oldStart, oldEnd] = item.name - .split("(")[1] - .split(")")[0] - .split("-") - .map((x: string) => parseInt(x) - 1); - if (newStart > oldEnd || newEnd < oldStart) { - continue; - } - const startLine = Math.min(newStart, oldStart); - const endLine = Math.max(newEnd, oldEnd); - - // const oldContents = item.content.split("\n"); - // const newContents = - // payload.rangeInFileWithContents.contents.split("\n"); - // const finalContents = []; - - contextItems[i] = { - ...item, - name: `${base} (${startLine + 1}-${endLine + 1})`, - content: payload.rangeInFileWithContents.contents, - editing: true, - editable: true, - }; - return { ...state, contextItems }; - } - } - const lineNums = `(${ payload.rangeInFileWithContents.range.start.line + 1 }-${payload.rangeInFileWithContents.range.end.line + 1})`; @@ -358,46 +303,7 @@ export const stateSlice = createSlice({ editing: true, editable: true, }); - - return { ...state, contextItems }; - }, - setEditingAtIds: ( - state, - { - payload, - }: PayloadAction<{ ids: ContextItemId[]; index: number | undefined }>, - ) => { - const ids = payload.ids.map((id) => id.itemId); - - if (typeof payload.index === "undefined") { - return { - ...state, - contextItems: state.contextItems.map((item) => { - return { - ...item, - editing: ids.includes(item.id.itemId), - }; - }), - }; - } else { - return { - ...state, - history: state.history.map((step, i) => { - if (i === payload.index) { - return { - ...step, - contextItems: step.contextItems.map((item) => { - return { - ...item, - editing: ids.includes(item.id.itemId), - }; - }), - }; - } - return step; - }), - }; - } + state.history[state.history.length - 1].contextItems = contextItems; }, setDefaultModel: ( state, @@ -418,23 +324,54 @@ export const stateSlice = createSlice({ selectedProfileId: payload, }; }, - setIsInMultifileEdit: (state, action: PayloadAction) => { - state.isInMultifileEdit = action.payload; + + setIsInMultifileEdit: (state, { payload }: PayloadAction) => { + state.isMultifileEdit = payload; + }, + setCurCheckpointIndex: (state, { payload }: PayloadAction) => { + state.curCheckpointIndex = payload; + }, + updateCurCheckpoint: ( + state, + { payload }: PayloadAction<{ filepath: string; content: string }>, + ) => { + state.checkpoints[state.curCheckpointIndex] = { + ...state.checkpoints[state.curCheckpointIndex], + [payload.filepath]: payload.content, + }; + }, + updateApplyState: (state, { payload }: PayloadAction) => { + const index = state.applyStates.findIndex( + (applyState) => applyState.streamId === payload.streamId, + ); + + const curApplyState = state.applyStates[index]; + + if (index === -1) { + state.applyStates.push(payload); + } else { + curApplyState.status = payload.status ?? curApplyState.status; + curApplyState.numDiffs = payload.numDiffs ?? curApplyState.numDiffs; + curApplyState.filepath = payload.filepath ?? curApplyState.filepath; + } + if(payload.status === "done"){ + state.nextCodeBlockToApplyIndex++; + } + }, + resetNextCodeBlockToApplyIndex: (state) => { + state.nextCodeBlockToApplyIndex = 0; }, }, }); export const { setContextItemsAtIndex, - addContextItems, addContextItemsAtIndex, setInactive, streamUpdate, newSession, - deleteContextWithIds, resubmitAtIndex, addHighlightedCode, - setEditingAtIds, setDefaultModel, setConfig, setConfigError, @@ -449,6 +386,10 @@ export const { deleteMessage, setIsGatheringContext, setIsInMultifileEdit, + updateCurCheckpoint, + setCurCheckpointIndex, + resetNextCodeBlockToApplyIndex, + updateApplyState, } = stateSlice.actions; export default stateSlice.reducer; diff --git a/gui/src/redux/slices/uiStateSlice.ts b/gui/src/redux/slices/uiStateSlice.ts index 24c4fc194..f4b531c39 100644 --- a/gui/src/redux/slices/uiStateSlice.ts +++ b/gui/src/redux/slices/uiStateSlice.ts @@ -1,5 +1,4 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit"; -import { ApplyState } from "core/protocol/ideWebview"; import { defaultOnboardingCardState, OnboardingCardState, @@ -9,13 +8,7 @@ type UiState = { showDialog: boolean; dialogMessage: string | JSX.Element | undefined; dialogEntryOn: boolean; - nextCodeBlockToApplyIndex: number; onboardingCard: OnboardingCardState; - - /** - * Syncs the sidebar with the accepted/rejected blocks in the editor. Reused for Edit as well. - */ - applyStates: ApplyState[]; }; export const uiStateSlice = createSlice({ @@ -24,9 +17,7 @@ export const uiStateSlice = createSlice({ showDialog: false, dialogMessage: "", dialogEntryOn: false, - nextCodeBlockToApplyIndex: 0, onboardingCard: defaultOnboardingCardState, - applyStates: [], } as UiState, reducers: { setOnboardingCard: ( @@ -50,28 +41,6 @@ export const uiStateSlice = createSlice({ setShowDialog: (state, action: PayloadAction) => { state.showDialog = action.payload; }, - - resetNextCodeBlockToApplyIndex: (state) => { - state.nextCodeBlockToApplyIndex = 0; - }, - incrementNextCodeBlockToApplyIndex: (state, action) => { - state.nextCodeBlockToApplyIndex++; - }, - updateApplyState: (state, { payload }: PayloadAction) => { - const index = state.applyStates.findIndex( - (applyState) => applyState.streamId === payload.streamId, - ); - - const curApplyState = state.applyStates[index]; - - if (index === -1) { - state.applyStates.push(payload); - } else { - curApplyState.status = payload.status ?? curApplyState.status; - curApplyState.numDiffs = payload.numDiffs ?? curApplyState.numDiffs; - curApplyState.filepath = payload.filepath ?? curApplyState.filepath; - } - }, }, }); @@ -80,9 +49,6 @@ export const { setDialogMessage, setDialogEntryOn, setShowDialog, - resetNextCodeBlockToApplyIndex, - incrementNextCodeBlockToApplyIndex, - updateApplyState, } = uiStateSlice.actions; export default uiStateSlice.reducer; diff --git a/gui/src/redux/store.ts b/gui/src/redux/store.ts index a5d0313f4..725d88c01 100644 --- a/gui/src/redux/store.ts +++ b/gui/src/redux/store.ts @@ -10,7 +10,6 @@ import { createFilter } from "redux-persist-transform-filter"; import autoMergeLevel2 from "redux-persist/lib/stateReconciler/autoMergeLevel2"; import storage from "redux-persist/lib/storage"; import editModeStateReducer from "./slices/editModeState"; - export interface ChatMessage { role: "system" | "user" | "assistant"; content: string; @@ -40,12 +39,7 @@ const windowIDTransform = (windowID: string) => ); const saveSubsetFilters = [ - createFilter("state", [ - "history", - "contextItems", - "sessionId", - "defaultModelTitle", - ]), + createFilter("state", ["history", "sessionId", "defaultModelTitle"]), ]; const persistConfig = { diff --git a/manual-testing-sandbox/helloNested.py b/manual-testing-sandbox/helloNested.py new file mode 100644 index 000000000..e69de29bb diff --git a/packages/openai-adapters/src/apis/Moonshot.ts b/packages/openai-adapters/src/apis/Moonshot.ts new file mode 100644 index 000000000..eb11124f0 --- /dev/null +++ b/packages/openai-adapters/src/apis/Moonshot.ts @@ -0,0 +1,63 @@ +import { streamSse } from "@continuedev/fetch"; +import fetch from "node-fetch"; +import { ChatCompletionChunk } from "openai/resources/index.mjs"; +import { LlmApiConfig } from "../index.js"; +import { OpenAIApi } from "./OpenAI.js"; +import { FimCreateParamsStreaming } from "./base.js"; + +export class MoonshotApi extends OpenAIApi { + constructor(config: LlmApiConfig) { + super(config); + this.apiBase = "https://api.moonshot.cn/"; + } + + async *fimStream( + body: FimCreateParamsStreaming, + ): AsyncGenerator { + const endpoint = new URL("v1/chat/completions", this.apiBase); + const resp = await fetch(endpoint, { + method: "POST", + body: JSON.stringify({ + model: body.model, + messages: [ + { + role: "user", + content: body.prompt + "[fill]" + body.suffix, + }, + ], + max_tokens: body.max_tokens, + temperature: body.temperature, + top_p: body.top_p, + frequency_penalty: body.frequency_penalty, + presence_penalty: body.presence_penalty, + stop: body.stop, + stream: true, + }), + headers: { + "Content-Type": "application/json", + Accept: "application/json", + Authorization: `Bearer ${this.config.apiKey}`, + }, + }); + + for await (const chunk of streamSse(resp as any)) { + yield { + choices: [ + { + delta: { + content: chunk.choices[0].delta.content, + role: "assistant", + }, + finish_reason: chunk.finish_reason, + index: 0, + logprobs: null, + }, + ], + created: Date.now(), + id: "", + model: body.model, + object: "chat.completion.chunk", + }; + } + } +} diff --git a/packages/openai-adapters/src/index.ts b/packages/openai-adapters/src/index.ts index f782f1c78..4856a7b11 100644 --- a/packages/openai-adapters/src/index.ts +++ b/packages/openai-adapters/src/index.ts @@ -6,6 +6,7 @@ import { CohereApi } from "./apis/Cohere.js"; import { DeepSeekApi } from "./apis/DeepSeek.js"; import { GeminiApi } from "./apis/Gemini.js"; import { JinaApi } from "./apis/Jina.js"; +import { MoonshotApi } from "./apis/Moonshot.js"; import { OpenAIApi } from "./apis/OpenAI.js"; dotenv.config(); @@ -48,6 +49,8 @@ export function constructLlmApi(config: LlmApiConfig): BaseLlmApi { }); case "deepseek": return new DeepSeekApi(config); + case "moonshot": + return new MoonshotApi(config); case "groq": return new OpenAIApi({ ...config,