phidatahq / phidata

Build AI Assistants with memory, knowledge and tools.
https://docs.phidata.com
Mozilla Public License 2.0
10.45k stars 1.51k forks source link

PythonAssistant only uses the 1 last one of the defined files. #1012

Open ujikol opened 2 weeks ago

ujikol commented 2 weeks ago

`from phi.assistant.python import PythonAssistant from phi.file.local.csv import CsvFile from pathlib import Path import pandas as pd

FILES = ['f1', 'f2']

for f in FILES: df = pd.DataFrame({f+'c1':[1,2], f+'c2':[3,4]}) df.to_csv(str(Path.cwd().joinpath(f))+'.csv') python_assistant = PythonAssistant( files=[ CsvFile(path=str(Path.cwd().joinpath(f))+'.csv') for f in FILES], )

python_assistant.print_response("Print the name of each column in each file perfixed by the corresponding file name.", markdown=True)`

f2.csv: f2.csv: f2c1 f2.csv: f2c2

ysolanky commented 2 weeks ago

@ujikol It might be better for your use case to use CSVTools. Please refer to this example here: https://docs.phidata.com/tools/csv

ujikol commented 2 weeks ago

Are you saying that this is the intended behavior? I do not get the point to have a list of documents and then just considering the last one.

I do not want to read or write CSVs. The example was just the minimal demonstration that the assistant ignores all files except the last one.

My use case is just to analysis of data from multiple tables. So the code to be generated needs to join these tables appropriately. The subset of which tables to be joined depends on the requested analysis. IMO the LLM just needs to be provided the description and columns of all files instead of just the last one.

ysolanky commented 2 weeks ago

@ujikol No, that is definitely not the intended behavior, and I have raised this issue. Thank you for bringing this to our attention.