full chat implemented
This commit is contained in:
25
src/app.rs
25
src/app.rs
@@ -457,6 +457,7 @@ enum GenerationCommand {
|
||||
engine: crate::settings::EngineSettings,
|
||||
turn: crate::settings::TurnSettings,
|
||||
messages: Vec<ChatTurn>,
|
||||
checkpoint: PathBuf,
|
||||
idle_timeout: Duration,
|
||||
cancel: Arc<AtomicBool>,
|
||||
},
|
||||
@@ -972,9 +973,23 @@ impl App {
|
||||
Some("Stop the active generation before deleting its project.".into());
|
||||
return Task::none();
|
||||
}
|
||||
let checkpoint_ids = self
|
||||
.projects
|
||||
.iter()
|
||||
.find(|item| item.project.id == project_id)
|
||||
.map(|item| {
|
||||
item.sessions
|
||||
.iter()
|
||||
.map(|session| session.id)
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
if let Some(database) = &mut self.database {
|
||||
match database.delete_project(project_id) {
|
||||
Ok(()) => {
|
||||
for session_id in checkpoint_ids {
|
||||
let _ = fs::remove_file(session_checkpoint_path(session_id));
|
||||
}
|
||||
if self.selected_project == Some(project_id) {
|
||||
self.selected_project = None;
|
||||
self.selected_session = None;
|
||||
@@ -1036,6 +1051,7 @@ impl App {
|
||||
if let Some(database) = &mut self.database {
|
||||
match database.delete_session(session_id) {
|
||||
Ok(()) => {
|
||||
let _ = fs::remove_file(session_checkpoint_path(session_id));
|
||||
if self.selected_session == Some(session_id) {
|
||||
self.selected_session = None;
|
||||
self.conversation.clear();
|
||||
@@ -1465,6 +1481,7 @@ impl App {
|
||||
engine: effective.engine,
|
||||
turn: effective.turn,
|
||||
messages,
|
||||
checkpoint: session_checkpoint_path(session_id),
|
||||
idle_timeout,
|
||||
cancel: Arc::clone(&cancel),
|
||||
};
|
||||
@@ -1594,6 +1611,7 @@ fn spawn_generation_worker() -> Result<GenerationWorker, String> {
|
||||
engine,
|
||||
turn,
|
||||
messages,
|
||||
checkpoint,
|
||||
idle_timeout: requested_timeout,
|
||||
cancel,
|
||||
}) => {
|
||||
@@ -1614,6 +1632,7 @@ fn spawn_generation_worker() -> Result<GenerationWorker, String> {
|
||||
}
|
||||
if let Some((_, generator)) = &mut loaded {
|
||||
let result = generator.generate(
|
||||
&checkpoint,
|
||||
&messages,
|
||||
&turn,
|
||||
&cancel,
|
||||
@@ -1687,6 +1706,12 @@ fn models_path() -> PathBuf {
|
||||
application_support_path().join("models")
|
||||
}
|
||||
|
||||
fn session_checkpoint_path(session_id: i32) -> PathBuf {
|
||||
application_support_path()
|
||||
.join("kv-cache")
|
||||
.join(format!("{session_id}.bin"))
|
||||
}
|
||||
|
||||
pub(crate) fn app_icon() -> window::Icon {
|
||||
let decoder = png::Decoder::new(std::io::Cursor::new(include_bytes!(
|
||||
"../assets/app-icon.png"
|
||||
|
||||
Reference in New Issue
Block a user