Summary
The issue is related to the create_csv_agent
function, which is causing a “FileNotFoundError” when trying to read the CSV file. I am deploying the app so it should be able to read the file when it’s uploaded and should not matter if the file is in the current dir or not.
Steps to reproduce
Code snippet:
# Upload PDF file
st.write(f'### 2. Upload your {file_type} file')
if file_type.lower().endswith('pdf'):
uploaded_file = st.file_uploader('Upload your PDF file', type=['pdf'], label_visibility="collapsed")
elif file_type.lower().endswith('csv'):
st.write(os.getcwd())
uploaded_file = st.file_uploader('Upload your CSV file', type=['csv'], label_visibility="collapsed")
else:
uploaded_file = None
# Read PDF file and extract text
if uploaded_file is not None:
if uploaded_file.name.endswith('.pdf'):
text = read_pdf(uploaded_file)
elif uploaded_file.name.endswith('.csv'):
st.write(text)
agent = create_csv_agent(OpenAI(openai_api_key=OPENAI_API_KEY,temperature=0), uploaded_file.name, verbose=True)
st.write(agent)
Actual behavior: