(save state) few random changes and fn adds
This commit is contained in:
parent
fa70d465d4
commit
e5036b55b1
@ -1,4 +1,9 @@
|
|||||||
use std::{fs::write, io::Write, process::Command, str::from_utf8};
|
use std::{
|
||||||
|
fs::write,
|
||||||
|
io::Write,
|
||||||
|
process::{Command, Output},
|
||||||
|
str::from_utf8,
|
||||||
|
};
|
||||||
|
|
||||||
// this is a comment test here
|
// this is a comment test here
|
||||||
pub struct GitGrabber {}
|
pub struct GitGrabber {}
|
||||||
@ -25,4 +30,23 @@ impl GitGrabber {
|
|||||||
let b = from_utf8(&output.stdout).unwrap();
|
let b = from_utf8(&output.stdout).unwrap();
|
||||||
String::from(b)
|
String::from(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn generate_repo_desc(&self, origin_branch: &str, local_branch: &str) -> String {
|
||||||
|
let output = Command::new("git")
|
||||||
|
.args([
|
||||||
|
"rev-list",
|
||||||
|
"--left-right",
|
||||||
|
"--pretty=oneline",
|
||||||
|
&format!(
|
||||||
|
"{}...{}",
|
||||||
|
origin_branch.to_string(),
|
||||||
|
local_branch.to_string()
|
||||||
|
),
|
||||||
|
])
|
||||||
|
.output()
|
||||||
|
.expect("Failed to get repo details");
|
||||||
|
|
||||||
|
let b = from_utf8(&output.stdout).unwrap();
|
||||||
|
String::from(b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
src/main.rs
21
src/main.rs
@ -12,17 +12,32 @@ fn main() {
|
|||||||
|
|
||||||
let gg = GitGrabber::new();
|
let gg = GitGrabber::new();
|
||||||
let diff = gg.get_diff();
|
let diff = gg.get_diff();
|
||||||
let mind_gen_text = MindGen::new(format!("input: {}; branch: {}", diff, "dev"));
|
let commits_msg = String::from("create a short commit message from this diff, with format Task(<branch_name>): <commit_message>. only respond with the commit message");
|
||||||
|
let mind_gen_text = MindGen::new(commits_msg, format!("input: {}; branch: {}", diff, "dev"));
|
||||||
let res_text = transporter
|
let res_text = transporter
|
||||||
.make_request(mind_gen_text)
|
.make_request(mind_gen_text)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.text()
|
.text()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let response: Result<GenRes, _> = serde_json::from_str(&res_text);
|
let response: Result<GenRes, _> = serde_json::from_str(&res_text);
|
||||||
|
|
||||||
if response.is_err() {
|
if response.is_err() {
|
||||||
panic!("oop something went wrong: {:?}", response.err());
|
panic!("oop something went wrong: {:?}", response.err());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:#?}", response.unwrap().response);
|
println!("{:#?}", response.unwrap().response);
|
||||||
|
|
||||||
|
let z = gg.generate_repo_desc("master", "dev");
|
||||||
|
let pr_msg = String::from(
|
||||||
|
"create a pull request description in markdown from the following revlog output. Only respond with pr description, nothing else.",
|
||||||
|
);
|
||||||
|
let mind_gen_repo = MindGen::new(pr_msg, z);
|
||||||
|
let repo_text = transporter
|
||||||
|
.make_request(mind_gen_repo)
|
||||||
|
.unwrap()
|
||||||
|
.text()
|
||||||
|
.unwrap();
|
||||||
|
let repo_response: Result<GenRes, _> = serde_json::from_str(&repo_text);
|
||||||
|
if repo_response.is_err() {
|
||||||
|
panic!("oop something went wrong: {:?}", repo_response.err());
|
||||||
|
}
|
||||||
|
println!("{:#?}", repo_response.unwrap().response);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
num_predict: u8,
|
num_predict: u8,
|
||||||
repeat_last_n: u8,
|
repeat_last_n: u8,
|
||||||
top_k: u8,
|
top_k: u8,
|
||||||
top_p: f32
|
top_p: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
@ -37,20 +37,20 @@
|
|||||||
|
|
||||||
impl MindGen {
|
impl MindGen {
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub fn new(input: String) -> Self {
|
pub fn new(directions: String, input: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
model: String::from("llama3.1"),
|
model: String::from("llama3.1"),
|
||||||
stream: false,
|
stream: false,
|
||||||
raw: false,
|
raw: false,
|
||||||
prompt: input,
|
prompt: input,
|
||||||
system: String::from("create a short commit message from this diff, with format Task(<branch_name>): <commit_message>. only respond with the commit message"),
|
system: directions,
|
||||||
options: GenOptions {
|
options: GenOptions {
|
||||||
temperature: 0.1,
|
temperature: 0.1,
|
||||||
num_predict: 0,
|
num_predict: 0,
|
||||||
repeat_last_n: 0,
|
repeat_last_n: 0,
|
||||||
top_k: 10,
|
top_k: 10,
|
||||||
top_p: 0.5
|
top_p: 0.5,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user