adding app
Browse files- .gitignore +2 -0
- README.md +1 -0
- app.py +43 -0
- requirements.txt +66 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
*.pyc
|
README.md
CHANGED
@@ -5,6 +5,7 @@ colorFrom: yellow
|
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.17.0
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
5 |
colorTo: purple
|
6 |
sdk: streamlit
|
7 |
sdk_version: 1.17.0
|
8 |
+
python_version: 3.10.6
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
---
|
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from pathlib import Path
|
3 |
+
import requests
|
4 |
+
import streamlit as st
|
5 |
+
from langchain.agents import create_pandas_dataframe_agent
|
6 |
+
from langchain.llms import OpenAI
|
7 |
+
from contextlib import contextmanager, redirect_stdout
|
8 |
+
from io import StringIO
|
9 |
+
from time import sleep
|
10 |
+
|
11 |
+
data_path = Path('umpire-full-text.csv')
|
12 |
+
if not data_path.exists():
|
13 |
+
r = requests.get('https://upenn.box.com/shared/static/dyxc1heqrfrgp22ntwpet3f57sir34c3.csv')
|
14 |
+
data_path.write_bytes(r.content)
|
15 |
+
|
16 |
+
@contextmanager
|
17 |
+
def st_capture(output_func):
|
18 |
+
with StringIO() as stdout, redirect_stdout(stdout):
|
19 |
+
old_write = stdout.write
|
20 |
+
|
21 |
+
def new_write(string):
|
22 |
+
ret = old_write(string)
|
23 |
+
output_func(stdout.getvalue())
|
24 |
+
return ret
|
25 |
+
|
26 |
+
stdout.write = new_write
|
27 |
+
yield
|
28 |
+
|
29 |
+
|
30 |
+
df = pd.read_csv('umpire-full-text.csv')
|
31 |
+
agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=True)
|
32 |
+
|
33 |
+
st.dataframe(df)
|
34 |
+
|
35 |
+
query = st.text_input('Enter query here:', '')
|
36 |
+
answer = st.empty()
|
37 |
+
|
38 |
+
if query:
|
39 |
+
output = st.empty()
|
40 |
+
with st_capture(output.info):
|
41 |
+
response = agent.run(query)
|
42 |
+
answer = st.write(response)
|
43 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohttp==3.8.4
|
2 |
+
aiosignal==1.3.1
|
3 |
+
altair==4.2.2
|
4 |
+
async-timeout==4.0.2
|
5 |
+
attrs==22.2.0
|
6 |
+
blinker==1.5
|
7 |
+
cachetools==5.3.0
|
8 |
+
certifi==2022.12.7
|
9 |
+
charset-normalizer==3.1.0
|
10 |
+
click==8.1.3
|
11 |
+
dataclasses-json==0.5.7
|
12 |
+
decorator==5.1.1
|
13 |
+
entrypoints==0.4
|
14 |
+
frozenlist==1.3.3
|
15 |
+
gitdb==4.0.10
|
16 |
+
GitPython==3.1.31
|
17 |
+
greenlet==2.0.2
|
18 |
+
idna==3.4
|
19 |
+
importlib-metadata==6.1.0
|
20 |
+
Jinja2==3.1.2
|
21 |
+
jsonschema==4.17.3
|
22 |
+
langchain==0.0.116
|
23 |
+
markdown-it-py==2.2.0
|
24 |
+
MarkupSafe==2.1.2
|
25 |
+
marshmallow==3.19.0
|
26 |
+
marshmallow-enum==1.5.1
|
27 |
+
mdurl==0.1.2
|
28 |
+
multidict==6.0.4
|
29 |
+
mypy-extensions==1.0.0
|
30 |
+
numpy==1.24.2
|
31 |
+
openai==0.27.2
|
32 |
+
packaging==23.0
|
33 |
+
pandas==1.5.3
|
34 |
+
Pillow==9.4.0
|
35 |
+
protobuf==3.20.3
|
36 |
+
pyarrow==11.0.0
|
37 |
+
pydantic==1.10.6
|
38 |
+
pydeck==0.8.0
|
39 |
+
Pygments==2.14.0
|
40 |
+
Pympler==1.0.1
|
41 |
+
pyrsistent==0.19.3
|
42 |
+
python-dateutil==2.8.2
|
43 |
+
pytz==2022.7.1
|
44 |
+
pytz-deprecation-shim==0.1.0.post0
|
45 |
+
PyYAML==6.0
|
46 |
+
requests==2.28.2
|
47 |
+
rich==13.3.2
|
48 |
+
semver==2.13.0
|
49 |
+
six==1.16.0
|
50 |
+
smmap==5.0.0
|
51 |
+
SQLAlchemy==1.4.47
|
52 |
+
streamlit==1.20.0
|
53 |
+
tenacity==8.2.2
|
54 |
+
toml==0.10.2
|
55 |
+
toolz==0.12.0
|
56 |
+
tornado==6.2
|
57 |
+
tqdm==4.65.0
|
58 |
+
typing-inspect==0.8.0
|
59 |
+
typing_extensions==4.5.0
|
60 |
+
tzdata==2022.7
|
61 |
+
tzlocal==4.3
|
62 |
+
urllib3==1.26.15
|
63 |
+
validators==0.20.0
|
64 |
+
watchdog==3.0.0
|
65 |
+
yarl==1.8.2
|
66 |
+
zipp==3.15.0
|