Spaces:
Sleeping
Sleeping
Vela
commited on
Commit
·
2d34419
1
Parent(s):
c67f9ba
updated fastapi url
Browse files- logs/api/yuvabe_care_companion_ai_api.log +18 -0
- logs/api/yuvabe_care_companion_ai_app.log +94 -0
- src/backend/routes/__pycache__/chat_api.cpython-313.pyc +0 -0
- src/backend/routes/chat_api.py +4 -4
- src/frontend/app/__pycache__/common_fuctions.cpython-313.pyc +0 -0
- src/frontend/app/__pycache__/homepage.cpython-313.pyc +0 -0
- src/frontend/app/common_fuctions.py +4 -3
- src/frontend/app/homepage.py +2 -8
- src/frontend/pages/database_response_page.py +2 -1
logs/api/yuvabe_care_companion_ai_api.log
CHANGED
@@ -177,3 +177,21 @@ Trying to import the above resulted in these errors:
|
|
177 |
2025-03-06 23:08 - INFO - Successfully fetched the data from database
|
178 |
2025-03-06 23:11 - INFO - Trying to fetch the data from database
|
179 |
2025-03-06 23:11 - INFO - Successfully fetched the data from database
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
2025-03-06 23:08 - INFO - Successfully fetched the data from database
|
178 |
2025-03-06 23:11 - INFO - Trying to fetch the data from database
|
179 |
2025-03-06 23:11 - INFO - Successfully fetched the data from database
|
180 |
+
2025-03-07 06:48 - INFO - Trying to fetch the data from database
|
181 |
+
2025-03-07 06:48 - INFO - Successfully fetched the data from database
|
182 |
+
2025-03-07 06:49 - INFO - Received user prompt: I'm not feeling well today
|
183 |
+
2025-03-07 06:49 - INFO - Trying to fetch the data from database
|
184 |
+
2025-03-07 06:49 - INFO - Successfully fetched the data from database
|
185 |
+
2025-03-07 06:49 - INFO - Generated AI response for user prompt: I'm not feeling well today...
|
186 |
+
2025-03-07 06:49 - INFO - Generated AI response: I'm so sorry to hear that you're not feeling well today. Can you please tell me more about your symp...
|
187 |
+
2025-03-07 06:54 - INFO - Received user prompt: I'm not feeling well today
|
188 |
+
2025-03-07 06:54 - INFO - Trying to fetch the data from database
|
189 |
+
2025-03-07 06:54 - INFO - Successfully fetched the data from database
|
190 |
+
2025-03-07 06:54 - INFO - Generated AI response for user prompt: I'm not feeling well today...
|
191 |
+
2025-03-07 06:54 - INFO - Generated AI response: I'm so sorry to hear that you're not feeling well today. It can be really frustrating and concerning...
|
192 |
+
2025-03-07 06:55 - INFO - Trying to fetch the data from database
|
193 |
+
2025-03-07 06:55 - INFO - Successfully fetched the data from database
|
194 |
+
2025-03-07 07:06 - INFO - Trying to fetch the data from database
|
195 |
+
2025-03-07 07:06 - INFO - Successfully fetched the data from database
|
196 |
+
2025-03-07 07:15 - INFO - Trying to fetch the data from database
|
197 |
+
2025-03-07 07:15 - INFO - Successfully fetched the data from database
|
logs/api/yuvabe_care_companion_ai_app.log
CHANGED
@@ -94,3 +94,97 @@
|
|
94 |
2025-03-06 23:06 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
95 |
2025-03-06 23:08 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
96 |
2025-03-06 23:11 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
2025-03-06 23:06 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
95 |
2025-03-06 23:08 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
96 |
2025-03-06 23:11 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
97 |
+
2025-03-07 06:51 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
98 |
+
2025-03-07 06:51 - INFO - user_name not found in session_state, setting to None.
|
99 |
+
2025-03-07 06:51 - INFO - user_name is None, requesting user input.
|
100 |
+
2025-03-07 06:51 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
101 |
+
2025-03-07 06:51 - INFO - user_name is None, requesting user input.
|
102 |
+
2025-03-07 06:51 - INFO - User entered name: Vela. Setting session_state.user_name.
|
103 |
+
2025-03-07 06:51 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
104 |
+
2025-03-07 06:51 - INFO - User already entered a name: Vela. Displaying greeting.
|
105 |
+
2025-03-07 06:51 - INFO - Displaying the chat history.
|
106 |
+
2025-03-07 06:51 - INFO - Waiting for user input...
|
107 |
+
2025-03-07 06:51 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
108 |
+
2025-03-07 06:51 - INFO - User already entered a name: Vela. Displaying greeting.
|
109 |
+
2025-03-07 06:51 - INFO - Displaying the chat history.
|
110 |
+
2025-03-07 06:51 - INFO - Waiting for user input...
|
111 |
+
2025-03-07 06:51 - INFO - Assistant response: An error occurred while processing your request....
|
112 |
+
2025-03-07 06:52 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
113 |
+
2025-03-07 06:52 - INFO - user_name not found in session_state, setting to None.
|
114 |
+
2025-03-07 06:52 - INFO - user_name is None, requesting user input.
|
115 |
+
2025-03-07 06:52 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
116 |
+
2025-03-07 06:52 - INFO - user_name is None, requesting user input.
|
117 |
+
2025-03-07 06:52 - INFO - User entered name: Velu. Setting session_state.user_name.
|
118 |
+
2025-03-07 06:52 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
119 |
+
2025-03-07 06:52 - INFO - User already entered a name: Velu. Displaying greeting.
|
120 |
+
2025-03-07 06:52 - INFO - Displaying the chat history.
|
121 |
+
2025-03-07 06:52 - INFO - Waiting for user input...
|
122 |
+
2025-03-07 06:52 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
123 |
+
2025-03-07 06:52 - INFO - User already entered a name: Velu. Displaying greeting.
|
124 |
+
2025-03-07 06:52 - INFO - Displaying the chat history.
|
125 |
+
2025-03-07 06:52 - INFO - Waiting for user input...
|
126 |
+
2025-03-07 06:52 - INFO - Assistant response: An error occurred while processing your request....
|
127 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
128 |
+
2025-03-07 06:54 - INFO - user_name not found in session_state, setting to None.
|
129 |
+
2025-03-07 06:54 - INFO - user_name is None, requesting user input.
|
130 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
131 |
+
2025-03-07 06:54 - INFO - user_name is None, requesting user input.
|
132 |
+
2025-03-07 06:54 - INFO - User entered name: Vela. Setting session_state.user_name.
|
133 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
134 |
+
2025-03-07 06:54 - INFO - User already entered a name: Vela. Displaying greeting.
|
135 |
+
2025-03-07 06:54 - INFO - Displaying the chat history.
|
136 |
+
2025-03-07 06:54 - INFO - Waiting for user input...
|
137 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
138 |
+
2025-03-07 06:54 - INFO - User already entered a name: Vela. Displaying greeting.
|
139 |
+
2025-03-07 06:54 - INFO - Displaying the chat history.
|
140 |
+
2025-03-07 06:54 - INFO - Waiting for user input...
|
141 |
+
2025-03-07 06:54 - INFO - Assistant response: I'm so sorry to hear that you're not feeling well today. It can be really frustrating and concerning...
|
142 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
143 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
144 |
+
2025-03-07 06:54 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
145 |
+
2025-03-07 06:55 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
146 |
+
2025-03-07 07:06 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
147 |
+
2025-03-07 07:06 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
148 |
+
2025-03-07 07:06 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
149 |
+
2025-03-07 07:15 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
150 |
+
2025-03-07 07:15 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
151 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
152 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
153 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
154 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
155 |
+
2025-03-07 07:16 - INFO - user_name not found in session_state, setting to None.
|
156 |
+
2025-03-07 07:16 - INFO - user_name is None, requesting user input.
|
157 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
158 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
159 |
+
2025-03-07 07:16 - INFO - user_name is None, requesting user input.
|
160 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
161 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
162 |
+
2025-03-07 07:16 - INFO - user_name is None, requesting user input.
|
163 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
164 |
+
2025-03-07 07:16 - INFO - user_name is None, requesting user input.
|
165 |
+
2025-03-07 07:16 - INFO - User entered name: Velu. Setting session_state.user_name.
|
166 |
+
2025-03-07 07:16 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
167 |
+
2025-03-07 07:16 - INFO - User already entered a name: Velu. Displaying greeting.
|
168 |
+
2025-03-07 07:16 - INFO - Displaying the chat history.
|
169 |
+
2025-03-07 07:16 - INFO - Waiting for user input...
|
170 |
+
2025-03-07 07:17 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
171 |
+
2025-03-07 07:17 - INFO - User already entered a name: Velu. Displaying greeting.
|
172 |
+
2025-03-07 07:17 - INFO - Displaying the chat history.
|
173 |
+
2025-03-07 07:17 - INFO - Waiting for user input...
|
174 |
+
2025-03-07 07:17 - INFO - Assistant response: I'm so sorry to hear that you're not feeling well today. It can be really frustrating and worrisome ...
|
175 |
+
2025-03-07 07:17 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
176 |
+
2025-03-07 07:17 - INFO - User already entered a name: Velu. Displaying greeting.
|
177 |
+
2025-03-07 07:17 - INFO - Displaying the chat history.
|
178 |
+
2025-03-07 07:17 - INFO - Displayed 2 messages from the chat history.
|
179 |
+
2025-03-07 07:17 - INFO - Displayed 2 messages from the chat history.
|
180 |
+
2025-03-07 07:17 - INFO - Waiting for user input...
|
181 |
+
2025-03-07 07:17 - INFO - Assistant response: Hello! It's nice to meet you. Is there something on your mind that you'd like to talk about, or perh...
|
182 |
+
2025-03-07 07:17 - INFO - Page successfully configured with title: Yuvabe Care Companion AI
|
183 |
+
2025-03-07 07:17 - INFO - User already entered a name: Velu. Displaying greeting.
|
184 |
+
2025-03-07 07:17 - INFO - Displaying the chat history.
|
185 |
+
2025-03-07 07:17 - INFO - Displayed 4 messages from the chat history.
|
186 |
+
2025-03-07 07:17 - INFO - Displayed 4 messages from the chat history.
|
187 |
+
2025-03-07 07:17 - INFO - Displayed 4 messages from the chat history.
|
188 |
+
2025-03-07 07:17 - INFO - Displayed 4 messages from the chat history.
|
189 |
+
2025-03-07 07:17 - INFO - Waiting for user input...
|
190 |
+
2025-03-07 07:17 - INFO - Assistant response: It seems like you've been provided with some general health advice, but you haven't asked a specific...
|
src/backend/routes/__pycache__/chat_api.cpython-313.pyc
CHANGED
Binary files a/src/backend/routes/__pycache__/chat_api.cpython-313.pyc and b/src/backend/routes/__pycache__/chat_api.cpython-313.pyc differ
|
|
src/backend/routes/chat_api.py
CHANGED
@@ -7,8 +7,8 @@ from data import chroma_db
|
|
7 |
logger = logger.get_logger()
|
8 |
router = APIRouter()
|
9 |
|
10 |
-
@router.post("/
|
11 |
-
async def
|
12 |
try:
|
13 |
logger.info(f"Received user prompt: {chat_request.prompt}")
|
14 |
response_text = llm_model.get_medical_assistant_response(chat_request.prompt)
|
@@ -18,8 +18,8 @@ async def get_chat_response(chat_request: Chat_Response):
|
|
18 |
logger.exception("Unexpected error occurred while processing the request.")
|
19 |
raise HTTPException(status_code=500, detail="An error occurred while processing your request.")
|
20 |
|
21 |
-
@router.post("/
|
22 |
-
async def
|
23 |
try:
|
24 |
response_text = chroma_db.search_vector_store(chat_request.prompt)
|
25 |
return {"status": "success", "response": response_text}
|
|
|
7 |
logger = logger.get_logger()
|
8 |
router = APIRouter()
|
9 |
|
10 |
+
@router.post("/agent_response")
|
11 |
+
async def get_assistant_response(chat_request: Chat_Response):
|
12 |
try:
|
13 |
logger.info(f"Received user prompt: {chat_request.prompt}")
|
14 |
response_text = llm_model.get_medical_assistant_response(chat_request.prompt)
|
|
|
18 |
logger.exception("Unexpected error occurred while processing the request.")
|
19 |
raise HTTPException(status_code=500, detail="An error occurred while processing your request.")
|
20 |
|
21 |
+
@router.post("/db_response")
|
22 |
+
async def get_db_response(chat_request: Chat_Response):
|
23 |
try:
|
24 |
response_text = chroma_db.search_vector_store(chat_request.prompt)
|
25 |
return {"status": "success", "response": response_text}
|
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__/homepage.cpython-313.pyc
CHANGED
Binary files a/src/frontend/app/__pycache__/homepage.cpython-313.pyc and b/src/frontend/app/__pycache__/homepage.cpython-313.pyc differ
|
|
src/frontend/app/common_fuctions.py
CHANGED
@@ -1,7 +1,10 @@
|
|
|
|
1 |
import base64
|
2 |
import requests
|
|
|
3 |
from utils import logger
|
4 |
|
|
|
5 |
logger = logger.get_logger()
|
6 |
|
7 |
def img_to_base64(image_path):
|
@@ -13,9 +16,7 @@ def img_to_base64(image_path):
|
|
13 |
logger.error(f"Error converting image to base64: {str(e)}")
|
14 |
return None
|
15 |
|
16 |
-
|
17 |
-
API_URL ="https://velatest-yuvabe-care-companion-ai.hf.space"
|
18 |
-
|
19 |
|
20 |
def get_api_response(endpoint:str, prompt: str):
|
21 |
try:
|
|
|
1 |
+
import os
|
2 |
import base64
|
3 |
import requests
|
4 |
+
from dotenv import load_dotenv
|
5 |
from utils import logger
|
6 |
|
7 |
+
load_dotenv()
|
8 |
logger = logger.get_logger()
|
9 |
|
10 |
def img_to_base64(image_path):
|
|
|
16 |
logger.error(f"Error converting image to base64: {str(e)}")
|
17 |
return None
|
18 |
|
19 |
+
API_URL = os.getenv("API_URL", "http://127.0.0.1:8000")
|
|
|
|
|
20 |
|
21 |
def get_api_response(endpoint:str, prompt: str):
|
22 |
try:
|
src/frontend/app/homepage.py
CHANGED
@@ -38,26 +38,20 @@ def display_chat():
|
|
38 |
logger.info(f"Displayed {len(st.session_state.messages)} messages from the chat history.")
|
39 |
|
40 |
def handle_user_input():
|
41 |
-
"""
|
42 |
-
Handles user input for Yuvabe Care Companion AI, validates query relevance,
|
43 |
-
and fetches a response from the medical assistant model.
|
44 |
-
"""
|
45 |
|
46 |
logger.info("Waiting for user input...")
|
47 |
-
|
48 |
prompt = st.chat_input("Ask me anything about health, physiotherapy, or medical advice!")
|
49 |
-
|
50 |
if prompt:
|
51 |
|
52 |
with st.chat_message("user"):
|
53 |
st.markdown(prompt)
|
54 |
-
|
55 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
56 |
|
57 |
try:
|
58 |
with st.spinner("Processing your query..."):
|
59 |
try:
|
60 |
-
|
|
|
61 |
except Exception as e:
|
62 |
logger.error(f"AI response generation failed: {str(e)}")
|
63 |
response = "⚠️ Sorry, I couldn't process your request. Please try again later."
|
|
|
38 |
logger.info(f"Displayed {len(st.session_state.messages)} messages from the chat history.")
|
39 |
|
40 |
def handle_user_input():
|
|
|
|
|
|
|
|
|
41 |
|
42 |
logger.info("Waiting for user input...")
|
|
|
43 |
prompt = st.chat_input("Ask me anything about health, physiotherapy, or medical advice!")
|
|
|
44 |
if prompt:
|
45 |
|
46 |
with st.chat_message("user"):
|
47 |
st.markdown(prompt)
|
|
|
48 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
49 |
|
50 |
try:
|
51 |
with st.spinner("Processing your query..."):
|
52 |
try:
|
53 |
+
endpoint = "/chat/agent_response"
|
54 |
+
response = common_fuctions.get_api_response(endpoint, prompt)
|
55 |
except Exception as e:
|
56 |
logger.error(f"AI response generation failed: {str(e)}")
|
57 |
response = "⚠️ Sorry, I couldn't process your request. Please try again later."
|
src/frontend/pages/database_response_page.py
CHANGED
@@ -7,7 +7,8 @@ st.title("Database Response")
|
|
7 |
st.write("This page is used to get the response from the database")
|
8 |
prompt = st.text_input("Enter your prompt")
|
9 |
if st.button("Get DB response"):
|
10 |
-
|
|
|
11 |
for metadata_group in response["metadatas"]:
|
12 |
for entry in metadata_group:
|
13 |
st.write("Question:", entry["question"])
|
|
|
7 |
st.write("This page is used to get the response from the database")
|
8 |
prompt = st.text_input("Enter your prompt")
|
9 |
if st.button("Get DB response"):
|
10 |
+
endpoint = "/chat/db_response"
|
11 |
+
response = common_fuctions.get_api_response(endpoint, prompt)
|
12 |
for metadata_group in response["metadatas"]:
|
13 |
for entry in metadata_group:
|
14 |
st.write("Question:", entry["question"])
|