A local-first private AI assistant for everyday use. Runs on-device models with encrypted P2P sync, and supports sharing chats publicly on ATProto.
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Basic impl for resume session ctx into model

+33 -4
+33 -4
tiles/src/runtime/mlx.rs
··· 424 424 session_id = state.session_id; 425 425 } 426 426 let mut session_turn_count = 0; 427 + // if true, we will prepend the resumed session history to the input 428 + let mut is_resume_session_pending = false; 429 + let mut resumed_session: String = String::from(""); 427 430 loop { 431 + is_resume_session_pending = false; 428 432 let readline = editor.readline(">>> "); 429 433 let input = match readline { 430 434 Ok(line) => line.trim().to_string().to_lowercase(), ··· 466 470 break; 467 471 } 468 472 InputType::Prompt => { 473 + let final_input = if is_resume_session_pending { 474 + info!("Pending resumed session, prepend the history"); 475 + format!( 476 + "user_chat_history - {}\nUser question- {}", 477 + resumed_session, input 478 + ) 479 + } else { 480 + input.to_owned() 481 + }; 469 482 let payload = json!({ 470 483 "type": "prompt", 471 - "message": input 484 + "message": final_input 472 485 }); 473 486 send_to_pi(pi_stdin, payload)?; 474 487 } ··· 497 510 } 498 511 CommandType::Resume => { 499 512 match load_session(db_conn, &args) { 500 - Ok((sesh_id, turn_count)) => { 513 + Ok((sesh_id, turn_count, history)) => { 501 514 session_id = sesh_id; 502 515 session_turn_count = turn_count; 516 + is_resume_session_pending = true; 517 + resumed_session = history; 503 518 } 519 + 504 520 Err(err) => { 505 521 println!("{}", err) 506 522 } ··· 550 566 } 551 567 PiResponse::TurnEnd(turn_event) => { 552 568 println!("\n"); 569 + // will just toggle off if was toggledon, since we dont need to compact 570 + // every time 571 + is_resume_session_pending = false; 553 572 session_turn_count += 1; 554 573 555 574 // on agent end create a new session entry, only for the ··· 912 931 } 913 932 914 933 //TODO: load the session via prompt into the model too 915 - fn load_session(db_conn: &Dbconn, args: &[&str]) -> Result<(String, usize)> { 934 + fn load_session(db_conn: &Dbconn, args: &[&str]) -> Result<(String, usize, String)> { 916 935 let args = if let Some((_main_command, sub_commands)) = args.split_first() { 917 936 sub_commands 918 937 } else { ··· 933 952 println!("Session {} not available", session_id); 934 953 } 935 954 955 + //TODO: we will later implement a decent compaction based on Pi's for 956 + // history 957 + // https://github.com/badlogic/pi-mono/blob/182d4ceea33beabe7c4712b04f1f5459e613de44/packages/coding-agent/docs/compaction.md 958 + 959 + let mut chat_history: String = "".to_owned(); 936 960 for chat in &delta_chats.chats { 961 + chat_history.push_str(&chat.content); 937 962 println!("{}", chat.content); 938 963 } 939 964 940 - Ok((session_id.to_string(), delta_chats.chats.len())) 965 + Ok(( 966 + session_id.to_string(), 967 + delta_chats.chats.len(), 968 + chat_history, 969 + )) 941 970 }