Skip to content

Commit 0278a4e

Browse files
committed
Merge branch 'develop' into 380-track-chatbot-costs
2 parents 6a84359 + c027b8e commit 0278a4e

File tree

11 files changed

+50
-49
lines changed

11 files changed

+50
-49
lines changed

config/env/dev.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
DEBUG=True
22
SECRET_KEY=foo
3-
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
3+
44
SQL_ENGINE=django.db.backends.postgresql
55
SQL_DATABASE=balancer_dev
66
SQL_USER=balancer
77
SQL_PASSWORD=balancer
88
SQL_HOST=db
99
SQL_PORT=5432
10-
DATABASE=postgres
10+
1111
LOGIN_REDIRECT_URL=
1212
OPENAI_API_KEY=
1313
ANTHROPIC_API_KEY=

config/env/prod.env.example

Lines changed: 0 additions & 16 deletions
This file was deleted.

deploy/manifests/balancer/base/secret.template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ metadata:
1313
namespace: balancer
1414
type: Opaque
1515
stringData:
16-
DATABASE: postgres
1716
DEBUG: '1'
1817
LOGIN_REDIRECT_URL: ''
1918
OPENAI_API_KEY: openapi_key_here

docker-compose.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ services:
1919
networks:
2020
app_net:
2121
ipv4_address: 192.168.0.2
22-
pgadmin:
23-
container_name: pgadmin4
24-
image: dpage/pgadmin4
25-
environment:
26-
PGADMIN_DEFAULT_EMAIL: [email protected]
27-
PGADMIN_DEFAULT_PASSWORD: balancer
28-
ports:
29-
- "5050:80"
30-
networks:
31-
app_net:
32-
ipv4_address: 192.168.0.4
22+
# pgadmin:
23+
# container_name: pgadmin4
24+
# image: dpage/pgadmin4
25+
# environment:
26+
# PGADMIN_DEFAULT_EMAIL: [email protected]
27+
# PGADMIN_DEFAULT_PASSWORD: balancer
28+
# ports:
29+
# - "5050:80"
30+
# networks:
31+
# app_net:
32+
# ipv4_address: 192.168.0.4
3333
backend:
3434
image: balancer-backend
3535
build: ./server

frontend/.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_BASE_URL=https://balancer.live.k8s.phl.io/

frontend/src/components/Header/Chat.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ const Chat: React.FC<ChatDropDownProps> = ({ showChat, setShowChat }) => {
310310
<div className="chat_bubble chat_bubble_header">
311311
<h5>Hi there, I'm {CHATBOT_NAME}!</h5>
312312
<p>
313-
You can ask me questions about your uploaded documents.
314-
I'll search through them to provide accurate, cited
315-
answers.
313+
You can ask me questions about bipolar medications.
314+
I'll search through our database of verified medical
315+
journal articles to provide accurate, cited answers.
316316
</p>
317317
<Link to="/data-sources" className="chat_link">
318318
Learn more about my sources.

frontend/src/services/actions/auth.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const checkAuthenticated = () => async (dispatch: AppDispatch) => {
7676

7777
const body = JSON.stringify({ token: localStorage.getItem("access") });
7878
const baseUrl = import.meta.env.VITE_API_BASE_URL;
79+
console.log(baseUrl);
7980
const url = `${baseUrl}/auth/jwt/verify/`;
8081
try {
8182
const res = await axios.post(url, body, config);
@@ -113,6 +114,7 @@ export const load_user = (): ThunkType => async (dispatch: AppDispatch) => {
113114
},
114115
};
115116
const baseUrl = import.meta.env.VITE_API_BASE_URL;
117+
console.log(baseUrl);
116118
const url = `${baseUrl}/auth/users/me/`;
117119
try {
118120
const res = await axios.get(url, config);
@@ -144,6 +146,7 @@ export const login =
144146

145147
const body = JSON.stringify({ email, password });
146148
const baseUrl = import.meta.env.VITE_API_BASE_URL;
149+
console.log(baseUrl);
147150
const url = `${baseUrl}/auth/jwt/create/`;
148151
try {
149152
const res = await axios.post(url, body, config);
@@ -170,8 +173,8 @@ export const login =
170173

171174
export const logout = () => async (dispatch: AppDispatch) => {
172175
// Clear chat conversation data on logout for security
173-
sessionStorage.removeItem('currentConversation');
174-
176+
sessionStorage.removeItem("currentConversation");
177+
175178
dispatch({
176179
type: LOGOUT,
177180
});

server/api/views/assistant/views.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,28 +196,42 @@ def search_documents(query: str, user=user) -> str:
196196
return f"Error searching documents: {str(e)}. Please try again if the issue persists."
197197

198198
INSTRUCTIONS = """
199-
You are an AI assistant that helps users find and understand information about bipolar disorder
200-
from their uploaded bipolar disorder research documents using semantic search.
201-
199+
You are an AI assistant that helps users find and understand information about bipolar disorder
200+
from your internal library of bipolar disorder research sources using semantic search.
201+
202+
IMPORTANT CONTEXT:
203+
- You have access to a library of sources that the user CANNOT see
204+
- The user did not upload these sources and doesn't know about them
205+
- You must explain what information exists in your sources and provide clear references
206+
207+
TOPIC RESTRICTIONS:
208+
When a prompt is received that is unrelated to bipolar disorder, mental health treatment,
209+
or psychiatric medications, respond by saying you are limited to bipolar-specific conversations.
210+
202211
SEMANTIC SEARCH STRATEGY:
203212
- Always perform semantic search using the search_documents function when users ask questions
204213
- Use conceptually related terms and synonyms, not just exact keyword matches
205214
- Search for the meaning and context of the user's question, not just literal words
206215
- Consider medical terminology, lay terms, and related conditions when searching
207-
216+
208217
FUNCTION USAGE:
209-
- When a user asks about information that might be in their documents ALWAYS use the search_documents function first
218+
- When a user asks about information that might be in your source library, ALWAYS use the search_documents function first
210219
- Perform semantic searches using concepts, symptoms, treatments, and related terms from the user's question
211-
- Only provide answers based on information found through document searches
212-
220+
- Only provide answers based on information found through your source searches
221+
213222
RESPONSE FORMAT:
214223
After gathering information through semantic searches, provide responses that:
215224
1. Answer the user's question directly using only the found information
216225
2. Structure responses with clear sections and paragraphs
217-
3. Include citations using this exact format: ***[Name {name}, Page {page_number}]***
218-
4. Only cite information that directly supports your statements
219-
220-
If no relevant information is found in the documents, clearly state that the information is not available in the uploaded documents.
226+
3. Explain what information you found in your sources and provide context
227+
4. Include citations using this exact format: [Name {name}, Page {page_number}]
228+
5. Only cite information that directly supports your statements
229+
230+
If no relevant information is found in your source library, clearly state that the information
231+
is not available in your current sources.
232+
233+
REMEMBER: You are working with an internal library of bipolar disorder sources that the user
234+
cannot see. Always search these sources first, explain what you found, and provide proper citations.
221235
"""
222236

223237
MODEL_DEFAULTS = {

server/balancer_backend/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
# Fetching the value from the environment and splitting to list if necessary.
3131
# Fallback to '*' if the environment variable is not set.
32-
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "*").split()
32+
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "*").split()
3333

3434
# If the environment variable contains '*', the split method would create a list with an empty string.
3535
# So you need to check for this case and adjust accordingly.

server/entrypoint.prod.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
if [ "$DATABASE" = "postgres" ]
3+
if [ "$SQL_ENGINE" = "django.db.backends.postgresql" ]
44
then
55
echo "Waiting for postgres..."
66

0 commit comments

Comments
 (0)