Flowise icon indicating copy to clipboard operation
Flowise copied to clipboard

[BUG] Pyodide Packages Loading Problem - Chatflow: CSV Agent with LocalAI

Open agpaola opened this issue 1 year ago • 6 comments

Describe the bug

I am encountering an issue when trying to use the CSV Agent with a LocalAI whose model is 'gpt-4-32k'. When I prompt "Hello" in the chat, it replies like this:

PythonError: Traceback (most recent call last): File "/lib/python311.zip/_pyodide/_base.py", line 571, in eval_code_async await CodeRunner( File "/lib/python311.zip/_pyodide/_base.py", line 394, in run_async coroutine = eval(self.code, globals, locals) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1, in ModuleNotFoundError: The module 'pandas' is included in the Pyodide distribution, but it is not installed. You can install it by calling: await micropip.install("pandas") in Python, or await pyodide.loadPackage("pandas") in JavaScript See
https://pyodide.org/en/stable/usage/loading-packages.html
for more details.

Is this a Flowise bug or caused by my flowise installed node_modules?

$ npm pandas --version
10.8.0

To Reproduce Steps to reproduce the behavior:

  1. Go to 'CSV Agent' template

image

  1. Replace the CHATOPENAI with LOCALAI (I am using a local model)
  2. Prompt "Hello"
  3. See error

Expected behavior A clear and concise description of what you expected to happen.

Flow The local AI is not publicly available.

Setup

  • Installation: npx flowise start
  • Flowise Version: flowise/1.8.0
  • OS: Linux
  • Node Version: node-v20.6.1
  • Browser: Firefox

agpaola avatar May 27 '24 15:05 agpaola

Any updates? I'm getting an error running csv-agent as well which is associated with pandas not being installed, which is rendering the following: { "statusCode": 500, "success": false, "message": "Error: nodesService.executeCustomFunction - Error running custom function: Error: ReferenceError: read_csv is not defined", "stack": {} }

WizKid1968 avatar Jun 09 '24 20:06 WizKid1968

Any updates? I'm getting an error running csv-agent as well which is associated with pandas not being installed, which is rendering the following: { "statusCode": 500, "success": false, "message": "Error: nodesService.executeCustomFunction - Error running custom function: Error: ReferenceError: read_csv is not defined", "stack": {} }

Hello, unfortunately I don't have any updates. Your read_csv error is related to the read csv code of the CSV agent. Just for curiosity, which model are you using?

agpaola avatar Jun 12 '24 07:06 agpaola

Yes, similar to @agpaola & @WizKid1968 , I received the same error as well ModuleNotFoundError: The module 'pandas' is included in the Pyodide distribution.

I am using llama2 and llama3.1 both give same error as above

$ npm pandas --version 10.8.2

it is working locally in docker desktop but not when deploying it server.

stever100 avatar Aug 27 '24 05:08 stever100

[INFO]: [server]: Chatflow xxxxxx added into ChatflowPool Loading pandas, numpy, python-dateutil, six, pytz Didn't find package pandas-1.5.3-cp311-cp311-emscripten_3_1_46_wasm32.whl locally, attempting to load from https://cdn.jsdelivr.net/pyodide/v0.25.0/full/ Didn't find package numpy-1.26.1-cp311-cp311-emscripten_3_1_46_wasm32.whl locally, attempting to load from https://cdn.jsdelivr.net/pyodide/v0.25.0/full/ Didn't find package six-1.16.0-py2.py3-none-any.whl locally, attempting to load from https://cdn.jsdelivr.net/pyodide/v0.25.0/full/ Didn't find package python_dateutil-2.8.2-py2.py3-none-any.whl locally, attempting to load from https://cdn.jsdelivr.net/pyodide/v0.25.0/full/ Didn't find package pytz-2023.3-py2.py3-none-any.whl locally, attempting to load from https://cdn.jsdelivr.net/pyodide/v0.25.0/full/ Failed to load pandas, python-dateutil, numpy, six, pytz The following error occurred while loading pandas: fetch failed The following error occurred while loading python-dateutil: fetch failed The following error occurred while loading numpy: fetch failed The following error occurred while loading six: fetch failed The following error occurred while loading pytz: fetch failed 2024-08-27 05:32:20 [ERROR]: [server]: Error: PythonError: Traceback (most recent call last): File "/lib/python311.zip/_pyodide/_base.py", line 573, in eval_code_async await CodeRunner( File "/lib/python311.zip/_pyodide/_base.py", line 393, in run_async coroutine = eval(self.code, globals, locals) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1, in ModuleNotFoundError: The module 'pandas' is included in the Pyodide distribution, but it is not installed. You can install it by calling: await micropip.install("pandas") in Python, or await pyodide.loadPackage("pandas") in JavaScript See https://pyodide.org/en/stable/usage/loading-packages.html for more details.

stever100 avatar Aug 27 '24 05:08 stever100

I found the issue. once deployed, it cannot load the package dynamically in the server. is there a way to install it first for below as part of package.json ?

https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pandas-1.5.3-cp311-cp311-emscripten_3_1_46_wasm32.whl

after reading Pyodide, it has potentially security risk of dynamically run python code in browser. It seems currently only use for CSV Agent and Airtable

stever100 avatar Aug 27 '24 05:08 stever100

Same issue on my side

boble23 avatar Sep 06 '24 20:09 boble23