assistant2: Add new conversation button, that also saves the current conversation (#11522)
This PR updates the new assistant with a button to start a new conversation. Clicking on it will reset the chat and put it into a fresh state. The current conversation will be serialized and written to `~/.config/zed/conversations`. Release Notes: - N/A
This commit is contained in:
parent
c77dd8b9e0
commit
33a72219c0
5 changed files with 126 additions and 6 deletions
|
@ -1,10 +1,27 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::MessageId;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SavedConversation {
|
||||
/// The schema version of the conversation.
|
||||
pub version: String,
|
||||
/// The title of the conversation, generated by the Assistant.
|
||||
pub title: String,
|
||||
pub messages: Vec<SavedMessage>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum SavedMessageRole {
|
||||
User,
|
||||
Assistant,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct SavedMessage {
|
||||
pub id: MessageId,
|
||||
pub role: SavedMessageRole,
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
|
@ -14,14 +31,17 @@ pub struct SavedMessage {
|
|||
pub fn placeholder_conversations() -> Vec<SavedConversation> {
|
||||
vec![
|
||||
SavedConversation {
|
||||
version: "0.3.0".to_string(),
|
||||
title: "How to get a list of exported functions in an Erlang module".to_string(),
|
||||
messages: vec![],
|
||||
},
|
||||
SavedConversation {
|
||||
version: "0.3.0".to_string(),
|
||||
title: "7 wonders of the ancient world".to_string(),
|
||||
messages: vec![],
|
||||
},
|
||||
SavedConversation {
|
||||
version: "0.3.0".to_string(),
|
||||
title: "Size difference between u8 and a reference to u8 in Rust".to_string(),
|
||||
messages: vec![],
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue