Spaces:
Running
Running
L154 give user ability to run ai judge
Browse files
app.py
CHANGED
@@ -46,6 +46,10 @@ st.sidebar.success(
|
|
46 |
)
|
47 |
st.sidebar.warning("Select a website first!")
|
48 |
option = st.sidebar.selectbox("Which website do you want to ask?", ("YSA", "Larkin"))
|
|
|
|
|
|
|
|
|
49 |
special_threshold = st.sidebar.number_input(
|
50 |
"Insert a number", value=0.2, placeholder="Type a number..."
|
51 |
) # 0.3
|
@@ -147,16 +151,17 @@ if prompt := st.chat_input(initial_input):
|
|
147 |
final_ref = final_ref.reset_index()
|
148 |
|
149 |
# add ai judge as additional rating
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
160 |
|
161 |
engineered_prompt = f"""
|
162 |
Based on the context: {ref_from_db_search}
|
|
|
46 |
)
|
47 |
st.sidebar.warning("Select a website first!")
|
48 |
option = st.sidebar.selectbox("Which website do you want to ask?", ("YSA", "Larkin"))
|
49 |
+
st.sidebar.warning("Runnning AI Judge takes longer.")
|
50 |
+
run_ai_judge = st.sidebar.selectbox(
|
51 |
+
"Shall we run AI Judge to provide additional scores?", ("Yes", "No")
|
52 |
+
)
|
53 |
special_threshold = st.sidebar.number_input(
|
54 |
"Insert a number", value=0.2, placeholder="Type a number..."
|
55 |
) # 0.3
|
|
|
151 |
final_ref = final_ref.reset_index()
|
152 |
|
153 |
# add ai judge as additional rating
|
154 |
+
if run_ai_judge == "Yes":
|
155 |
+
independent_ai_judge_score = []
|
156 |
+
for i in range(final_ref.shape[0]):
|
157 |
+
this_content = final_ref["answers"][i]
|
158 |
+
if len(this_content) > 3:
|
159 |
+
this_score = calculate_sts_openai_score(question, this_content)
|
160 |
+
else:
|
161 |
+
this_score = 0
|
162 |
+
independent_ai_judge_score.append(this_score)
|
163 |
+
|
164 |
+
final_ref["ai_judge"] = independent_ai_judge_score
|
165 |
|
166 |
engineered_prompt = f"""
|
167 |
Based on the context: {ref_from_db_search}
|