Update app.py
Browse files
app.py
CHANGED
@@ -9,29 +9,28 @@ import requests
|
|
9 |
from pydantic import BaseModel, Field
|
10 |
from typing import Optional
|
11 |
|
12 |
-
placeHolderPersona1 = """##
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
#
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
Do not give a diagnosis """
|
22 |
-
|
23 |
-
placeHolderPersona2 = """## Mission
|
24 |
-
To analyse a clinical triaging discussion between a patient and AI doctor interactions with a focus on Immunology symptoms, medical history, and test results to deduce the most probable Immunology diagnosis.
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
1. Review the patient's presenting symptoms and consider their relevance to immunopathology.
|
29 |
-
2. Cross-reference the gathered information with my knowledge base of immunology to identify patterns or indicators of specific immune disorders.
|
30 |
-
3. Formulate a diagnosis from the potential conditions.
|
31 |
-
4. Determine the most likely diagnosis and assign a confidence score from 1-100, with 100 being absolute certainty.
|
32 |
-
|
33 |
-
# Limitations
|
34 |
-
While I am specialized in immunology, I understand that not all cases will fall neatly within my domain. In instances where the clinical notes point to a condition outside of my expertise, I will provide the best possible diagnosis with the acknowledgment that my confidence score will reflect the limitations of my specialization in those cases"""
|
35 |
|
36 |
|
37 |
class ChatRequestClient(BaseModel):
|
@@ -73,33 +72,31 @@ def format_elapsed_time(time):
|
|
73 |
|
74 |
# Title of the application
|
75 |
# st.image('agentBuilderLogo.png')
|
76 |
-
st.title('
|
77 |
|
78 |
# Sidebar for inputting personas
|
79 |
st.sidebar.image('cognizant_logo.jpg')
|
80 |
-
st.sidebar.header("
|
81 |
# st.sidebar.subheader("Welcome Message")
|
82 |
# welcomeMessage = st.sidebar.text_area("Define Intake Persona", value=welcomeMessage, height=300)
|
83 |
-
st.sidebar.subheader("
|
84 |
-
numberOfQuestions = st.sidebar.slider("Number of Questions", min_value=0, max_value=10, step=1, value=5, key='persona1_questions')
|
85 |
-
persona1SystemMessage = st.sidebar.text_area("
|
86 |
-
|
87 |
-
st.write("This AI persona will converse with the patient to gather their symptoms. With each round of chat, the object of the AI is to ask more specific follow up questions as it narrows down to the specific diagnosis. However this AI should never give a diagnosis")
|
88 |
-
st.image("agentPersona1.png")
|
89 |
llm1 = st.sidebar.selectbox("Model Selection", ['GPT-4', 'GPT3.5'], key='persona1_size')
|
90 |
temp1 = st.sidebar.slider("Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.6, key='persona1_temp')
|
91 |
tokens1 = st.sidebar.slider("Tokens", min_value=0, max_value=4000, step=100, value=500, key='persona1_tokens')
|
92 |
|
93 |
-
# Persona 2
|
94 |
-
st.sidebar.subheader("Recommendation and Next Best Action AI")
|
95 |
-
persona2SystemMessage = st.sidebar.text_area("Define Recommendation Persona", value=placeHolderPersona2, height=300)
|
96 |
-
with st.sidebar.expander("See explanation"):
|
97 |
-
|
98 |
-
|
99 |
-
llm2 = st.sidebar.selectbox("Model Selection", ['GPT-4', 'GPT3.5'], key='persona2_size')
|
100 |
-
temp2 = st.sidebar.slider("Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.5, key='persona2_temp')
|
101 |
-
tokens2 = st.sidebar.slider("Tokens", min_value=0, max_value=4000, step=100, value=500, key='persona2_tokens')
|
102 |
-
userMessage2 = st.sidebar.text_area("Define User Message", value="This is the conversation todate, ", height=150)
|
103 |
st.sidebar.caption(f"Session ID: {genuuid()}")
|
104 |
|
105 |
|
@@ -132,17 +129,17 @@ else:
|
|
132 |
data = ChatRequestClient(
|
133 |
user_id=user_id, # Ensure user_id is passed correctly
|
134 |
user_input=user_input,
|
135 |
-
numberOfQuestions=
|
136 |
welcomeMessage="",
|
137 |
llm1=llm1,
|
138 |
tokens1=tokens1,
|
139 |
temperature1=temp1,
|
140 |
persona1SystemMessage=persona1SystemMessage,
|
141 |
-
persona2SystemMessage=
|
142 |
-
userMessage2=
|
143 |
-
llm2=
|
144 |
-
tokens2=
|
145 |
-
temperature2=
|
146 |
)
|
147 |
|
148 |
# Call the API
|
@@ -159,7 +156,7 @@ else:
|
|
159 |
st.markdown(agent_message)
|
160 |
|
161 |
# Display additional metadata
|
162 |
-
st.
|
163 |
-
st.
|
164 |
|
165 |
|
|
|
9 |
from pydantic import BaseModel, Field
|
10 |
from typing import Optional
|
11 |
|
12 |
+
placeHolderPersona1 = """##Mission
|
13 |
+
Please use the Conversation Summary and the Follow Up Question to create a highly targeted query for a semantic search engine. The query must represent the follow up question in the context of the conversation to date. Use the conversation summary to guide your thinking.
|
14 |
+
You will be given the converstaion to date in the user prompt
|
15 |
+
|
16 |
+
##Rules
|
17 |
+
Ensure the query is concise
|
18 |
+
Ensure the query has keywords from the Conversation Summary embedding within it such as the technical details from the summary
|
19 |
+
If the Conversation Summary mentions a product like a 'loadcell' or 'hoist' or specific version of lift or moving walkway like 'Skyrise' or 'Gen2' then please use this in the query.
|
20 |
+
Do not respond with anything other than the query for the Semantic Search Engine."""
|
21 |
+
|
22 |
+
# placeHolderPersona2 = """## Mission
|
23 |
+
# To analyse a clinical triaging discussion between a patient and AI doctor interactions with a focus on Immunology symptoms, medical history, and test results to deduce the most probable Immunology diagnosis.
|
24 |
|
25 |
+
# ## Diagnostic Process
|
26 |
+
# Upon receipt of the clinical notes, I will follow a systematic approach to arrive at a diagnosis:
|
27 |
+
# 1. Review the patient's presenting symptoms and consider their relevance to immunopathology.
|
28 |
+
# 2. Cross-reference the gathered information with my knowledge base of immunology to identify patterns or indicators of specific immune disorders.
|
29 |
+
# 3. Formulate a diagnosis from the potential conditions.
|
30 |
+
# 4. Determine the most likely diagnosis and assign a confidence score from 1-100, with 100 being absolute certainty.
|
|
|
|
|
|
|
|
|
31 |
|
32 |
+
# # Limitations
|
33 |
+
# While I am specialized in immunology, I understand that not all cases will fall neatly within my domain. In instances where the clinical notes point to a condition outside of my expertise, I will provide the best possible diagnosis with the acknowledgment that my confidence score will reflect the limitations of my specialization in those cases"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
class ChatRequestClient(BaseModel):
|
|
|
72 |
|
73 |
# Title of the application
|
74 |
# st.image('agentBuilderLogo.png')
|
75 |
+
st.title('RAG Query Designer')
|
76 |
|
77 |
# Sidebar for inputting personas
|
78 |
st.sidebar.image('cognizant_logo.jpg')
|
79 |
+
st.sidebar.header("Query Designer")
|
80 |
# st.sidebar.subheader("Welcome Message")
|
81 |
# welcomeMessage = st.sidebar.text_area("Define Intake Persona", value=welcomeMessage, height=300)
|
82 |
+
st.sidebar.subheader("Query Designer Config")
|
83 |
+
# numberOfQuestions = st.sidebar.slider("Number of Questions", min_value=0, max_value=10, step=1, value=5, key='persona1_questions')
|
84 |
+
persona1SystemMessage = st.sidebar.text_area("Query Designer System Message", value=placeHolderPersona1, height=300)
|
85 |
+
|
|
|
|
|
86 |
llm1 = st.sidebar.selectbox("Model Selection", ['GPT-4', 'GPT3.5'], key='persona1_size')
|
87 |
temp1 = st.sidebar.slider("Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.6, key='persona1_temp')
|
88 |
tokens1 = st.sidebar.slider("Tokens", min_value=0, max_value=4000, step=100, value=500, key='persona1_tokens')
|
89 |
|
90 |
+
# # Persona 2
|
91 |
+
# st.sidebar.subheader("Recommendation and Next Best Action AI")
|
92 |
+
# persona2SystemMessage = st.sidebar.text_area("Define Recommendation Persona", value=placeHolderPersona2, height=300)
|
93 |
+
# with st.sidebar.expander("See explanation"):
|
94 |
+
# st.write("This AI persona uses the output of the symptom intake AI as its input. This AI’s job is to augment a health professional by assisting with a diagnosis and possible next best action. The teams will need to determine if this should be a tool used directly by the patient, as an assistant to the health professional or a hybrid of the two. ")
|
95 |
+
# st.image("agentPersona2.png")
|
96 |
+
# llm2 = st.sidebar.selectbox("Model Selection", ['GPT-4', 'GPT3.5'], key='persona2_size')
|
97 |
+
# temp2 = st.sidebar.slider("Temperature", min_value=0.0, max_value=1.0, step=0.1, value=0.5, key='persona2_temp')
|
98 |
+
# tokens2 = st.sidebar.slider("Tokens", min_value=0, max_value=4000, step=100, value=500, key='persona2_tokens')
|
99 |
+
# userMessage2 = st.sidebar.text_area("Define User Message", value="This is the conversation todate, ", height=150)
|
100 |
st.sidebar.caption(f"Session ID: {genuuid()}")
|
101 |
|
102 |
|
|
|
129 |
data = ChatRequestClient(
|
130 |
user_id=user_id, # Ensure user_id is passed correctly
|
131 |
user_input=user_input,
|
132 |
+
numberOfQuestions=1000,
|
133 |
welcomeMessage="",
|
134 |
llm1=llm1,
|
135 |
tokens1=tokens1,
|
136 |
temperature1=temp1,
|
137 |
persona1SystemMessage=persona1SystemMessage,
|
138 |
+
persona2SystemMessage="",
|
139 |
+
userMessage2="",
|
140 |
+
llm2="GPT3.5",
|
141 |
+
tokens2=1000,
|
142 |
+
temperature2=0.2
|
143 |
)
|
144 |
|
145 |
# Call the API
|
|
|
156 |
st.markdown(agent_message)
|
157 |
|
158 |
# Display additional metadata
|
159 |
+
st.caption(f"##### Time taken: {format_elapsed_time(elapsed_time)} seconds")
|
160 |
+
st.caption(f"##### Question Count: {count} of {numberOfQuestions}")
|
161 |
|
162 |
|