Pijush2023
commited on
Commit
•
0d5a4ba
1
Parent(s):
d9ffaea
Update app.py
Browse files
app.py
CHANGED
@@ -155,6 +155,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
155 |
with gr.Row():
|
156 |
submit_button = gr.Button("Submit")
|
157 |
clear_button = gr.Button("Clear")
|
|
|
158 |
|
159 |
with gr.Row():
|
160 |
highlighted_user_prompt = gr.HTML()
|
@@ -187,7 +188,7 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
187 |
tree2 = gr.Plot()
|
188 |
tree2_tabs.append(tree2)
|
189 |
|
190 |
-
|
191 |
with gr.Row():
|
192 |
gr.Markdown("### Re-paraphrased Sentences") # Label for re-paraphrased sentences
|
193 |
|
@@ -205,9 +206,28 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
205 |
with gr.Row():
|
206 |
three_D_plot = gr.Plot()
|
207 |
|
208 |
-
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
clear_button.click(lambda: "", inputs=None, outputs=user_input)
|
211 |
clear_button.click(lambda: "", inputs=None, outputs=[highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + tree1_tabs + tree2_tabs + reparaphrased_sentences_tabs + [three_D_plot])
|
212 |
|
213 |
demo.launch(share=True)
|
|
|
|
155 |
with gr.Row():
|
156 |
submit_button = gr.Button("Submit")
|
157 |
clear_button = gr.Button("Clear")
|
158 |
+
generate_non_melting_point_button = gr.Button("Generate Non-Melting Point") # New button
|
159 |
|
160 |
with gr.Row():
|
161 |
highlighted_user_prompt = gr.HTML()
|
|
|
188 |
tree2 = gr.Plot()
|
189 |
tree2_tabs.append(tree2)
|
190 |
|
191 |
+
# Adding the "Re-paraphrased Sentences" section
|
192 |
with gr.Row():
|
193 |
gr.Markdown("### Re-paraphrased Sentences") # Label for re-paraphrased sentences
|
194 |
|
|
|
206 |
with gr.Row():
|
207 |
three_D_plot = gr.Plot()
|
208 |
|
209 |
+
# Logic for the new button
|
210 |
+
def generate_non_melting_points_only(prompt):
|
211 |
+
user_prompt = prompt
|
212 |
+
paraphrased_sentences = generate_paraphrase(user_prompt)
|
213 |
+
analyzed_paraphrased_sentences, selected_sentences, discarded_sentences = analyze_entailment(user_prompt, paraphrased_sentences, 0.7)
|
214 |
+
common_grams = find_common_subsequences(user_prompt, selected_sentences)
|
215 |
+
highlighted_user_prompt = highlight_common_words(common_grams, [user_prompt], "Non-melting Points in the User Prompt")
|
216 |
+
return highlighted_user_prompt
|
217 |
+
|
218 |
+
# Connect buttons to functions
|
219 |
+
submit_button.click(
|
220 |
+
model,
|
221 |
+
inputs=user_input,
|
222 |
+
outputs=[highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + tree1_tabs + tree2_tabs + reparaphrased_sentences_tabs + [three_D_plot]
|
223 |
+
)
|
224 |
+
generate_non_melting_point_button.click(
|
225 |
+
generate_non_melting_points_only,
|
226 |
+
inputs=user_input,
|
227 |
+
outputs=highlighted_user_prompt
|
228 |
+
)
|
229 |
clear_button.click(lambda: "", inputs=None, outputs=user_input)
|
230 |
clear_button.click(lambda: "", inputs=None, outputs=[highlighted_user_prompt, highlighted_accepted_sentences, highlighted_discarded_sentences] + tree1_tabs + tree2_tabs + reparaphrased_sentences_tabs + [three_D_plot])
|
231 |
|
232 |
demo.launch(share=True)
|
233 |
+
|