mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
clippy fixes
This commit is contained in:
parent
c98ca240a6
commit
b0d66cb176
4 changed files with 7 additions and 38 deletions
|
|
@ -415,11 +415,9 @@ pub fn unified_stage_diff(repo_path: &RepoPath) -> Result<String> {
|
|||
_ => "",
|
||||
};
|
||||
|
||||
output.push_str(&format!(
|
||||
"{}{}",
|
||||
prefix,
|
||||
bytes2string(line.content()).unwrap()
|
||||
));
|
||||
if let Ok(line) = bytes2string(line.content()) {
|
||||
output.push_str(&format!("{prefix}{line}"));
|
||||
}
|
||||
|
||||
true
|
||||
})?;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ use std::env;
|
|||
fn main() {
|
||||
let diff = include_str!("simple.diff");
|
||||
|
||||
let summary = git2_summarize::git_diff_summarize_old(
|
||||
let summary = git2_summarize::git_diff_summarize(
|
||||
&env::var("OPENAI_API_KEY").unwrap(),
|
||||
diff,
|
||||
50,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +1,11 @@
|
|||
//! Uses Open API GPT-3 to summarize unified git diffs
|
||||
//! Uses Open API GPT-3 to summarize unified git diffs
|
||||
|
||||
use openai_api_rs::v1::{
|
||||
api::Client,
|
||||
chat_completion::{self, ChatCompletionRequest},
|
||||
common::GPT3_5_TURBO,
|
||||
completion::{self, CompletionRequest},
|
||||
};
|
||||
|
||||
/// Uses old GPT3_TEXT_DAVINCI_003 model to generate message
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `api_key` - open api key
|
||||
/// * `diff` - expects a diff formatted as a unified diff
|
||||
pub fn git_diff_summarize_old(
|
||||
api_key: &str,
|
||||
diff: &str,
|
||||
) -> Result<String, String> {
|
||||
let client = Client::new(api_key.to_string());
|
||||
|
||||
let req = CompletionRequest::new(
|
||||
completion::GPT3_TEXT_DAVINCI_003.to_string(),
|
||||
format!("Generate a Git commit message based on the following summary: {}\n\nCommit message: ",diff),
|
||||
)
|
||||
.max_tokens(500)
|
||||
.temperature(0.5)
|
||||
.n(1);
|
||||
|
||||
let result = client.completion(req).map_err(|e| e.message)?;
|
||||
Ok(result
|
||||
.choices
|
||||
.get(0)
|
||||
.ok_or_else(|| String::from("choises empty"))?
|
||||
.text
|
||||
.clone())
|
||||
}
|
||||
|
||||
/// Uses GPT3_5_TURBO model to generate message using chat completion API
|
||||
///
|
||||
/// # Arguments
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@ impl CommitComponent {
|
|||
}
|
||||
|
||||
match git2_summarize::git_diff_summarize(
|
||||
&api_key,
|
||||
api_key,
|
||||
&unified_diff,
|
||||
FIRST_LINE_LIMIT,
|
||||
) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue