Spaces:
Running
Running
Update insight_and_tasks/agents/follower_agent.py
Browse files
insight_and_tasks/agents/follower_agent.py
CHANGED
@@ -363,15 +363,20 @@ class EnhancedFollowerAnalysisAgent:
|
|
363 |
# Ensure the LLM for PandasAI is correctly configured before this call
|
364 |
# This might involve re-calling configure_pandasai if it's not persistent
|
365 |
# or if the LLM object needs to be explicitly passed to PandasAI DataFrame.
|
366 |
-
|
|
|
|
|
367 |
logger.warning("PandasAI LLM not configured. Attempting to configure now.")
|
368 |
-
# This assumes configure_pandasai is available and sets
|
369 |
from insight_and_tasks.utils.pandasai_setup import configure_pandasai
|
370 |
configure_pandasai(self.api_key, self.model_name)
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
373 |
|
374 |
-
logger.info(f"Executing PandasAI chat for follower analysis with LLM: {
|
375 |
return pandas_ai_df.chat(analysis_query)
|
376 |
|
377 |
analysis_result_raw = self.retry_mechanism.retry_with_backoff(
|
|
|
363 |
# Ensure the LLM for PandasAI is correctly configured before this call
|
364 |
# This might involve re-calling configure_pandasai if it's not persistent
|
365 |
# or if the LLM object needs to be explicitly passed to PandasAI DataFrame.
|
366 |
+
# Check if LLM is configured using the proper config.get() method
|
367 |
+
config = pai.config.get()
|
368 |
+
if not config.get("llm"):
|
369 |
logger.warning("PandasAI LLM not configured. Attempting to configure now.")
|
370 |
+
# This assumes configure_pandasai is available and sets the LLM config
|
371 |
from insight_and_tasks.utils.pandasai_setup import configure_pandasai
|
372 |
configure_pandasai(self.api_key, self.model_name)
|
373 |
+
|
374 |
+
# Re-check configuration after setup attempt
|
375 |
+
config = pai.config.get()
|
376 |
+
if not config.get("llm"):
|
377 |
+
raise RuntimeError("PandasAI LLM could not be configured for chat operation.")
|
378 |
|
379 |
+
logger.info(f"Executing PandasAI chat for follower analysis with LLM: {config.get('llm')}")
|
380 |
return pandas_ai_df.chat(analysis_query)
|
381 |
|
382 |
analysis_result_raw = self.retry_mechanism.retry_with_backoff(
|