EtiennePerot / safe-code-execution

Code execution utilities for Open WebUI & Ollama
Apache License 2.0
194 stars 12 forks source link

How can I perform data analysis on a specific file using Python? #33

Open murong1 opened 1 week ago

murong1 commented 1 week ago

I want to analyze the data in a particular Excel file using Python. I attempted to use the pandas library to load the file and calculate the sum of a specific column ('Quantity'). However, I encountered a 'FileNotFoundError' indicating that the file could not be located. How can I resolve this issue, and what are the best practices for loading and analyzing data from an Excel file in Python? image image

EtiennePerot commented 1 week ago

Sorry, there is currently no support for reading uploaded files, so this won't work. However, if your file is downloadable from an online source, you can ask the LLM to generate code that downloads the file and then does analysis on it.

I'll keep this issue open to track whether Open WebUI allows tools and functions to access uploaded files.

latent-variable commented 1 week ago

I am also interested in this functionality!

garyfanhku commented 2 days ago

Sorry, there is currently no support for reading uploaded files, so this won't work. However, if your file is downloadable from an online source, you can ask the LLM to generate code that downloads the file and then does analysis on it.

I'll keep this issue open to track whether Open WebUI allows tools and functions to access uploaded files.

Would it be possible for the tools/functions to access Minio?

EtiennePerot commented 1 day ago

@garyfanhku You can ask the LLM to generate code that fetches data from Minio or any other solution that can be remotely accessed programmatically. It wouldn't make sense to manually implement each one of them manually. That being said I realize that it would be good to have easier support for automatically installing Python packages and libraries so that LLM-generated code can use more than just the Python standard library. That work is tracked in #15.

EtiennePerot commented 1 day ago

I'll keep this issue open to track whether Open WebUI allows tools and functions to access uploaded files.

I've looked into this a bit and, for my own reference (or for whoever wants to work on implementing this): Open WebUI does allow tools and functions to allow user-uploaded files.

Example of a function that accesses files: https://openwebui.com/f/omar97/visualize - however this one currently erroneously assumes that the installation is single-user, and so it uses Files.get_files() to get a list of files, which lists the uploaded files from all users. They instead need to be filtered by user_id using Files.get_files_by_user_id. Example of a function that looks up the current user's ID: https://openwebui.com/f/mhwhgm/auto_tool_v2.

The ID of the conversation that a file was uploaded from doesn't seem to be recorded, so I think this means all files from a user (or perhaps the most recent N files, to put a limit on resource usage) would need to be available to all code executions.