zed/assets/icons/library.svg

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

2 lines
298 B
XML
Raw Normal View History

Add prompt library (#11910) This PR adds a Prompt Library to Zed, powering custom prompts and any default prompts we want to package with the assistant. These are useful for: - Creating a "default prompt" - a super prompt that includes a collection of things you want the assistant to know in every conversation. - Adding single prompts to your current context to help guide the assistant's responses. - (In the future) dynamically adding certain prompts to the assistant based on the current context, such as the presence of Rust code or a specific async runtime you want to work with. These will also be useful for populating the assistant actions typeahead we plan to build in the near future. ## Prompt Library The prompt library is a registry of prompts. Initially by default when opening the assistant, the prompt manager will load any custom prompts present in your `~/.config/zed/prompts` directory. Checked prompts are included in your "default prompt", which can be inserted into the assitant by running `assistant: insert default prompt` or clicking the `Insert Default Prompt` button in the assistant panel's more menu. When the app starts, no prompts are set to default. You can add prompts to the default by checking them in the Prompt Library. I plan to improve this UX in the future, allowing your default prompts to be remembered, and allowing creating, editing and exporting prompts from the Library. ### Creating a custom prompt Prompts have a simple format: ```json { // ~/.config/zed/prompts/no-comments.json "title": "No comments in code", "version": "1.0", "author": "Nate Butler <iamnbutler@gmail.com>", "languages": ["*"], "prompt": "Do not add inline or doc comments to any returned code. Avoid removing existing comments unless they are no longer accurate due to changes in the code." } ``` Ensure you properly escape your prompt string when creating a new prompt file. Example: ```json { // ... "prompt": "This project using the gpui crate as it's UI framework for building UI in Rust. When working in Rust files with gpui components, import it's dependencies using `use gpui::{*, prelude::*}`.\n\nWhen a struct has a `#[derive(IntoElement)]` attribute, it is a UI component that must implement `RenderOnce`. Example:\n\n```rust\n#[derive(IntoElement)]\nstruct MyComponent {\n id: ElementId,\n}\n\nimpl MyComponent {\n pub fn new(id: impl Into<ElementId>) -> Self {\n Self { id.into() }\n }\n}\n\nimpl RenderOnce for MyComponent {\n fn render(self, cx: &mut WindowContext) -> impl IntoElement {\n div().id(self.id.clone()).child(text(\"Hello, world!\"))\n }\n}\n```" } ``` Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-05-16 20:55:54 +00:00
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-library"><path d="m16 6 4 14"/><path d="M12 6v14"/><path d="M8 8v12"/><path d="M4 4v16"/></svg>