Start on an assistant panel based on multi-buffers
Each message is represented as a multibuffer excerpt to allow for fluid editing of the conversation transcript. Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
parent
128c19875d
commit
80080a43e4
7 changed files with 381 additions and 34 deletions
|
@ -1,3 +1,5 @@
|
|||
mod assistant;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use assets::Assets;
|
||||
use collections::HashMap;
|
||||
|
@ -16,6 +18,8 @@ use std::{io, sync::Arc};
|
|||
use util::channel::{ReleaseChannel, RELEASE_CHANNEL};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
|
||||
pub use assistant::AssistantPanel;
|
||||
|
||||
actions!(ai, [Assist]);
|
||||
|
||||
// Data types for chat completion requests
|
||||
|
@ -38,7 +42,7 @@ struct ResponseMessage {
|
|||
content: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
enum Role {
|
||||
User,
|
||||
|
@ -86,25 +90,27 @@ struct OpenAIChoice {
|
|||
}
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
if *RELEASE_CHANNEL == ReleaseChannel::Stable {
|
||||
return;
|
||||
}
|
||||
// if *RELEASE_CHANNEL == ReleaseChannel::Stable {
|
||||
// return;
|
||||
// }
|
||||
|
||||
let assistant = Rc::new(Assistant::default());
|
||||
cx.add_action({
|
||||
let assistant = assistant.clone();
|
||||
move |editor: &mut Editor, _: &Assist, cx: &mut ViewContext<Editor>| {
|
||||
assistant.assist(editor, cx).log_err();
|
||||
}
|
||||
});
|
||||
cx.capture_action({
|
||||
let assistant = assistant.clone();
|
||||
move |_: &mut Editor, _: &editor::Cancel, cx: &mut ViewContext<Editor>| {
|
||||
if !assistant.cancel_last_assist(cx.view_id()) {
|
||||
cx.propagate_action();
|
||||
}
|
||||
}
|
||||
});
|
||||
assistant::init(cx);
|
||||
|
||||
// let assistant = Rc::new(Assistant::default());
|
||||
// cx.add_action({
|
||||
// let assistant = assistant.clone();
|
||||
// move |editor: &mut Editor, _: &Assist, cx: &mut ViewContext<Editor>| {
|
||||
// assistant.assist(editor, cx).log_err();
|
||||
// }
|
||||
// });
|
||||
// cx.capture_action({
|
||||
// let assistant = assistant.clone();
|
||||
// move |_: &mut Editor, _: &editor::Cancel, cx: &mut ViewContext<Editor>| {
|
||||
// if !assistant.cancel_last_assist(cx.view_id()) {
|
||||
// cx.propagate_action();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
type CompletionId = usize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue