-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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](64bit/async-openai@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] <[email protected]>
- Loading branch information
1 parent
8667c41
commit 6764fe7
Showing
3 changed files
with
25 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ | |
// Akira Moroo <[email protected]> 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()?; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,10 @@ | |
// Akira Moroo <[email protected]> 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<TokenStream, Box<dyn std::error::Error>> { | ||
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(), | ||
); | ||
} | ||
} | ||
|