From ebac9a7342b1118969c07ab5692616b606af75ec Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Fri, 16 Aug 2024 13:37:54 -0400 Subject: [PATCH] Combine assistant documentation (#16362) Release Notes: - N/A --- crates/assistant/src/using-the-assistant.md | 42 ---------- docs/src/SUMMARY.md | 2 +- ...uage-model-integration.md => assistant.md} | 79 ++++++++++++++----- docs/src/completions.md | 2 +- 4 files changed, 61 insertions(+), 64 deletions(-) delete mode 100644 crates/assistant/src/using-the-assistant.md rename docs/src/{language-model-integration.md => assistant.md} (69%) diff --git a/crates/assistant/src/using-the-assistant.md b/crates/assistant/src/using-the-assistant.md deleted file mode 100644 index 23cc3b287c..0000000000 --- a/crates/assistant/src/using-the-assistant.md +++ /dev/null @@ -1,42 +0,0 @@ -## Assistant Panel - -Once you have configured a provider, you can interact with the provider's language models in a context editor. - -To create a new context editor, use the menu in the top right of the assistant panel and select the `New Context` option. - -In the context editor, select a model from one of the configured providers, type a message in the `You` block, and submit with `cmd-enter` (or `ctrl-enter` on Linux). - -### Adding Prompts - -You can customize the default prompts used in new context editors by opening the `Prompt Library`. - -Open the `Prompt Library` using either the menu in the top right of the assistant panel and choosing the `Prompt Library` option, or by using the `assistant: deploy prompt library` command when the assistant panel is focused. - -### Viewing past contexts - -You can view all previous contexts by opening the `History` tab in the assistant panel. - -Open the `History` using the menu in the top right of the assistant panel and choosing `History`. - -### Slash commands - -Slash commands enhance the assistant's capabilities. Begin by typing a `/` at the beginning of the line to see a list of available commands: - -- default: Inserts the default prompt into the context -- diagnostics: Injects errors reported by the project's language server into the context -- fetch: Pulls the content of a webpage and inserts it into the context -- file: Pulls a single file or a directory of files into the context -- now: Inserts the current date and time into the context -- prompt: Adds a custom-configured prompt to the context (see Prompt Library) -- search: Performs semantic search for content in your project based on natural language -- symbols: Pulls the current tab's active symbols into the context -- tab: Pulls in the content of the active tab or all open tabs into the context -- terminal: Pulls in a select number of lines of output from the terminal - -## Inline assistant - -You can use `ctrl-enter` to open the inline assistant in both a normal editor and within the assistant panel. - -The inline assistant allows you to send the current selection (or the current line) to a language model and modify the selection with the language model's response. - -The inline assistant pulls its context from the assistant panel, allowing you to provide additional instructions or rules for code transformations. diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 9ca879814a..a7eefa9313 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -22,7 +22,7 @@ # Using Zed - [Multibuffers](./multibuffers.md) -- [Language model integration](./language-model-integration.md) +- [Assistant](./assistant.md) - [Code Completions](./completions.md) - [Channels](./channels.md) - [Collaboration](./collaboration.md) diff --git a/docs/src/language-model-integration.md b/docs/src/assistant.md similarity index 69% rename from docs/src/language-model-integration.md rename to docs/src/assistant.md index 7cc4afd07d..6a1446b4fd 100644 --- a/docs/src/language-model-integration.md +++ b/docs/src/assistant.md @@ -1,11 +1,17 @@ -# Language model integration +# Language Model Integration ## Assistant Panel -The assistant panel provides you with a way to interact with large language models. The assistant is good for various tasks, such as generating code, asking questions about existing code, and even writing plaintext, such as emails and documentation. To open the assistant panel, toggle the right dock by using the `workspace: toggle right dock` action in the command palette or by using the `cmd-r` (Mac) or `ctrl-alt-b` (Linux) shortcut. +The assistant panel provides you with a way to interact with large language models. The assistant is useful for various tasks, such as generating code, asking questions about existing code, and even writing plaintext, such as emails and documentation. To open the assistant panel, toggle the right dock by using the `workspace: toggle right dock` action in the command palette or by using the `cmd-r` (Mac) or `ctrl-alt-b` (Linux) shortcut. > **Note**: A custom [key binding](./key-bindings.md) can be set to toggle the right dock. +Once you have configured a provider, you can interact with the provider's language models in a context editor. + +To create a new context editor, use the menu in the top right of the assistant panel and select the `New Context` option. + +In the context editor, select a model from one of the configured providers, type a message in the `You` block, and submit with `cmd-enter` (or `ctrl-enter` on Linux). + ## Setup - [OpenAI API Setup Instructions](#openai) @@ -15,7 +21,7 @@ The assistant panel provides you with a way to interact with large language mode - [Google Gemini API Setup Instructions](#google-gemini) - [GitHub Copilot Chat](#github-copilot) -### Having a conversation +### Having a Conversation The assistant editor in Zed functions similarly to any other editor. You can use custom key bindings and work with multiple cursors, allowing for seamless transitions between coding and engaging in discussions with the language models. However, the assistant editor differs with the inclusion of message blocks. These blocks serve as containers for text that correspond to different roles within the conversation. These roles include: @@ -45,35 +51,68 @@ If you want to start a new conversation at any time, you can hit `cmd-n` or use Simple back-and-forth conversations work well with the assistant. However, there may come a time when you want to modify the previous text in the conversation and steer it in a different direction. -### Editing a conversation +### Editing a Conversation The assistant gives you the flexibility to have control over the conversation. You can freely edit any previous text, including the responses from the assistant. If you want to remove a message block entirely, simply place your cursor at the beginning of the block and use the `delete` key. A typical workflow might involve making edits and adjustments throughout the conversation to refine your inquiry or provide additional context. Here's an example: 1. Write text in a `You` block. -2. Submit the message with `cmd-enter` -3. Receive an `Assistant` response that doesn't meet your expectations -4. Cancel the response with `escape` -5. Erase the content of the `Assistant` message block and remove the block entirely -6. Add additional context to your original message -7. Submit the message with `cmd-enter` +2. Submit the message with `cmd-enter`. +3. Receive an `Assistant` response that doesn't meet your expectations. +4. Cancel the response with `escape`. +5. Erase the content of the `Assistant` message block and remove the block entirely. +6. Add additional context to your original message. +7. Submit the message with `cmd-enter`. -Being able to edit previous messages gives you control over how tokens are used. You don't need to start up a new context to correct a mistake or to add additional context and you don't have to waste tokens by submitting follow-up corrections. +Being able to edit previous messages gives you control over how tokens are used. You don't need to start up a new context to correct a mistake or to add additional context, and you don't have to waste tokens by submitting follow-up corrections. Some additional points to keep in mind: - You are free to change the model type at any point in the conversation. - You can cycle the role of a message block by clicking on the role, which is useful when you receive a response in an `Assistant` block that you want to edit and send back up as a `You` block. -### Saving and loading conversations +### Saving and Loading Conversations After you submit your first message, a name for your conversation is generated by the language model, and the conversation is automatically saved to your file system in `~/.config/zed/conversations`. You can access and load previous messages by clicking on the hamburger button in the top-left corner of the assistant panel. ![Viewing assistant history](https://zed.dev/img/assistant/assistant-history.png) -## Inline generation +### Adding Prompts + +You can customize the default prompts used in new context editors by opening the `Prompt Library`. + +Open the `Prompt Library` using either the menu in the top right of the assistant panel and choosing the `Prompt Library` option, or by using the `assistant: deploy prompt library` command when the assistant panel is focused. + +### Viewing Past Contexts + +You can view all previous contexts by opening the `History` tab in the assistant panel. + +Open the `History` using the menu in the top right of the assistant panel and choosing `History`. + +### Slash Commands + +Slash commands enhance the assistant's capabilities. Begin by typing a `/` at the beginning of the line to see a list of available commands: + +- `/default`: Inserts the default prompt into the context +- `/diagnostics`: Injects errors reported by the project's language server into the context +- `/fetch`: Inserts the content of a webpage and inserts it into the context +- `/file`: Inserts a single file or a directory of files into the context +- `/now`: Inserts the current date and time into the context +- `/prompt`: Adds a custom-configured prompt to the context (see Prompt Library) +- `/search`: Performs semantic search for content in your project based on natural language +- `/symbols`: Inserts the current tab's active symbols into the context +- `/tab`: Inserts the content of the active tab or all open tabs into the context +- `/terminal`: Inserts a select number of lines of output from the terminal + +Additionally, you can use `assistant: quote selection` (`cmd + >`) to insert the active editor buffer selection as a quoted code block in the assistant panel. + +## Inline Assistant + +You can use `ctrl-enter` to open the inline assistant in both a normal editor and within the assistant panel. + +The inline assistant allows you to send the current selection (or the current line) to a language model and modify the selection with the language model's response. You can also perform multiple generation requests in parallel by pressing `ctrl-enter` with multiple cursors, or by pressing `ctrl-enter` with a selection that spans multiple excerpts in a multibuffer. + +The inline assistant pulls its context from the assistant panel, allowing you to provide additional instructions or rules for code transformations. -You can generate and transform text in any editor by selecting text and pressing `ctrl-enter`. -You can also perform multiple generation requests in parallel by pressing `ctrl-enter` with multiple cursors, or by pressing `ctrl-enter` with a selection that spans multiple excerpts in a multibuffer. To create a custom keybinding that prefills a prompt, you can add the following format in your keymap: ```json @@ -90,7 +129,7 @@ To create a custom keybinding that prefills a prompt, you can add the following ] ``` -## Advanced: Overriding prompt templates +## Advanced: Overriding Prompt Templates Zed allows you to override the default prompts used for various assistant features by placing custom Handlebars (.hbs) templates in your `~/.config/zed/prompts/templates` directory. The following templates can be overridden: @@ -165,7 +204,7 @@ Zed allows you to override the default prompts used for various assistant featur You can customize these templates to better suit your needs while maintaining the core structure and variables used by Zed. Zed will automatically reload your prompt overrides when they change on disk. Consult Zed's assets/prompts directory for current versions you can play with. -Be sure you want to override these, as you'll miss out on iteration on our built in features. This should be primarily used when developing Zed. +Be sure you want to override these, as you'll miss out on iteration on our built-in features. This should be primarily used when developing Zed. ## Setup Instructions @@ -206,7 +245,7 @@ The custom URL here is `http://localhost:11434/v1`. ### Ollama -Download and install ollama from [ollama.com/download](https://ollama.com/download) (Linux or MacOS) and ensure it's running with `ollama --version`. +Download and install Ollama from [ollama.com/download](https://ollama.com/download) (Linux or macOS) and ensure it's running with `ollama --version`. You can use Ollama with the Zed assistant by making Ollama appear as an OpenAPI endpoint. @@ -223,7 +262,7 @@ You can use Ollama with the Zed assistant by making Ollama appear as an OpenAPI ``` 3. In the assistant panel, select one of the Ollama models using the model dropdown. -4. (Optional) If you want to change the default url that is used to access the Ollama server, you can do so by adding the following settings: +4. (Optional) If you want to change the default URL that is used to access the Ollama server, you can do so by adding the following settings: ```json { @@ -249,6 +288,6 @@ You can use Gemini 1.5 Pro/Flash with the Zed assistant by choosing it via the m You can obtain an API key [here](https://aistudio.google.com/app/apikey). -### GitHub Copilot +### GitHub Copilot Chat You can use GitHub Copilot chat with the Zed assistant by choosing it via the model dropdown in the assistant panel. diff --git a/docs/src/completions.md b/docs/src/completions.md index 9663d6f162..060a7d96ad 100644 --- a/docs/src/completions.md +++ b/docs/src/completions.md @@ -88,4 +88,4 @@ You can also add this as a language-specific setting in your `settings.json` to ## See also -You may also use the Assistant Panel or the Inline Assistant to interact with language models, see [Language Model Integration](language-model-integration.md) documentation for more information. +You may also use the Assistant Panel or the Inline Assistant to interact with language models, see the [assistant](assistant.md) documentation for more information.