Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

[BUG] CSV agent is not working with OpenAI ChatGPT

Open automaton82 opened this issue 1 year ago • 4 comments

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

  • Installation pnpm start
  • Flowise Version latest as of https://github.com/FlowiseAI/Flowise/commit/ef532866fde6b32305eadf076a220926c3c732a6
  • OS: Windows 11
  • Browser all

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.

automaton82 avatar May 07 '24 00:05 automaton82

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 avatar May 07 '24 00:05 HenryHengZJ

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

HenryHengZJ avatar May 07 '24 00:05 HenryHengZJ

@HenryHengZJ

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

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

toi500 avatar May 09 '24 01:05 toi500

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

Hariharan1828 avatar May 11 '24 05:05 Hariharan1828

Closing as https://github.com/FlowiseAI/Flowise/pull/2983 merged

HenryHengZJ avatar Aug 09 '24 11:08 HenryHengZJ