-
Notifications
You must be signed in to change notification settings - Fork 6
open responses and mem model compatibility + fixes #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b126eeb
dfe3598
5e1212d
fe6d522
4683fce
ca4fde8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| { | ||
| "lock_input_hash": "sha256:182c606e20dd957344cc3adc54391f47f4b6dd80b4481ddf219392a7aad6e0ce", | ||
| "lock_version": 1, | ||
| "locked_at": "2026-01-30T08:41:45.203370+00:00", | ||
| "locked_at": "2026-02-04T07:05:20.498851+00:00", | ||
| "other_inputs_hash": "sha256:63b3c2cfe2ec414938e81dace7aac779c7b902bae681618cd8827e9f16880985", | ||
| "requirements_hash": "sha256:288220847007f2f14c9a0aa2a972b33e92f6bb84f25dac1a248fbe6e55ec2bea", | ||
| "requirements_hash": "sha256:fa370cac93a65e09d769497457de2c60027eb53d6b7f05e44ff23e5a4a7f1b2e", | ||
| "version_inputs_hash": "sha256:58db986b7cd72eeded675f7c9afd8138fe024fb51451131b5562922bbde3cf43" | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||||
| use crate::runtime::RunArgs; | ||||||||||||||||||||||||||||||||||||
| use crate::utils::config::{ | ||||||||||||||||||||||||||||||||||||
| create_default_memory_folder, get_config_dir, get_default_memory_path, get_lib_dir, | ||||||||||||||||||||||||||||||||||||
| ConfigProvider, DefaultProvider, create_default_memory_folder, get_default_memory_path, | ||||||||||||||||||||||||||||||||||||
| get_memory_path, set_memory_path, | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
| use crate::utils::hf_model_downloader::*; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -100,8 +100,8 @@ impl MLXRuntime { | |||||||||||||||||||||||||||||||||||
| return Ok(()); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let config_dir = get_config_dir()?; | ||||||||||||||||||||||||||||||||||||
| let mut server_dir = get_lib_dir()?; | ||||||||||||||||||||||||||||||||||||
| let config_dir = DefaultProvider.get_config_dir()?; | ||||||||||||||||||||||||||||||||||||
| let mut server_dir = DefaultProvider.get_lib_dir()?; | ||||||||||||||||||||||||||||||||||||
| let pid_file = config_dir.join("server.pid"); | ||||||||||||||||||||||||||||||||||||
| fs::create_dir_all(&config_dir).context("Failed to create config directory")?; | ||||||||||||||||||||||||||||||||||||
| server_dir = server_dir.join("server"); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -129,7 +129,7 @@ impl MLXRuntime { | |||||||||||||||||||||||||||||||||||
| println!("Server is not running"); | ||||||||||||||||||||||||||||||||||||
| return Ok(()); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| let pid_file = get_config_dir()?.join("server.pid"); | ||||||||||||||||||||||||||||||||||||
| let pid_file = DefaultProvider.get_config_dir()?.join("server.pid"); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if !pid_file.exists() { | ||||||||||||||||||||||||||||||||||||
| eprintln!("server pid doesnt exist"); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -144,70 +144,14 @@ impl MLXRuntime { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| #[allow(dead_code)] | ||||||||||||||||||||||||||||||||||||
| fn run_model_by_sub_process(modelfile: Modelfile) { | ||||||||||||||||||||||||||||||||||||
| // build the arg list from modelfile | ||||||||||||||||||||||||||||||||||||
| let mut args: Vec<String> = vec![]; | ||||||||||||||||||||||||||||||||||||
| args.push("--model".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(modelfile.from.unwrap()); | ||||||||||||||||||||||||||||||||||||
| for parameter in modelfile.parameters { | ||||||||||||||||||||||||||||||||||||
| let param_value = parameter.value.to_string(); | ||||||||||||||||||||||||||||||||||||
| match parameter.param_type.as_str() { | ||||||||||||||||||||||||||||||||||||
| "num_predict" => { | ||||||||||||||||||||||||||||||||||||
| args.push("--max-tokens".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(param_value); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| "temperature" => { | ||||||||||||||||||||||||||||||||||||
| args.push("--temp".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(param_value); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| "top_p" => { | ||||||||||||||||||||||||||||||||||||
| args.push("--top-p".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(param_value); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| "seed" => { | ||||||||||||||||||||||||||||||||||||
| args.push("--seed".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(param_value); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| _ => {} | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| if let Some(system_prompt) = modelfile.system { | ||||||||||||||||||||||||||||||||||||
| args.push("--system-prompt".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(system_prompt); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| if let Some(adapter_path) = modelfile.adapter { | ||||||||||||||||||||||||||||||||||||
| args.push("--adapter-path".to_owned()); | ||||||||||||||||||||||||||||||||||||
| args.push(adapter_path); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| let mut mlx = match Command::new("mlx_lm.chat").args(args).spawn() { | ||||||||||||||||||||||||||||||||||||
| Ok(child) => child, | ||||||||||||||||||||||||||||||||||||
| Err(e) => { | ||||||||||||||||||||||||||||||||||||
| if e.kind() == std::io::ErrorKind::NotFound { | ||||||||||||||||||||||||||||||||||||
| eprintln!("❌ Error: mlx_lm.chat command not found"); | ||||||||||||||||||||||||||||||||||||
| eprintln!("💡 Hint: Install mlx-lm by running: pip install mlx-lm"); | ||||||||||||||||||||||||||||||||||||
| eprintln!("📝 Note: mlx-lm is only available on macOS with Apple Silicon"); | ||||||||||||||||||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| eprintln!("❌ Error: Failed to spawn mlx_lm.chat: {}", e); | ||||||||||||||||||||||||||||||||||||
| std::process::exit(1); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if let Err(err) = mlx.wait() { | ||||||||||||||||||||||||||||||||||||
| eprintln!("❌ Error: Failed to wait for mlx_lm: {}", err); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| struct TilesHinter; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| impl Hinter for TilesHinter { | ||||||||||||||||||||||||||||||||||||
| type Hint = String; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| fn hint(&self, line: &str, _pos: usize, _ctx: &rustyline::Context<'_>) -> Option<Self::Hint> { | ||||||||||||||||||||||||||||||||||||
| if line.is_empty() { | ||||||||||||||||||||||||||||||||||||
| Some("Send a message (/? for help)".to_string()) | ||||||||||||||||||||||||||||||||||||
| Some("Send a message (/help for help)".to_string()) | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| None | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
@@ -260,20 +204,22 @@ fn handle_slash_command(input: &str, modelname: &str) -> SlashCommand { | |||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| fn show_help(model_name: &str) { | ||||||||||||||||||||||||||||||||||||
| println!("\n=== Tiles REPL Help ===\n"); | ||||||||||||||||||||||||||||||||||||
| println!("\n=== Tiles REPL ===\n"); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| println!("Model:"); | ||||||||||||||||||||||||||||||||||||
| println!(" {}", model_name); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| println!("Directory:"); | ||||||||||||||||||||||||||||||||||||
| println!(" {}\n", get_memory_path().unwrap()); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| println!("Available Commands:"); | ||||||||||||||||||||||||||||||||||||
| println!(" /? Show this help message"); | ||||||||||||||||||||||||||||||||||||
| println!(" /help Show this help message"); | ||||||||||||||||||||||||||||||||||||
| println!(" /bye Exit the REPL"); | ||||||||||||||||||||||||||||||||||||
| println!(); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| println!("Current Model:"); | ||||||||||||||||||||||||||||||||||||
| println!(" {}", model_name); | ||||||||||||||||||||||||||||||||||||
| println!(); | ||||||||||||||||||||||||||||||||||||
| println!("\nDocumentation: https://tiles.run/book"); | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| println!("Usage Tips:"); | ||||||||||||||||||||||||||||||||||||
| println!(" - Type your questions or prompts directly"); | ||||||||||||||||||||||||||||||||||||
| println!("Report issues: https://github.com/tilesprivacy/tiles/issues"); | ||||||||||||||||||||||||||||||||||||
| println!(); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -542,12 +488,12 @@ async fn chat( | |||||||||||||||||||||||||||||||||||
| "python_code": python_code, | ||||||||||||||||||||||||||||||||||||
| "messages": [{"role": "assistant", "content": g_reply}, {"role": "user", "content": input}] | ||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||
| let res = client | ||||||||||||||||||||||||||||||||||||
| .post("http://127.0.0.1:6969/v1/responses") | ||||||||||||||||||||||||||||||||||||
| .json(&body) | ||||||||||||||||||||||||||||||||||||
| .send() | ||||||||||||||||||||||||||||||||||||
| .await | ||||||||||||||||||||||||||||||||||||
| .unwrap(); | ||||||||||||||||||||||||||||||||||||
| let api_url = if run_args.memory { | ||||||||||||||||||||||||||||||||||||
| "http://127.0.0.1:6969/v1/chat/completions" | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| "http://127.0.0.1:6969/v1/responses" | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
| let res = client.post(api_url).json(&body).send().await.unwrap(); | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+491
to
+496
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cd tiles && find . -name "mlx.rs" -type fRepository: tilesprivacy/tiles Length of output: 82 🏁 Script executed: wc -l tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles Length of output: 90 🏁 Script executed: sed -n '480,510p' tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles Length of output: 1077 🏁 Script executed: sed -n '470,490p' tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles Length of output: 559 🏁 Script executed: sed -n '500,530p' tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles Length of output: 1196 🏁 Script executed: sed -n '491,496p' tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles Length of output: 287 Propagate HTTP request errors instead of panicking with The 🛠️ Suggested fix- let res = client.post(api_url).json(&body).send().await.unwrap();
+ let res = client
+ .post(api_url)
+ .json(&body)
+ .send()
+ .await
+ .map_err(|e| e.to_string())?;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| let mut stream = res.bytes_stream(); | ||||||||||||||||||||||||||||||||||||
| let mut accumulated = String::new(); | ||||||||||||||||||||||||||||||||||||
|
|
@@ -574,12 +520,17 @@ async fn chat( | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| // Parse JSON | ||||||||||||||||||||||||||||||||||||
| let v: Value = serde_json::from_str(data).unwrap(); | ||||||||||||||||||||||||||||||||||||
| // println!("{:?}", v); | ||||||||||||||||||||||||||||||||||||
| // Check for metrics in the response | ||||||||||||||||||||||||||||||||||||
| if let Some(metrics_obj) = v.get("metrics") { | ||||||||||||||||||||||||||||||||||||
| metrics = serde_json::from_value(metrics_obj.clone()).ok(); | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| if let Some(delta) = v["output"][0]["content"][0]["text"].as_str() { | ||||||||||||||||||||||||||||||||||||
| let model_text: Option<&str> = if run_args.memory { | ||||||||||||||||||||||||||||||||||||
| v["choices"][0]["delta"]["content"].as_str() | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| v["output"][0]["content"][0]["text"].as_str() | ||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| if let Some(delta) = model_text { | ||||||||||||||||||||||||||||||||||||
| accumulated.push_str(delta); | ||||||||||||||||||||||||||||||||||||
| if !run_args.memory && delta.contains("**[Answer]**") { | ||||||||||||||||||||||||||||||||||||
| is_answer_start = true; | ||||||||||||||||||||||||||||||||||||
|
|
@@ -648,10 +599,10 @@ async fn wait_until_server_is_up() { | |||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| fn get_default_modelfile(memory_mode: bool) -> Result<PathBuf> { | ||||||||||||||||||||||||||||||||||||
| if memory_mode { | ||||||||||||||||||||||||||||||||||||
| let path = get_lib_dir()?.join("modelfiles/mem-agent"); | ||||||||||||||||||||||||||||||||||||
| let path = DefaultProvider.get_lib_dir()?.join("modelfiles/mem-agent"); | ||||||||||||||||||||||||||||||||||||
| Ok(path) | ||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||
| let path = get_lib_dir()?.join("modelfiles/gpt-oss"); | ||||||||||||||||||||||||||||||||||||
| let path = DefaultProvider.get_lib_dir()?.join("modelfiles/gpt-oss"); | ||||||||||||||||||||||||||||||||||||
| Ok(path) | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 351
🏁 Script executed:
# Check if the file exists ls -la tiles/src/runtime/mlx.rsRepository: tilesprivacy/tiles
Length of output: 136
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 275
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 551
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 544
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 522
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 1085
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 593
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 248
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 1814
🏁 Script executed:
Repository: tilesprivacy/tiles
Length of output: 44
🏁 Script executed:
# Look at the beginning of config.rs to see what Result is head -30 tiles/src/utils/config.rsRepository: tilesprivacy/tiles
Length of output: 1018
Handle error gracefully in
show_help()instead of panicking.get_memory_path()returnsResult<String>and can fail when memory path isn't configured, causingunwrap()to panic the REPL. Replace with error handling usingget_default_memory_path()as a fallback, or display "" instead.🛠️ Proposed fix
🤖 Prompt for AI Agents