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
13.06k stars 1.26k forks source link

conversational failed #1405

Open HAL9KKK opened 9 hours ago

HAL9KKK commented 9 hours ago

System Info

OS version: windows 10 Python version: 3.12.7 The current version of pandasai being used: 2.3.0

🐛 Describe the bug

It seems the pipeline is not able to categorize correctly the conversation:

Here the config code for the Agent: config = {"llm":llm,"verbose": True, "direct_sql": False,"enable_cache": True,"response_parser": StreamlitResponse2, 'conversational':True}

Here the pipepline log, where in the first attempt with "Hello" it is ok, then with "How are you?" it is trying to create the code...missing the skipping:

2024-10-21 19:03:01 [INFO] Question: hello
2024-10-21 19:03:01 [INFO] Running PandasAI with azure-openai LLM...
2024-10-21 19:03:01 [INFO] Prompt ID: 0e905df9-dec5-4279-9c2e-cd16bff1b15a
2024-10-21 19:03:01 [INFO] Executing Pipeline: GenerateChatPipeline
2024-10-21 19:03:01 [INFO] Executing Step 0: ValidatePipelineInput
2024-10-21 19:03:01 [INFO] Executing Step 1: CacheLookup
2024-10-21 19:03:01 [INFO] Using cached response
2024-10-21 19:03:01 [INFO] Executing Step 2: PromptGeneration
2024-10-21 19:03:01 [INFO] Executing Step 2: Skipping...
2024-10-21 19:03:01 [INFO] Executing Step 3: CodeGenerator
2024-10-21 19:03:01 [INFO] Executing Step 3: Skipping...
2024-10-21 19:03:01 [INFO] Executing Step 4: CachePopulation
2024-10-21 19:03:01 [INFO] Executing Step 4: Skipping...
2024-10-21 19:03:01 [INFO] Executing Step 5: CodeCleaning
2024-10-21 19:03:01 [INFO] 
Code running:

result = {'type': 'string', 'value': 'Hello! How can I assist you today?'} print(result)

2024-10-21 19:03:01 [INFO] Executing Step 6: CodeExecution
2024-10-21 19:03:01 [INFO] Executing Step 7: ResultValidation
2024-10-21 19:03:01 [INFO] Answer: {'type': 'string', 'value': 'Hello! How can I assist you today?'}
2024-10-21 19:03:01 [INFO] Executing Step 8: ResultParsing
2024-10-21 19:03:07 [INFO] Question: how are you?
2024-10-21 19:03:07 [INFO] Running PandasAI with azure-openai LLM...
2024-10-21 19:03:07 [INFO] Prompt ID: 03e3f142-d68f-48b7-9475-f7e163e49234
2024-10-21 19:03:07 [INFO] Executing Pipeline: GenerateChatPipeline
2024-10-21 19:03:07 [INFO] Executing Step 0: ValidatePipelineInput
2024-10-21 19:03:07 [INFO] Executing Step 1: CacheLookup
2024-10-21 19:03:07 [INFO] Executing Step 2: PromptGeneration
2024-10-21 19:03:07 [INFO] Using prompt: 
dosubot[bot] commented 9 hours ago

The issue you're experiencing seems to be related to the pipeline not correctly categorizing conversational inputs, specifically when it should skip steps for general greetings like "How are you?".

In the PandasAI pipeline, steps like PromptGeneration and CodeGenerator are typically skipped if the response is found in the cache, as determined by the is_cached method [1]. However, it seems that the pipeline is not correctly identifying "How are you?" as a conversational input that should be skipped.

To address this, you might want to check the logic that determines when to skip these steps for conversational inputs. Ensure that the configuration or logic responsible for identifying and categorizing conversational inputs is correctly implemented. This might involve reviewing how the conversational parameter is being used in your setup, as its expected behavior is not clearly documented in the available information.

If the issue persists, consider reviewing the implementation of the SemanticChatPipeline and related components like SemanticResultParser, which are responsible for parsing and categorizing conversational inputs [2][3]. Adjustments in these areas might help in correctly categorizing and skipping steps for conversational inputs.

To continue talking to Dosu, mention @dosu.