Skip to content

Commit

Permalink
tests: Added code completion test
Browse files Browse the repository at this point in the history
  • Loading branch information
SpeedCrash100 committed Sep 6, 2024
1 parent 6cc5688 commit 3e67995
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/code_completion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use ollama_rs::{
generation::{completion::request::GenerationRequest, options::GenerationOptions},
Ollama,
};

const CODE_MODEL: &str = "granite-code:3b";

#[tokio::test]
async fn typical_c_code_main() {
const C_PREFIX: &str = "int m";
const C_SUFFIX: &str = "(int argc, char **argv)";
const C_COMPLETION: &str = "ain";

let options = GenerationOptions::default().seed(146);
let request =
GenerationRequest::new_with_suffix(CODE_MODEL.into(), C_PREFIX.into(), C_SUFFIX.into())
.options(options);

let ollama = Ollama::default();
let res = ollama.generate(request).await.unwrap();

let completion = res.response;
assert_eq!(completion, C_COMPLETION);
}

0 comments on commit 3e67995

Please sign in to comment.