"feat(main): Update main function to use new MlBody and ml.make_request APIs"

This commit is contained in:
Triston Armstrong 2025-01-12 12:50:59 -05:00
parent 3c0a1c505c
commit 4132b953c9
Signed by: tristonarmstrong
GPG Key ID: A23B48AE45EB6EFE

View File

@ -17,17 +17,17 @@ fn main() {
}; };
if prompt.is_none() { if prompt.is_none() {
println!("Sorry nothing to do.. exiting");
return; return;
} }
let mut ml = MlInterface::new(); let mut ml = MlInterface::new();
let (directions, content) = prompt.unwrap(); let (directions, content) = prompt.unwrap();
let mind_gen_text = MlBody::new(content, directions); let body = MlBody::new(content, directions);
let res_text = ml.make_request(mind_gen_text).unwrap().text().unwrap(); let res_text = ml.make_request(body).unwrap().text().unwrap();
let response: Result<MlResponse, _> = serde_json::from_str(&res_text); let response: Result<MlResponse, _> = 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()); println!("{:?}", response.unwrap().response);
} }