"feat(ml_interface): add prompt validation to make_request function"

This commit is contained in:
Triston Armstrong 2025-01-12 13:12:14 -05:00
parent f96ab7523e
commit 8445e2f076
Signed by: tristonarmstrong
GPG Key ID: A23B48AE45EB6EFE

View File

@ -75,11 +75,15 @@ impl MlInterface {
}
#[allow(unused)]
pub fn make_request(
&mut self,
gen_data: MlBody,
) -> Result<reqwest::blocking::Response, reqwest::Error> {
pub fn make_request(&mut self, gen_data: MlBody) -> Result<reqwest::blocking::Response, &str> {
if gen_data.prompt.len() < 1 {
panic!("No prompt provided");
}
let json_body = serde_json::to_string(&gen_data).unwrap();
self.client.post(OLLAMA_ENDP).body(json_body).send()
let res = self.client.post(OLLAMA_ENDP).body(json_body).send();
if res.is_err() {
panic!("Failed to send ollama payload");
}
Ok(res.unwrap())
}
}