(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
|
||||
pub struct GitGrabber {}
|
||||
@ -25,4 +30,23 @@ impl GitGrabber {
|
||||
let b = from_utf8(&output.stdout).unwrap();
|
||||
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 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
|
||||
.make_request(mind_gen_text)
|
||||
.unwrap()
|
||||
.text()
|
||||
.unwrap();
|
||||
let response: Result<GenRes, _> = serde_json::from_str(&res_text);
|
||||
|
||||
if response.is_err() {
|
||||
panic!("oop something went wrong: {:?}", response.err());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// this is a test comment
|
||||
#[derive(Debug, Deserialize)]
|
||||
// this is a test comment
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[allow(unused)]
|
||||
pub struct GenRes {
|
||||
model: String,
|
||||
created_at: String,
|
||||
pub response: String,
|
||||
done: bool,
|
||||
total_duration: u64,
|
||||
load_duration: u64,
|
||||
prompt_eval_count: u64,
|
||||
prompt_eval_duration: u64,
|
||||
eval_count: u64,
|
||||
eval_duration: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct GenOptions {
|
||||
temperature: f32,
|
||||
num_predict: u8,
|
||||
repeat_last_n: u8,
|
||||
top_k: u8,
|
||||
top_p: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct MindGen {
|
||||
model: String,
|
||||
prompt: String,
|
||||
stream: bool,
|
||||
raw: bool,
|
||||
system: String,
|
||||
options: GenOptions,
|
||||
}
|
||||
|
||||
impl MindGen {
|
||||
#[allow(unused)]
|
||||
pub struct GenRes {
|
||||
model: String,
|
||||
created_at: String,
|
||||
pub response: String,
|
||||
done: bool,
|
||||
total_duration: u64,
|
||||
load_duration: u64,
|
||||
prompt_eval_count: u64,
|
||||
prompt_eval_duration: u64,
|
||||
eval_count: u64,
|
||||
eval_duration: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct GenOptions {
|
||||
temperature: f32,
|
||||
num_predict: u8,
|
||||
repeat_last_n: u8,
|
||||
top_k: u8,
|
||||
top_p: f32
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct MindGen {
|
||||
model: String,
|
||||
prompt: String,
|
||||
stream: bool,
|
||||
raw: bool,
|
||||
system: String,
|
||||
options: GenOptions,
|
||||
}
|
||||
|
||||
impl MindGen {
|
||||
#[allow(unused)]
|
||||
pub fn new(input: String) -> Self {
|
||||
Self {
|
||||
pub fn new(directions: String, input: String) -> Self {
|
||||
Self {
|
||||
model: String::from("llama3.1"),
|
||||
stream: false,
|
||||
raw: false,
|
||||
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"),
|
||||
options: GenOptions {
|
||||
system: directions,
|
||||
options: GenOptions {
|
||||
temperature: 0.1,
|
||||
num_predict: 0,
|
||||
repeat_last_n: 0,
|
||||
top_k: 10,
|
||||
top_p: 0.5
|
||||
}
|
||||
top_p: 0.5,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user