Vela commited on
Commit
696ff74
Β·
1 Parent(s): a190548

enhance ui

Browse files
src/frontend/__pycache__/app.cpython-313.pyc ADDED
Binary file (1.97 kB). View file
 
src/frontend/app/__pycache__/common_fuctions.cpython-313.pyc CHANGED
Binary files a/src/frontend/app/__pycache__/common_fuctions.cpython-313.pyc and b/src/frontend/app/__pycache__/common_fuctions.cpython-313.pyc differ
 
src/frontend/app/__pycache__/pinecone_data_handler.cpython-313.pyc CHANGED
Binary files a/src/frontend/app/__pycache__/pinecone_data_handler.cpython-313.pyc and b/src/frontend/app/__pycache__/pinecone_data_handler.cpython-313.pyc differ
 
src/frontend/app/common_fuctions.py CHANGED
@@ -16,7 +16,7 @@ ABOUT_US = "An AI-powered assistant for personalized healthcare guidance."
16
 
17
  API_URL = os.getenv("API_URL", "http://localhost:8000")
18
 
19
- def config_homepage(st):
20
  st.set_page_config(
21
  page_title=PAGE_TITLE,
22
  page_icon= PAGE_ICON,
@@ -26,7 +26,9 @@ def config_homepage(st):
26
  "Report a bug": GITHUB_LINK,
27
  "About": ABOUT_US}
28
  )
 
29
 
 
30
  st.markdown(f"""
31
  <h1 style="color: darkblue; text-align: left; font-size: 50px;">
32
  <i>{PAGE_TITLE} πŸ₯βš•οΈπŸ€–</i>
@@ -34,10 +36,6 @@ def config_homepage(st):
34
  """, unsafe_allow_html=True
35
  )
36
 
37
- logger.info(f"Page successfully configured with title: {PAGE_TITLE}")
38
- st.session_state.config_status = False
39
- st.markdown("<hr>", unsafe_allow_html=True) # To add a Horizontal line below title
40
-
41
  def img_to_base64(image_path):
42
  """Convert image to base64."""
43
  try:
 
16
 
17
  API_URL = os.getenv("API_URL", "http://localhost:8000")
18
 
19
+ def config_homepage(st, page_title=PAGE_TITLE):
20
  st.set_page_config(
21
  page_title=PAGE_TITLE,
22
  page_icon= PAGE_ICON,
 
26
  "Report a bug": GITHUB_LINK,
27
  "About": ABOUT_US}
28
  )
29
+ logger.info(f"Page successfully configured with title: {PAGE_TITLE}")
30
 
31
+ def set_page_title(st, page_title=PAGE_TITLE):
32
  st.markdown(f"""
33
  <h1 style="color: darkblue; text-align: left; font-size: 50px;">
34
  <i>{PAGE_TITLE} πŸ₯βš•οΈπŸ€–</i>
 
36
  """, unsafe_allow_html=True
37
  )
38
 
 
 
 
 
39
  def img_to_base64(image_path):
40
  """Convert image to base64."""
41
  try:
src/frontend/home.py CHANGED
@@ -1,5 +1,55 @@
1
- from app import common_fuctions
2
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- common_fuctions.config_homepage(st)
 
 
5
 
 
 
 
 
 
1
  import streamlit as st
2
+ from app import common_fuctions
3
+ from PIL import Image
4
+
5
+ def render_homepage():
6
+ """Renders the Yuvabe Care Companion AI homepage."""
7
+
8
+ # Page Configuration
9
+ common_fuctions.config_homepage(st)
10
+ common_fuctions.set_page_title(st)
11
+
12
+
13
+ # Welcome Section with Visual
14
+ st.image("src/frontend/images/health_care_baner.png",
15
+ use_container_width=True,
16
+ caption="Your AI-Powered Health Companion")
17
+
18
+ st.markdown("""
19
+ ### πŸ‘‹ Welcome to the Yuvabe Care Companion AI!
20
+ This platform offers comprehensive tools to support your healthcare journey. Use the tabs below to navigate:
21
+ """)
22
+
23
+ # Feature Overview Section
24
+ st.markdown("""
25
+ ### πŸ”Ή Key Features
26
+ - **Admin Portal** β€” Manage records, data, and configurations efficiently.
27
+ - **Knowledge Base Explorer** β€” Leverage advanced vector search to find relevant knowledge entries with precision.
28
+ - **Patient Assistance** β€” Personalized guidance to help patients describe their concerns.
29
+
30
+ > πŸ’‘ *Explore each section for detailed functionality.*
31
+ """)
32
+
33
+ # Navigation Tabs
34
+ Home, Admin_Portal, Knowledge_Base_Explorer = st.tabs(
35
+ ["🏠 Home", "πŸ”’ Admin Portal", "πŸ“š Knowledge Base Explorer"]
36
+ )
37
+
38
+ with Home:
39
+ st.markdown("### 🌟 Getting Started")
40
+ st.markdown("""
41
+ - Select **Admin Portal** for system configurations and data management.
42
+ - Go to **Knowledge Base Explorer** to explore and manage knowledge entries.
43
+ """)
44
+
45
+ with Admin_Portal:
46
+ if st.button("Go to Admin Portal"):
47
+ st.switch_page("pages/admin_portal.py")
48
 
49
+ with Knowledge_Base_Explorer:
50
+ if st.button("Go to Knowledge Base Explorer"):
51
+ st.switch_page("pages/knowledge_base_explorer.py")
52
 
53
+ # Render the Homepage
54
+ if __name__ == "__main__":
55
+ render_homepage()
src/frontend/pages/Admin_Portal.py CHANGED
@@ -1,61 +1,39 @@
1
  import streamlit as st
2
  from app import pinecone_data_handler
3
 
4
-
5
- st.title("Admin Portal")
6
-
7
- DataManager = st.tabs(["Pinecone Data Manager"])[0]
8
-
9
- with DataManager:
10
- Upsert, Delete = st.tabs(["Upsert Data", "Delete Records"])
11
-
12
- with Upsert:
13
- pinecone_data_handler.upsert_data(st)
14
- with Delete:
15
- pinecone_data_handler.delete_records(st)
16
-
17
-
18
- # with tab3:
19
-
20
-
21
-
22
-
23
- # # Upsert Data Form
24
- # st.header("Upsert Data")
25
- # with st.form("upsert_form"):
26
- # input_text = st.text_area("Input", "What is mental health?")
27
- # output_text = st.text_area("Output", "Mental health refers to...")
28
- # instruction_text = st.text_input("Instruction", "Focus on general well-being.")
29
- # upsert_submit = st.form_submit_button("Upsert Data")
30
-
31
- # if upsert_submit:
32
- # payload = {"data": [{"input": input_text, "output": output_text, "instruction": instruction_text}]}
33
- # response = requests.post(f"{API_BASE_URL}/upsert-data", json=payload)
34
- # st.success(response.json()["message"]) if response.status_code == 200 else st.error(response.json()["detail"])
35
-
36
- # # Delete Records Form
37
- # st.header("Delete Records")
38
- # with st.form("delete_form"):
39
- # ids_to_delete = st.text_area("IDs to Delete", "id_123, id_456").split(",")
40
- # delete_submit = st.form_submit_button("Delete Records")
41
-
42
- # if delete_submit:
43
- # payload = {"ids_to_delete": [id.strip() for id in ids_to_delete]}
44
- # response = requests.post(f"{API_BASE_URL}/delete-records", json=payload)
45
- # st.success(response.json()["message"]) if response.status_code == 200 else st.error(response.json()["detail"])
46
-
47
- # # Fetch Metadata Form
48
- # st.header("Fetch Metadata")
49
- # with st.form("fetch_metadata_form"):
50
- # prompt_text = st.text_area("Prompt", "Tell me about mental health")
51
- # n_result = st.number_input("Number of Results", min_value=1, value=3)
52
- # score_threshold = st.number_input("Score Threshold", min_value=0.0, max_value=1.0, value=0.47)
53
- # metadata_submit = st.form_submit_button("Fetch Metadata")
54
-
55
- # if metadata_submit:
56
- # payload = {"prompt": prompt_text, "n_result": n_result, "score_threshold": score_threshold}
57
- # response = requests.post(f"{API_BASE_URL}/fetch-metadata", json=payload)
58
- # if response.status_code == 200:
59
- # st.json(response.json()["metadata"])
60
- # else:
61
- # st.error(response.json()["detail"])
 
1
  import streamlit as st
2
  from app import pinecone_data_handler
3
 
4
+ def render_admin_portal():
5
+ """Renders the Admin Portal page with improved UI and navigation."""
6
+
7
+ # Page Configuration
8
+ st.set_page_config(page_title="Admin Portal", page_icon="πŸ”’", layout="wide")
9
+
10
+ # Header Section
11
+ st.title("πŸ”’ Admin Portal")
12
+ st.markdown("""
13
+ ### Welcome to the Admin Portal!
14
+ Manage your Pinecone data efficiently with the options below.
15
+ """)
16
+
17
+ # Data Manager Tabs
18
+ DataManager = st.tabs(["πŸ“‚ Pinecone Data Manager"])[0]
19
+
20
+ with DataManager:
21
+ Upsert, Delete = st.tabs(["πŸ“₯ Upsert Data", "πŸ—‘οΈ Delete Records"])
22
+
23
+ with Upsert:
24
+ st.markdown("### πŸ“₯ Upsert Data")
25
+ st.info("Use this section to insert or update data in Pinecone.")
26
+ pinecone_data_handler.upsert_data(st)
27
+
28
+ with Delete:
29
+ st.markdown("### πŸ—‘οΈ Delete Records")
30
+ st.warning("Use this section to delete records from Pinecone. Be cautious when performing deletions.")
31
+ pinecone_data_handler.delete_records(st)
32
+
33
+ # Sidebar for Navigation
34
+ st.sidebar.title("πŸ”€ Navigation")
35
+ st.sidebar.markdown("[🏠 Home](http://localhost:8501)", unsafe_allow_html=True)
36
+
37
+ # Call the function to render the Admin Portal
38
+ if __name__ == "__main__":
39
+ render_admin_portal()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/frontend/pages/Knowledge_Base_Explorer.py CHANGED
@@ -1,9 +1,28 @@
1
  import streamlit as st
2
  from app import pinecone_data_handler
3
 
4
- st.title("Knowledge Base Explorer")
 
 
 
 
5
 
6
- st.markdown("Enter your concerns below to receive helpful information.")
 
 
 
 
 
7
 
8
- with st.expander("Knowledge Base"):
9
- pinecone_data_handler.render_metadata_fetch_form(st)
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from app import pinecone_data_handler
3
 
4
+ def render_knowledge_base_explorer():
5
+ """Renders the Knowledge Base Explorer page with improved UI and navigation."""
6
+
7
+ # Page Configuration
8
+ st.set_page_config(page_title="Knowledge Base Explorer", page_icon="πŸ“š", layout="wide")
9
 
10
+ # Header Section
11
+ st.title("πŸ“š Knowledge Base Explorer")
12
+ st.markdown("""
13
+ ### Discover Helpful Information!
14
+ Enter your concerns below to receive insights and solutions tailored to your needs.
15
+ """)
16
 
17
+ # Knowledge Base Section
18
+ with st.expander("πŸ” Explore the Knowledge Base"):
19
+ pinecone_data_handler.render_metadata_fetch_form(st)
20
+
21
+ # Sidebar for Navigation
22
+ st.sidebar.title("πŸ”€ Navigation")
23
+ st.sidebar.markdown("[🏠 Home](http://localhost:8501)", unsafe_allow_html=True)
24
+ st.sidebar.markdown("[πŸ”’ Admin Portal](http://localhost:8501/Admin_Portal)", unsafe_allow_html=True)
25
+
26
+ # Call the function to render the Knowledge Base Explorer
27
+ if __name__ == "__main__":
28
+ render_knowledge_base_explorer()
src/frontend/pages/__pycache__/Admin_Portal.cpython-313.pyc ADDED
Binary file (2.35 kB). View file
 
src/frontend/pages/__pycache__/Knowledge_Base_Explorer.cpython-313.pyc ADDED
Binary file (874 Bytes). View file
 
src/frontend/pages/chat_with_me.py DELETED
@@ -1,33 +0,0 @@
1
- from app import common_fuctions
2
- import streamlit as st
3
-
4
- common_fuctions.config_homepage(st)
5
-
6
- def open_chat():
7
-
8
- prompt = st.chat_input("Ask me anything related to health care")
9
-
10
- if "chat_history" not in st.session_state:
11
- st.session_state.chat_history = []
12
-
13
- if prompt :
14
-
15
- with st.chat_message('user'):
16
- st.markdown(prompt)
17
-
18
- with st.spinner("Thinking..."):
19
- # response = common_fuctions.fetch_response(prompt, st.session_state.chat_history)
20
- response = common_fuctions.get_api_response("/test/relevant-response",prompt)
21
-
22
- with st.chat_message('assistant'):
23
- st.markdown(response)
24
-
25
- # Append to chat history
26
- st.session_state.chat_history.append({"role": "user", "content": prompt})
27
- st.session_state.chat_history.append({"role": "assistant", "content": response})
28
-
29
- # for chat in st.session_state.chat_history:
30
- # with st.chat_message(chat["role"]):
31
- # st.markdown(chat["content"])
32
-
33
- open_chat()