Update app.py
Browse files
app.py
CHANGED
|
@@ -478,4 +478,112 @@ Perfect for mid-career professionals who need **clarity, structure, and ownershi
|
|
| 478 |
base_url = gr.Textbox(
|
| 479 |
label="Base URL (optional)",
|
| 480 |
value="https://api.openai.com",
|
| 481 |
-
placeholder="e.g. https://api.openai.com or your custom OpenAI
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
base_url = gr.Textbox(
|
| 479 |
label="Base URL (optional)",
|
| 480 |
value="https://api.openai.com",
|
| 481 |
+
placeholder="e.g. https://api.openai.com or your custom OpenAI-compatible endpoint",
|
| 482 |
+
)
|
| 483 |
+
model_name = gr.Textbox(
|
| 484 |
+
label="Model Name",
|
| 485 |
+
value="gpt-4.1-mini",
|
| 486 |
+
placeholder="e.g. gpt-4.1, gpt-4o, deepseek-chat, mistral-large, etc.",
|
| 487 |
+
)
|
| 488 |
+
|
| 489 |
+
gr.Markdown(
|
| 490 |
+
"""
|
| 491 |
+
You can use **any OpenAI-compatible provider**
|
| 492 |
+
(just update the Base URL + Model Name accordingly).
|
| 493 |
+
"""
|
| 494 |
+
)
|
| 495 |
+
|
| 496 |
+
gr.Markdown("### Step 2: Choose or Load a Sample")
|
| 497 |
+
|
| 498 |
+
sample_dropdown = gr.Dropdown(
|
| 499 |
+
label="Sample scenarios",
|
| 500 |
+
choices=list(SAMPLE_SOPS.keys()),
|
| 501 |
+
value=None,
|
| 502 |
+
info="Optional: load a pre-filled example to see how it works.",
|
| 503 |
+
)
|
| 504 |
+
load_button = gr.Button("Load Sample into Form")
|
| 505 |
+
|
| 506 |
+
with gr.Column(scale=2):
|
| 507 |
+
gr.Markdown("### Step 3: Describe the SOP you want to generate")
|
| 508 |
+
|
| 509 |
+
sop_title = gr.Textbox(
|
| 510 |
+
label="SOP Title",
|
| 511 |
+
placeholder="e.g. Volunteer Onboarding Workflow, IT Outage Response, New Program Launch",
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
description = gr.Textbox(
|
| 515 |
+
label="Describe the process / context",
|
| 516 |
+
placeholder="Describe what this SOP should cover, who it's for, and any constraints.",
|
| 517 |
+
lines=6,
|
| 518 |
+
)
|
| 519 |
+
|
| 520 |
+
industry = gr.Textbox(
|
| 521 |
+
label="Industry / Domain",
|
| 522 |
+
placeholder="e.g. Nonprofit / Finance / Education / Healthcare / IT",
|
| 523 |
+
value="General",
|
| 524 |
+
)
|
| 525 |
+
|
| 526 |
+
tone = gr.Dropdown(
|
| 527 |
+
label="Tone",
|
| 528 |
+
choices=[
|
| 529 |
+
"Professional",
|
| 530 |
+
"Executive",
|
| 531 |
+
"Supportive",
|
| 532 |
+
"Direct",
|
| 533 |
+
"Compliance-focused",
|
| 534 |
+
],
|
| 535 |
+
value="Professional",
|
| 536 |
+
)
|
| 537 |
+
|
| 538 |
+
detail_level = gr.Dropdown(
|
| 539 |
+
label="Detail Level",
|
| 540 |
+
choices=["Standard", "High detail", "Checklist-style", "Overview only"],
|
| 541 |
+
value="Standard",
|
| 542 |
+
)
|
| 543 |
+
|
| 544 |
+
generate_button = gr.Button("🚀 Generate SOP", variant="primary")
|
| 545 |
+
|
| 546 |
+
gr.Markdown("### Step 4: Results")
|
| 547 |
+
|
| 548 |
+
with gr.Row():
|
| 549 |
+
with gr.Column(scale=3):
|
| 550 |
+
sop_output = gr.Markdown(
|
| 551 |
+
label="Generated SOP",
|
| 552 |
+
value="SOP output will appear here.",
|
| 553 |
+
)
|
| 554 |
+
with gr.Column(scale=2):
|
| 555 |
+
sop_json_output = gr.Code(
|
| 556 |
+
label="Raw SOP JSON (for automation / export)",
|
| 557 |
+
language="json",
|
| 558 |
+
)
|
| 559 |
+
|
| 560 |
+
gr.Markdown("### Visual Flow of Steps")
|
| 561 |
+
|
| 562 |
+
sop_figure = gr.Plot(label="SOP Steps Infographic")
|
| 563 |
+
|
| 564 |
+
# Wire up events
|
| 565 |
+
load_button.click(
|
| 566 |
+
fn=load_sample,
|
| 567 |
+
inputs=[sample_dropdown],
|
| 568 |
+
outputs=[sop_title, description, industry],
|
| 569 |
+
)
|
| 570 |
+
|
| 571 |
+
generate_button.click(
|
| 572 |
+
fn=generate_sop_ui,
|
| 573 |
+
inputs=[
|
| 574 |
+
api_key_state,
|
| 575 |
+
api_key_input,
|
| 576 |
+
base_url,
|
| 577 |
+
model_name,
|
| 578 |
+
sop_title,
|
| 579 |
+
description,
|
| 580 |
+
industry,
|
| 581 |
+
tone,
|
| 582 |
+
detail_level,
|
| 583 |
+
],
|
| 584 |
+
outputs=[sop_output, sop_json_output, sop_figure, api_key_state],
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
if __name__ == "__main__":
|
| 589 |
+
demo.launch()
|