pandas-ai
pandas-ai copied to clipboard
exec() KeyError: '__import__'
System Info
pandasai 2.0.42
🐛 Describe the bug
I want to describe the table, but sometimes it has KeyError: 'import', but the code does not import anything. How to solve this issue? sdf1 = Agent(tables, config={"llm": ollama_llm, "enable_cache": False, "custom_whitelisted_dependencies": ["calendar", "dateutil"], "use_error_correction_framework": True})
Code running:
description = f'The table has {dfs[0].shape[0]} rows and {dfs[0].shape[1]} columns.\n\n'
description += 'Columns:\n'
for column in dfs[0].columns:
description += f'- {column} ({dfs[0][column].dtype}): {dfs[0][column].describe()}\n'
result = {'type': 'string', 'value': description}
```
2024-06-19 19:21:58 [INFO] Executing Step 6: CodeExecution
2024-06-19 19:21:58 [ERROR] Failed with error: Traceback (most recent call last):
File "C:\pandasai\pipelines\chat\code_execution.py", line 85, in execute
result = self.execute_code(code_to_run, code_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\pandasai\pipelines\chat\code_execution.py", line 171, in execute_code
exec(code, environment)
File "<string>", line 4, in <module>
KeyError: '__import__'