Update LLMInsights.py
Browse files- LLMInsights.py +10 -10
LLMInsights.py
CHANGED
@@ -179,11 +179,11 @@ def rag_response(response):
|
|
179 |
|
180 |
st.markdown('<h1 style="color:#100170;font-size:48px;text-align:center;">RAG Response</h1>', unsafe_allow_html=True)
|
181 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Question</h1>', unsafe_allow_html=True)
|
182 |
-
st.text_area(value=response["query"], height=30)
|
183 |
st.markdown('<h1 style="color:#100170;font-size:24px;">RAG Output</h1>', unsafe_allow_html=True)
|
184 |
-
st.text_area(value=response["result"])
|
185 |
# st.markdown('<h1 style="color:#100170;font-size:24px;">Augmented knowledge</h1>', unsafe_allow_html=True)
|
186 |
-
# st.text_area(value=response["source_documents"])
|
187 |
|
188 |
#st.button("Check Hallucination")
|
189 |
|
@@ -206,7 +206,7 @@ def hallu_eval(question: str, answer: str, context: str):
|
|
206 |
)
|
207 |
print("got hallu score")
|
208 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Hallucinated?</h1>', unsafe_allow_html=True)
|
209 |
-
st.text_area(value=hallucination_score, height=30)
|
210 |
#return {"hallucination_score": hallucination_score}
|
211 |
#time.sleep(10)
|
212 |
|
@@ -221,7 +221,7 @@ def scoring_eval(question: str, answer: str, context: str):
|
|
221 |
)
|
222 |
print("got score")
|
223 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Completion Score</h1>', unsafe_allow_html=True)
|
224 |
-
st.text_area(value=score, height=30)
|
225 |
#return {"hallucination_score": hallucination_score}
|
226 |
#time.sleep(10)
|
227 |
|
@@ -328,7 +328,7 @@ with tab1:
|
|
328 |
|
329 |
st.markdown('<h1 style="color:#100170;font-size:24px;">User Query</h1>', unsafe_allow_html=True)
|
330 |
|
331 |
-
question = st.text_input(label=
|
332 |
#st.markdown('<h2 style="color:#3a0aa6;font-size:24px;">Evaluation</h2>', unsafe_allow_html=True)
|
333 |
st.markdown("<h1 style='color:#100170;font-size:24px;'>Perform Evaluation</h1>", unsafe_allow_html=True)
|
334 |
evaluate = st.radio("", ["True", "False"])
|
@@ -396,15 +396,15 @@ with tab1:
|
|
396 |
else:
|
397 |
score = "Evaluation is Turned OFF"
|
398 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Confidence Score</h1>', unsafe_allow_html=True)
|
399 |
-
st.text_area(value=score, height=30)
|
400 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Hallucinated?</h1>', unsafe_allow_html=True)
|
401 |
-
st.text_area(value=hallucination_score, height=30)
|
402 |
st.markdown('<h1 style="color:#100170;font-size:24px;">context</h1>', unsafe_allow_html=True)
|
403 |
-
st.text_area(value=context)
|
404 |
metadata_list = [doc.metadata for doc in response["source_documents"]]
|
405 |
formatted_metadata_list = []
|
406 |
for i, metadata in enumerate(metadata_list, start=1):
|
407 |
-
formatted_metadata = f"<h2 style='color:#
|
408 |
source = metadata.get('source', '').replace('\n', '')
|
409 |
title = metadata.get('title', '').replace('\n', '')
|
410 |
description = metadata.get('description', '').replace('\n', '')
|
|
|
179 |
|
180 |
st.markdown('<h1 style="color:#100170;font-size:48px;text-align:center;">RAG Response</h1>', unsafe_allow_html=True)
|
181 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Question</h1>', unsafe_allow_html=True)
|
182 |
+
st.text_area(label=None, value=response["query"], height=30)
|
183 |
st.markdown('<h1 style="color:#100170;font-size:24px;">RAG Output</h1>', unsafe_allow_html=True)
|
184 |
+
st.text_area(label=None, value=response["result"])
|
185 |
# st.markdown('<h1 style="color:#100170;font-size:24px;">Augmented knowledge</h1>', unsafe_allow_html=True)
|
186 |
+
# st.text_area(label=None, value=response["source_documents"])
|
187 |
|
188 |
#st.button("Check Hallucination")
|
189 |
|
|
|
206 |
)
|
207 |
print("got hallu score")
|
208 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Hallucinated?</h1>', unsafe_allow_html=True)
|
209 |
+
st.text_area(label=None, value=hallucination_score, height=30)
|
210 |
#return {"hallucination_score": hallucination_score}
|
211 |
#time.sleep(10)
|
212 |
|
|
|
221 |
)
|
222 |
print("got score")
|
223 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Completion Score</h1>', unsafe_allow_html=True)
|
224 |
+
st.text_area(label=None, value=score, height=30)
|
225 |
#return {"hallucination_score": hallucination_score}
|
226 |
#time.sleep(10)
|
227 |
|
|
|
328 |
|
329 |
st.markdown('<h1 style="color:#100170;font-size:24px;">User Query</h1>', unsafe_allow_html=True)
|
330 |
|
331 |
+
question = st.text_input(label=None, value="", placeholder="Type in question",label_visibility="visible", disabled=False)
|
332 |
#st.markdown('<h2 style="color:#3a0aa6;font-size:24px;">Evaluation</h2>', unsafe_allow_html=True)
|
333 |
st.markdown("<h1 style='color:#100170;font-size:24px;'>Perform Evaluation</h1>", unsafe_allow_html=True)
|
334 |
evaluate = st.radio("", ["True", "False"])
|
|
|
396 |
else:
|
397 |
score = "Evaluation is Turned OFF"
|
398 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Confidence Score</h1>', unsafe_allow_html=True)
|
399 |
+
st.text_area(label=None, value=score, height=30)
|
400 |
st.markdown('<h1 style="color:#100170;font-size:24px;">Hallucinated?</h1>', unsafe_allow_html=True)
|
401 |
+
st.text_area(label=None, value=hallucination_score, height=30)
|
402 |
st.markdown('<h1 style="color:#100170;font-size:24px;">context</h1>', unsafe_allow_html=True)
|
403 |
+
st.text_area(label=None, value=context)
|
404 |
metadata_list = [doc.metadata for doc in response["source_documents"]]
|
405 |
formatted_metadata_list = []
|
406 |
for i, metadata in enumerate(metadata_list, start=1):
|
407 |
+
formatted_metadata = f"<h2 style='color:#3366ff; font-size:16px;'>Metadata {i}:</h2><br>"
|
408 |
source = metadata.get('source', '').replace('\n', '')
|
409 |
title = metadata.get('title', '').replace('\n', '')
|
410 |
description = metadata.get('description', '').replace('\n', '')
|