@@ -49,11 +49,16 @@ def generate_profile(self) -> Dict[str, Any]:
4949 Returns:
5050 Dictionary containing the complete data profile
5151 """
52- self .data = self ._read_data ()
53- content = self ._generate_content (self .prompt , self .data )
54- # content = self.prompt.format(data=self.data)
55- res = self ._call_model (content )
56- self .profile = self ._wrap_data_response (res )
52+ try :
53+ self .profile = self .generate_profile ()
54+ self .data = self ._read_data ()
55+ content = self ._generate_content (self .prompt , self .data )
56+ # content = self.prompt.format(data=self.data)
57+ res = self ._call_model (content )
58+ self .profile = self ._wrap_data_response (res )
59+ except Exception as e :
60+ print (f"Error generating profile: { e } " )
61+ self .profile = {}
5762 return self .profile
5863
5964 @staticmethod
@@ -212,6 +217,7 @@ def _call_model(
212217 messages = messages ,
213218 api_key = self .api_key ,
214219 )
220+ # TODO: handle failed call of model
215221 response = response .output ["choices" ][0 ]["message" ]["content" ]
216222 # Clean and parse the JSON response from the LLM
217223 response = (
@@ -223,10 +229,8 @@ def _call_model(
223229 )
224230 return response
225231
226- except Exception :
227- import traceback
228-
229- print (traceback .format_exc ())
232+ except Exception as e :
233+ print (f"Error calling the model { self .model } with { e } " )
230234 # Consider returning None or an empty dict on failure
231235 return {}
232236
0 commit comments