Extract PromptLibrary
to prompt_library
(#23285)
This PR extracts the `PromptLibrary` out of the `assistant` crate and moves it to the `prompt_library` crate. The `PromptLibrary` is now decoupled from the specifics of the `AssistantPanel` and `InlineAssistant`. Release Notes: - N/A
This commit is contained in:
parent
81dd68d696
commit
cb35b73020
7 changed files with 1224 additions and 1148 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -413,7 +413,6 @@ dependencies = [
|
||||||
"proto",
|
"proto",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
"regex",
|
"regex",
|
||||||
"release_channel",
|
|
||||||
"rope",
|
"rope",
|
||||||
"rpc",
|
"rpc",
|
||||||
"schemars",
|
"schemars",
|
||||||
|
@ -9892,6 +9891,7 @@ dependencies = [
|
||||||
"assets",
|
"assets",
|
||||||
"chrono",
|
"chrono",
|
||||||
"collections",
|
"collections",
|
||||||
|
"editor",
|
||||||
"fs",
|
"fs",
|
||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
|
@ -9899,14 +9899,23 @@ dependencies = [
|
||||||
"handlebars 4.5.0",
|
"handlebars 4.5.0",
|
||||||
"heed",
|
"heed",
|
||||||
"language",
|
"language",
|
||||||
|
"language_model",
|
||||||
"log",
|
"log",
|
||||||
|
"menu",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"paths",
|
"paths",
|
||||||
|
"picker",
|
||||||
|
"release_channel",
|
||||||
"rope",
|
"rope",
|
||||||
"serde",
|
"serde",
|
||||||
|
"settings",
|
||||||
"text",
|
"text",
|
||||||
|
"theme",
|
||||||
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
"workspace",
|
||||||
|
"zed_actions",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -58,7 +58,6 @@ project.workspace = true
|
||||||
prompt_library.workspace = true
|
prompt_library.workspace = true
|
||||||
proto.workspace = true
|
proto.workspace = true
|
||||||
regex.workspace = true
|
regex.workspace = true
|
||||||
release_channel.workspace = true
|
|
||||||
rope.workspace = true
|
rope.workspace = true
|
||||||
rpc.workspace = true
|
rpc.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
|
|
|
@ -5,7 +5,6 @@ mod context;
|
||||||
pub mod context_store;
|
pub mod context_store;
|
||||||
mod inline_assistant;
|
mod inline_assistant;
|
||||||
mod patch;
|
mod patch;
|
||||||
mod prompt_library;
|
|
||||||
mod slash_command;
|
mod slash_command;
|
||||||
pub(crate) mod slash_command_picker;
|
pub(crate) mod slash_command_picker;
|
||||||
pub mod slash_command_settings;
|
pub mod slash_command_settings;
|
||||||
|
@ -14,7 +13,6 @@ mod terminal_inline_assistant;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ::prompt_library::{PromptBuilder, PromptLoadingParams};
|
|
||||||
use assistant_settings::AssistantSettings;
|
use assistant_settings::AssistantSettings;
|
||||||
use assistant_slash_command::SlashCommandRegistry;
|
use assistant_slash_command::SlashCommandRegistry;
|
||||||
use assistant_slash_commands::{ProjectSlashCommandFeatureFlag, SearchSlashCommandFeatureFlag};
|
use assistant_slash_commands::{ProjectSlashCommandFeatureFlag, SearchSlashCommandFeatureFlag};
|
||||||
|
@ -27,6 +25,7 @@ use gpui::{actions, AppContext, Global, SharedString, UpdateGlobal};
|
||||||
use language_model::{
|
use language_model::{
|
||||||
LanguageModelId, LanguageModelProviderId, LanguageModelRegistry, LanguageModelResponseMessage,
|
LanguageModelId, LanguageModelProviderId, LanguageModelRegistry, LanguageModelResponseMessage,
|
||||||
};
|
};
|
||||||
|
use prompt_library::{PromptBuilder, PromptLoadingParams};
|
||||||
use semantic_index::{CloudEmbeddingProvider, SemanticDb};
|
use semantic_index::{CloudEmbeddingProvider, SemanticDb};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
|
@ -214,7 +213,7 @@ pub fn init(
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
context_store::init(&client.clone().into());
|
context_store::init(&client.clone().into());
|
||||||
::prompt_library::init(cx);
|
prompt_library::init(cx);
|
||||||
init_language_model_settings(cx);
|
init_language_model_settings(cx);
|
||||||
assistant_slash_command::init(cx);
|
assistant_slash_command::init(cx);
|
||||||
assistant_tool::init(cx);
|
assistant_tool::init(cx);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
humanize_token_count, prompt_library::open_prompt_library,
|
humanize_token_count, slash_command::SlashCommandCompletionProvider, slash_command_picker,
|
||||||
slash_command::SlashCommandCompletionProvider, slash_command_picker,
|
|
||||||
terminal_inline_assistant::TerminalInlineAssistant, Assist, AssistantPatch,
|
terminal_inline_assistant::TerminalInlineAssistant, Assist, AssistantPatch,
|
||||||
AssistantPatchStatus, CacheStatus, ConfirmCommand, Content, Context, ContextEvent, ContextId,
|
AssistantPatchStatus, CacheStatus, ConfirmCommand, Content, Context, ContextEvent, ContextId,
|
||||||
ContextStore, ContextStoreEvent, CopyCode, CycleMessageRole, DeployHistory,
|
ContextStore, ContextStoreEvent, CopyCode, CycleMessageRole, DeployHistory,
|
||||||
|
@ -55,7 +54,7 @@ use multi_buffer::MultiBufferRow;
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use project::lsp_store::LocalLspAdapterDelegate;
|
use project::lsp_store::LocalLspAdapterDelegate;
|
||||||
use project::{Project, Worktree};
|
use project::{Project, Worktree};
|
||||||
use prompt_library::PromptBuilder;
|
use prompt_library::{open_prompt_library, PromptBuilder, PromptLibrary};
|
||||||
use rope::Point;
|
use rope::Point;
|
||||||
use search::{buffer_search::DivRegistrar, BufferSearchBar};
|
use search::{buffer_search::DivRegistrar, BufferSearchBar};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -1186,7 +1185,19 @@ impl AssistantPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deploy_prompt_library(&mut self, _: &DeployPromptLibrary, cx: &mut ViewContext<Self>) {
|
fn deploy_prompt_library(&mut self, _: &DeployPromptLibrary, cx: &mut ViewContext<Self>) {
|
||||||
open_prompt_library(self.languages.clone(), cx).detach_and_log_err(cx);
|
open_prompt_library(
|
||||||
|
self.languages.clone(),
|
||||||
|
Box::new(PromptLibraryInlineAssist),
|
||||||
|
Arc::new(|| {
|
||||||
|
Box::new(SlashCommandCompletionProvider::new(
|
||||||
|
Arc::new(SlashCommandWorkingSet::default()),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
))
|
||||||
|
}),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_model_selector(&mut self, _: &ToggleModelSelector, cx: &mut ViewContext<Self>) {
|
fn toggle_model_selector(&mut self, _: &ToggleModelSelector, cx: &mut ViewContext<Self>) {
|
||||||
|
@ -1469,6 +1480,29 @@ impl FocusableView for AssistantPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PromptLibraryInlineAssist;
|
||||||
|
|
||||||
|
impl prompt_library::InlineAssistDelegate for PromptLibraryInlineAssist {
|
||||||
|
fn assist(
|
||||||
|
&self,
|
||||||
|
prompt_editor: &View<Editor>,
|
||||||
|
initial_prompt: Option<String>,
|
||||||
|
cx: &mut ViewContext<PromptLibrary>,
|
||||||
|
) {
|
||||||
|
InlineAssistant::update_global(cx, |assistant, cx| {
|
||||||
|
assistant.assist(&prompt_editor, None, None, initial_prompt, cx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn focus_assistant_panel(
|
||||||
|
&self,
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) -> bool {
|
||||||
|
workspace.focus_panel::<AssistantPanel>(cx).is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum ContextEditorEvent {
|
pub enum ContextEditorEvent {
|
||||||
Edited,
|
Edited,
|
||||||
TabContentChanged,
|
TabContentChanged,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -16,6 +16,7 @@ anyhow.workspace = true
|
||||||
assets.workspace = true
|
assets.workspace = true
|
||||||
chrono.workspace = true
|
chrono.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
|
editor.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
fuzzy.workspace = true
|
fuzzy.workspace = true
|
||||||
|
@ -23,11 +24,20 @@ gpui.workspace = true
|
||||||
handlebars.workspace = true
|
handlebars.workspace = true
|
||||||
heed.workspace = true
|
heed.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
|
language_model.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
|
menu.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
|
picker.workspace = true
|
||||||
|
release_channel.workspace = true
|
||||||
rope.workspace = true
|
rope.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
settings.workspace = true
|
||||||
text.workspace = true
|
text.workspace = true
|
||||||
|
theme.workspace = true
|
||||||
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
|
workspace.workspace = true
|
||||||
|
zed_actions.workspace = true
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue