Arafath10 commited on
Commit
7dff946
1 Parent(s): d92c861

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +8 -5
main.py CHANGED
@@ -29,8 +29,11 @@ async def get_image_for_text(email,query,file: UploadFile = File(...)):
29
  with open(email+".csv", "wb") as file_object:
30
  file_object.write(file.file.read())
31
  llm = OpenAI(api_token=secret,save_charts=True)
32
- df = pd.read_csv(email+".csv")
33
- sdf = SmartDataframe(df, config={"llm": llm})
34
- sdf.chat(query)
35
- image_path = "exports/charts/temp_chart.png" # Replace with your image's path
36
- return FileResponse(image_path)
 
 
 
 
29
  with open(email+".csv", "wb") as file_object:
30
  file_object.write(file.file.read())
31
  llm = OpenAI(api_token=secret,save_charts=True)
32
+ try:
33
+ df = pd.read_csv(email+".csv")
34
+ sdf = SmartDataframe(df, config={"llm": llm})
35
+ sdf.chat(query)
36
+ image_path = "exports/charts/temp_chart.png" # Replace with your image's path
37
+ return FileResponse(image_path)
38
+ except:
39
+ return "try again"