nnngoc commited on
Commit
986ba7d
2 Parent(s): 85cc062 a9bcd08

Merge branch 'main' of https://huggingface.co/spaces/nnngoc/chatbot_bk1 into main

Browse files
Files changed (3) hide show
  1. .github/workflows/sync.yml +20 -0
  2. README.md +0 -12
  3. app.py +0 -69
.github/workflows/sync.yml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+ - name: Push to hub
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: git push https://nnngoc:[email protected]/spaces/nnngoc/chatbot_bk1 main
README.md CHANGED
@@ -1,12 +0,0 @@
1
- ---
2
- title: Chatbot Bk1
3
- emoji: 📈
4
- colorFrom: gray
5
- colorTo: green
6
- sdk: streamlit
7
- sdk_version: 1.29.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
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,69 +0,0 @@
1
- import streamlit as st
2
- from rag import rag
3
-
4
- # Tạo ra một dictionary lưu trữ mapping giữa câu hỏi và giá trị tương ứng của nút
5
- guiding_questions = {
6
- "Có những loại chương trình đào tạo thạc sĩ nào?": False,
7
- "Cho tôi thông tin về chương trình đào tạo thạc sĩ ứng dụng?": False,
8
- "Tiêu chuẩn huy chương vàng được quy định như thế nào?": False,
9
- "Miễn thi được quy định như thế nào?": False,
10
- "Yêu cầu ngoại ngữ đối với học viên thạc sĩ?": False
11
- }
12
-
13
- def main():
14
- st.set_page_config(page_title="Chatbot BK1")
15
-
16
- st.image(["logo.jpg"], width=100)
17
- # with st.columns(3)[1]:
18
- # st.image(["logo.jpg"])
19
-
20
- st.title("Chatbot Phòng Đào Tạo")
21
- # st.markdown("<h1 style='text-align: center'>Chatbot Phòng Đào Tạo</h1>", unsafe_allow_html=True)
22
-
23
- st.subheader("Tôi có thể giải đáp các thắc mắc về quy định học vụ của Trường Đại Học Bách Khoa - ĐHQG TP.HCM", divider='rainbow')
24
-
25
- # Hiển thị sidebar với các câu hỏi hướng dẫn
26
- st.sidebar.subheader("Có thể bạn quan tâm những câu hỏi dưới đây:")
27
-
28
- # set initial message
29
- if "messages" not in st.session_state.keys():
30
- st.session_state.messages = [
31
- {"role": "assistant", "content": "Xin chào, tôi có thể giúp gì cho bạn"}
32
- ]
33
-
34
- if "messages" in st.session_state.keys():
35
- # display messages
36
- for message in st.session_state.messages:
37
- with st.chat_message(message["role"]):
38
- st.write(message["content"])
39
-
40
- # get user input
41
- user_prompt = st.chat_input()
42
- for question in guiding_questions.keys():
43
- if st.sidebar.button(question, key=question):
44
- user_prompt = question
45
- guiding_questions[question] = True # Đánh dấu câu hỏi được chọn
46
- handle_user_input(user_prompt)
47
-
48
- def handle_user_input(user_prompt):
49
- if user_prompt is not None:
50
- st.session_state.messages.append({"role": "user", "content": user_prompt})
51
- with st.chat_message("user"):
52
- st.write(user_prompt)
53
-
54
- # process user input
55
- if st.session_state.messages[-1]["role"] != "assistant":
56
- with st.chat_message("assistant"):
57
- with st.spinner("Loading..."):
58
- ai_response = rag(user_prompt)
59
- if ai_response == "Encountered some errors. Please recheck your request!":
60
- st.write("Xin lỗi, tôi không có thông tin về câu hỏi này!")
61
- else:
62
- st.write(ai_response)
63
-
64
- new_ai_message = {"role": "assistant", "content": ai_response}
65
- st.session_state.messages.append(new_ai_message)
66
-
67
-
68
- if __name__ == '__main__':
69
- main()