Spaces:
Running
Running
ghengx
commited on
Commit
·
9f5a9cc
1
Parent(s):
71b26bd
init
Browse files- app.py +52 -0
- requirements.txt +68 -0
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
from huggingface_hub import Repository
|
6 |
+
from huggingface_hub import login
|
7 |
+
|
8 |
+
login(token = os.environ['HF_TOKEN'])
|
9 |
+
|
10 |
+
repo = Repository(
|
11 |
+
local_dir="agent_function",
|
12 |
+
repo_type="dataset",
|
13 |
+
clone_from=os.environ['DATASET'],
|
14 |
+
token=True
|
15 |
+
)
|
16 |
+
repo.git_pull()
|
17 |
+
|
18 |
+
from agent_function.function import generate_answer
|
19 |
+
|
20 |
+
Image.MAX_IMAGE_PIXELS = None
|
21 |
+
|
22 |
+
st.set_page_config(layout="wide")
|
23 |
+
|
24 |
+
st.title("Map2U Chatbot")
|
25 |
+
col1, col2 = st.columns([1 ,2])
|
26 |
+
|
27 |
+
if "messages" not in st.session_state:
|
28 |
+
st.session_state.messages = []
|
29 |
+
|
30 |
+
if "overlay" not in st.session_state:
|
31 |
+
st.session_state.overlay = 'base'
|
32 |
+
|
33 |
+
with col1:
|
34 |
+
messages_box = st.container(height=500)
|
35 |
+
# Display chat messages from history on app rerun
|
36 |
+
for message in st.session_state.messages:
|
37 |
+
with messages_box.chat_message(message["role"]):
|
38 |
+
st.markdown(message["content"])
|
39 |
+
|
40 |
+
# React to user input
|
41 |
+
if prompt := st.chat_input("What is up?"):
|
42 |
+
messages_box.chat_message("user").markdown(prompt)
|
43 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
44 |
+
response = generate_answer(prompt)
|
45 |
+
with messages_box.chat_message("assistant"):
|
46 |
+
st.markdown(response)
|
47 |
+
# Add assistant response to chat history
|
48 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
49 |
+
|
50 |
+
with col2:
|
51 |
+
image = Image.open(f'agent_function/{st.session_state.overlay}.png')
|
52 |
+
st.image(image)
|
requirements.txt
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
affine==2.4.0
|
2 |
+
altair==5.5.0
|
3 |
+
annotated-types==0.7.0
|
4 |
+
anyio==4.8.0
|
5 |
+
attrs==24.3.0
|
6 |
+
blinker==1.9.0
|
7 |
+
cachetools==5.5.1
|
8 |
+
certifi==2024.12.14
|
9 |
+
charset-normalizer==3.4.1
|
10 |
+
click==8.1.8
|
11 |
+
click-plugins==1.1.1
|
12 |
+
cligj==0.7.2
|
13 |
+
contourpy==1.3.1
|
14 |
+
cycler==0.12.1
|
15 |
+
distro==1.9.0
|
16 |
+
filelock==3.17.0
|
17 |
+
fonttools==4.55.3
|
18 |
+
fsspec==2024.12.0
|
19 |
+
gitdb==4.0.12
|
20 |
+
GitPython==3.1.44
|
21 |
+
h11==0.14.0
|
22 |
+
httpcore==1.0.7
|
23 |
+
httpx==0.28.1
|
24 |
+
huggingface-hub==0.27.1
|
25 |
+
idna==3.10
|
26 |
+
Jinja2==3.1.5
|
27 |
+
jiter==0.8.2
|
28 |
+
jsonschema==4.23.0
|
29 |
+
jsonschema-specifications==2024.10.1
|
30 |
+
kiwisolver==1.4.8
|
31 |
+
markdown-it-py==3.0.0
|
32 |
+
MarkupSafe==3.0.2
|
33 |
+
matplotlib==3.10.0
|
34 |
+
mdurl==0.1.2
|
35 |
+
narwhals==1.23.0
|
36 |
+
numpy==2.2.1
|
37 |
+
openai==1.59.9
|
38 |
+
packaging==24.2
|
39 |
+
pandas==2.2.3
|
40 |
+
pillow==11.1.0
|
41 |
+
protobuf==5.29.3
|
42 |
+
pyarrow==19.0.0
|
43 |
+
pydantic==2.10.5
|
44 |
+
pydantic_core==2.27.2
|
45 |
+
pydeck==0.9.1
|
46 |
+
Pygments==2.19.1
|
47 |
+
pyparsing==3.2.1
|
48 |
+
python-dateutil==2.9.0.post0
|
49 |
+
python-dotenv==1.0.1
|
50 |
+
pytz==2024.2
|
51 |
+
PyYAML==6.0.2
|
52 |
+
rasterio==1.4.3
|
53 |
+
referencing==0.36.1
|
54 |
+
requests==2.32.3
|
55 |
+
rich==13.9.4
|
56 |
+
rpds-py==0.22.3
|
57 |
+
shapely==2.0.6
|
58 |
+
six==1.17.0
|
59 |
+
smmap==5.0.2
|
60 |
+
sniffio==1.3.1
|
61 |
+
streamlit==1.41.1
|
62 |
+
tenacity==9.0.0
|
63 |
+
toml==0.10.2
|
64 |
+
tornado==6.4.2
|
65 |
+
tqdm==4.67.1
|
66 |
+
typing_extensions==4.12.2
|
67 |
+
tzdata==2025.1
|
68 |
+
urllib3==2.3.0
|