Multi-step wizard for creating a new pattern.
()
| 493 | |
| 494 | |
| 495 | def pattern_creation_wizard(): |
| 496 | """Multi-step wizard for creating a new pattern.""" |
| 497 | st.header("Create New Pattern") |
| 498 | |
| 499 | pattern_name = st.text_input("Pattern Name") |
| 500 | if pattern_name: |
| 501 | edit_mode = st.radio( |
| 502 | "Edit Mode", |
| 503 | ["Simple Editor", "Advanced (Wizard)"], |
| 504 | key="pattern_creation_edit_mode", |
| 505 | horizontal=True, |
| 506 | ) |
| 507 | |
| 508 | if edit_mode == "Simple Editor": |
| 509 | new_content = st.text_area("Enter Pattern Content", height=400) |
| 510 | |
| 511 | if st.button("Create Pattern", type="primary"): |
| 512 | success, message = create_pattern(pattern_name, new_content) |
| 513 | if success: |
| 514 | st.success(message) |
| 515 | st.experimental_rerun() |
| 516 | else: |
| 517 | st.error(message) |
| 518 | |
| 519 | else: |
| 520 | sections = ["IDENTITY", "GOAL", "OUTPUT", "OUTPUT INSTRUCTIONS"] |
| 521 | current_section = st.radio( |
| 522 | "Edit Section", sections, key="pattern_creation_section_select" |
| 523 | ) |
| 524 | |
| 525 | if current_section == "IDENTITY": |
| 526 | identity = st.text_area("Define the IDENTITY", height=200) |
| 527 | st.session_state.new_pattern_identity = identity |
| 528 | |
| 529 | elif current_section == "GOAL": |
| 530 | goal = st.text_area("Define the GOAL", height=200) |
| 531 | st.session_state.new_pattern_goal = goal |
| 532 | |
| 533 | elif current_section == "OUTPUT": |
| 534 | output = st.text_area("Define the OUTPUT", height=200) |
| 535 | st.session_state.new_pattern_output = output |
| 536 | |
| 537 | elif current_section == "OUTPUT INSTRUCTIONS": |
| 538 | instructions = st.text_area( |
| 539 | "Define the OUTPUT INSTRUCTIONS", height=200 |
| 540 | ) |
| 541 | st.session_state.new_pattern_instructions = instructions |
| 542 | |
| 543 | pattern_content = f"""# IDENTITY |
| 544 | {st.session_state.get('new_pattern_identity', '')} |
| 545 | |
| 546 | # GOAL |
| 547 | {st.session_state.get('new_pattern_goal', '')} |
| 548 | |
| 549 | # OUTPUT |
| 550 | {st.session_state.get('new_pattern_output', '')} |
| 551 | |
| 552 | # OUTPUT INSTRUCTIONS |
no test coverage detected