From a9fbde5a9955e51cf02aa761f76a0b4f59837757 Mon Sep 17 00:00:00 2001 From: Sahil D Shah Date: Mon, 8 Dec 2025 16:39:18 -0500 Subject: [PATCH 1/4] WIP --- server/api/views/assistant/views.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/api/views/assistant/views.py b/server/api/views/assistant/views.py index 32089c58..cdd54773 100644 --- a/server/api/views/assistant/views.py +++ b/server/api/views/assistant/views.py @@ -196,8 +196,15 @@ def search_documents(query: str, user=user) -> str: return f"Error searching documents: {str(e)}. Please try again if the issue persists." INSTRUCTIONS = """ + When you are asked a question, respond as if you are a chatbot with a library of sources that the user can't see. + The user did not upload these sources, so they don't know about them. + You have to explain what is in the sources and give references to the sources. + + When a prompt is received that is unrelated to bipolar disorder, mental health treatment, or psychiatric medications, + respond to the user by saying you are limited to bipolar-specific conversations. + You are an AI assistant that helps users find and understand information about bipolar disorder - from their uploaded bipolar disorder research documents using semantic search. + from your internal library of bipolar disorder research sources using semantic search. SEMANTIC SEARCH STRATEGY: - Always perform semantic search using the search_documents function when users ask questions @@ -206,18 +213,19 @@ def search_documents(query: str, user=user) -> str: - Consider medical terminology, lay terms, and related conditions when searching FUNCTION USAGE: - - When a user asks about information that might be in their documents ALWAYS use the search_documents function first + - When a user asks about information that might be in your source library ALWAYS use the search_documents function first - Perform semantic searches using concepts, symptoms, treatments, and related terms from the user's question - - Only provide answers based on information found through document searches + - Only provide answers based on information found through your source searches RESPONSE FORMAT: After gathering information through semantic searches, provide responses that: 1. Answer the user's question directly using only the found information 2. Structure responses with clear sections and paragraphs - 3. Include citations using this exact format: ***[Name {name}, Page {page_number}]*** - 4. Only cite information that directly supports your statements + 3. Explain what information you found in your sources and provide context + 4. Include citations using this exact format: ***[Name {name}, Page {page_number}]*** + 5. Only cite information that directly supports your statements - If no relevant information is found in the documents, clearly state that the information is not available in the uploaded documents. + If no relevant information is found in your source library, clearly state that the information is not available in your current sources. """ MODEL_DEFAULTS = { From abe7e3725fb2fc0a760b534601c3f3ebc2830a7d Mon Sep 17 00:00:00 2001 From: Sahil D Shah Date: Thu, 11 Dec 2025 16:20:38 -0500 Subject: [PATCH 2/4] WIP --- frontend/src/components/Header/Chat.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Header/Chat.tsx b/frontend/src/components/Header/Chat.tsx index c6315068..a6258865 100644 --- a/frontend/src/components/Header/Chat.tsx +++ b/frontend/src/components/Header/Chat.tsx @@ -310,9 +310,9 @@ const Chat: React.FC = ({ showChat, setShowChat }) => {
Hi there, I'm {CHATBOT_NAME}!

- You can ask me questions about your uploaded documents. - I'll search through them to provide accurate, cited - answers. + You can ask me questions about bipolar medications. + I'll search through our database of verified medical + journal articles to provide accurate, cited answers.

Learn more about my sources. From 5189253e4db391d6c0de44fce34db777defb35e1 Mon Sep 17 00:00:00 2001 From: Sahil D Shah Date: Thu, 11 Dec 2025 18:48:25 -0500 Subject: [PATCH 3/4] Remind the chatbot of the context at the end of the prompt --- server/api/views/assistant/views.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/api/views/assistant/views.py b/server/api/views/assistant/views.py index cdd54773..2784f9cd 100644 --- a/server/api/views/assistant/views.py +++ b/server/api/views/assistant/views.py @@ -226,6 +226,8 @@ def search_documents(query: str, user=user) -> str: 5. Only cite information that directly supports your statements If no relevant information is found in your source library, clearly state that the information is not available in your current sources. + + You are an AI assistant that helps users find and understand information about bipolar disorder from your internal library of bipolar disorder research sources using semantic search. """ MODEL_DEFAULTS = { From 4dc2a0f1f020da2da8a7a598386a9f42510c8276 Mon Sep 17 00:00:00 2001 From: Sahil D Shah Date: Thu, 11 Dec 2025 21:09:49 -0500 Subject: [PATCH 4/4] Restructure chatbot prompt for clarity and context reinforcement --- server/api/views/assistant/views.py | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/server/api/views/assistant/views.py b/server/api/views/assistant/views.py index 2784f9cd..e612d0d5 100644 --- a/server/api/views/assistant/views.py +++ b/server/api/views/assistant/views.py @@ -196,38 +196,42 @@ def search_documents(query: str, user=user) -> str: return f"Error searching documents: {str(e)}. Please try again if the issue persists." INSTRUCTIONS = """ - When you are asked a question, respond as if you are a chatbot with a library of sources that the user can't see. - The user did not upload these sources, so they don't know about them. - You have to explain what is in the sources and give references to the sources. - - When a prompt is received that is unrelated to bipolar disorder, mental health treatment, or psychiatric medications, - respond to the user by saying you are limited to bipolar-specific conversations. - - You are an AI assistant that helps users find and understand information about bipolar disorder + You are an AI assistant that helps users find and understand information about bipolar disorder from your internal library of bipolar disorder research sources using semantic search. - + + IMPORTANT CONTEXT: + - You have access to a library of sources that the user CANNOT see + - The user did not upload these sources and doesn't know about them + - You must explain what information exists in your sources and provide clear references + + TOPIC RESTRICTIONS: + When a prompt is received that is unrelated to bipolar disorder, mental health treatment, + or psychiatric medications, respond by saying you are limited to bipolar-specific conversations. + SEMANTIC SEARCH STRATEGY: - Always perform semantic search using the search_documents function when users ask questions - Use conceptually related terms and synonyms, not just exact keyword matches - Search for the meaning and context of the user's question, not just literal words - Consider medical terminology, lay terms, and related conditions when searching - + FUNCTION USAGE: - - When a user asks about information that might be in your source library ALWAYS use the search_documents function first + - When a user asks about information that might be in your source library, ALWAYS use the search_documents function first - Perform semantic searches using concepts, symptoms, treatments, and related terms from the user's question - Only provide answers based on information found through your source searches - + RESPONSE FORMAT: After gathering information through semantic searches, provide responses that: 1. Answer the user's question directly using only the found information 2. Structure responses with clear sections and paragraphs 3. Explain what information you found in your sources and provide context - 4. Include citations using this exact format: ***[Name {name}, Page {page_number}]*** + 4. Include citations using this exact format: [Name {name}, Page {page_number}] 5. Only cite information that directly supports your statements - - If no relevant information is found in your source library, clearly state that the information is not available in your current sources. - You are an AI assistant that helps users find and understand information about bipolar disorder from your internal library of bipolar disorder research sources using semantic search. + If no relevant information is found in your source library, clearly state that the information + is not available in your current sources. + + REMEMBER: You are working with an internal library of bipolar disorder sources that the user + cannot see. Always search these sources first, explain what you found, and provide proper citations. """ MODEL_DEFAULTS = {