diff --git a/astro.config.mjs b/astro.config.mjs index 0e7f022..647b244 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -73,8 +73,9 @@ export default defineConfig({ label: 'Features', items: [ { label: 'AI Chat', link: '/features/ai-chat/' }, - { label: 'Code Completion', link: '/features/code-completion/' }, { label: 'AI Toolbox', link: '/features/ai-toolbox/' }, + { label: 'Code Completion', link: '/features/code-completion/' }, + { label: 'Context', link: '/features/context/' }, ] }, ], diff --git a/src/assets/ast_vecdb.png b/src/assets/ast_vecdb.png new file mode 100644 index 0000000..6a8ae96 Binary files /dev/null and b/src/assets/ast_vecdb.png differ diff --git a/src/assets/refact_settings_rag.png b/src/assets/refact_settings_rag.png new file mode 100644 index 0000000..e101e20 Binary files /dev/null and b/src/assets/refact_settings_rag.png differ diff --git a/src/assets/starcoder2.png b/src/assets/starcoder2.png new file mode 100644 index 0000000..15e4d79 Binary files /dev/null and b/src/assets/starcoder2.png differ diff --git a/src/assets/thenpler.png b/src/assets/thenpler.png new file mode 100644 index 0000000..ee3048e Binary files /dev/null and b/src/assets/thenpler.png differ diff --git a/src/content/docs/features/ai-chat.md b/src/content/docs/features/ai-chat.md index b6deac0..1769599 100644 --- a/src/content/docs/features/ai-chat.md +++ b/src/content/docs/features/ai-chat.md @@ -4,3 +4,53 @@ description: A reference page for AI Chat. --- You can ask questions about your code in the integrated AI chat, and it can provide you with answers about your code or generate new code for you based on the context of your current file. + +## @-commands + +This section outlines various commands that can be used in the AI chat. Below you can find information about functionality and usage of each command. + +### `@workspace` + +- **Description**: Searches within VecDB for any specified query. This command allows you to search for any query within your repository/workspace. +- **Usage**: + - Single-line Query: Append the query directly after the command, e.g., `@workspace Something definition`. + - Multi-line Query: Type the command followed by pressing `Enter`. Subsequent lines entered will be considered part of the query, allowing for multi-line entries such as code snippets. + +### `@file` + +- **Description**: Attaches a file to the chat. +- **Usage**: + - To attach a whole file, use the command followed by the file name, e.g., `@file example.ext`. + - To specify a particular section of a file, include the line numbers, e.g., `@file large_file.ext:42` or for a range, `@file large_file.ext:42-56`. + +### `@definition` + +- **Description**: Retrieves the definition of a symbol. +- **Usage**: Type `@definition` followed by the symbol name, e.g., `@definition MyClass`. + +### `@references` + +- **Description**: Returns references for a symbol, including usage examples. +- **Usage**: Type `@references` followed by the symbol name, e.g., `@references MyClass`. + +### `@symbols-at` + +- **Description**: Searches for and adds symbols near a specified line in a file to the chat context. +- **Usage**: Specify both the file and the line number, e.g., `@symbols-at some_file.ext:42`. + +## Chat Initialization Options + +Upon starting a new chat, several options are available that mimic the above commands: + +- `Search workspace`: Equivalent to using `@workspace`. It uses the entered query to perform a search. +- `Attach current_file.ext`: Similar to the `@file` command. It attaches the file at the current cursor position (CURSOR_LINE), useful for dealing with large files. +- `Lookup symbols`: Corresponds to the `@symbols-at` command. It extracts symbols around the cursor position and searches them in the AST index. +- `Selected N lines`: Adds the currently selected lines as a snippet for analysis or modification. This is similar to embedding code within backticks ``` in the chat. + +## Enabling commands + +To use @-commands in the AI chat, you need to enable specific settings: +- `@workspace` - enable the `Enable embedded vecdb for search` checkbox under the `Refactai: Vecdb` section. +- `@definition`, `@file`, `@references`, `@symbols-at` - enable the `Enable syntax parsing` checkbox under the `Refactai: Ast` section. + +Read more in the [Enabling RAG Documentation](https://docs.refact.ai/features/context/). \ No newline at end of file diff --git a/src/content/docs/features/context.md b/src/content/docs/features/context.md new file mode 100644 index 0000000..bca8515 --- /dev/null +++ b/src/content/docs/features/context.md @@ -0,0 +1,53 @@ +--- +title: Context +description: A reference page about the context. +--- + +Context refers to the surrounding information that Refact.ai uses to provide a better quality of generated code. This can include: +- **Code Syntax**: By analyzing the current state of the code, Refact.ai can provide syntactically correct code completions. +- **Developer's Intent**: Interpreting comments, variable names, and function signatures, Refact.ai can provide code suggestions that are more relevant to the developer's intent. +- **Repo-level awareness**: By analyzing the repository's codebase, Refact.ai can provide code suggestions that are more relevant to the existing codebase. + +## RAG +Refact.ai uses RAG (Retrieval-Augmented Generation) to fill the +context with the information that is needed to provide a better quality of generated code. + +### Enabling RAG + +In order to enable RAG, you need to follow the instructions depending on the version of the Refact.ai you are using. + +### Cloud Version + +1. In the settings of the plugin (can be accessed by pressing the cogwheel icon in the sidebar), under the `Refactai: Code Completion Model` section, specify the `starcoder2/3b` model. +![Refact Settings](../../../assets/refact_settings_rag.png) +2. To enable RAG for **code completion**, you need to enable the `Enable syntax parsing` checkbox under the `Refactai: Ast` section. +3. To enable RAG for the **AI chat**, you need to enable the `Enable embedded vecdb for search` checkbox under the `Refactai: Vecdb` section. Read more in the [AI Chat Documentation](https://docs.refact.ai/features/ai-chat/) about available features. + +![RAG Settings](../../../assets/ast_vecdb.png) + +:::note +RAG is more useful for the context size **more than 2048 tokens**, which is available for **Pro users**. + +Be aware that RAG indexing is a **high resource-consuming process**, so you will experience increased memory consumption of your **GPU, RAM, and CPU**. +::: +### Refact Enterprise + +1. In the Web UI of your Refact.ai instance, navigate to the `Model Hosting` page. press the `Add Model` button to switch the model, locate and select one of the `starcoder2/` models. +![Starcoder2 model](../../../assets/starcoder2.png) +:::note +You can use different models from the `starcoder2` family. But be aware that with Stacoder2 models, the results will be more accurate and the code completion will be more accurate. +::: +2. To enable RAG for **code completion**, you need to enable the `Enable syntax parsing` checkbox under the `Refactai: Ast` section. +3. To enable RAG for the **AI chat**, you need to enable the `Enable embedded vecdb for search` checkbox under the `Refactai: Vecdb` section. Read more in the [AI Chat Documentation](https://docs.refact.ai/features/ai-chat/) about available features. +![RAG Settings](../../../assets/ast_vecdb.png) +4. If Vecdb checkbox is enabled in your VS Code settings, you need to select the `thenlper/gte-base` model in your Refact.ai instance. +In the Web UI of your Refact.ai instance, navigate to the `Model Hosting` page. Press the `Add Model` button, locate and select the `thenlper/gte-base` model. +![thenlper model](../../../assets/thenpler.png) + +:::note +Make sure that you have enough memory available on your GPU for the model to be loaded and served. + +Altrnitavely you can use unoccupied GPU to avoid the memory issue and interruption of the code generation. + +As an aditional option, you can switch from vLLM model to a regular model. +::: \ No newline at end of file diff --git a/src/content/docs/guides/deployment/aws.md b/src/content/docs/guides/deployment/aws.md index 00232fa..5b38476 100644 --- a/src/content/docs/guides/deployment/aws.md +++ b/src/content/docs/guides/deployment/aws.md @@ -54,7 +54,7 @@ Replace `"/path/to/your/refact_id_rsa.pem"` with the actual path to your downloa ## Deploy Refact -Once connected via SSH, continue to the [Refact Enterprise](https://docs.refact.ai/guides/enterprise/) page to learn how to use Refact for teams. +Once connected via SSH, continue to the [Refact Enterprise](https://docs.refact.ai/guides/version-specific/enterprise/) page to learn how to use Refact for teams. ## Known issues