UI component for creating patterns with simple and wizard modes.
()
| 620 | |
| 621 | |
| 622 | def pattern_creation_ui(): |
| 623 | """UI component for creating patterns with simple and wizard modes.""" |
| 624 | pattern_name = st.text_input("Pattern Name") |
| 625 | if not pattern_name: |
| 626 | st.info("Enter a pattern name to create a new pattern") |
| 627 | return |
| 628 | |
| 629 | system_content = """# IDENTITY and PURPOSE |
| 630 | |
| 631 | You are an AI assistant designed to {purpose}. |
| 632 | |
| 633 | # STEPS |
| 634 | |
| 635 | - Step 1 |
| 636 | - Step 2 |
| 637 | - Step 3 |
| 638 | |
| 639 | # OUTPUT INSTRUCTIONS |
| 640 | |
| 641 | - Output format instructions here |
| 642 | """ |
| 643 | new_content = st.text_area("Edit Pattern Content", system_content, height=400) |
| 644 | |
| 645 | if st.button("Create Pattern", type="primary"): |
| 646 | if not pattern_name: |
| 647 | st.error("Pattern name cannot be empty.") |
| 648 | else: |
| 649 | success, message = create_pattern(pattern_name) |
| 650 | if success: |
| 651 | system_file = os.path.join(pattern_dir, pattern_name, "system.md") |
| 652 | with open(system_file, "w") as f: |
| 653 | f.write(new_content) |
| 654 | st.success(f"Pattern '{pattern_name}' created successfully!") |
| 655 | st.experimental_rerun() |
| 656 | else: |
| 657 | st.error(message) |
| 658 | |
| 659 | |
| 660 | def pattern_management_ui(): |
no test coverage detected