Prathamesh1420 commited on
Commit
8fa38a8
·
verified ·
1 Parent(s): 27a2214

Upload 4 files

Browse files
Files changed (4) hide show
  1. 2019.csv +157 -0
  2. README.md +51 -11
  3. app.py +47 -0
  4. requirements.txt +3 -0
2019.csv ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Overall rank,Country or region,Score,GDP per capita,Social support,Healthy life expectancy,Freedom to make life choices,Generosity,Perceptions of corruption
2
+ 1,Finland,7.769,1.340,1.587,0.986,0.596,0.153,0.393
3
+ 2,Denmark,7.600,1.383,1.573,0.996,0.592,0.252,0.410
4
+ 3,Norway,7.554,1.488,1.582,1.028,0.603,0.271,0.341
5
+ 4,Iceland,7.494,1.380,1.624,1.026,0.591,0.354,0.118
6
+ 5,Netherlands,7.488,1.396,1.522,0.999,0.557,0.322,0.298
7
+ 6,Switzerland,7.480,1.452,1.526,1.052,0.572,0.263,0.343
8
+ 7,Sweden,7.343,1.387,1.487,1.009,0.574,0.267,0.373
9
+ 8,New Zealand,7.307,1.303,1.557,1.026,0.585,0.330,0.380
10
+ 9,Canada,7.278,1.365,1.505,1.039,0.584,0.285,0.308
11
+ 10,Austria,7.246,1.376,1.475,1.016,0.532,0.244,0.226
12
+ 11,Australia,7.228,1.372,1.548,1.036,0.557,0.332,0.290
13
+ 12,Costa Rica,7.167,1.034,1.441,0.963,0.558,0.144,0.093
14
+ 13,Israel,7.139,1.276,1.455,1.029,0.371,0.261,0.082
15
+ 14,Luxembourg,7.090,1.609,1.479,1.012,0.526,0.194,0.316
16
+ 15,United Kingdom,7.054,1.333,1.538,0.996,0.450,0.348,0.278
17
+ 16,Ireland,7.021,1.499,1.553,0.999,0.516,0.298,0.310
18
+ 17,Germany,6.985,1.373,1.454,0.987,0.495,0.261,0.265
19
+ 18,Belgium,6.923,1.356,1.504,0.986,0.473,0.160,0.210
20
+ 19,United States,6.892,1.433,1.457,0.874,0.454,0.280,0.128
21
+ 20,Czech Republic,6.852,1.269,1.487,0.920,0.457,0.046,0.036
22
+ 21,United Arab Emirates,6.825,1.503,1.310,0.825,0.598,0.262,0.182
23
+ 22,Malta,6.726,1.300,1.520,0.999,0.564,0.375,0.151
24
+ 23,Mexico,6.595,1.070,1.323,0.861,0.433,0.074,0.073
25
+ 24,France,6.592,1.324,1.472,1.045,0.436,0.111,0.183
26
+ 25,Taiwan,6.446,1.368,1.430,0.914,0.351,0.242,0.097
27
+ 26,Chile,6.444,1.159,1.369,0.920,0.357,0.187,0.056
28
+ 27,Guatemala,6.436,0.800,1.269,0.746,0.535,0.175,0.078
29
+ 28,Saudi Arabia,6.375,1.403,1.357,0.795,0.439,0.080,0.132
30
+ 29,Qatar,6.374,1.684,1.313,0.871,0.555,0.220,0.167
31
+ 30,Spain,6.354,1.286,1.484,1.062,0.362,0.153,0.079
32
+ 31,Panama,6.321,1.149,1.442,0.910,0.516,0.109,0.054
33
+ 32,Brazil,6.300,1.004,1.439,0.802,0.390,0.099,0.086
34
+ 33,Uruguay,6.293,1.124,1.465,0.891,0.523,0.127,0.150
35
+ 34,Singapore,6.262,1.572,1.463,1.141,0.556,0.271,0.453
36
+ 35,El Salvador,6.253,0.794,1.242,0.789,0.430,0.093,0.074
37
+ 36,Italy,6.223,1.294,1.488,1.039,0.231,0.158,0.030
38
+ 37,Bahrain,6.199,1.362,1.368,0.871,0.536,0.255,0.110
39
+ 38,Slovakia,6.198,1.246,1.504,0.881,0.334,0.121,0.014
40
+ 39,Trinidad & Tobago,6.192,1.231,1.477,0.713,0.489,0.185,0.016
41
+ 40,Poland,6.182,1.206,1.438,0.884,0.483,0.117,0.050
42
+ 41,Uzbekistan,6.174,0.745,1.529,0.756,0.631,0.322,0.240
43
+ 42,Lithuania,6.149,1.238,1.515,0.818,0.291,0.043,0.042
44
+ 43,Colombia,6.125,0.985,1.410,0.841,0.470,0.099,0.034
45
+ 44,Slovenia,6.118,1.258,1.523,0.953,0.564,0.144,0.057
46
+ 45,Nicaragua,6.105,0.694,1.325,0.835,0.435,0.200,0.127
47
+ 46,Kosovo,6.100,0.882,1.232,0.758,0.489,0.262,0.006
48
+ 47,Argentina,6.086,1.092,1.432,0.881,0.471,0.066,0.050
49
+ 48,Romania,6.070,1.162,1.232,0.825,0.462,0.083,0.005
50
+ 49,Cyprus,6.046,1.263,1.223,1.042,0.406,0.190,0.041
51
+ 50,Ecuador,6.028,0.912,1.312,0.868,0.498,0.126,0.087
52
+ 51,Kuwait,6.021,1.500,1.319,0.808,0.493,0.142,0.097
53
+ 52,Thailand,6.008,1.050,1.409,0.828,0.557,0.359,0.028
54
+ 53,Latvia,5.940,1.187,1.465,0.812,0.264,0.075,0.064
55
+ 54,South Korea,5.895,1.301,1.219,1.036,0.159,0.175,0.056
56
+ 55,Estonia,5.893,1.237,1.528,0.874,0.495,0.103,0.161
57
+ 56,Jamaica,5.890,0.831,1.478,0.831,0.490,0.107,0.028
58
+ 57,Mauritius,5.888,1.120,1.402,0.798,0.498,0.215,0.060
59
+ 58,Japan,5.886,1.327,1.419,1.088,0.445,0.069,0.140
60
+ 59,Honduras,5.860,0.642,1.236,0.828,0.507,0.246,0.078
61
+ 60,Kazakhstan,5.809,1.173,1.508,0.729,0.410,0.146,0.096
62
+ 61,Bolivia,5.779,0.776,1.209,0.706,0.511,0.137,0.064
63
+ 62,Hungary,5.758,1.201,1.410,0.828,0.199,0.081,0.020
64
+ 63,Paraguay,5.743,0.855,1.475,0.777,0.514,0.184,0.080
65
+ 64,Northern Cyprus,5.718,1.263,1.252,1.042,0.417,0.191,0.162
66
+ 65,Peru,5.697,0.960,1.274,0.854,0.455,0.083,0.027
67
+ 66,Portugal,5.693,1.221,1.431,0.999,0.508,0.047,0.025
68
+ 67,Pakistan,5.653,0.677,0.886,0.535,0.313,0.220,0.098
69
+ 68,Russia,5.648,1.183,1.452,0.726,0.334,0.082,0.031
70
+ 69,Philippines,5.631,0.807,1.293,0.657,0.558,0.117,0.107
71
+ 70,Serbia,5.603,1.004,1.383,0.854,0.282,0.137,0.039
72
+ 71,Moldova,5.529,0.685,1.328,0.739,0.245,0.181,0.000
73
+ 72,Libya,5.525,1.044,1.303,0.673,0.416,0.133,0.152
74
+ 73,Montenegro,5.523,1.051,1.361,0.871,0.197,0.142,0.080
75
+ 74,Tajikistan,5.467,0.493,1.098,0.718,0.389,0.230,0.144
76
+ 75,Croatia,5.432,1.155,1.266,0.914,0.296,0.119,0.022
77
+ 76,Hong Kong,5.430,1.438,1.277,1.122,0.440,0.258,0.287
78
+ 77,Dominican Republic,5.425,1.015,1.401,0.779,0.497,0.113,0.101
79
+ 78,Bosnia and Herzegovina,5.386,0.945,1.212,0.845,0.212,0.263,0.006
80
+ 79,Turkey,5.373,1.183,1.360,0.808,0.195,0.083,0.106
81
+ 80,Malaysia,5.339,1.221,1.171,0.828,0.508,0.260,0.024
82
+ 81,Belarus,5.323,1.067,1.465,0.789,0.235,0.094,0.142
83
+ 82,Greece,5.287,1.181,1.156,0.999,0.067,0.000,0.034
84
+ 83,Mongolia,5.285,0.948,1.531,0.667,0.317,0.235,0.038
85
+ 84,North Macedonia,5.274,0.983,1.294,0.838,0.345,0.185,0.034
86
+ 85,Nigeria,5.265,0.696,1.111,0.245,0.426,0.215,0.041
87
+ 86,Kyrgyzstan,5.261,0.551,1.438,0.723,0.508,0.300,0.023
88
+ 87,Turkmenistan,5.247,1.052,1.538,0.657,0.394,0.244,0.028
89
+ 88,Algeria,5.211,1.002,1.160,0.785,0.086,0.073,0.114
90
+ 89,Morocco,5.208,0.801,0.782,0.782,0.418,0.036,0.076
91
+ 90,Azerbaijan,5.208,1.043,1.147,0.769,0.351,0.035,0.182
92
+ 91,Lebanon,5.197,0.987,1.224,0.815,0.216,0.166,0.027
93
+ 92,Indonesia,5.192,0.931,1.203,0.660,0.491,0.498,0.028
94
+ 93,China,5.191,1.029,1.125,0.893,0.521,0.058,0.100
95
+ 94,Vietnam,5.175,0.741,1.346,0.851,0.543,0.147,0.073
96
+ 95,Bhutan,5.082,0.813,1.321,0.604,0.457,0.370,0.167
97
+ 96,Cameroon,5.044,0.549,0.910,0.331,0.381,0.187,0.037
98
+ 97,Bulgaria,5.011,1.092,1.513,0.815,0.311,0.081,0.004
99
+ 98,Ghana,4.996,0.611,0.868,0.486,0.381,0.245,0.040
100
+ 99,Ivory Coast,4.944,0.569,0.808,0.232,0.352,0.154,0.090
101
+ 100,Nepal,4.913,0.446,1.226,0.677,0.439,0.285,0.089
102
+ 101,Jordan,4.906,0.837,1.225,0.815,0.383,0.110,0.130
103
+ 102,Benin,4.883,0.393,0.437,0.397,0.349,0.175,0.082
104
+ 103,Congo (Brazzaville),4.812,0.673,0.799,0.508,0.372,0.105,0.093
105
+ 104,Gabon,4.799,1.057,1.183,0.571,0.295,0.043,0.055
106
+ 105,Laos,4.796,0.764,1.030,0.551,0.547,0.266,0.164
107
+ 106,South Africa,4.722,0.960,1.351,0.469,0.389,0.130,0.055
108
+ 107,Albania,4.719,0.947,0.848,0.874,0.383,0.178,0.027
109
+ 108,Venezuela,4.707,0.960,1.427,0.805,0.154,0.064,0.047
110
+ 109,Cambodia,4.700,0.574,1.122,0.637,0.609,0.232,0.062
111
+ 110,Palestinian Territories,4.696,0.657,1.247,0.672,0.225,0.103,0.066
112
+ 111,Senegal,4.681,0.450,1.134,0.571,0.292,0.153,0.072
113
+ 112,Somalia,4.668,0.000,0.698,0.268,0.559,0.243,0.270
114
+ 113,Namibia,4.639,0.879,1.313,0.477,0.401,0.070,0.056
115
+ 114,Niger,4.628,0.138,0.774,0.366,0.318,0.188,0.102
116
+ 115,Burkina Faso,4.587,0.331,1.056,0.380,0.255,0.177,0.113
117
+ 116,Armenia,4.559,0.850,1.055,0.815,0.283,0.095,0.064
118
+ 117,Iran,4.548,1.100,0.842,0.785,0.305,0.270,0.125
119
+ 118,Guinea,4.534,0.380,0.829,0.375,0.332,0.207,0.086
120
+ 119,Georgia,4.519,0.886,0.666,0.752,0.346,0.043,0.164
121
+ 120,Gambia,4.516,0.308,0.939,0.428,0.382,0.269,0.167
122
+ 121,Kenya,4.509,0.512,0.983,0.581,0.431,0.372,0.053
123
+ 122,Mauritania,4.490,0.570,1.167,0.489,0.066,0.106,0.088
124
+ 123,Mozambique,4.466,0.204,0.986,0.390,0.494,0.197,0.138
125
+ 124,Tunisia,4.461,0.921,1.000,0.815,0.167,0.059,0.055
126
+ 125,Bangladesh,4.456,0.562,0.928,0.723,0.527,0.166,0.143
127
+ 126,Iraq,4.437,1.043,0.980,0.574,0.241,0.148,0.089
128
+ 127,Congo (Kinshasa),4.418,0.094,1.125,0.357,0.269,0.212,0.053
129
+ 128,Mali,4.390,0.385,1.105,0.308,0.327,0.153,0.052
130
+ 129,Sierra Leone,4.374,0.268,0.841,0.242,0.309,0.252,0.045
131
+ 130,Sri Lanka,4.366,0.949,1.265,0.831,0.470,0.244,0.047
132
+ 131,Myanmar,4.360,0.710,1.181,0.555,0.525,0.566,0.172
133
+ 132,Chad,4.350,0.350,0.766,0.192,0.174,0.198,0.078
134
+ 133,Ukraine,4.332,0.820,1.390,0.739,0.178,0.187,0.010
135
+ 134,Ethiopia,4.286,0.336,1.033,0.532,0.344,0.209,0.100
136
+ 135,Swaziland,4.212,0.811,1.149,0.000,0.313,0.074,0.135
137
+ 136,Uganda,4.189,0.332,1.069,0.443,0.356,0.252,0.060
138
+ 137,Egypt,4.166,0.913,1.039,0.644,0.241,0.076,0.067
139
+ 138,Zambia,4.107,0.578,1.058,0.426,0.431,0.247,0.087
140
+ 139,Togo,4.085,0.275,0.572,0.410,0.293,0.177,0.085
141
+ 140,India,4.015,0.755,0.765,0.588,0.498,0.200,0.085
142
+ 141,Liberia,3.975,0.073,0.922,0.443,0.370,0.233,0.033
143
+ 142,Comoros,3.973,0.274,0.757,0.505,0.142,0.275,0.078
144
+ 143,Madagascar,3.933,0.274,0.916,0.555,0.148,0.169,0.041
145
+ 144,Lesotho,3.802,0.489,1.169,0.168,0.359,0.107,0.093
146
+ 145,Burundi,3.775,0.046,0.447,0.380,0.220,0.176,0.180
147
+ 146,Zimbabwe,3.663,0.366,1.114,0.433,0.361,0.151,0.089
148
+ 147,Haiti,3.597,0.323,0.688,0.449,0.026,0.419,0.110
149
+ 148,Botswana,3.488,1.041,1.145,0.538,0.455,0.025,0.100
150
+ 149,Syria,3.462,0.619,0.378,0.440,0.013,0.331,0.141
151
+ 150,Malawi,3.410,0.191,0.560,0.495,0.443,0.218,0.089
152
+ 151,Yemen,3.380,0.287,1.163,0.463,0.143,0.108,0.077
153
+ 152,Rwanda,3.334,0.359,0.711,0.614,0.555,0.217,0.411
154
+ 153,Tanzania,3.231,0.476,0.885,0.499,0.417,0.276,0.147
155
+ 154,Afghanistan,3.203,0.350,0.517,0.361,0.000,0.158,0.025
156
+ 155,Central African Republic,3.083,0.026,0.000,0.105,0.225,0.235,0.035
157
+ 156,South Sudan,2.853,0.306,0.575,0.295,0.010,0.202,0.091
README.md CHANGED
@@ -1,12 +1,52 @@
1
- ---
2
- title: CHAT WITH CSV FILE
3
- emoji: 🔥
4
- colorFrom: blue
5
- colorTo: gray
6
- sdk: streamlit
7
- sdk_version: 1.38.0
8
- app_file: app.py
9
- pinned: false
10
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # ChatCSV-Streamlit-App
2
+ An LLM powered ChatCSV Streamlit app so you can chat with your CSV files.
3
+
4
+ <h1> How to run the app?</h1>
5
+ <p> OpenAI instantly revokes the API key once it detects that the key has been exposed publicly. So, that's the only thing to take care of.</p>
6
+
7
+ Generate your OpenAI API key here: <a href="https://platform.openai.com/account/api-keys"> Click Here </a>
8
+ <br>
9
+ <h2> Run locally </h2>
10
+ <p> If you are running the app locally, then you can freely use the API key. <br>
11
+ in app.py, line 11: <br>
12
+
13
+ ```
14
+
15
+ openai_api_key = 's#-#####################jz'
16
+
17
+ #can set the API key directly, if running locally.
18
+
19
+ ```
20
+
21
+ Else if you want to keep the key private, store it in an environment variable named 'API_KEY' in your OS and then refer the key in app.py by:
22
+
23
+ ```
24
+ from dotenv import load_dotenv
25
+ load_dotenv()
26
+ openai_api_key = os.getenv("OPENAI_API_KEY")
27
+
28
+ ```
29
+
30
+
31
+ Henceforth make sure to have Streamlit installed in your system. Run the app by:
32
+
33
+ ```
34
+ git clone https://github.com/AIAnytime/ChatCSV-Streamlit-App.git
35
+ cd ChatCSV-Streamlit-App
36
+ pip install -r requirements.txt
37
+ streamlit run app.py
38
+
39
+ ```
40
+ <h2> Run on Cloud </h2>
41
+
42
+ <p> You can also run this app locally on Streamlit Cloud, which is a free Cloud Hosting Service.
43
+ <br>
44
+ Make a .env file and store the key as
45
+
46
+ ```
47
+ OPENAI_API_KEY='##-###############'
48
+
49
+ ```
50
+ There's already a .gitignore file with .env mentioned in it. If not, make one. <br>
51
+ Remaining code remains the same.
52
 
 
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pandasai.llm.openai import OpenAI
3
+ from dotenv import load_dotenv
4
+ import os
5
+ import pandas as pd
6
+ from pandasai import PandasAI
7
+
8
+ load_dotenv()
9
+
10
+
11
+ openai_api_key = os.getenv("OPENAI_API_KEY")
12
+
13
+
14
+ def chat_with_csv(df,prompt):
15
+ llm = OpenAI(api_token=openai_api_key)
16
+ pandas_ai = PandasAI(llm)
17
+ result = pandas_ai.run(df, prompt=prompt)
18
+ print(result)
19
+ return result
20
+
21
+ st.set_page_config(layout='wide')
22
+
23
+ st.title("ChatCSV powered by LLM")
24
+
25
+ input_csv = st.file_uploader("Upload your CSV file", type=['csv'])
26
+
27
+ if input_csv is not None:
28
+
29
+ col1, col2 = st.columns([1,1])
30
+
31
+ with col1:
32
+ st.info("CSV Uploaded Successfully")
33
+ data = pd.read_csv(input_csv)
34
+ st.dataframe(data, use_container_width=True)
35
+
36
+ with col2:
37
+
38
+ st.info("Chat Below")
39
+
40
+ input_text = st.text_area("Enter your query")
41
+
42
+ if input_text is not None:
43
+ if st.button("Chat with CSV"):
44
+ st.info("Your Query: "+input_text)
45
+ result = chat_with_csv(data, input_text)
46
+ st.success(result)
47
+
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ pandasai
3
+ python-dotenv