ArturG9 commited on
Commit
40273bc
·
verified ·
1 Parent(s): 433b27a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -27
app.py CHANGED
@@ -17,7 +17,7 @@ from utills import load_txt_documents , split_docs, load_uploaded_documents,ret
17
 
18
 
19
  script_dir = os.path.dirname(os.path.abspath(__file__))
20
- data_path = "data"
21
  model_path = os.path.join(script_dir, 'qwen2-0_5b-instruct-q4_0.gguf')
22
  store = {}
23
 
@@ -99,15 +99,7 @@ def display_chat_history(chat_history):
99
  for msg in chat_history.messages:
100
  st.chat_message(msg.type).write(msg.content)
101
 
102
- def display_documents(docs, on_click=None):
103
- """Displays retrieved documents with optional click action."""
104
- if docs:
105
- for i, document in enumerate(docs):
106
- st.write(f"**Docs {i+1}**")
107
- st.markdown(document, unsafe_allow_html=True)
108
- if on_click:
109
- if st.button(f"Expand Article {i+1}"):
110
- on_click(i)
111
 
112
  def main_page(conversational_rag_chain):
113
  """Main page for the Streamlit app."""
@@ -135,27 +127,12 @@ def main_page(conversational_rag_chain):
135
 
136
  st.session_state["chat_history"] = msgs
137
 
138
- def upload_page():
139
- """Page for uploading and viewing documents."""
140
- st.title("Upload and Check Documents")
141
-
142
- uploaded_files = st.file_uploader("Upload Text Files", type=["txt"], accept_multiple_files=True)
143
-
144
- if uploaded_files:
145
- documents = load_uploaded_documents(uploaded_files)
146
- for document in documents:
147
- st.write(f"**Filename: {document['filename']}**")
148
- st.text(document['content'])
149
 
150
  def main():
151
  """Main function for the Streamlit app with page navigation."""
152
- st.sidebar.title("Navigation")
153
- page = st.sidebar.radio("Go to", ["Chatbot", "Upload Documents"])
154
 
155
- if page == "Chatbot":
156
- main_page(conversational_rag_chain)
157
- elif page == "Upload Documents":
158
- upload_page()
159
 
160
  if __name__ == "__main__":
161
  main()
 
17
 
18
 
19
  script_dir = os.path.dirname(os.path.abspath(__file__))
20
+ data_path = os.path.join(script_dir, "data/")
21
  model_path = os.path.join(script_dir, 'qwen2-0_5b-instruct-q4_0.gguf')
22
  store = {}
23
 
 
99
  for msg in chat_history.messages:
100
  st.chat_message(msg.type).write(msg.content)
101
 
102
+
 
 
 
 
 
 
 
 
103
 
104
  def main_page(conversational_rag_chain):
105
  """Main page for the Streamlit app."""
 
127
 
128
  st.session_state["chat_history"] = msgs
129
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
  def main():
132
  """Main function for the Streamlit app with page navigation."""
 
 
133
 
134
+ main_page(conversational_rag_chain)
135
+
 
 
136
 
137
  if __name__ == "__main__":
138
  main()