From 8445e2f0761d90231028c59c6372feedb469255d Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sun, 12 Jan 2025 13:12:14 -0500 Subject: [PATCH] "feat(ml_interface): add prompt validation to make_request function" --- src/ml_interface.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ml_interface.rs b/src/ml_interface.rs index a7aa8f2..d0070e4 100644 --- a/src/ml_interface.rs +++ b/src/ml_interface.rs @@ -75,11 +75,15 @@ impl MlInterface { } #[allow(unused)] - pub fn make_request( - &mut self, - gen_data: MlBody, - ) -> Result { + pub fn make_request(&mut self, gen_data: MlBody) -> Result { + 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()) } }