init commit with logic
This commit is contained in:
commit
6117b40357
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1529
Cargo.lock
generated
Normal file
1529
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "ferro"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
git2 = "0.19.0"
|
||||
reqwest = { version = "0.12.9", features = ["blocking"] }
|
||||
serde = { version = "1.0.215", features = ["derive"] }
|
||||
serde_json = "1.0.133"
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
"Ferro" is inspired by:
|
||||
|
||||
|
||||
Scientific Roots
|
||||
|
||||
1. Ferrum: Latin for iron, reflecting Rust's iron/oxidation themes.
|
||||
2. Ferro-: Greek prefix meaning iron or iron-containing.
|
||||
|
||||
|
||||
Relevant Connections
|
||||
|
||||
1. Ferrocene: An iron-containing compound.
|
||||
2. Ferroelectric: Materials exhibiting iron-like electrical properties.
|
||||
|
||||
|
||||
Simple, Modern Sound
|
||||
|
||||
"Ferro" is concise, memorable and has a technical feel, fitting for a Rust CLI tool.
|
25
src/git_grabber.rs
Normal file
25
src/git_grabber.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use git2::Repository;
|
||||
use std::{env::current_dir, path::PathBuf};
|
||||
|
||||
pub struct GitGrabber {
|
||||
pub repo: Option<Repository>,
|
||||
dir: PathBuf,
|
||||
}
|
||||
|
||||
impl GitGrabber {
|
||||
pub fn new() -> Self {
|
||||
GitGrabber {
|
||||
repo: None,
|
||||
dir: current_dir().unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_repo(&mut self) {
|
||||
let repo = match Repository::open(self.dir.clone()) {
|
||||
Ok(repo) => repo,
|
||||
Err(e) => panic!("Failed to open: {}", e),
|
||||
};
|
||||
|
||||
self.repo = Some(repo);
|
||||
}
|
||||
}
|
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@ -0,0 +1,35 @@
|
||||
mod git_grabber;
|
||||
mod mind_bridge;
|
||||
mod transporter;
|
||||
|
||||
// use core::panic;
|
||||
use git_grabber::GitGrabber;
|
||||
use mind_bridge::*;
|
||||
// use transporter::Transporter;
|
||||
|
||||
fn main() {
|
||||
// let a = MindGen::new("Some random commit message");
|
||||
// let mut transporter = Transporter::new();
|
||||
|
||||
let mut gg = GitGrabber::new();
|
||||
gg.get_repo();
|
||||
|
||||
gg.repo.unwrap().revwalk().unwrap().for_each(|x| {
|
||||
if x.is_ok() {
|
||||
println!("{:?}", x.unwrap())
|
||||
} else {
|
||||
println!("No rev")
|
||||
}
|
||||
});
|
||||
|
||||
return ();
|
||||
|
||||
// let res_text = transporter.make_request(a).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());
|
||||
}
|
49
src/mind_bridge.rs
Normal file
49
src/mind_bridge.rs
Normal file
@ -0,0 +1,49 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[allow(unused)]
|
||||
pub struct GenRes {
|
||||
model: String,
|
||||
created_at: String,
|
||||
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,
|
||||
}
|
||||
|
||||
#[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: &str) -> Self {
|
||||
Self {
|
||||
model: String::from("llama3.1"),
|
||||
stream: false,
|
||||
raw: false,
|
||||
prompt: String::from(input),
|
||||
system: String::from("You are a commit message generator. You will generate commit messages following this format Task(<task #>): <commit message> making sure to never go over 90 characters"),
|
||||
options: GenOptions {
|
||||
temperature: 0.5,
|
||||
num_predict: 90
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
src/transporter.rs
Normal file
29
src/transporter.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use crate::MindGen;
|
||||
use reqwest::blocking::Client;
|
||||
|
||||
#[allow(unused)]
|
||||
pub static OLLAMA_ENDP: &str = "http://localhost:11434/api/generate";
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct Transporter {
|
||||
pub client: Client,
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
impl Transporter {
|
||||
#[allow(unused)]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
client: Client::new(),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn make_request(
|
||||
&mut self,
|
||||
gen_data: MindGen,
|
||||
) -> Result<reqwest::blocking::Response, reqwest::Error> {
|
||||
let json_body = serde_json::to_string(&gen_data).unwrap();
|
||||
self.client.post(OLLAMA_ENDP).body(json_body).send()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user