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.

fix: feeding the model reply back to nxt user prompts (#48)

authored by

Anandu Pavanan and committed by
GitHub
2318391a 0a62b970

+8 -4
+8 -4
tiles/src/runtime/mlx.rs
··· 352 352 let config = Config::builder().auto_add_history(true).build(); 353 353 let mut editor = Editor::<TilesHinter, DefaultHistory>::with_config(config).unwrap(); 354 354 editor.set_helper(Some(TilesHinter)); 355 - 355 + let mut g_reply: String = "".to_owned(); 356 356 loop { 357 357 let readline = editor.readline(">>> "); 358 358 let input = match readline { ··· 383 383 continue; 384 384 } 385 385 let mut remaining_count = run_args.relay_count; 386 - let mut g_reply: String = "".to_owned(); 387 386 let mut python_code: String = "".to_owned(); 388 387 loop { 389 388 if remaining_count > 0 { 390 389 let chat_start = remaining_count == run_args.relay_count; 391 - if let Ok(response) = chat(&input, modelname, chat_start, &python_code).await { 390 + if let Ok(response) = 391 + chat(&input, modelname, chat_start, &python_code, &g_reply).await 392 + { 392 393 if response.reply.is_empty() { 393 394 if !response.code.is_empty() { 394 395 python_code = response.code; ··· 404 405 break; 405 406 } 406 407 } else { 408 + // if out of relay count, then clear the global_reply and ready for next fresh prompt 409 + g_reply.clear(); 407 410 break; 408 411 } 409 412 } ··· 459 462 model_name: &str, 460 463 chat_start: bool, 461 464 python_code: &str, 465 + g_reply: &str, 462 466 ) -> Result<ChatResponse, String> { 463 467 let client = Client::new(); 464 468 ··· 467 471 "chat_start": chat_start, 468 472 "stream": true, 469 473 "python_code": python_code, 470 - "messages": [{"role": "user", "content": input}] 474 + "messages": [{"role": "assistant", "content": g_reply}, {"role": "user", "content": input}] 471 475 }); 472 476 let res = client 473 477 .post("http://127.0.0.1:6969/v1/chat/completions")