Spaces:
Running
Running
Added main file
Browse files
app.py
CHANGED
|
@@ -99,7 +99,7 @@ def compare_documents(file1, file2):
|
|
| 99 |
groq_response = response.choices[0].message.content
|
| 100 |
similar_terms = groq_response.split('\n')
|
| 101 |
else:
|
| 102 |
-
groq_response = "
|
| 103 |
similar_terms = ["Error retrieving important terms."]
|
| 104 |
|
| 105 |
comparison_summary = generate_comparison_summary(overall_similarity, similar_terms)
|
|
@@ -291,7 +291,7 @@ ANSWER:</s>[INST]
|
|
| 291 |
|
| 292 |
prompt = PromptTemplate(template=prompt_template, input_variables=['context', 'question', 'chat_history'])
|
| 293 |
|
| 294 |
-
TOGETHER_AI_API = "
|
| 295 |
|
| 296 |
llm = Together(
|
| 297 |
model="mistralai/Mistral-7B-Instruct-v0.2",
|
|
@@ -329,17 +329,16 @@ def chat_bot_interface(user_message, chat_history=[]):
|
|
| 329 |
|
| 330 |
with gr.Blocks() as demo:
|
| 331 |
with gr.Tabs():
|
| 332 |
-
with gr.Tab("
|
| 333 |
-
gr.Markdown("## PDF
|
| 334 |
with gr.Row():
|
| 335 |
with gr.Column():
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
compare_button = gr.Button("Compare")
|
| 339 |
with gr.Column():
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
|
| 344 |
with gr.Tab("Translator"):
|
| 345 |
gr.Markdown("## Document Translation using Groq")
|
|
@@ -357,16 +356,17 @@ with gr.Blocks() as demo:
|
|
| 357 |
download_link = gr.File(label="Download Translated PDF", interactive=False)
|
| 358 |
translate_button.click(process_pdf_and_translate, inputs=[pdf_input, language_input], outputs=[translated_output, download_link])
|
| 359 |
|
| 360 |
-
with gr.Tab("
|
| 361 |
-
gr.Markdown("## PDF
|
| 362 |
with gr.Row():
|
| 363 |
with gr.Column():
|
| 364 |
-
|
| 365 |
-
|
|
|
|
| 366 |
with gr.Column():
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
|
| 371 |
with gr.Tab("Law Chatbot"):
|
| 372 |
gr.Markdown("<h1 style='text-align: center;'>Legal Chatbot</h1>")
|
|
|
|
| 99 |
groq_response = response.choices[0].message.content
|
| 100 |
similar_terms = groq_response.split('\n')
|
| 101 |
else:
|
| 102 |
+
groq_response = "API key not found. Skipping further analysis."
|
| 103 |
similar_terms = ["Error retrieving important terms."]
|
| 104 |
|
| 105 |
comparison_summary = generate_comparison_summary(overall_similarity, similar_terms)
|
|
|
|
| 291 |
|
| 292 |
prompt = PromptTemplate(template=prompt_template, input_variables=['context', 'question', 'chat_history'])
|
| 293 |
|
| 294 |
+
TOGETHER_AI_API = os.getenv("T_API_KEY")
|
| 295 |
|
| 296 |
llm = Together(
|
| 297 |
model="mistralai/Mistral-7B-Instruct-v0.2",
|
|
|
|
| 329 |
|
| 330 |
with gr.Blocks() as demo:
|
| 331 |
with gr.Tabs():
|
| 332 |
+
with gr.Tab("Summarizer"):
|
| 333 |
+
gr.Markdown("## PDF Summarizer")
|
| 334 |
with gr.Row():
|
| 335 |
with gr.Column():
|
| 336 |
+
pdf_input_summary = gr.File(label="Upload PDF", file_types=[".pdf"])
|
| 337 |
+
summarize_button = gr.Button("Summarize")
|
|
|
|
| 338 |
with gr.Column():
|
| 339 |
+
summary_output = gr.Textbox(label="Summary", lines=10, interactive=False)
|
| 340 |
+
download_link_summary = gr.File(label="Download Summary as PDF", interactive=False)
|
| 341 |
+
summarize_button.click(process_pdf_and_summarize, inputs=[pdf_input_summary], outputs=[summary_output, download_link_summary])
|
| 342 |
|
| 343 |
with gr.Tab("Translator"):
|
| 344 |
gr.Markdown("## Document Translation using Groq")
|
|
|
|
| 356 |
download_link = gr.File(label="Download Translated PDF", interactive=False)
|
| 357 |
translate_button.click(process_pdf_and_translate, inputs=[pdf_input, language_input], outputs=[translated_output, download_link])
|
| 358 |
|
| 359 |
+
with gr.Tab("PDF Similarity Checker"):
|
| 360 |
+
gr.Markdown("## PDF Similarity Checker")
|
| 361 |
with gr.Row():
|
| 362 |
with gr.Column():
|
| 363 |
+
file1 = gr.File(label="Upload PDF 1")
|
| 364 |
+
file2 = gr.File(label="Upload PDF 2")
|
| 365 |
+
compare_button = gr.Button("Compare")
|
| 366 |
with gr.Column():
|
| 367 |
+
result = gr.Textbox(label="Results")
|
| 368 |
+
report = gr.File(label="Download Report")
|
| 369 |
+
compare_button.click(compare_documents, inputs=[file1, file2], outputs=[result, report])
|
| 370 |
|
| 371 |
with gr.Tab("Law Chatbot"):
|
| 372 |
gr.Markdown("<h1 style='text-align: center;'>Legal Chatbot</h1>")
|