Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,12 @@
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import requests
|
| 3 |
from bs4 import BeautifulSoup
|
| 4 |
import gradio as gr
|
|
@@ -80,7 +88,7 @@ def chat_between_bots(system_message1, system_message2, max_tokens, temperature,
|
|
| 80 |
outcome = generate_case_outcome(prosecutor_response, defense_response)
|
| 81 |
winner = determine_winner(outcome)
|
| 82 |
|
| 83 |
-
return prosecutor_response, defense_response, history1, history2, shared_history,
|
| 84 |
|
| 85 |
def extract_text_from_pdf(pdf_file):
|
| 86 |
text = ""
|
|
@@ -146,7 +154,7 @@ def print_like_dislike(x: gr.LikeData):
|
|
| 146 |
print(x.index, x.value, x.liked)
|
| 147 |
|
| 148 |
def reset_conversation():
|
| 149 |
-
return [], [], "", ""
|
| 150 |
|
| 151 |
def save_conversation(history1, history2, shared_history):
|
| 152 |
return history1, history2, shared_history
|
|
@@ -268,7 +276,6 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 268 |
with gr.Column(scale=1):
|
| 269 |
defense_score_color = gr.HTML()
|
| 270 |
|
| 271 |
-
shared_argument = gr.Textbox(label="Case Outcome", interactive=True, elem_classes=["scroll-box"])
|
| 272 |
winner = gr.Textbox(label="Winner", interactive=False, elem_classes=["scroll-box"])
|
| 273 |
|
| 274 |
with gr.Row():
|
|
@@ -276,8 +283,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 276 |
clear_btn = gr.Button("Clear and Reset")
|
| 277 |
save_btn = gr.Button("Save Conversation")
|
| 278 |
|
| 279 |
-
submit_btn.click(chat_between_bots, inputs=[system_message1, system_message2, max_tokens, temperature, top_p, history1, history2, shared_history, message], outputs=[prosecutor_response, defense_response, history1, history2,
|
| 280 |
-
clear_btn.click(reset_conversation, outputs=[history1, history2, shared_history, prosecutor_response, defense_response,
|
| 281 |
save_btn.click(save_conversation, inputs=[history1, history2, shared_history], outputs=[history1, history2, shared_history])
|
| 282 |
|
| 283 |
# Inner HTML for asking about the case outcome
|
|
|
|
| 1 |
import os
|
| 2 |
+
os.system('pip install transformers')
|
| 3 |
+
os.system('pip install datasets')
|
| 4 |
+
os.system('pip install gradio')
|
| 5 |
+
os.system('pip install minijinja')
|
| 6 |
+
os.system('pip install PyMuPDF')
|
| 7 |
+
os.system('pip install beautifulsoup4')
|
| 8 |
+
os.system('pip install requests')
|
| 9 |
+
|
| 10 |
import requests
|
| 11 |
from bs4 import BeautifulSoup
|
| 12 |
import gradio as gr
|
|
|
|
| 88 |
outcome = generate_case_outcome(prosecutor_response, defense_response)
|
| 89 |
winner = determine_winner(outcome)
|
| 90 |
|
| 91 |
+
return prosecutor_response, defense_response, history1, history2, shared_history, winner
|
| 92 |
|
| 93 |
def extract_text_from_pdf(pdf_file):
|
| 94 |
text = ""
|
|
|
|
| 154 |
print(x.index, x.value, x.liked)
|
| 155 |
|
| 156 |
def reset_conversation():
|
| 157 |
+
return [], [], "", ""
|
| 158 |
|
| 159 |
def save_conversation(history1, history2, shared_history):
|
| 160 |
return history1, history2, shared_history
|
|
|
|
| 276 |
with gr.Column(scale=1):
|
| 277 |
defense_score_color = gr.HTML()
|
| 278 |
|
|
|
|
| 279 |
winner = gr.Textbox(label="Winner", interactive=False, elem_classes=["scroll-box"])
|
| 280 |
|
| 281 |
with gr.Row():
|
|
|
|
| 283 |
clear_btn = gr.Button("Clear and Reset")
|
| 284 |
save_btn = gr.Button("Save Conversation")
|
| 285 |
|
| 286 |
+
submit_btn.click(chat_between_bots, inputs=[system_message1, system_message2, max_tokens, temperature, top_p, history1, history2, shared_history, message], outputs=[prosecutor_response, defense_response, history1, history2, shared_history, winner])
|
| 287 |
+
clear_btn.click(reset_conversation, outputs=[history1, history2, shared_history, prosecutor_response, defense_response, winner])
|
| 288 |
save_btn.click(save_conversation, inputs=[history1, history2, shared_history], outputs=[history1, history2, shared_history])
|
| 289 |
|
| 290 |
# Inner HTML for asking about the case outcome
|