Spaces:
Sleeping
Sleeping
Vela
commited on
Commit
Β·
43f57f4
1
Parent(s):
696ff74
admin portal
Browse files
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/pinecone_data_handler.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import requests
|
2 |
from app import common_fuctions
|
|
|
|
|
3 |
|
4 |
API_BASE_URL = "http://localhost:8000/knowledge-base"
|
5 |
|
@@ -27,32 +29,82 @@ def delete_records(st):
|
|
27 |
response = requests.post(f"{API_BASE_URL}/delete-records", json=payload)
|
28 |
st.success(response.json()["message"]) if response.status_code == 200 else st.error(response.json()["detail"])
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
def render_metadata_fetch_form(st):
|
31 |
st.header("Fetch Metadata")
|
32 |
with st.form("fetch_metadata_form"):
|
33 |
-
prompt_text = st.text_area(
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
metadata_submit = st.form_submit_button("Fetch Metadata")
|
37 |
|
38 |
if metadata_submit:
|
39 |
payload = {
|
40 |
-
"prompt": prompt_text,
|
41 |
"n_result": n_result,
|
42 |
"score_threshold": score_threshold
|
43 |
}
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
metadata = response.json().get('metadata', [])
|
|
|
47 |
if metadata:
|
48 |
st.subheader("Search Results")
|
49 |
for index, entry in enumerate(metadata, start=1):
|
50 |
st.markdown(f"### Result {index}")
|
51 |
-
common_fuctions.typewriter_effect(st, f"**Question:** {entry
|
52 |
-
common_fuctions.typewriter_effect(st, f"**Answer:** {entry
|
53 |
-
st.markdown(f"**Score:** {entry
|
54 |
-
st.markdown(f"**ID:** {entry
|
55 |
-
st.markdown("---")
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
1 |
import requests
|
2 |
from app import common_fuctions
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
|
6 |
API_BASE_URL = "http://localhost:8000/knowledge-base"
|
7 |
|
|
|
29 |
response = requests.post(f"{API_BASE_URL}/delete-records", json=payload)
|
30 |
st.success(response.json()["message"]) if response.status_code == 200 else st.error(response.json()["detail"])
|
31 |
|
32 |
+
# def render_metadata_fetch_form(st):
|
33 |
+
# st.header("Fetch Metadata")
|
34 |
+
# with st.form("fetch_metadata_form"):
|
35 |
+
# prompt_text = st.text_area("Describe Your Concern", "e.g., I've been feeling anxious lately.")
|
36 |
+
# n_result = st.number_input("Number of Results", min_value=1, value=3)
|
37 |
+
# score_threshold = st.number_input("Score Threshold", min_value=0.0, max_value=1.0, value=0.47)
|
38 |
+
# metadata_submit = st.form_submit_button("Fetch Metadata")
|
39 |
+
|
40 |
+
# if metadata_submit:
|
41 |
+
# payload = {
|
42 |
+
# "prompt": prompt_text,
|
43 |
+
# "n_result": n_result,
|
44 |
+
# "score_threshold": score_threshold
|
45 |
+
# }
|
46 |
+
# response = requests.post(f"{API_BASE_URL}/fetch-metadata", json=payload)
|
47 |
+
# if response.status_code == 200:
|
48 |
+
# metadata = response.json().get('metadata', [])
|
49 |
+
# try:
|
50 |
+
# if metadata:
|
51 |
+
# st.subheader("Search Results")
|
52 |
+
# for index, entry in enumerate(metadata, start=1):
|
53 |
+
# st.markdown(f"### Result {index}")
|
54 |
+
# common_fuctions.typewriter_effect(st, f"**Question:** {entry['question']}")
|
55 |
+
# common_fuctions.typewriter_effect(st, f"**Answer:** {entry['answer']}")
|
56 |
+
# st.markdown(f"**Score:** {entry['score']}")
|
57 |
+
# st.markdown(f"**ID:** {entry['id']}")
|
58 |
+
# st.markdown("---")
|
59 |
+
# except Exception as e:
|
60 |
+
# st.info("There is not relevant data to fetch")
|
61 |
+
|
62 |
def render_metadata_fetch_form(st):
|
63 |
st.header("Fetch Metadata")
|
64 |
with st.form("fetch_metadata_form"):
|
65 |
+
prompt_text = st.text_area(
|
66 |
+
"Describe Your Concern",
|
67 |
+
"e.g., I've been feeling anxious lately.",
|
68 |
+
help="Provide a brief description of your concern to get relevant metadata."
|
69 |
+
)
|
70 |
+
n_result = st.number_input(
|
71 |
+
"Number of Results",
|
72 |
+
min_value=1,
|
73 |
+
value=3,
|
74 |
+
help="Specify the number of search results you'd like to retrieve."
|
75 |
+
)
|
76 |
+
score_threshold = st.number_input(
|
77 |
+
"Score Threshold",
|
78 |
+
min_value=0.0,
|
79 |
+
max_value=1.0,
|
80 |
+
value=0.47,
|
81 |
+
help="Set the minimum relevance score for the results. Higher values ensure more accurate matches."
|
82 |
+
)
|
83 |
+
|
84 |
metadata_submit = st.form_submit_button("Fetch Metadata")
|
85 |
|
86 |
if metadata_submit:
|
87 |
payload = {
|
88 |
+
"prompt": prompt_text.strip(),
|
89 |
"n_result": n_result,
|
90 |
"score_threshold": score_threshold
|
91 |
}
|
92 |
+
|
93 |
+
try:
|
94 |
+
response = requests.post(f"{API_BASE_URL}/fetch-metadata", json=payload)
|
95 |
+
response.raise_for_status() # Ensures HTTP errors are caught
|
96 |
metadata = response.json().get('metadata', [])
|
97 |
+
|
98 |
if metadata:
|
99 |
st.subheader("Search Results")
|
100 |
for index, entry in enumerate(metadata, start=1):
|
101 |
st.markdown(f"### Result {index}")
|
102 |
+
common_fuctions.typewriter_effect(st, f"**Question:** {entry.get('question', 'N/A')}")
|
103 |
+
common_fuctions.typewriter_effect(st, f"**Answer:** {entry.get('answer', 'N/A')}")
|
104 |
+
st.markdown(f"**Score:** {entry.get('score', 'N/A')}")
|
105 |
+
st.markdown(f"**ID:** {entry.get('id', 'N/A')}")
|
106 |
+
st.markdown("---")
|
107 |
+
else:
|
108 |
+
st.info("No relevant data found based on your input. Try refining your concern or adjusting the threshold.")
|
109 |
+
except Exception as e:
|
110 |
+
st.error(f"An unexpected error occurred: {e}")
|
src/frontend/home.py
CHANGED
@@ -15,31 +15,30 @@ def render_homepage():
|
|
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 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
""")
|
44 |
|
45 |
with Admin_Portal:
|
|
|
15 |
use_container_width=True,
|
16 |
caption="Your AI-Powered Health Companion")
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Navigation Tabs
|
19 |
Home, Admin_Portal, Knowledge_Base_Explorer = st.tabs(
|
20 |
["π Home", "π Admin Portal", "π Knowledge Base Explorer"]
|
21 |
)
|
22 |
|
23 |
with Home:
|
24 |
+
# st.markdown("### π Getting Started")
|
25 |
+
# st.markdown("""
|
26 |
+
# - Select **Admin Portal** for system configurations and data management.
|
27 |
+
# - Go to **Knowledge Base Explorer** to explore and manage knowledge entries.
|
28 |
+
# """)
|
29 |
st.markdown("""
|
30 |
+
### π Welcome to the Yuvabe Care Companion AI!
|
31 |
+
This platform offers comprehensive tools to support your healthcare journey. Use the tabs above to navigate:
|
32 |
+
""")
|
33 |
+
|
34 |
+
# Feature Overview Section
|
35 |
+
st.markdown("""
|
36 |
+
### πΉ Key Features
|
37 |
+
- **Admin Portal** β Manage records, data, and configurations efficiently.
|
38 |
+
- **Knowledge Base Explorer** β Leverage advanced vector search to find relevant knowledge entries with precision.
|
39 |
+
- **Patient Assistance** β Personalized guidance to help patients describe their concerns.
|
40 |
+
|
41 |
+
> π‘ *Explore each section for detailed functionality.*
|
42 |
""")
|
43 |
|
44 |
with Admin_Portal:
|
src/frontend/pages/Admin_Portal.py
CHANGED
@@ -1,12 +1,11 @@
|
|
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("""
|
@@ -33,6 +32,7 @@ def render_admin_portal():
|
|
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__":
|
|
|
1 |
import streamlit as st
|
2 |
from app import pinecone_data_handler
|
3 |
|
4 |
+
# Page Configuration
|
5 |
+
# st.set_page_config(page_title="Admin Portal", page_icon="π", layout="wide")
|
6 |
def render_admin_portal():
|
7 |
"""Renders the Admin Portal page with improved UI and navigation."""
|
8 |
|
|
|
|
|
|
|
9 |
# Header Section
|
10 |
st.title("π Admin Portal")
|
11 |
st.markdown("""
|
|
|
32 |
# Sidebar for Navigation
|
33 |
st.sidebar.title("π Navigation")
|
34 |
st.sidebar.markdown("[π Home](http://localhost:8501)", unsafe_allow_html=True)
|
35 |
+
st.sidebar.markdown("[π Knowledge Base](http://localhost:8501/Knowledge_Base_Explorer)", unsafe_allow_html=True)
|
36 |
|
37 |
# Call the function to render the Admin Portal
|
38 |
if __name__ == "__main__":
|
src/frontend/pages/__pycache__/Admin_Portal.cpython-313.pyc
CHANGED
Binary files a/src/frontend/pages/__pycache__/Admin_Portal.cpython-313.pyc and b/src/frontend/pages/__pycache__/Admin_Portal.cpython-313.pyc differ
|
|