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.

Merge pull request #6 from tileshq/fix/comment-parsing-issue

Modelfile: Fixed parsing error on comments with reserved definitions

authored by

Anandu Pavanan and committed by
GitHub
96f798c8 74000485

+36 -3
+36 -3
src/core/modelfile.rs
··· 50 50 Single(&'a str), 51 51 Pair((&'a str, &'a str)), 52 52 } 53 + impl<'a> Display for Output<'a> { 54 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 55 + match self { 56 + Self::Single(word) => write!(f, "{}", word), 57 + Self::Pair((word, word_1)) => write!(f, "{} {}", word, word_1), 58 + } 59 + } 60 + } 53 61 54 62 impl FromStr for Role { 55 63 type Err = String; ··· 341 349 ("adapter", Output::Single(adapter)) => modelfile.add_adapter(adapter), 342 350 ("message", Output::Pair((role, message))) => modelfile.add_message(role, message), 343 351 ("license", Output::Single(license)) => modelfile.add_license(license), 344 - ("#", Output::Single(comment)) => modelfile.add_comment(comment), 345 - _ => { 346 - modelfile.errors.push(String::from("Invalid instruction")); 352 + ("#", comment) => { 353 + let comment_str = comment.to_string(); 354 + modelfile.add_comment(&comment_str) 355 + } 356 + (instruction, command) => { 357 + modelfile.errors.push(format!( 358 + "Invalid instruction Instruction: `{}` command: `{}`", 359 + instruction, command 360 + )); 347 361 Ok(()) 348 362 } 349 363 }; ··· 433 447 let modelfile = " 434 448 FROM llama3.2 435 449 PARAMETER num_ctx 4096 450 + "; 451 + 452 + assert!(parse(modelfile).is_ok()); 453 + } 454 + #[test] 455 + fn test_invalid_instruction() { 456 + let modelfile = " 457 + FROM llama3.2 458 + adapter num_ctx 4096 459 + "; 460 + 461 + assert!(parse(modelfile).is_err()); 462 + } 463 + 464 + #[test] 465 + fn test_valid_comment() { 466 + let modelfile = " 467 + FROM llama3.2 468 + # system num_ctx 4096 436 469 "; 437 470 438 471 assert!(parse(modelfile).is_ok());