nikhil061307 commited on
Commit
aae4643
·
verified ·
1 Parent(s): 361eec6

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +45 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ from dotenv import load_dotenv
5
+ from pandasai.llm.google_gemini import GoogleGemini
6
+ from pandasai import SmartDataframe
7
+ import os
8
+
9
+ load_dotenv()
10
+
11
+ llm=GoogleGemini(api_key=os.getenv('GOOGLE_API_KEY'))
12
+
13
+ def chat_with_csv(df,prompt):
14
+ pandas_ai = SmartDataframe(df,config={'llm':llm})
15
+ result=pandas_ai.chat(prompt)
16
+ return result
17
+
18
+ st.set_page_config(layout='wide')
19
+
20
+ st.title('ChatCSV powered by LLM')
21
+
22
+ input_csv=st.file_uploader('upload your csv file',type=['csv'])
23
+
24
+ if input_csv is not None:
25
+
26
+ col1,col2=st.columns([1,1])
27
+
28
+ with col1:
29
+ st.info('CSV Uploaded successfully')
30
+
31
+ data=pd.read_csv(input_csv)
32
+
33
+ st.dataframe(data)
34
+
35
+ with col2:
36
+ st.info('Chat with CSV')
37
+
38
+ input_text=st.text_area('Enter your query')
39
+
40
+ if input_text is not None:
41
+ if st.button('Chat with CSV'):
42
+ st.info(f'Your query: {input_text}')
43
+ result=chat_with_csv(data,input_text)
44
+ st.success(result)
45
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas==1.5.3
2
+ numpy==1.23.4
3
+ streamlit==1.36.0
4
+ pandasai
5
+ python-dotenv