From 6764fe7572025ce360c3f4f8968abd1f1a1314ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 02:27:22 +0000 Subject: [PATCH] build(deps): update async-openai requirement from 0.14.2 to 0.16.2 Updates the requirements on [async-openai](https://github.com/64bit/async-openai) to permit the latest version. - [Release notes](https://github.com/64bit/async-openai/releases) - [Commits](https://github.com/64bit/async-openai/compare/async-openai-v0.14.2...async-openai-v0.16.2) --- updated-dependencies: - dependency-name: async-openai dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- src/internal/auto_impl.rs | 20 ++++++++++---------- src/internal/auto_test.rs | 28 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 28cdf76..45dd0d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,5 +20,5 @@ trybuild = { version = "1.0", features = ["diff"] } syn = { version = "2.0", features = ["full", "extra-traits", "parsing"] } proc-macro2 = { version = "1.0", features = ["nightly"] } quote = "1.0" -async-openai = "0.14.2" +async-openai = "0.16.2" tokio = { version = "1.0", features = ["rt-multi-thread"] } diff --git a/src/internal/auto_impl.rs b/src/internal/auto_impl.rs index f707648..6af594b 100644 --- a/src/internal/auto_impl.rs +++ b/src/internal/auto_impl.rs @@ -2,7 +2,10 @@ // Akira Moroo 2023 use async_openai::{ - types::{ChatCompletionRequestMessageArgs, CreateChatCompletionRequestArgs, Role}, + types::{ + ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestUserMessageArgs, + CreateChatCompletionRequestArgs, + }, Client, }; use proc_macro::TokenStream; @@ -39,24 +42,21 @@ impl AutoImpl { let request = CreateChatCompletionRequestArgs::default() .model("gpt-3.5-turbo") .messages([ - ChatCompletionRequestMessageArgs::default() - .role(Role::System) + ChatCompletionRequestSystemMessageArgs::default() .content("You are a Rust expert who can implement the given function.") - .build()?, - ChatCompletionRequestMessageArgs::default() - .role(Role::User) + .build()?.into(), + ChatCompletionRequestUserMessageArgs::default() .content(format!( "Read this incomplete Rust code:\n```rust\n{}\n```", self.token_stream )) - .build()?, - ChatCompletionRequestMessageArgs::default() - .role(Role::User) + .build()?.into(), + ChatCompletionRequestUserMessageArgs::default() .content(format!( "Complete the Rust code that follows this instruction: '{}'. Your response must start with code block '```rust'.", self.doc )) - .build()?, + .build()?.into(), ]) .build()?; diff --git a/src/internal/auto_test.rs b/src/internal/auto_test.rs index 5a11a5e..2368540 100644 --- a/src/internal/auto_test.rs +++ b/src/internal/auto_test.rs @@ -2,7 +2,10 @@ // Akira Moroo 2023 use async_openai::{ - types::{ChatCompletionRequestMessageArgs, CreateChatCompletionRequestArgs, Role}, + types::{ + ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestUserMessageArgs, + CreateChatCompletionRequestArgs, + }, Client, }; use proc_macro::TokenStream; @@ -46,43 +49,40 @@ impl AutoTest { async fn completion(&mut self, args: Args) -> Result> { let mut output = self.token_stream.clone(); - let mut messages = vec![ - ChatCompletionRequestMessageArgs::default() - .role(Role::System) + let mut messages = + vec![ + ChatCompletionRequestSystemMessageArgs::default() .content( "You are a Rust expert who can generate perfect tests for the given function.", ) - .build()?, - ChatCompletionRequestMessageArgs::default() - .role(Role::User) + .build()?.into(), + ChatCompletionRequestUserMessageArgs::default() .content(format!( "Read this Rust function:\n```rust\n{}\n```", self.token_stream )) - .build()?, + .build()?.into(), ]; if args.test_names.is_empty() { messages.push( - ChatCompletionRequestMessageArgs::default() - .role(Role::User) + ChatCompletionRequestUserMessageArgs::default() .content( "Write a test case for the function as much as possible in Markdown code snippet style. Your response must start with code block '```rust'.", ) - .build()?, + .build()?.into(), ); } else { for test_name in args.test_names { messages.push( - ChatCompletionRequestMessageArgs::default() - .role(Role::User) + ChatCompletionRequestUserMessageArgs::default() .content( format!( "Write a test case `{}` for the function in Markdown code snippet style. Your response must start with code block '```rust'.", test_name ) ) - .build()?, + .build()?.into(), ); } }