YoniFriedman commited on
Commit
6883d82
·
verified ·
1 Parent(s): 52b83a1

adding instructions to shorten responses

Browse files
Files changed (1) hide show
  1. app.py +29 -31
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- os.environ["OPENAI_API_KEY"] = "sk-proj-SeS1zovo9pAJ7Smv3rZ3T3BlbkFJFN5hs2s9AsGmv1b7OiV1"
3
 
4
  from llama_index.llms.openai import OpenAI
5
  from llama_index.core.schema import MetadataMode
@@ -214,35 +214,31 @@ def nishauri(user_params: str, conversation_history: list[str]):
214
 
215
  # If user consented, add user parameters, otherwise proceed with out
216
  if consent == "YES":
217
- background = ("The person who asked the question is a person living with HIV."
218
- f" The person is {gender} and age is {age}. "
219
- f" The person's next clinical check in is scheduled for {next_appt_date}. This has no bearing on when viral loads are taken. "
220
- f" The person is on the following regimen for HIV {regimen}. "
221
- f" The person's most recent viral load result was {vl_result} and it was taken on {vl_date}. "
222
- " They are asking questions about HIV. Do not talk about anything that is not related to HIV. "
223
- " Recognize that they already have HIV and do not suggest that they have to get tested"
224
- " for HIV or take post-exposure prophylaxis, as that is not relevant, though their partners perhaps should."
225
- " Do not suggest anything that is not relevant to someone who already has HIV."
226
- " Do not mention in the response that the person is living with HIV."
227
- " The following information about viral loads is authoritative for any question about viral loads:"
228
- " Under 50 copies/ml is low detectable level,"
229
- " 50 - 199 copies/ml is low level viremia, 200 - 999 is high level viremia, and "
230
- " 1000 and above is suspected treatment failure."
231
- " A high viral load or non-suppressed viral load is any viral load above 200 copies/ml."
232
- " A suppressed viral load is one below 200 copies / ml.")
233
  else:
234
- background = ("The person who asked the question is a person living with HIV."
235
- " They are asking questions about HIV. Do not talk about anything that is not related to HIV. "
236
- " Recognize that they already have HIV and do not suggest that they have to get tested"
237
- " for HIV or take post-exposure prophylaxis, as that is not relevant, though their partners perhaps should."
238
- " Do not suggest anything that is not relevant to someone who already has HIV."
239
- " Do not mention in the response that the person is living with HIV."
240
- " The following information about viral loads is authoritative for any question about viral loads:"
241
- " Under 50 copies/ml is low detectable level,"
242
- " 50 - 199 copies/ml is low level viremia, 200 - 999 is high level viremia, and "
243
- " 1000 and above is suspected treatment failure."
244
- " A high viral load or non-suppressed viral load is any viral load above 200 copies/ml."
245
- " A suppressed viral load is one below 200 copies / ml.")
246
 
247
  # Combine into final prompt - user background, conversation history, new question, retrieved sources
248
  question_final = (
@@ -253,8 +249,10 @@ def nishauri(user_params: str, conversation_history: list[str]):
253
  " Keep answers brief and limited to the question that was asked."
254
  " If they share a greeting, just greet them in return and ask if they have a question."
255
  " Do not change the subject or address anything the user didn't directly ask about."
256
- " If they respond with an acknowledgement, simply thank them ask if there is anything else that you can help with."
257
- " Keep the response to under 50 words and use simple language. The user may not know technical terms."
 
 
258
  )
259
 
260
  # Generate response
 
1
  import os
2
+ os.environ["OPENAI_API_KEY"]
3
 
4
  from llama_index.llms.openai import OpenAI
5
  from llama_index.core.schema import MetadataMode
 
214
 
215
  # If user consented, add user parameters, otherwise proceed with out
216
  if consent == "YES":
217
+ background = ("The person who asked the question is a person living with HIV."
218
+ f" The person is {gender} and age is {age}. "
219
+ f" The person's next clinical check in is scheduled for {next_appt_date}. This has no bearing on when viral loads are taken. "
220
+ f" The person is on the following regimen for HIV {regimen}. "
221
+ f" The person's most recent viral load result was {vl_result} and it was taken on {vl_date}. "
222
+ " They are asking questions about HIV. Do not talk about anything that is not related to HIV. "
223
+ " Recognize that they already have HIV and do not suggest that they have to get tested"
224
+ " for HIV or take post-exposure prophylaxis, as that is not relevant, though their partners perhaps should."
225
+ " Do not suggest anything that is not relevant to someone who already has HIV."
226
+ " Do not mention in the response that the person is living with HIV."
227
+ " The following information about viral loads is authoritative for any question about viral loads:"
228
+ " A high viral load or non-suppressed viral load is any viral load above 200 copies/ml."
229
+ " A viral load above 1000 copies/ml suggests treatment failure."
230
+ " A suppressed viral load is one below 200 copies / ml.")
 
 
231
  else:
232
+ background = ("The person who asked the question is a person living with HIV."
233
+ " They are asking questions about HIV. Do not talk about anything that is not related to HIV. "
234
+ " Recognize that they already have HIV and do not suggest that they have to get tested"
235
+ " for HIV or take post-exposure prophylaxis, as that is not relevant, though their partners perhaps should."
236
+ " Do not suggest anything that is not relevant to someone who already has HIV."
237
+ " Do not mention in the response that the person is living with HIV."
238
+ " The following information about viral loads is authoritative for any question about viral loads:"
239
+ " A high viral load or non-suppressed viral load is any viral load above 200 copies/ml."
240
+ " A viral load above 1000 copies/ml suggests treatment failure."
241
+ " A suppressed viral load is one below 200 copies / ml.")
 
 
242
 
243
  # Combine into final prompt - user background, conversation history, new question, retrieved sources
244
  question_final = (
 
249
  " Keep answers brief and limited to the question that was asked."
250
  " If they share a greeting, just greet them in return and ask if they have a question."
251
  " Do not change the subject or address anything the user didn't directly ask about."
252
+ " If they respond with an acknowledgement, simply thank them."
253
+ " Do not discuss anything other than HIV. If they ask a question that is not about HIV, respond that"
254
+ " you are only able to discuss HIV."
255
+ " Keep the response to under 50 words and use simple language. The person asking the question does not know technical terms."
256
  )
257
 
258
  # Generate response