Skip to content

Instantly share code, notes, and snippets.

@junichiro
Created May 18, 2023 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichiro/22b78474c1829cf69d0431c32af729d8 to your computer and use it in GitHub Desktop.
Save junichiro/22b78474c1829cf69d0431c32af729d8 to your computer and use it in GitHub Desktop.
Rust で OpenAI を呼ぶコードのテストコード
use app::openai::OpenAi;
#[tokio::test]
async fn test_openai() {
let input_text = "Hello, world!";
let client = OpenAi::new("text-davinci-003".to_string(), 400_u16);
let response_text = client.ask(input_text).await;
assert!(
response_text.contains(input_text),
"Expected '{}' to contain '{}'",
response_text,
input_text
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment