Sinaptik-AI / pandas-ai

Chat with your database (SQL, CSV, pandas, polars, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.
https://pandas-ai.com
Other
12.75k stars 1.23k forks source link

pandasai.exceptions.PandasAIApiCallError: Training failed because of internal server error try again later! #1081

Closed vpurandara closed 6 months ago

vpurandara commented 6 months ago

System Info

Please share your system info with us. OS version: ubuntu: 22.04 Python version: python 3.9 The current version of pandasai being used: 2.0.19

🐛 Describe the bug

Still 2 days before it is working fine, currently it is throwing error, even update to pandasa==2.0.26 but still same

2024-04-01 14:54:36 [INFO] Agent successfully trained on the data
2024-04-01 14:54:36 [INFO] Question: Use 'pd.Timestamp.now()' for relative points in time, e.g. 'this month'. 'this week', 'yesterday', 'last week'. How Many Leads This Week
2024-04-01 14:54:36 [INFO] Running PandasAI with openai LLM...
2024-04-01 14:54:36 [INFO] Prompt ID: e6cc1467-c3dd-40b0-9aec-4876a98add15
2024-04-01 14:54:36 [INFO] Executing Pipeline: GenerateChatPipeline
2024-04-01 14:54:36 [INFO] Executing Step 0: ValidatePipelineInput
2024-04-01 14:54:36 [INFO] Executing Step 1: CacheLookup
2024-04-01 14:54:36 [INFO] Executing Step 2: PromptGeneration
2024-04-01 14:54:37 [ERROR] Pipeline failed on step 2: Training failed because of internal server error try again later!
Traceback (most recent call last):
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/pipelines/chat/generate_chat_pipeline.py", line 281, in run
    output = (self.code_generation_pipeline | self.code_execution_pipeline).run(
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/pipelines/pipeline.py", line 137, in run
    raise e
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/pipelines/pipeline.py", line 101, in run
    step_output = logic.execute(
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/pipelines/chat/prompt_generation.py", line 37, in execute
    self.logger.log(f"Using prompt: {prompt}")
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/prompts/base.py", line 54, in __str__
    return self.to_string()
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/prompts/base.py", line 49, in to_string
    self._resolved_prompt = self.prompt.render(**self.props)
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/prompts/templates/generate_python_code.tmpl", line 19, in top-level template code
    {% include 'shared/vectordb_docs.tmpl' with context %}
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/prompts/templates/shared/vectordb_docs.tmpl", line 1, in top-level template code
    {% if context.vectorstore %}{% set documents = context.vectorstore.get_relevant_qa_documents(context.memory.get_last_message()) %}
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/vectorstores/bamboo_vectorstore.py", line 56, in get_relevant_qa_documents
    docs = self._session.get(
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/helpers/request.py", line 34, in get
    return self.make_request("GET", path, **kwargs)["data"]
  File "/home/purandara/anaconda3/envs/propflo-ai2/lib/python3.9/site-packages/pandasai/helpers/request.py", line 71, in make_request
    raise PandasAIApiCallError(data["message"])
pandasai.exceptions.PandasAIApiCallError: Training failed because of internal server error try again later!

@gventuri

fralu07 commented 6 months ago

i have the same problem.

My setup: MacOs 14.3.1 Jupyter lap 4.1.4 run in docker Python version: 3.11 pandasai: 2.0.26

image
HITjunle commented 6 months ago

I still do not solve the problem, but you can ignore pandasai api by using the code:

    os.environ.pop("PANDASAI_API_KEY", None)
    llm = OpenAI()
    df = pd.read_csv(path)
    agent = Agent(df, config={"llm": llm, "enable_cache": False}, description=description)

and it will work by ignoring pandasai's training data.

vpurandara commented 6 months ago

@HITjunle , this resolves the issue temporarily. Thanks for resposne.