[update] app.py
Browse files
app.py
CHANGED
|
@@ -460,7 +460,7 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 460 |
qwen_api_key, zhipuai_api_key, openrouter_api_key):
|
| 461 |
"""Start generation process"""
|
| 462 |
if pdf_file is None:
|
| 463 |
-
return "β Please upload a PDF file", gr.update(visible=False), "", "", gr.update(), gr.update()
|
| 464 |
|
| 465 |
# Validate API keys
|
| 466 |
validation_errors = validate_api_keys(
|
|
@@ -470,7 +470,7 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 470 |
|
| 471 |
if validation_errors:
|
| 472 |
error_msg = "β API Key Validation Failed:\n" + "\n".join(f"β’ {error}" for error in validation_errors)
|
| 473 |
-
return error_msg, gr.update(visible=False), "", "", gr.update(), gr.update()
|
| 474 |
|
| 475 |
state.reset()
|
| 476 |
|
|
@@ -489,7 +489,7 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 489 |
try:
|
| 490 |
matched = matching(template_requirement)
|
| 491 |
except Exception as e:
|
| 492 |
-
return f"β Template recommendation failed: {e}", gr.update(visible=False), "", "", gr.update(choices=[], value=None), gr.update(visible=False, value="")
|
| 493 |
|
| 494 |
html_finder_ = HtmlFinder()
|
| 495 |
with open('templates/template_link.json','r') as f:
|
|
@@ -510,14 +510,14 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 510 |
continue
|
| 511 |
|
| 512 |
if not previews:
|
| 513 |
-
return "β No previewable templates found", gr.update(visible=False), "", "", gr.update(choices=[], value=None), gr.update(visible=False, value="")
|
| 514 |
|
| 515 |
md_lines = ["### π Please select a template to preview before clicking **Start Generation**", ""]
|
| 516 |
for name, _, url in previews:
|
| 517 |
md_lines.append(f"- **{name}** β [{url}]({url})")
|
| 518 |
md = "\n".join(md_lines)
|
| 519 |
|
| 520 |
-
return "Recommended 3 templates, please select one to continue", gr.update(visible=False), "", "", gr.update(choices=[n for n, _, _ in previews], value=None), gr.update(visible=True, value=md)
|
| 521 |
|
| 522 |
template_dir = os.path.join(template_root, template_choice_value)
|
| 523 |
|
|
@@ -545,7 +545,7 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 545 |
)
|
| 546 |
|
| 547 |
if not args.template_dir:
|
| 548 |
-
return "β Please select a template", gr.update(visible=False), "", "", gr.update(), gr.update()
|
| 549 |
|
| 550 |
if not args.template_file:
|
| 551 |
html_finder_ = HtmlFinder()
|
|
@@ -627,14 +627,23 @@ def start_generation(pdf_file, model_name_t, model_name_v, template_root,
|
|
| 627 |
section_display_md, # Markdown format
|
| 628 |
section_display_json, # JSON format (hidden)
|
| 629 |
gr.update(),
|
| 630 |
-
gr.update(visible=False, value="")
|
|
|
|
| 631 |
)
|
| 632 |
|
| 633 |
except Exception as e:
|
| 634 |
import traceback
|
| 635 |
error_msg = f"β Generation failed: {str(e)}\n{traceback.format_exc()}"
|
| 636 |
-
return error_msg, gr.update(visible=False), "", "", gr.update(), gr.update()
|
| 637 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
def generate_section_initial():
|
| 639 |
"""Generate initial Section"""
|
| 640 |
import yaml
|
|
@@ -659,16 +668,6 @@ def generate_section_initial():
|
|
| 659 |
response = state.planner.planner_agent.step(prompt)
|
| 660 |
input_token, output_token = account_token(response)
|
| 661 |
generated_section = get_json_from_response(response.msgs[0].content)
|
| 662 |
-
|
| 663 |
-
def create_dynamic_page_dict(sections):
|
| 664 |
-
poster_dict = {
|
| 665 |
-
"title": "Title of the paper",
|
| 666 |
-
"authors": "Authors of the paper",
|
| 667 |
-
"affiliation": "Affiliation of the authors",
|
| 668 |
-
}
|
| 669 |
-
poster_dict.update(sections)
|
| 670 |
-
return poster_dict
|
| 671 |
-
|
| 672 |
generated_section = create_dynamic_page_dict(generated_section)
|
| 673 |
state.generated_section = generated_section
|
| 674 |
|
|
@@ -691,6 +690,7 @@ def submit_section_feedback(feedback_text):
|
|
| 691 |
"", # section_feedback_input clear
|
| 692 |
gr.update(visible=False), # feedback_section hide
|
| 693 |
fc_section_visible, # feedback_full_content show
|
|
|
|
| 694 |
fc_display_md, # full_content_display_md content
|
| 695 |
fc_display_json, # full_content_display_json content
|
| 696 |
fc_feedback_visible # full_content_feedback_input show
|
|
@@ -711,6 +711,7 @@ def submit_section_feedback(feedback_text):
|
|
| 711 |
state.total_output_tokens_t += output_token
|
| 712 |
|
| 713 |
generated_section = get_json_from_response(response.msgs[0].content)
|
|
|
|
| 714 |
state.generated_section = generated_section
|
| 715 |
|
| 716 |
generated_path = f'project_contents/{state.args.paper_name}_generated_section.json'
|
|
@@ -728,6 +729,7 @@ def submit_section_feedback(feedback_text):
|
|
| 728 |
"", # Clear input box
|
| 729 |
gr.update(visible=True), # feedback_section keep visible
|
| 730 |
gr.update(visible=False), # feedback_full_content keep hidden
|
|
|
|
| 731 |
"", # full_content_display_md content
|
| 732 |
"", # full_content_display_json content
|
| 733 |
gr.update(visible=False) # full_content_feedback_input keep hidden
|
|
@@ -1233,6 +1235,8 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1233 |
gr.Markdown("""
|
| 1234 |
**β οΈ Security Notice**: Your API keys are only stored in memory during the session and are never saved to disk.
|
| 1235 |
|
|
|
|
|
|
|
| 1236 |
**π How to get API keys:**
|
| 1237 |
- **OpenAI**: Get your API key from [OpenAI Platform](https://platform.openai.com/api-keys)
|
| 1238 |
- **Gemini**: Get your API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
|
|
@@ -1337,59 +1341,46 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1337 |
info="Select model for vision processing"
|
| 1338 |
)
|
| 1339 |
|
| 1340 |
-
|
| 1341 |
template_root = gr.Textbox(
|
| 1342 |
label="Template Root",
|
| 1343 |
value="templates",
|
| 1344 |
-
|
| 1345 |
)
|
| 1346 |
template_dir = gr.Textbox(
|
| 1347 |
label="Template Directory",
|
| 1348 |
value="",
|
| 1349 |
-
|
| 1350 |
)
|
| 1351 |
template_file = gr.Textbox(
|
| 1352 |
label="Template File",
|
| 1353 |
value="",
|
| 1354 |
-
|
| 1355 |
-
)
|
| 1356 |
-
template_choice = gr.Radio(
|
| 1357 |
-
label="Recommended Templates",
|
| 1358 |
-
choices=[],
|
| 1359 |
-
value=None,
|
| 1360 |
-
info="Select from recommended templates",
|
| 1361 |
-
visible=True
|
| 1362 |
)
|
| 1363 |
output_dir = gr.Textbox(
|
| 1364 |
label="Output Directory",
|
| 1365 |
value="generated_project_pages",
|
| 1366 |
-
|
| 1367 |
)
|
| 1368 |
style_preference = gr.Textbox(
|
| 1369 |
label="Style Preference JSON",
|
| 1370 |
value="",
|
| 1371 |
-
|
| 1372 |
)
|
| 1373 |
tmp_dir = gr.Textbox(
|
| 1374 |
label="Temporary Directory",
|
| 1375 |
value="tmp",
|
| 1376 |
-
info="Directory for temporary files"
|
| 1377 |
-
)
|
| 1378 |
-
|
| 1379 |
-
template_preview_links = gr.Markdown(
|
| 1380 |
-
label="Template Preview Links",
|
| 1381 |
-
value="",
|
| 1382 |
visible=False
|
| 1383 |
)
|
| 1384 |
|
| 1385 |
-
#
|
| 1386 |
resume = gr.Radio(
|
| 1387 |
label="Resume From Step",
|
| 1388 |
choices=['parse_pdf', 'generate_content','full_content_check', 'generate_html', 'html_check','modify_table','html_feedback'],
|
| 1389 |
value='parse_pdf',
|
| 1390 |
visible=False
|
| 1391 |
)
|
| 1392 |
-
|
| 1393 |
human_input = gr.Radio(
|
| 1394 |
label="Enable Human Feedback",
|
| 1395 |
choices=[0, 1],
|
|
@@ -1397,65 +1388,100 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1397 |
visible=False
|
| 1398 |
)
|
| 1399 |
|
| 1400 |
-
|
| 1401 |
-
|
| 1402 |
-
|
| 1403 |
-
|
| 1404 |
-
|
| 1405 |
-
choices=["light", "dark"],
|
| 1406 |
-
value="light",
|
| 1407 |
-
info="Background color theme"
|
| 1408 |
)
|
| 1409 |
|
| 1410 |
-
|
| 1411 |
-
label="
|
| 1412 |
-
|
| 1413 |
-
|
| 1414 |
-
|
| 1415 |
)
|
| 1416 |
|
| 1417 |
-
|
| 1418 |
-
|
| 1419 |
-
|
| 1420 |
-
value="yes",
|
| 1421 |
-
info="Include hero/header section"
|
| 1422 |
-
)
|
| 1423 |
|
| 1424 |
-
|
| 1425 |
-
|
| 1426 |
-
|
| 1427 |
-
|
| 1428 |
-
|
| 1429 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1430 |
|
| 1431 |
-
|
| 1432 |
-
|
| 1433 |
-
|
| 1434 |
-
|
| 1435 |
-
|
| 1436 |
-
)
|
| 1437 |
|
| 1438 |
-
|
| 1439 |
-
label="Image Layout",
|
| 1440 |
-
choices=["rotation", "parallelism"],
|
| 1441 |
-
value="parallelism",
|
| 1442 |
-
info="Image layout style"
|
| 1443 |
-
)
|
| 1444 |
|
| 1445 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1446 |
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
-
|
|
|
|
|
|
|
| 1452 |
)
|
| 1453 |
|
| 1454 |
-
|
| 1455 |
-
|
| 1456 |
-
|
| 1457 |
-
precision=0,
|
| 1458 |
-
info="Number of HTML validation checks"
|
| 1459 |
)
|
| 1460 |
|
| 1461 |
# Start Generation Button
|
|
@@ -1557,28 +1583,6 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1557 |
interactive=False
|
| 1558 |
)
|
| 1559 |
|
| 1560 |
-
gr.Markdown("""
|
| 1561 |
-
---
|
| 1562 |
-
### π‘ User Guide
|
| 1563 |
-
|
| 1564 |
-
1. **Upload PDF**: Select your research paper PDF file
|
| 1565 |
-
2. **Configure Parameters**: Adjust model, path, and style settings as needed
|
| 1566 |
-
3. **Start Generation**: Click the "Start Generation" button
|
| 1567 |
-
4. **Three-Stage Feedback**:
|
| 1568 |
-
- π **Section Feedback**: Review the generated page structure (Markdown preview + JSON data), provide feedback or enter 'yes' to continue
|
| 1569 |
-
- π **Full Content Feedback**: Review the generated complete content (Markdown preview + JSON data), provide feedback or enter 'yes' to continue
|
| 1570 |
-
- π **HTML Feedback**: View the generated webpage in a new tab, provide feedback or enter 'yes' to finalize
|
| 1571 |
-
5. **Download Results**: Download the complete project archive after completion
|
| 1572 |
-
|
| 1573 |
-
β οΈ **Tips**:
|
| 1574 |
-
- Each stage supports multiple rounds of feedback until you're satisfied
|
| 1575 |
-
- Section and Full Content stages offer **Markdown preview** and **JSON raw data** viewing options
|
| 1576 |
-
- Markdown preview is more visually appealing, JSON data shows complete structure
|
| 1577 |
-
- HTML stage requires clicking "Open Preview in New Tab" to view the full page in browser
|
| 1578 |
-
- Enter 'yes' to indicate satisfaction and proceed to the next stage
|
| 1579 |
-
- The final ZIP download includes the complete project folder with all resources
|
| 1580 |
-
""")
|
| 1581 |
-
|
| 1582 |
# Bind Events
|
| 1583 |
start_btn.click(
|
| 1584 |
fn=start_generation,
|
|
@@ -1598,7 +1602,7 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1598 |
section_display_json,
|
| 1599 |
template_choice,
|
| 1600 |
template_preview_links,
|
| 1601 |
-
|
| 1602 |
]
|
| 1603 |
)
|
| 1604 |
|
|
@@ -1613,6 +1617,7 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1613 |
feedback_section,
|
| 1614 |
feedback_full_content,
|
| 1615 |
full_content_display_md,
|
|
|
|
| 1616 |
full_content_display_json,
|
| 1617 |
full_content_feedback_input
|
| 1618 |
]
|
|
@@ -1646,13 +1651,10 @@ with gr.Blocks(title="Paper2ProjectPage Generator", theme=gr.themes.Soft(), css=
|
|
| 1646 |
html_file_output
|
| 1647 |
]
|
| 1648 |
)
|
| 1649 |
-
def dummy_open_preview(url):
|
| 1650 |
-
"""Dummy function to pass URL to JavaScript"""
|
| 1651 |
-
return None
|
| 1652 |
|
| 1653 |
# Open Preview Button - Use JavaScript to open in new tab
|
| 1654 |
open_preview_btn.click(
|
| 1655 |
-
fn=
|
| 1656 |
inputs=[preview_url_state],
|
| 1657 |
outputs=None,
|
| 1658 |
js="(url) => window.open(url, '_blank')"
|
|
@@ -1665,4 +1667,4 @@ if __name__ == "__main__":
|
|
| 1665 |
server_port=7860,
|
| 1666 |
share=False,
|
| 1667 |
show_error=True
|
| 1668 |
-
)
|
|
|
|
| 460 |
qwen_api_key, zhipuai_api_key, openrouter_api_key):
|
| 461 |
"""Start generation process"""
|
| 462 |
if pdf_file is None:
|
| 463 |
+
return "β Please upload a PDF file", gr.update(visible=False), "", "", gr.update(), gr.update(), ""
|
| 464 |
|
| 465 |
# Validate API keys
|
| 466 |
validation_errors = validate_api_keys(
|
|
|
|
| 470 |
|
| 471 |
if validation_errors:
|
| 472 |
error_msg = "β API Key Validation Failed:\n" + "\n".join(f"β’ {error}" for error in validation_errors)
|
| 473 |
+
return error_msg, gr.update(visible=False), "", "", gr.update(), gr.update(), ""
|
| 474 |
|
| 475 |
state.reset()
|
| 476 |
|
|
|
|
| 489 |
try:
|
| 490 |
matched = matching(template_requirement)
|
| 491 |
except Exception as e:
|
| 492 |
+
return f"β Template recommendation failed: {e}", gr.update(visible=False), "", "", gr.update(choices=[], value=None), gr.update(visible=False, value=""), ""
|
| 493 |
|
| 494 |
html_finder_ = HtmlFinder()
|
| 495 |
with open('templates/template_link.json','r') as f:
|
|
|
|
| 510 |
continue
|
| 511 |
|
| 512 |
if not previews:
|
| 513 |
+
return "β No previewable templates found", gr.update(visible=False), "", "", gr.update(choices=[], value=None), gr.update(visible=False, value=""), ""
|
| 514 |
|
| 515 |
md_lines = ["### π Please select a template to preview before clicking **Start Generation**", ""]
|
| 516 |
for name, _, url in previews:
|
| 517 |
md_lines.append(f"- **{name}** β [{url}]({url})")
|
| 518 |
md = "\n".join(md_lines)
|
| 519 |
|
| 520 |
+
return "Recommended 3 templates, please select one to continue", gr.update(visible=False), "", "", gr.update(choices=[n for n, _, _ in previews], value=None), gr.update(visible=True, value=md), ""
|
| 521 |
|
| 522 |
template_dir = os.path.join(template_root, template_choice_value)
|
| 523 |
|
|
|
|
| 545 |
)
|
| 546 |
|
| 547 |
if not args.template_dir:
|
| 548 |
+
return "β Please select a template", gr.update(visible=False), "", "", gr.update(), gr.update(), ""
|
| 549 |
|
| 550 |
if not args.template_file:
|
| 551 |
html_finder_ = HtmlFinder()
|
|
|
|
| 627 |
section_display_md, # Markdown format
|
| 628 |
section_display_json, # JSON format (hidden)
|
| 629 |
gr.update(),
|
| 630 |
+
gr.update(visible=False, value=""),
|
| 631 |
+
""
|
| 632 |
)
|
| 633 |
|
| 634 |
except Exception as e:
|
| 635 |
import traceback
|
| 636 |
error_msg = f"β Generation failed: {str(e)}\n{traceback.format_exc()}"
|
| 637 |
+
return error_msg, gr.update(visible=False), "", "", gr.update(), gr.update(), ""
|
| 638 |
|
| 639 |
+
def create_dynamic_page_dict(sections):
|
| 640 |
+
poster_dict = {
|
| 641 |
+
"title": "Title of the paper",
|
| 642 |
+
"authors": "Authors of the paper",
|
| 643 |
+
"affiliation": "Affiliation of the authors",
|
| 644 |
+
}
|
| 645 |
+
poster_dict.update(sections)
|
| 646 |
+
return poster_dict
|
| 647 |
def generate_section_initial():
|
| 648 |
"""Generate initial Section"""
|
| 649 |
import yaml
|
|
|
|
| 668 |
response = state.planner.planner_agent.step(prompt)
|
| 669 |
input_token, output_token = account_token(response)
|
| 670 |
generated_section = get_json_from_response(response.msgs[0].content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 671 |
generated_section = create_dynamic_page_dict(generated_section)
|
| 672 |
state.generated_section = generated_section
|
| 673 |
|
|
|
|
| 690 |
"", # section_feedback_input clear
|
| 691 |
gr.update(visible=False), # feedback_section hide
|
| 692 |
fc_section_visible, # feedback_full_content show
|
| 693 |
+
fc_display_visible, # full_content_display_md show
|
| 694 |
fc_display_md, # full_content_display_md content
|
| 695 |
fc_display_json, # full_content_display_json content
|
| 696 |
fc_feedback_visible # full_content_feedback_input show
|
|
|
|
| 711 |
state.total_output_tokens_t += output_token
|
| 712 |
|
| 713 |
generated_section = get_json_from_response(response.msgs[0].content)
|
| 714 |
+
generated_section = create_dynamic_page_dict(generated_section)
|
| 715 |
state.generated_section = generated_section
|
| 716 |
|
| 717 |
generated_path = f'project_contents/{state.args.paper_name}_generated_section.json'
|
|
|
|
| 729 |
"", # Clear input box
|
| 730 |
gr.update(visible=True), # feedback_section keep visible
|
| 731 |
gr.update(visible=False), # feedback_full_content keep hidden
|
| 732 |
+
gr.update(visible=False), # full_content_display_md keep hidden
|
| 733 |
"", # full_content_display_md content
|
| 734 |
"", # full_content_display_json content
|
| 735 |
gr.update(visible=False) # full_content_feedback_input keep hidden
|
|
|
|
| 1235 |
gr.Markdown("""
|
| 1236 |
**β οΈ Security Notice**: Your API keys are only stored in memory during the session and are never saved to disk.
|
| 1237 |
|
| 1238 |
+
**π‘ Note**: You only need to fill in ONE API key corresponding to the models you selected below.
|
| 1239 |
+
|
| 1240 |
**π How to get API keys:**
|
| 1241 |
- **OpenAI**: Get your API key from [OpenAI Platform](https://platform.openai.com/api-keys)
|
| 1242 |
- **Gemini**: Get your API key from [Google AI Studio](https://aistudio.google.com/app/apikey)
|
|
|
|
| 1341 |
info="Select model for vision processing"
|
| 1342 |
)
|
| 1343 |
|
| 1344 |
+
# Hidden backend configuration fields
|
| 1345 |
template_root = gr.Textbox(
|
| 1346 |
label="Template Root",
|
| 1347 |
value="templates",
|
| 1348 |
+
visible=False
|
| 1349 |
)
|
| 1350 |
template_dir = gr.Textbox(
|
| 1351 |
label="Template Directory",
|
| 1352 |
value="",
|
| 1353 |
+
visible=False
|
| 1354 |
)
|
| 1355 |
template_file = gr.Textbox(
|
| 1356 |
label="Template File",
|
| 1357 |
value="",
|
| 1358 |
+
visible=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1359 |
)
|
| 1360 |
output_dir = gr.Textbox(
|
| 1361 |
label="Output Directory",
|
| 1362 |
value="generated_project_pages",
|
| 1363 |
+
visible=False
|
| 1364 |
)
|
| 1365 |
style_preference = gr.Textbox(
|
| 1366 |
label="Style Preference JSON",
|
| 1367 |
value="",
|
| 1368 |
+
visible=False
|
| 1369 |
)
|
| 1370 |
tmp_dir = gr.Textbox(
|
| 1371 |
label="Temporary Directory",
|
| 1372 |
value="tmp",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1373 |
visible=False
|
| 1374 |
)
|
| 1375 |
|
| 1376 |
+
# Hidden parameters with default values
|
| 1377 |
resume = gr.Radio(
|
| 1378 |
label="Resume From Step",
|
| 1379 |
choices=['parse_pdf', 'generate_content','full_content_check', 'generate_html', 'html_check','modify_table','html_feedback'],
|
| 1380 |
value='parse_pdf',
|
| 1381 |
visible=False
|
| 1382 |
)
|
| 1383 |
+
|
| 1384 |
human_input = gr.Radio(
|
| 1385 |
label="Enable Human Feedback",
|
| 1386 |
choices=[0, 1],
|
|
|
|
| 1388 |
visible=False
|
| 1389 |
)
|
| 1390 |
|
| 1391 |
+
full_content_check_times = gr.Number(
|
| 1392 |
+
label="Full Content Check Times",
|
| 1393 |
+
value=1,
|
| 1394 |
+
precision=0,
|
| 1395 |
+
visible=False
|
|
|
|
|
|
|
|
|
|
| 1396 |
)
|
| 1397 |
|
| 1398 |
+
html_check_times = gr.Number(
|
| 1399 |
+
label="HTML Check Times",
|
| 1400 |
+
value=1,
|
| 1401 |
+
precision=0,
|
| 1402 |
+
visible=False
|
| 1403 |
)
|
| 1404 |
|
| 1405 |
+
with gr.Column(scale=1):
|
| 1406 |
+
gr.Markdown("""
|
| 1407 |
+
### π‘ User Guide
|
|
|
|
|
|
|
|
|
|
| 1408 |
|
| 1409 |
+
1. **Upload PDF**: Select your research paper PDF file
|
| 1410 |
+
2. **Configure API Key**: Fill in ONE API key for your selected models
|
| 1411 |
+
3. **Select Models**: Choose text and vision models from dropdowns
|
| 1412 |
+
4. **Configure Style**: Adjust style preferences below
|
| 1413 |
+
5. **Start Generation**: Click the "Start Generation" button
|
| 1414 |
+
6. **Three-Stage Feedback**:
|
| 1415 |
+
- π **Section Feedback**: Review the generated page structure (Markdown preview + JSON data)
|
| 1416 |
+
- π **Full Content Feedback**: Review the generated complete content (Markdown preview + JSON data)
|
| 1417 |
+
- π **HTML Feedback**: View the generated webpage in a new tab
|
| 1418 |
+
7. **Download Results**: Download the complete project archive after completion
|
| 1419 |
|
| 1420 |
+
β οΈ **Tips**:
|
| 1421 |
+
- Each stage supports multiple rounds of feedback until you're satisfied
|
| 1422 |
+
- Enter 'yes' to proceed to the next stage
|
| 1423 |
+
- The final ZIP download includes the complete project folder with all resources
|
| 1424 |
+
""")
|
|
|
|
| 1425 |
|
| 1426 |
+
gr.Markdown("### π¨ Style Configuration")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1427 |
|
| 1428 |
+
with gr.Row():
|
| 1429 |
+
with gr.Column():
|
| 1430 |
+
background_color = gr.Radio(
|
| 1431 |
+
label="Background Color",
|
| 1432 |
+
choices=["light", "dark"],
|
| 1433 |
+
value="light",
|
| 1434 |
+
info="Background color theme"
|
| 1435 |
+
)
|
| 1436 |
+
|
| 1437 |
+
has_navigation = gr.Radio(
|
| 1438 |
+
label="Has Navigation",
|
| 1439 |
+
choices=["yes", "no"],
|
| 1440 |
+
value="yes",
|
| 1441 |
+
info="Include navigation bar"
|
| 1442 |
+
)
|
| 1443 |
+
|
| 1444 |
+
has_hero_section = gr.Radio(
|
| 1445 |
+
label="Has Hero Section",
|
| 1446 |
+
choices=["yes", "no"],
|
| 1447 |
+
value="yes",
|
| 1448 |
+
info="Include hero/header section"
|
| 1449 |
+
)
|
| 1450 |
+
|
| 1451 |
+
with gr.Column():
|
| 1452 |
+
title_color = gr.Radio(
|
| 1453 |
+
label="Title Color",
|
| 1454 |
+
choices=["pure", "colorful"],
|
| 1455 |
+
value="pure",
|
| 1456 |
+
info="Title color style"
|
| 1457 |
+
)
|
| 1458 |
+
|
| 1459 |
+
page_density = gr.Radio(
|
| 1460 |
+
label="Page Density",
|
| 1461 |
+
choices=["spacious", "compact"],
|
| 1462 |
+
value="spacious",
|
| 1463 |
+
info="Page spacing density"
|
| 1464 |
+
)
|
| 1465 |
+
|
| 1466 |
+
image_layout = gr.Radio(
|
| 1467 |
+
label="Image Layout",
|
| 1468 |
+
choices=["rotation", "parallelism"],
|
| 1469 |
+
value="parallelism",
|
| 1470 |
+
info="Image layout style"
|
| 1471 |
+
)
|
| 1472 |
|
| 1473 |
+
gr.Markdown("### π Template Selection")
|
| 1474 |
+
|
| 1475 |
+
template_choice = gr.Radio(
|
| 1476 |
+
label="Recommended Templates",
|
| 1477 |
+
choices=[],
|
| 1478 |
+
value=None,
|
| 1479 |
+
info="Select from recommended templates"
|
| 1480 |
)
|
| 1481 |
|
| 1482 |
+
template_preview_links = gr.Markdown(
|
| 1483 |
+
value="",
|
| 1484 |
+
visible=False
|
|
|
|
|
|
|
| 1485 |
)
|
| 1486 |
|
| 1487 |
# Start Generation Button
|
|
|
|
| 1583 |
interactive=False
|
| 1584 |
)
|
| 1585 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1586 |
# Bind Events
|
| 1587 |
start_btn.click(
|
| 1588 |
fn=start_generation,
|
|
|
|
| 1602 |
section_display_json,
|
| 1603 |
template_choice,
|
| 1604 |
template_preview_links,
|
| 1605 |
+
section_feedback_input
|
| 1606 |
]
|
| 1607 |
)
|
| 1608 |
|
|
|
|
| 1617 |
feedback_section,
|
| 1618 |
feedback_full_content,
|
| 1619 |
full_content_display_md,
|
| 1620 |
+
full_content_display_md,
|
| 1621 |
full_content_display_json,
|
| 1622 |
full_content_feedback_input
|
| 1623 |
]
|
|
|
|
| 1651 |
html_file_output
|
| 1652 |
]
|
| 1653 |
)
|
|
|
|
|
|
|
|
|
|
| 1654 |
|
| 1655 |
# Open Preview Button - Use JavaScript to open in new tab
|
| 1656 |
open_preview_btn.click(
|
| 1657 |
+
fn=None,
|
| 1658 |
inputs=[preview_url_state],
|
| 1659 |
outputs=None,
|
| 1660 |
js="(url) => window.open(url, '_blank')"
|
|
|
|
| 1667 |
server_port=7860,
|
| 1668 |
share=False,
|
| 1669 |
show_error=True
|
| 1670 |
+
)
|