GuglielmoTor commited on
Commit
ecfc07b
·
verified ·
1 Parent(s): 12bbfb7

Update insight_and_tasks/agents/mentions_agent.py

Browse files
insight_and_tasks/agents/mentions_agent.py CHANGED
@@ -287,13 +287,20 @@ class EnhancedMentionsAnalysisAgent:
287
  Provide a concise summary of brand perception based on this data.
288
  """
289
  def chat_operation():
290
- if not pai.config.get("llm"):
291
- logger.warning("PandasAI LLM not configured for mentions agent. Attempting to configure.")
292
- from insight_and_tasks.utils.pandasai_setup import configure_pandasai
 
 
 
293
  configure_pandasai(self.api_key, self.model_name)
294
- if not pai.config.get("llm"):
295
- raise RuntimeError("PandasAI LLM could not be configured for mentions chat operation.")
296
- logger.info(f"Executing PandasAI chat for mentions analysis with LLM: {pai.config.get('llm')}")
 
 
 
 
297
  return pandas_ai_df.chat(analysis_query)
298
 
299
  analysis_result_raw = self.retry_mechanism.retry_with_backoff(
 
287
  Provide a concise summary of brand perception based on this data.
288
  """
289
  def chat_operation():
290
+ config = pai.config.get()
291
+ logger.info(f"pai_config: {config}, Type of config: {type(config)}")
292
+ if not config.llm:
293
+ logger.warning("PandasAI LLM not configured. Attempting to configure now.")
294
+ # This assumes configure_pandasai is available and sets the LLM config
295
+ from insight_and_tasks.utils.pandasai_setup import configure_pandasai
296
  configure_pandasai(self.api_key, self.model_name)
297
+
298
+ # Re-check configuration after setup attempt
299
+ config = pai.config.get()
300
+ if not config.llm:
301
+ raise RuntimeError("PandasAI LLM could not be configured for chat operation.")
302
+
303
+ logger.info(f"Executing PandasAI chat for follower analysis with LLM: {config.llm}")
304
  return pandas_ai_df.chat(analysis_query)
305
 
306
  analysis_result_raw = self.retry_mechanism.retry_with_backoff(