thhung
commited on
Commit
·
8ba4688
1
Parent(s):
9ef5b69
[app] add app and requirements
Browse files- app.py +42 -0
- requirements.txt +76 -0
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from git import Repo
|
2 |
+
import os
|
3 |
+
|
4 |
+
import shutil
|
5 |
+
|
6 |
+
|
7 |
+
git_url = os.getenv("GIT_URL")
|
8 |
+
repo_dir = "./temp"
|
9 |
+
Repo.clone_from(git_url, repo_dir)
|
10 |
+
|
11 |
+
# Specify the folder you want to move and the current folder path
|
12 |
+
source_folder = "./temp/hnrecommender/"
|
13 |
+
destination_folder = os.getcwd() # Gets the path of the current folder
|
14 |
+
|
15 |
+
# Move the folder
|
16 |
+
shutil.move(source_folder, destination_folder)
|
17 |
+
|
18 |
+
import streamlit as st
|
19 |
+
|
20 |
+
from hnrecommender import recommend_hacker_news
|
21 |
+
|
22 |
+
# Streamlit UI
|
23 |
+
st.title("HNews Recommendation")
|
24 |
+
|
25 |
+
# Text input for the user to enter a query
|
26 |
+
user_bio = st.text_area("Enter the user bio:", height=100)
|
27 |
+
|
28 |
+
# Submit button
|
29 |
+
if st.button("Submit"):
|
30 |
+
if user_bio:
|
31 |
+
# Show spinner
|
32 |
+
with st.spinner("Fetching articles... Please wait."):
|
33 |
+
articles = recommend_hacker_news(user_bio, 500)
|
34 |
+
|
35 |
+
# Display the results after processing
|
36 |
+
st.success("Here are the articles recommended for you:")
|
37 |
+
for story in articles:
|
38 |
+
title = story["title"] if "title" in story else "No title article"
|
39 |
+
url = story["url"] if "url" in story else "HN article"
|
40 |
+
st.write(f"[{title}]({url})")
|
41 |
+
else:
|
42 |
+
st.error("Please enter an user bio.")
|
requirements.txt
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiohappyeyeballs==2.4.3
|
2 |
+
aiohttp==3.10.10
|
3 |
+
aiosignal==1.3.1
|
4 |
+
altair==5.4.1
|
5 |
+
attrs==24.2.0
|
6 |
+
blinker==1.9.0
|
7 |
+
cachetools==5.5.0
|
8 |
+
certifi==2024.8.30
|
9 |
+
charset-normalizer==3.4.0
|
10 |
+
click==8.1.7
|
11 |
+
coloredlogs==15.0.1
|
12 |
+
datasets==3.1.0
|
13 |
+
dill==0.3.8
|
14 |
+
filelock==3.13.1
|
15 |
+
flatbuffers==24.3.25
|
16 |
+
frozenlist==1.5.0
|
17 |
+
fsspec==2024.2.0
|
18 |
+
gitdb==4.0.11
|
19 |
+
GitPython==3.1.43
|
20 |
+
huggingface-hub==0.26.2
|
21 |
+
humanfriendly==10.0
|
22 |
+
idna==3.10
|
23 |
+
Jinja2==3.1.4
|
24 |
+
joblib==1.4.2
|
25 |
+
jsonschema==4.23.0
|
26 |
+
jsonschema-specifications==2024.10.1
|
27 |
+
markdown-it-py==3.0.0
|
28 |
+
MarkupSafe==3.0.2
|
29 |
+
mdurl==0.1.2
|
30 |
+
mpmath==1.3.0
|
31 |
+
multidict==6.1.0
|
32 |
+
multiprocess==0.70.16
|
33 |
+
narwhals==1.13.4
|
34 |
+
networkx==3.2.1
|
35 |
+
nltk==3.9.1
|
36 |
+
numpy==2.1.3
|
37 |
+
onnx==1.17.0
|
38 |
+
onnxruntime==1.20.0
|
39 |
+
optimum==1.23.3
|
40 |
+
packaging==24.2
|
41 |
+
pandas==2.2.3
|
42 |
+
pillow==11.0.0
|
43 |
+
propcache==0.2.0
|
44 |
+
protobuf==5.28.3
|
45 |
+
pyarrow==18.0.0
|
46 |
+
pydeck==0.9.1
|
47 |
+
Pygments==2.18.0
|
48 |
+
python-dateutil==2.9.0.post0
|
49 |
+
pytz==2024.2
|
50 |
+
PyYAML==6.0.2
|
51 |
+
referencing==0.35.1
|
52 |
+
regex==2024.11.6
|
53 |
+
requests==2.32.3
|
54 |
+
rich==13.9.4
|
55 |
+
rpds-py==0.21.0
|
56 |
+
safetensors==0.4.5
|
57 |
+
setuptools==75.1.0
|
58 |
+
six==1.16.0
|
59 |
+
smmap==5.0.1
|
60 |
+
streamlit==1.40.1
|
61 |
+
sympy==1.13.1
|
62 |
+
tenacity==9.0.0
|
63 |
+
tokenizers==0.20.3
|
64 |
+
toml==0.10.2
|
65 |
+
torch==2.5.1+cpu
|
66 |
+
tornado==6.4.1
|
67 |
+
tqdm==4.67.0
|
68 |
+
transformers==4.46.2
|
69 |
+
typing_extensions==4.12.2
|
70 |
+
tzdata==2024.2
|
71 |
+
urllib3==2.2.3
|
72 |
+
watchdog==6.0.0
|
73 |
+
wheel==0.44.0
|
74 |
+
xxhash==3.5.0
|
75 |
+
yarl==1.17.1
|
76 |
+
GitPython
|