Vela commited on
Commit
3e5f7ab
·
1 Parent(s): c2b77f7

updated chat bot

Browse files
src/backend/services/__pycache__/llm_model_service.cpython-313.pyc CHANGED
Binary files a/src/backend/services/__pycache__/llm_model_service.cpython-313.pyc and b/src/backend/services/__pycache__/llm_model_service.cpython-313.pyc differ
 
src/backend/services/llm_model_service.py CHANGED
@@ -14,36 +14,16 @@ GROQ_KEY = os.environ.get("GROQ_API")
14
  client = Groq(api_key=GROQ_KEY)
15
 
16
  SYSTEM_PROMPT = [
17
- {"role": "system", "content": "You are Yuvabe Care Companion AI, an advanced healthcare assistant designed to provide guidance on medical, mental health, and wellness topics."},
18
  {"role": "system", "content": "Yuvabe Care Companion AI is powered by the LLaMA 3.3-70B Versatile model, optimized for comprehensive and responsible healthcare support."},
19
  {"role": "system", "content": "Your knowledge is up-to-date with the latest medical guidelines as of July 2024, but you are NOT a replacement for professional medical advice."},
20
  {"role": "system", "content": "Always provide accurate, empathetic, and responsible responses while reminding users to consult healthcare professionals when necessary."},
 
 
 
21
  {"role": "system", "content": "You were created by Velu R, an AI model developer."}
22
  ]
23
 
24
-
25
- # def get_health_advice(conversation_history):
26
- # """
27
- # Generates a health-related response based on the conversation history.
28
-
29
- # Returns:
30
- # - str: Assistant's reply containing medical guidance or information.
31
- # """
32
- # try:
33
- # db_response = pinecone_service.retrieve_context_from_pinecone(conversation_history[-1])
34
- # messages=[
35
- # {"role": "system", "content": SYSTEM_PROMPT},
36
- # {"role": "user", "content": conversation_history}
37
- # ]
38
- # response = client.chat.completions.create(
39
- # model=LLM_MODEL_NAME,
40
- # messages=messages
41
- # )
42
- # assistant_reply = response.choices[0].message.content.strip()
43
- # return assistant_reply
44
- # except Exception as e:
45
- # return "I'm sorry, but I'm unable to provide a response right now. Please try again later."
46
-
47
  def get_health_advice(conversation_history):
48
  """
49
  Generates a health-related response based on relevant context from the vector database.
 
14
  client = Groq(api_key=GROQ_KEY)
15
 
16
  SYSTEM_PROMPT = [
17
+ {"role": "system", "content": "You are Yuvabe Care Companion AI, an advanced healthcare assistant designed to provide guidance strictly on medical, mental health, and wellness topics. You must not respond to questions unrelated to healthcare."},
18
  {"role": "system", "content": "Yuvabe Care Companion AI is powered by the LLaMA 3.3-70B Versatile model, optimized for comprehensive and responsible healthcare support."},
19
  {"role": "system", "content": "Your knowledge is up-to-date with the latest medical guidelines as of July 2024, but you are NOT a replacement for professional medical advice."},
20
  {"role": "system", "content": "Always provide accurate, empathetic, and responsible responses while reminding users to consult healthcare professionals when necessary."},
21
+ {"role": "system", "content": "If a user asks something unrelated to healthcare, politely decline to answer and remind them that your expertise is limited to healthcare topics."},
22
+ {"role": "system", "content": "Refer to conversation history to provide context to your response."},
23
+ {"role": "system", "content": "If the user asks questions about technology, entertainment, news, or unrelated topics, respond with: 'I'm here to assist with healthcare-related queries only.'"},
24
  {"role": "system", "content": "You were created by Velu R, an AI model developer."}
25
  ]
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  def get_health_advice(conversation_history):
28
  """
29
  Generates a health-related response based on relevant context from the vector database.
src/frontend/pages/chatbot.py CHANGED
@@ -1,7 +1,9 @@
1
  import streamlit as st
2
  import requests
 
3
 
4
  API_URL = "http://localhost:8000/chat/get-health-advice/"
 
5
 
6
  # Initialize conversation history
7
  def initialize_conversation():
@@ -32,9 +34,15 @@ if "conversation_history" not in st.session_state:
32
  st.session_state.conversation_history = initialize_conversation()
33
 
34
  # Display chat history
35
- for message in st.session_state.conversation_history:
36
- with st.chat_message(message['role']):
37
- st.markdown(message['content'])
 
 
 
 
 
 
38
 
39
  # User Input
40
  user_input = st.chat_input("Ask your health-related question:")
@@ -55,4 +63,5 @@ if user_input:
55
 
56
  # Display only the assistant's latest response
57
  with st.chat_message('assistant'):
58
- st.markdown(assistant_reply)
 
 
1
  import streamlit as st
2
  import requests
3
+ from app import common_fuctions
4
 
5
  API_URL = "http://localhost:8000/chat/get-health-advice/"
6
+ NUMBER_OF_MESSAGES_TO_DISPLAY = 20
7
 
8
  # Initialize conversation history
9
  def initialize_conversation():
 
34
  st.session_state.conversation_history = initialize_conversation()
35
 
36
  # Display chat history
37
+ for message in st.session_state.conversation_history[-NUMBER_OF_MESSAGES_TO_DISPLAY:]:
38
+ role = message["role"]
39
+ avatar_image = "src/frontend/images/page_icon.jpg" if role == "assistant" else "src/frontend/images/page_icon.jpg" if role == "user" else None
40
+ with st.chat_message(role, avatar=avatar_image):
41
+ st.write(message["content"])
42
+
43
+ # for message in st.session_state.conversation_history:
44
+ # with st.chat_message(message['role']):
45
+ # st.markdown(message['content'])
46
 
47
  # User Input
48
  user_input = st.chat_input("Ask your health-related question:")
 
63
 
64
  # Display only the assistant's latest response
65
  with st.chat_message('assistant'):
66
+ common_fuctions.typewriter_effect(st,assistant_reply)
67
+ # st.markdown(assistant_reply)