Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -107,37 +107,32 @@ else:
|
|
107 |
html(timer(), height=50)
|
108 |
status_text = st.empty()
|
109 |
progress_bar = st.progress(0)
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
st.write("**Generated Report:**", report[0]['generated_text'])
|
140 |
-
# except Exception as e:
|
141 |
-
#html("<script>document.getElementById('timer').remove();</script>")
|
142 |
-
s#tatus_text.error(f"**β Error:** {str(e)}")
|
143 |
-
#progress_bar.empty()
|
|
|
107 |
html(timer(), height=50)
|
108 |
status_text = st.empty()
|
109 |
progress_bar = st.progress(0)
|
110 |
+
|
111 |
+
# Stage 1: Score candidate documents (all reviews) without including the query.
|
112 |
+
status_text.markdown("**π Scoring candidate documents...**")
|
113 |
+
progress_bar.progress(0)
|
114 |
+
|
115 |
+
# Assuming score_pipe can take a list of texts directly:
|
116 |
+
scored_results = score_pipe(candidate_docs)
|
117 |
+
# Pair each review with its score assuming the output order matches the input order.
|
118 |
+
scored_docs = list(zip(candidate_docs, [result["score"] for result in scored_results]))
|
119 |
+
|
120 |
+
progress_bar.progress(50)
|
121 |
+
|
122 |
+
# Stage 2: Generate Report using Gemma, include the query and scored results.
|
123 |
+
status_text.markdown("**π Generating report with Gemma...**")
|
124 |
+
prompt = f"""
|
125 |
+
Generate a detailed report based on the following analysis.
|
126 |
+
Query:
|
127 |
+
"{query_input}"
|
128 |
+
Candidate Reviews with their scores:
|
129 |
+
{scored_docs}
|
130 |
+
Please provide a concise summary report explaining the insights derived from these scores.
|
131 |
+
"""
|
132 |
+
report = gemma_pipe(prompt, max_length=200)
|
133 |
+
progress_bar.progress(100)
|
134 |
+
status_text.success("**β
Generation complete!**")
|
135 |
+
html("<script>localStorage.setItem('freezeTimer', 'true');</script>", height=0)
|
136 |
+
st.session_state.timer_frozen = True
|
137 |
+
st.write("**Scored Candidate Reviews:**", scored_docs)
|
138 |
+
st.write("**Generated Report:**", report[0]['generated_text'])
|
|
|
|
|
|
|
|
|
|