AppFlowy/frontend/rust-lib/flowy-ai/tests/text/completion_test.rs
Nathan.fooo 6ba7fc0317
feat: openai and stabilityai integration (#3439)
* chore: create trait

* test: add tests

* chore: remove log

* chore: disable log
2023-09-21 12:41:52 +08:00

19 lines
629 B
Rust

use crate::util::get_openai_config;
use async_openai::types::CreateCompletionRequestArgs;
use flowy_ai::text::open_ai::OpenAITextCompletion;
use flowy_ai::text::TextCompletion;
#[tokio::test]
async fn text_completion_test() {
if let Some(config) = get_openai_config() {
let client = OpenAITextCompletion::new(&config.openai_api_key);
let params = CreateCompletionRequestArgs::default()
.model("text-davinci-003")
.prompt("Write a rust function to calculate the sum of two numbers")
.build()
.unwrap();
let resp = client.text_completion(params).await.unwrap();
dbg!("{:?}", resp);
}
}