Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -178,14 +178,20 @@ def chat_between_bots(system_message1, system_message2, max_tokens, temperature,
|
|
178 |
|
179 |
return response1, response2, history1, history2, shared_history, f"{response1}\n\n{response2}", prosecutor_score_color, defense_score_color
|
180 |
|
|
|
|
|
|
|
|
|
181 |
# Gradio interface
|
182 |
with gr.Blocks(css=custom_css) as demo:
|
183 |
history1 = gr.State([])
|
184 |
history2 = gr.State([])
|
185 |
shared_history = gr.State([])
|
|
|
|
|
186 |
message = gr.Textbox(label="Case to Argue")
|
187 |
system_message1 = gr.State("You are an expert Prosecutor. Give your best arguments for the case on behalf of the prosecution.")
|
188 |
-
system_message2 = gr.State("You are an expert Defense Attorney. Give your best arguments for the case on behalf of the Defense.
|
189 |
max_tokens = gr.State(512) # Adjusted to balance response length
|
190 |
temperature = gr.State(0.6)
|
191 |
top_p = gr.State(0.95)
|
@@ -195,17 +201,21 @@ with gr.Blocks(css=custom_css) as demo:
|
|
195 |
prosecutor_response = gr.Textbox(label="Prosecutor's Response", interactive=True)
|
196 |
with gr.Column(scale=1):
|
197 |
prosecutor_score_color = gr.HTML()
|
198 |
-
|
199 |
with gr.Column(scale=4):
|
200 |
defense_response = gr.Textbox(label="Defense Attorney's Response", interactive=True)
|
201 |
with gr.Column(scale=1):
|
202 |
defense_score_color = gr.HTML()
|
203 |
|
204 |
shared_argument = gr.Textbox(label="Case Outcome", interactive=True)
|
|
|
|
|
205 |
|
206 |
submit_btn = gr.Button("Argue")
|
|
|
207 |
|
208 |
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, shared_argument, prosecutor_score_color, defense_score_color])
|
|
|
209 |
|
210 |
if __name__ == "__main__":
|
211 |
demo.launch()
|
|
|
178 |
|
179 |
return response1, response2, history1, history2, shared_history, f"{response1}\n\n{response2}", prosecutor_score_color, defense_score_color
|
180 |
|
181 |
+
# Function to handle PDF uploads and display them in a gallery
|
182 |
+
def update_pdf_gallery(pdf_files):
|
183 |
+
return pdf_files
|
184 |
+
|
185 |
# Gradio interface
|
186 |
with gr.Blocks(css=custom_css) as demo:
|
187 |
history1 = gr.State([])
|
188 |
history2 = gr.State([])
|
189 |
shared_history = gr.State([])
|
190 |
+
pdf_files = gr.State([])
|
191 |
+
|
192 |
message = gr.Textbox(label="Case to Argue")
|
193 |
system_message1 = gr.State("You are an expert Prosecutor. Give your best arguments for the case on behalf of the prosecution.")
|
194 |
+
system_message2 = gr.State("You are an expert Defense Attorney. Give your best arguments for the case on behalf of the Defense.")
|
195 |
max_tokens = gr.State(512) # Adjusted to balance response length
|
196 |
temperature = gr.State(0.6)
|
197 |
top_p = gr.State(0.95)
|
|
|
201 |
prosecutor_response = gr.Textbox(label="Prosecutor's Response", interactive=True)
|
202 |
with gr.Column(scale=1):
|
203 |
prosecutor_score_color = gr.HTML()
|
204 |
+
|
205 |
with gr.Column(scale=4):
|
206 |
defense_response = gr.Textbox(label="Defense Attorney's Response", interactive=True)
|
207 |
with gr.Column(scale=1):
|
208 |
defense_score_color = gr.HTML()
|
209 |
|
210 |
shared_argument = gr.Textbox(label="Case Outcome", interactive=True)
|
211 |
+
pdf_upload = gr.File(label="Upload Case Files (PDF)", file_types=[".pdf"], multiple=True)
|
212 |
+
pdf_gallery = gr.Gallery(label="PDF Gallery")
|
213 |
|
214 |
submit_btn = gr.Button("Argue")
|
215 |
+
pdf_upload_btn = gr.Button("Update PDF Gallery")
|
216 |
|
217 |
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, shared_argument, prosecutor_score_color, defense_score_color])
|
218 |
+
pdf_upload_btn.click(update_pdf_gallery, inputs=[pdf_upload], outputs=[pdf_gallery, pdf_files])
|
219 |
|
220 |
if __name__ == "__main__":
|
221 |
demo.launch()
|