liamxdev commited on
Commit
34b531b
·
verified ·
1 Parent(s): 195806d

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +9 -0
  2. .gitattributes +7 -0
  3. Dockerfile +18 -13
  4. README.md +51 -13
  5. __pycache__/app.cpython-314.pyc +0 -0
  6. __pycache__/hf_bootstrap.cpython-314.pyc +0 -0
  7. app/.streamlit/config.toml +2 -0
  8. app/__init__.py +1 -0
  9. app/__pycache__/__init__.cpython-311.pyc +0 -0
  10. app/__pycache__/__init__.cpython-311.pyc.1973711792576 +0 -0
  11. app/__pycache__/__init__.cpython-311.pyc.2306772232640 +0 -0
  12. app/__pycache__/__init__.cpython-311.pyc.2544356157888 +0 -0
  13. app/__pycache__/__init__.cpython-314.pyc +0 -0
  14. app/__pycache__/config.cpython-311.pyc +0 -0
  15. app/__pycache__/config.cpython-311.pyc.1580759400608 +0 -0
  16. app/__pycache__/config.cpython-311.pyc.1725774067760 +0 -0
  17. app/__pycache__/config.cpython-311.pyc.1783676383760 +0 -0
  18. app/__pycache__/config.cpython-311.pyc.1802465591456 +0 -0
  19. app/__pycache__/config.cpython-311.pyc.1935848577424 +0 -0
  20. app/__pycache__/config.cpython-311.pyc.1962180850192 +0 -0
  21. app/__pycache__/config.cpython-311.pyc.1973720126656 +0 -0
  22. app/__pycache__/config.cpython-311.pyc.1993952126864 +0 -0
  23. app/__pycache__/config.cpython-311.pyc.2050849738064 +0 -0
  24. app/__pycache__/config.cpython-311.pyc.2070801723920 +0 -0
  25. app/__pycache__/config.cpython-311.pyc.2151036698784 +0 -0
  26. app/__pycache__/config.cpython-311.pyc.2199857928480 +0 -0
  27. app/__pycache__/config.cpython-311.pyc.2306780517680 +0 -0
  28. app/__pycache__/config.cpython-311.pyc.2323301603616 +0 -0
  29. app/__pycache__/config.cpython-311.pyc.2544364459200 +0 -0
  30. app/__pycache__/config.cpython-311.pyc.2779348867024 +0 -0
  31. app/__pycache__/config.cpython-311.pyc.2969461649936 +0 -0
  32. app/__pycache__/config.cpython-314.pyc +0 -0
  33. app/__pycache__/context_compression.cpython-311.pyc +0 -0
  34. app/__pycache__/context_compression.cpython-311.pyc.1783676588720 +0 -0
  35. app/__pycache__/context_compression.cpython-311.pyc.1962181054896 +0 -0
  36. app/__pycache__/context_compression.cpython-311.pyc.2070801928624 +0 -0
  37. app/__pycache__/context_compression.cpython-314.pyc +0 -0
  38. app/__pycache__/embedding_cache.cpython-311.pyc +0 -0
  39. app/__pycache__/embedding_cache.cpython-314.pyc +0 -0
  40. app/__pycache__/embeddings.cpython-311.pyc +0 -0
  41. app/__pycache__/embeddings.cpython-311.pyc.1935805179792 +0 -0
  42. app/__pycache__/embeddings.cpython-311.pyc.1974185286032 +0 -0
  43. app/__pycache__/embeddings.cpython-311.pyc.2199813547920 +0 -0
  44. app/__pycache__/embeddings.cpython-311.pyc.2307245939200 +0 -0
  45. app/__pycache__/embeddings.cpython-311.pyc.2323257419664 +0 -0
  46. app/__pycache__/embeddings.cpython-311.pyc.2542682446224 +0 -0
  47. app/__pycache__/embeddings.cpython-314.pyc +0 -0
  48. app/__pycache__/evaluate.cpython-311.pyc +0 -0
  49. app/__pycache__/evaluate.cpython-311.pyc.1949709152400 +0 -0
  50. app/__pycache__/evaluate.cpython-311.pyc.1973714458800 +0 -0
.dockerignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .git
2
+ .venv
3
+ __pycache__
4
+ *.pyc
5
+ .env
6
+ data/logs
7
+ data/processed/embedding_cache.sqlite3
8
+ ml
9
+
.gitattributes CHANGED
@@ -33,3 +33,10 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/mascots/chat.png filter=lfs diff=lfs merge=lfs -text
37
+ assets/mascots/chatvns.png filter=lfs diff=lfs merge=lfs -text
38
+ assets/mascots/insight.png filter=lfs diff=lfs merge=lfs -text
39
+ assets/mascots/processing.png filter=lfs diff=lfs merge=lfs -text
40
+ assets/mascots/trust.png filter=lfs diff=lfs merge=lfs -text
41
+ assets/mascots/welcome.png filter=lfs diff=lfs merge=lfs -text
42
+ documents/kien-truc-tong-the.png filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,20 +1,25 @@
1
- FROM python:3.13.5-slim
2
 
3
- WORKDIR /app
 
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- git \
9
- && rm -rf /var/lib/apt/lists/*
 
 
 
10
 
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
14
- RUN pip3 install -r requirements.txt
 
 
15
 
16
- EXPOSE 8501
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ FROM python:3.11-slim
2
 
3
+ RUN useradd -m -u 1000 user
4
+ USER user
5
 
6
+ ENV HOME=/home/user \
7
+ PATH=/home/user/.local/bin:$PATH \
8
+ PYTHONUNBUFFERED=1 \
9
+ PYTHONDONTWRITEBYTECODE=1 \
10
+ APP_TICKERS=HPG,FPT,VCB \
11
+ REQUIRE_USER_API_KEYS=1 \
12
+ STREAMLIT_SERVER_HEADLESS=true \
13
+ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
14
 
15
+ WORKDIR $HOME/app
 
16
 
17
+ COPY --chown=user requirements.txt ./requirements.txt
18
+ RUN pip install --no-cache-dir --upgrade pip \
19
+ && pip install --no-cache-dir -r requirements.txt
20
 
21
+ COPY --chown=user . .
22
 
23
+ EXPOSE 7860
24
 
25
+ CMD ["sh", "-c", "python hf_bootstrap.py && exec streamlit run app/streamlit_app.py --server.address=0.0.0.0 --server.port=7860"]
README.md CHANGED
@@ -1,19 +1,57 @@
1
  ---
2
- title: Chatvns
3
- emoji: 🚀
4
- colorFrom: red
5
- colorTo: red
6
  sdk: docker
7
- app_port: 8501
8
- tags:
9
- - streamlit
10
- pinned: false
11
- short_description: a stock chatbot for the Vietnamese market
12
  ---
13
 
14
- # Welcome to Streamlit!
15
 
16
- Edit `/src/streamlit_app.py` to customize this app to your heart's desire. :heart:
17
 
18
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
19
- forums](https://discuss.streamlit.io).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: ChatVNS
3
+ emoji: 📈
4
+ colorFrom: blue
5
+ colorTo: indigo
6
  sdk: docker
7
+ app_port: 7860
8
+ python_version: 3.11
 
 
 
9
  ---
10
 
11
+ # ChatVNS
12
 
13
+ Chatbot RAG hỗ trợ phân tích dữ liệu chứng khoán Việt Nam.
14
 
15
+ ## API key do người dùng cung cấp
16
+
17
+ Space không dùng Gemini API key hoặc Hugging Face inference token của chủ Space.
18
+ Mỗi người dùng nhập key của họ trong mục **API key của bạn** ở sidebar:
19
+
20
+ - Gemini API key: dùng để tạo câu trả lời.
21
+ - Hugging Face token: không bắt buộc, dùng cho embedding và reranking.
22
+
23
+ Key được giữ trong bộ nhớ của session Streamlit hiện tại, không ghi vào file hoặc
24
+ interaction log. Khi thiếu Hugging Face token hoặc Qdrant không khả dụng, ứng dụng
25
+ tự fallback sang BM25 trên dữ liệu chunks đi kèm.
26
+
27
+ ## Cấu hình Space
28
+
29
+ Không cấu hình `GEMINI_API_KEY` hoặc `HF_API_KEY` trong Space Secrets.
30
+
31
+ Các biến hạ tầng tùy chọn:
32
+
33
+ - `QDRANT_URL` và `QDRANT_API_KEY`: Qdrant Cloud dùng chung.
34
+ - `CHATVNS_DATASET_REPO`: Hugging Face Dataset repo chứa thư mục `data/`.
35
+ - `HF_DATASET_TOKEN`: chỉ cần khi dataset repo ở chế độ private.
36
+ - `APP_TICKERS=HPG,FPT,VCB`
37
+
38
+ ## Tạo bundle để push
39
+
40
+ Chạy từ thư mục gốc dự án:
41
+
42
+ ```powershell
43
+ powershell -ExecutionPolicy Bypass -File .\prepare_hf_space.ps1
44
+ ```
45
+
46
+ Lệnh mặc định đóng gói mã nguồn và tối đa 500 chunks cho mỗi scope
47
+ `HPG`, `FPT`, `VCB`, `MARKET`, đủ để Space chạy ngay bằng BM25.
48
+
49
+ Đóng gói toàn bộ dữ liệu local:
50
+
51
+ ```powershell
52
+ powershell -ExecutionPolicy Bypass -File .\prepare_hf_space.ps1 -IncludeLocalData
53
+ ```
54
+
55
+ Sau đó push toàn bộ nội dung trong `hf-space/` lên Hugging Face Space repository.
56
+ Với dữ liệu lớn, nên dùng một Dataset repo và `CHATVNS_DATASET_REPO` thay vì commit
57
+ trực tiếp vào Space.
__pycache__/app.cpython-314.pyc ADDED
Binary file (22.9 kB). View file
 
__pycache__/hf_bootstrap.cpython-314.pyc ADDED
Binary file (2.1 kB). View file
 
app/.streamlit/config.toml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [client]
2
+ showSidebarNavigation = false
app/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """RAG app for the Stock VN pipeline."""
app/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (187 Bytes). View file
 
app/__pycache__/__init__.cpython-311.pyc.1973711792576 ADDED
Binary file (187 Bytes). View file
 
app/__pycache__/__init__.cpython-311.pyc.2306772232640 ADDED
Binary file (187 Bytes). View file
 
app/__pycache__/__init__.cpython-311.pyc.2544356157888 ADDED
Binary file (187 Bytes). View file
 
app/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (182 Bytes). View file
 
app/__pycache__/config.cpython-311.pyc ADDED
Binary file (5.56 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1580759400608 ADDED
Binary file (2.74 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1725774067760 ADDED
Binary file (2.74 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1783676383760 ADDED
Binary file (4.13 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1802465591456 ADDED
Binary file (3.56 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1935848577424 ADDED
Binary file (3.17 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1962180850192 ADDED
Binary file (4.13 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1973720126656 ADDED
Binary file (2.14 kB). View file
 
app/__pycache__/config.cpython-311.pyc.1993952126864 ADDED
Binary file (3.17 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2050849738064 ADDED
Binary file (2.66 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2070801723920 ADDED
Binary file (4.13 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2151036698784 ADDED
Binary file (2.74 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2199857928480 ADDED
Binary file (3.17 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2306780517680 ADDED
Binary file (2.14 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2323301603616 ADDED
Binary file (3.17 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2544364459200 ADDED
Binary file (2.14 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2779348867024 ADDED
Binary file (3.56 kB). View file
 
app/__pycache__/config.cpython-311.pyc.2969461649936 ADDED
Binary file (2.7 kB). View file
 
app/__pycache__/config.cpython-314.pyc ADDED
Binary file (4.95 kB). View file
 
app/__pycache__/context_compression.cpython-311.pyc ADDED
Binary file (6.47 kB). View file
 
app/__pycache__/context_compression.cpython-311.pyc.1783676588720 ADDED
Binary file (6.46 kB). View file
 
app/__pycache__/context_compression.cpython-311.pyc.1962181054896 ADDED
Binary file (6.46 kB). View file
 
app/__pycache__/context_compression.cpython-311.pyc.2070801928624 ADDED
Binary file (6.47 kB). View file
 
app/__pycache__/context_compression.cpython-314.pyc ADDED
Binary file (6.54 kB). View file
 
app/__pycache__/embedding_cache.cpython-311.pyc ADDED
Binary file (4.66 kB). View file
 
app/__pycache__/embedding_cache.cpython-314.pyc ADDED
Binary file (4.82 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc ADDED
Binary file (9.4 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.1935805179792 ADDED
Binary file (10.6 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.1974185286032 ADDED
Binary file (4.07 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.2199813547920 ADDED
Binary file (10.3 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.2307245939200 ADDED
Binary file (4.07 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.2323257419664 ADDED
Binary file (10.6 kB). View file
 
app/__pycache__/embeddings.cpython-311.pyc.2542682446224 ADDED
Binary file (4.07 kB). View file
 
app/__pycache__/embeddings.cpython-314.pyc ADDED
Binary file (9.45 kB). View file
 
app/__pycache__/evaluate.cpython-311.pyc ADDED
Binary file (56.6 kB). View file
 
app/__pycache__/evaluate.cpython-311.pyc.1949709152400 ADDED
Binary file (53.6 kB). View file
 
app/__pycache__/evaluate.cpython-311.pyc.1973714458800 ADDED
Binary file (50.6 kB). View file