Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -479,40 +479,53 @@ def create_conversation_chain(vector_store, docs, mode, language, detail_level,
|
|
| 479 |
chain = LLMChain(llm=llm_gemini, prompt=general_qa_prompt.partial(language=language))
|
| 480 |
return chain
|
| 481 |
|
| 482 |
-
# ر
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
)
|
| 496 |
-
query = gr.Textbox(lines=3, placeholder="Enter your question or request here...", label="Question or Request")
|
| 497 |
-
section = gr.Dropdown(["Entire Document", "Introduction", "Methodology", "Results", "Discussion", "References"], label="Target Section", value="Entire Document")
|
| 498 |
-
language_dropdown = gr.Dropdown(["English", "Farsi"], label="Response Language", value="English", interactive=True)
|
| 499 |
-
detail = gr.Dropdown(["Brief", "Detailed"], label="Detail Level", value="Detailed")
|
| 500 |
-
submit = gr.Button("Submit")
|
| 501 |
-
with gr.Column():
|
| 502 |
-
output = gr.Textbox(label="Processing Result", lines=10, placeholder="Results will be displayed here...")
|
| 503 |
-
|
| 504 |
-
# بهروزرسانی رابط کاربری بر اساس زبان
|
| 505 |
-
language_dropdown.change(
|
| 506 |
-
fn=update_interface,
|
| 507 |
-
inputs=language_dropdown,
|
| 508 |
-
outputs=[title, description, pdf_input, mode, query, section, language_dropdown, detail, submit, output]
|
| 509 |
-
)
|
| 510 |
-
|
| 511 |
-
submit.click(
|
| 512 |
-
fn=academic_chatbot,
|
| 513 |
-
inputs=[pdf_input, mode, query, language_dropdown, detail, section],
|
| 514 |
-
outputs=output
|
| 515 |
-
)
|
| 516 |
|
| 517 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
iface.launch()
|
|
|
|
| 479 |
chain = LLMChain(llm=llm_gemini, prompt=general_qa_prompt.partial(language=language))
|
| 480 |
return chain
|
| 481 |
|
| 482 |
+
# تعریف CSS بهصورت متغیر
|
| 483 |
+
css = """
|
| 484 |
+
body {background-color: #f0f4f8; font-family: 'Arial', sans-serif; color: #2c3e50; transition: all 0.3s ease;}
|
| 485 |
+
.gr-button {background-color: #4CAF50; color: white; border: none; padding: 12px 25px; border-radius: 5px; margin-right: 15px; width: auto; display: inline-block; transition: all 0.3s ease;}
|
| 486 |
+
.gr-button:hover {background-color: #45a049;}
|
| 487 |
+
.gr-textbox, .gr-dropdown, .gr-radio, .gr-file {background-color: #ffffff; border: 1px solid #ddd; border-radius: 5px; padding: 12px; margin-right: 15px; width: 95%; box-sizing: border-box; font-size: 16px; color: #2c3e50; transition: all 0.3s ease;}
|
| 488 |
+
.gr-row {display: flex; justify-content: space-between; margin-bottom: 15px;}
|
| 489 |
+
.gr-column {padding: 15px;}
|
| 490 |
+
h1, h2, h3 {color: #2c3e50; text-align: left; margin-bottom: 20px; font-size: 24px; transition: all 0.3s ease;}
|
| 491 |
+
.markdown {color: #2c3e50; margin-bottom: 15px; font-size: 16px; transition: all 0.3s ease;}
|
| 492 |
+
/* نمایش بهتر کلمات انگلیسی */
|
| 493 |
+
.english {display: inline; font-family: 'Arial', sans-serif; background: #e0e0e0; padding: 2px 4px; border-radius: 3px; box-shadow: 0 1px 2px rgba(0,0,0,0.1);}
|
| 494 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
|
| 496 |
if __name__ == "__main__":
|
| 497 |
+
with gr.Blocks(css=css, title="Professional Thesis Analyzer with Gemini") as iface:
|
| 498 |
+
language = gr.State(value="English") # حالت پیشفرض انگلیسی
|
| 499 |
+
|
| 500 |
+
with gr.Row():
|
| 501 |
+
with gr.Column():
|
| 502 |
+
title = gr.Markdown("# Professional Thesis Analyzer with Gemini")
|
| 503 |
+
description = gr.Markdown("Upload your <span class='english'>PDF</span> file and use the analysis, summary, plagiarism check, or quality evaluation features.")
|
| 504 |
+
pdf_input = gr.File(file_types=['.pdf'], label="Upload <span class='english'>PDF</span> File", file_count="multiple")
|
| 505 |
+
mode = gr.Radio(
|
| 506 |
+
["Academic Analysis (RAG)", "Auto Summary", "Plagiarism Check", "Quality Evaluation", "Standard Response"],
|
| 507 |
+
label="Processing Mode",
|
| 508 |
+
value="Academic Analysis (RAG)"
|
| 509 |
+
)
|
| 510 |
+
query = gr.Textbox(lines=3, placeholder="Enter your question or request here...", label="Question or Request")
|
| 511 |
+
section = gr.Dropdown(["Entire Document", "Introduction", "Methodology", "Results", "Discussion", "References"], label="Target Section", value="Entire Document")
|
| 512 |
+
language_dropdown = gr.Dropdown(["English", "Farsi"], label="Response Language", value="English", interactive=True)
|
| 513 |
+
detail = gr.Dropdown(["Brief", "Detailed"], label="Detail Level", value="Detailed")
|
| 514 |
+
submit = gr.Button("Submit")
|
| 515 |
+
with gr.Column():
|
| 516 |
+
output = gr.Textbox(label="Processing Result", lines=10, placeholder="Results will be displayed here...")
|
| 517 |
+
|
| 518 |
+
# بهروزرسانی رابط کاربری بر اساس زبان
|
| 519 |
+
language_dropdown.change(
|
| 520 |
+
fn=update_interface,
|
| 521 |
+
inputs=language_dropdown,
|
| 522 |
+
outputs=[title, description, pdf_input, mode, query, section, language_dropdown, detail, submit, output]
|
| 523 |
+
)
|
| 524 |
+
|
| 525 |
+
submit.click(
|
| 526 |
+
fn=academic_chatbot,
|
| 527 |
+
inputs=[pdf_input, mode, query, language_dropdown, detail, section],
|
| 528 |
+
outputs=output
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
iface.launch()
|