-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstreamlit_app.py
34 lines (26 loc) · 858 Bytes
/
streamlit_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
import utils
import pandas as pd
from time import time
import re
# Streamlit app layout
st.title('Anti-Hallucination Chatbot')
# Text input
user_input = st.text_input("Enter your text:")
if user_input:
prompt = user_input
output, sampled_passages = utils.get_output_and_samples(prompt)
# LLM score
start = time()
self_similarity_score = utils.llm_evaluate(output,sampled_passages)
try:
self_similarity_score = float(self_similarity_score)
except:
self_similarity_score = re.findall(r'\d+', self_similarity_score)
end = time()
# Display the output
st.write("**LLM output:**")
if float(self_similarity_score) > 0.5:
st.write(output)
else:
st.write("I'm sorry, but I don't have the specific information required to answer your question accurately. ")