FlowiseAI / Flowise

Drag & drop UI to build your customized LLM flow
https://flowiseai.com
Apache License 2.0
27.16k stars 13.99k forks source link

[BUG] CSV agent is not working with OpenAI ChatGPT #2341

Open automaton82 opened 1 month ago

automaton82 commented 1 month ago

Describe the bug If you attempt to use the CSV agent with the attached public csv city data file, you get the following error:

Question: what cities are there

Response:

{'LatD': 'int64', ' "LatM"': 'int64', ' "LatS"': 'int64', ' "NS"': 'object', ' "LonD"': 'int64', ' "LonM"': 'int64', ' "LonS"': 'int64', ' "EW"': 'object', ' "City"': 'object', ' "State"': 'object'}
2024-05-06 19:54:32 [ERROR]: [server]: Error: Sorry, I'm unable to find answer for question: "what cities do you have" using following code: "df["City"].unique()"
Error: Sorry, I'm unable to find answer for question: "what cities do you have" using following code: "df["City"].unique()"
    at CSV_Agents.run (C:\git\flowise\packages\components\dist\nodes\agents\CSVAgent\CSVAgent.js:165:23)
    at async utilBuildChatflow (C:\git\flowise\packages\server\dist\utils\buildChatflow.js:232:15)
    at async createInternalPrediction (C:\git\flowise\packages\server\dist\controllers\internal-predictions\index.js:7:29)

All questions will fail though.

CSV file: cities.csv

To Reproduce Steps to reproduce the behavior:

  1. Create a chatflow and add a CSV agent node
  2. Use OpenAI ChatGPT Chat Model or LLM node, it's the same result for both
  3. Upload the attached csv file
  4. Ask "what cities are there"

Expected behavior This should work.

Setup

Additional context Aside from this problem, it also appears the uploaded file does not go into DISK BLOB storage. It goes into the database as base64. This behaviour is different than the CSV document loader which does go into DISK BLOB storage immediately when uploaded. Not sure if this is intended or not.

HenryHengZJ commented 1 month ago

OpenAI suddenly gives the prefix python, so the whole code becomes:

import pandas as pd
```python
print(df["Company Name"])
` ` `

which causes error when trying to run on pyodide image

HenryHengZJ commented 1 month ago

so the solution is to do some regex check to get rid of the prefix

toi500 commented 1 month ago

@HenryHengZJ

It looks like the same issue I just reported with the Airtable Agent.

https://github.com/FlowiseAI/Flowise/issues/2364

Hariharan1828 commented 1 month ago

I would like to take up this issue, planning to implement the changes in the ChatflowPool, kindly assign me @HenryHengZJ. Thanks in advance.