frankai98 commited on
Commit
1d9c203
Β·
verified Β·
1 Parent(s): 0a40d95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -34
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
- #try:
111
- # Stage 1: Score candidate documents using the provided query.
112
- status_text.markdown("**πŸ” Scoring candidate documents...**")
113
- progress_bar.progress(0)
114
-
115
- scored_docs = []
116
- for doc in candidate_docs:
117
- combined_text = f"Query: {query_input} Document: {doc}"
118
- result = score_pipe(combined_text)[0]
119
- scored_docs.append((doc, result["score"]))
120
-
121
- progress_bar.progress(50)
122
-
123
- # Stage 2: Generate Report using Gemma, including query and scored results.
124
- status_text.markdown("**πŸ“ Generating report with Gemma...**")
125
- prompt = f"""
126
- Generate a detailed report based on the following analysis.
127
- Query:
128
- "{query_input}"
129
- Candidate Reviews with their scores:
130
- {scored_docs}
131
- Please provide a concise summary report explaining the insights derived from these scores.
132
- """
133
- report = gemma_pipe(prompt, max_length=200)
134
- progress_bar.progress(100)
135
- status_text.success("**βœ… Generation complete!**")
136
- html("<script>localStorage.setItem('freezeTimer', 'true');</script>", height=0)
137
- st.session_state.timer_frozen = True
138
- st.write("**Scored Candidate Reviews:**", scored_docs)
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'])