Skip to content

Commit

Permalink
fix: use available legacy completion model
Browse files Browse the repository at this point in the history
  • Loading branch information
rellfy committed Feb 22, 2024
1 parent 4c9a5f4 commit 14543fa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/completions_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() {

stdin().read_line(&mut prompt).unwrap();

let completion = Completion::builder("text-davinci-003")
let completion = Completion::builder("gpt-3.5-turbo-instruct")
.prompt(&prompt)
.max_tokens(1024)
.create()
Expand Down
5 changes: 3 additions & 2 deletions src/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,14 @@ mod tests {
use crate::set_key;
use dotenvy::dotenv;
use std::env;
use crate::tests::DEFAULT_LEGACY_MODEL;

#[tokio::test]
async fn completion() {
dotenv().ok();
set_key(env::var("OPENAI_KEY").unwrap());

let completion = Completion::builder("text-davinci-003")
let completion = Completion::builder(DEFAULT_LEGACY_MODEL)
.prompt("Say this is a test")
.max_tokens(7)
.temperature(0.0)
Expand All @@ -185,7 +186,7 @@ mod tests {

assert_eq!(
completion.choices.first().unwrap().text,
"\n\nThis is indeed a test"
"\n\nThis is a test."
);
}
}
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,11 @@ fn get_base_url() -> &'static Mutex<String> {
}

#[cfg(test)]
mod tests {
pub mod tests {
use super::*;

pub const DEFAULT_LEGACY_MODEL: &str = "gpt-3.5-turbo-instruct";

#[test]
fn test_get_base_url_default() {
assert_eq!(
Expand Down
7 changes: 3 additions & 4 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ mod tests {
use crate::set_key;
use dotenvy::dotenv;
use std::env;
use crate::tests::DEFAULT_LEGACY_MODEL;

#[tokio::test]
async fn model() {
dotenv().ok();
set_key(env::var("OPENAI_KEY").unwrap());

let model = Model::from("text-davinci-003").await.unwrap();

assert_eq!(model.id, "text-davinci-003");
let model = Model::from(DEFAULT_LEGACY_MODEL).await.unwrap();
assert_eq!(model.id, DEFAULT_LEGACY_MODEL);
}
}

0 comments on commit 14543fa

Please sign in to comment.