Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -438,70 +438,16 @@ with gr.Blocks(title="Synthetic Test Data Generator") as demo:
|
|
| 438 |
gr.Markdown("# 🎲 Synthetic Test Data Generator")
|
| 439 |
gr.Markdown("### Create Realistic Test Data for Your Applications with AI")
|
| 440 |
|
| 441 |
-
|
| 442 |
-
|
| 443 |
# ============================================
|
| 444 |
# Tab 0: Home
|
| 445 |
# ============================================
|
| 446 |
with gr.Tab("🏠 Home"):
|
| 447 |
gr.Markdown("""
|
| 448 |
🎯 Welcome to Synthetic Test Data Generator
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
✨ Features
|
| 452 |
-
Feature Description
|
| 453 |
-
🎨 Multiple Formats JSON, CSV, SQL, XML, YAML, Python dictionaries, and tables
|
| 454 |
-
📊 Smart Generation AI-powered data that looks and feels real
|
| 455 |
-
🎯 Multiple Languages Python, JavaScript, Java, C# ready output
|
| 456 |
-
📝 Schema Templates Pre-built templates for common use cases
|
| 457 |
-
⚡ Bulk Generation Generate 1-100 records with one click
|
| 458 |
-
🔍 Edge Cases Includes boundary values, nulls, and extreme cases
|
| 459 |
-
|
| 460 |
-
🚀 Quick Start Guide
|
| 461 |
-
1. Choose Your Data Format
|
| 462 |
-
Select from 7 different output formats based on your testing needs
|
| 463 |
-
|
| 464 |
-
2. Define Your Schema
|
| 465 |
-
Use the built-in templates or create your own custom schema
|
| 466 |
-
|
| 467 |
-
3. Generate & Use
|
| 468 |
-
Click "Generate Test Data" and copy the ready-to-use code
|
| 469 |
-
|
| 470 |
-
📋 Example Schemas
|
| 471 |
-
User Profile:
|
| 472 |
-
```json
|
| 473 |
-
{
|
| 474 |
-
"user_id": "integer",
|
| 475 |
-
"username": "string (3-20 chars)",
|
| 476 |
-
"email": "email format",
|
| 477 |
-
"age": "integer (18-80)",
|
| 478 |
-
"is_active": "boolean"
|
| 479 |
-
}
|
| 480 |
-
|
| 481 |
-
E-commerce Order:
|
| 482 |
-
|
| 483 |
-
{
|
| 484 |
-
"order_id": "string (ORD-XXXX)",
|
| 485 |
-
"customer_name": "string",
|
| 486 |
-
"items": ["product_id", "quantity", "price"],
|
| 487 |
-
"total": "decimal",
|
| 488 |
-
"status": "enum(pending,shipped,delivered)"
|
| 489 |
-
}
|
| 490 |
-
|
| 491 |
-
💡 Best Practices
|
| 492 |
-
|
| 493 |
-
Start Simple: Begin with a basic schema and expand as needed
|
| 494 |
-
Use Templates: Leverage pre-built templates for common scenarios
|
| 495 |
-
Validate Output: Always review generated data before using in production tests
|
| 496 |
-
Adjust Count: Generate 5-10 records for development, 50-100 for load testing
|
| 497 |
-
|
| 498 |
-
🎯 Ready to Get Started?
|
| 499 |
-
Navigate to the Generator tab to create your first test dataset!
|
| 500 |
""")
|
| 501 |
|
| 502 |
-
# ============================================
|
| 503 |
# Stats and Use Cases
|
| 504 |
-
# ============================================
|
| 505 |
with gr.Row():
|
| 506 |
with gr.Column():
|
| 507 |
gr.Markdown("### 📊 Quick Stats")
|
|
@@ -522,71 +468,68 @@ Integration Tests
|
|
| 522 |
Demo Data Creation
|
| 523 |
""")
|
| 524 |
|
| 525 |
-
# ============================================
|
| 526 |
# Quick Action Button
|
| 527 |
-
# ============================================
|
| 528 |
gr.Markdown("---")
|
| 529 |
gr.Markdown("### 🔧 Quick Action")
|
| 530 |
quick_generate_btn = gr.Button("🚀 Go to Generator Tab", variant="primary")
|
| 531 |
|
| 532 |
-
# JavaScript for switching tab
|
| 533 |
quick_generate_btn.click(
|
| 534 |
fn=None,
|
| 535 |
inputs=[],
|
| 536 |
outputs=[],
|
| 537 |
js='() => { document.querySelector(\'[data-testid="tab-Generator"]\').click(); }'
|
| 538 |
)
|
| 539 |
-
# ============================================
|
| 540 |
-
# Tab 1: Generator (Main)
|
| 541 |
-
# ============================================
|
| 542 |
-
|
| 543 |
-
with gr.Tab("Generator") as generator_tab:
|
| 544 |
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
"user_id": "uuid",
|
| 591 |
"full_name": "name",
|
| 592 |
"email": "email",
|
|
@@ -594,243 +537,155 @@ with gr.Tab("Generator") as generator_tab:
|
|
| 594 |
"is_active": "boolean",
|
| 595 |
"country": "country"
|
| 596 |
}''',
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
|
|
|
| 660 |
|
| 661 |
-
#
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 670 |
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
},
|
| 701 |
-
"contact_info": {
|
| 702 |
-
"desc": "Contact Information Schema\n\nUseful for CRM systems, address books, and contact management features.\n\nUse Cases:\n- Contact import/export\n- Address validation\n- Phone number formatting\n- Data enrichment tests",
|
| 703 |
-
"schema": load_schema_template(template_name)
|
| 704 |
-
},
|
| 705 |
-
"financial_transaction": {
|
| 706 |
-
"desc": "Financial Transaction Schema\n\nEssential for banking, payment systems, and financial applications.\n\nUse Cases:\n- Payment processing tests\n- Transaction history\n- Fraud detection\n- Statement generation",
|
| 707 |
-
"schema": load_schema_template(template_name)
|
| 708 |
-
},
|
| 709 |
-
"healthcare_patient": {
|
| 710 |
-
"desc": "Healthcare Patient Schema\n\nDesigned for healthcare systems, patient management, and medical records.\n\nUse Cases:\n- Patient registration\n- Medical records\n- Appointment scheduling\n- Insurance verification",
|
| 711 |
-
"schema": load_schema_template(template_name)
|
| 712 |
}
|
| 713 |
-
}
|
| 714 |
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
gr.Markdown("### 💡 Tips for Creating Custom Schemas")
|
| 733 |
-
gr.Markdown("""
|
| 734 |
- Use descriptive field names - The AI understands context (e.g., 'email' vs 'e')
|
| 735 |
- Specify data types - Include hints like 'string', 'integer', 'decimal', 'date'
|
| 736 |
- Add constraints - Use ranges like 'age: 18-80' or patterns like 'email format'
|
| 737 |
- Include enums - For fields with limited options (e.g., 'status: pending,active,closed')
|
| 738 |
- Structure nested data - Use JSON objects or arrays for complex relationships
|
| 739 |
""")
|
| 740 |
-
|
| 741 |
-
# ============================================
|
| 742 |
-
# Tab 3: About & Help
|
| 743 |
-
# ============================================
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
gr.Markdown("""
|
| 747 |
ℹ️ **About Synthetic Test Data Generator**
|
| 748 |
|
| 749 |
**What is this tool?**
|
| 750 |
This tool uses AI (Groq's LLM) to generate realistic, production-like test data based on your schema definitions. It helps QA engineers and developers create comprehensive test datasets quickly and efficiently.
|
| 751 |
|
| 752 |
-
|
| 753 |
-
- **Define Your Schema** - Describe the data structure you need
|
| 754 |
-
- **Select Format** - Choose how you want the data output
|
| 755 |
-
- **Generate** - AI creates realistic data matching your schema
|
| 756 |
-
- **Use** - Copy the ready-to-use code into your tests
|
| 757 |
-
|
| 758 |
-
**Supported Formats**
|
| 759 |
-
|
| 760 |
-
| Format | Best For |
|
| 761 |
-
|---------------|--------------------------------------------|
|
| 762 |
-
| JSON | API testing, data interchange |
|
| 763 |
-
| CSV | Data import, spreadsheets |
|
| 764 |
-
| SQL | Database seeding, migration testing |
|
| 765 |
-
| XML | Legacy systems, enterprise integration |
|
| 766 |
-
| Python Dict | Python unit tests, data manipulation |
|
| 767 |
-
| YAML | Configuration, Kubernetes testing |
|
| 768 |
-
| Table | Documentation, manual test cases |
|
| 769 |
-
|
| 770 |
-
**Tips for Better Results**
|
| 771 |
-
**Schema Design Tips**
|
| 772 |
-
- Be specific about field types
|
| 773 |
-
- Include validation rules (min/max, patterns)
|
| 774 |
-
- Use realistic naming conventions
|
| 775 |
-
- Define relationships between fields when possible
|
| 776 |
-
|
| 777 |
-
**Common Field Types**
|
| 778 |
-
- Strings: "name", "email", "phone number"
|
| 779 |
-
- Numbers: "age: 18-80", "price: decimal"
|
| 780 |
-
- Dates: "birth_date: 1980-2020", "timestamp: datetime"
|
| 781 |
-
- Booleans: "is_active: boolean"
|
| 782 |
-
- Enums: "status: active,inactive,pending"
|
| 783 |
-
|
| 784 |
-
**Example Schemas**
|
| 785 |
-
|
| 786 |
-
**Simple User:**
|
| 787 |
-
```json
|
| 788 |
-
{
|
| 789 |
-
"id": "integer",
|
| 790 |
-
"name": "string",
|
| 791 |
-
"email": "email"
|
| 792 |
-
}
|
| 793 |
-
|
| 794 |
-
Complex Order:
|
| 795 |
-
|
| 796 |
-
{
|
| 797 |
-
"order_id": "string (ORD-XXXX)",
|
| 798 |
-
"customer": {
|
| 799 |
-
"name": "string",
|
| 800 |
-
"email": "email"
|
| 801 |
-
},
|
| 802 |
-
"items": [
|
| 803 |
-
{
|
| 804 |
-
"product": "string",
|
| 805 |
-
"quantity": "integer (1-5)",
|
| 806 |
-
"price": "decimal (10-500)"
|
| 807 |
-
}
|
| 808 |
-
],
|
| 809 |
-
"total": "decimal"
|
| 810 |
-
}
|
| 811 |
-
|
| 812 |
-
Technical Details
|
| 813 |
-
|
| 814 |
-
AI Model: Groq's Llama 3.3 70B
|
| 815 |
-
Max Records: 100 per generation
|
| 816 |
-
Formats: 7 output formats
|
| 817 |
-
Languages: Python, JavaScript, Java, C#
|
| 818 |
-
|
| 819 |
-
Need Help?
|
| 820 |
-
If you encounter any issues or have suggestions for improvement, please check:
|
| 821 |
-
|
| 822 |
-
Your schema format (valid JSON recommended)
|
| 823 |
-
Record count (1-100 recommended)
|
| 824 |
-
API key configuration
|
| 825 |
-
Internet connection
|
| 826 |
-
|
| 827 |
-
Version: 1.0.0
|
| 828 |
-
Last Updated: January 2026
|
| 829 |
""")
|
| 830 |
|
| 831 |
-
# ============================================
|
| 832 |
-
# Launch Application
|
| 833 |
-
# ============================================
|
| 834 |
# ============================================
|
| 835 |
# Launch Application
|
| 836 |
# ============================================
|
|
@@ -839,18 +694,10 @@ if __name__ == "__main__":
|
|
| 839 |
print("🎲 Synthetic Test Data Generator")
|
| 840 |
print("=" * 60)
|
| 841 |
print("✅ All components loaded successfully!")
|
| 842 |
-
print("📊 Features:")
|
| 843 |
-
print(" - Home tab with overview and quick start")
|
| 844 |
-
print(" - Generator tab with full configuration")
|
| 845 |
-
print(" - Templates Library with pre-built schemas")
|
| 846 |
-
print(" - About & Help section")
|
| 847 |
-
print("📄 Supported formats: JSON, CSV, SQL, XML, Python Dict, YAML, Table")
|
| 848 |
-
print("🎯 Supported languages: Python, JavaScript, Java, C#")
|
| 849 |
print("=" * 60)
|
| 850 |
print("🚀 Launching application...")
|
| 851 |
print("=" * 60)
|
| 852 |
|
| 853 |
-
# تم نقل theme إلى هنا
|
| 854 |
demo.launch(
|
| 855 |
share=True,
|
| 856 |
debug=False,
|
|
|
|
| 438 |
gr.Markdown("# 🎲 Synthetic Test Data Generator")
|
| 439 |
gr.Markdown("### Create Realistic Test Data for Your Applications with AI")
|
| 440 |
|
|
|
|
|
|
|
| 441 |
# ============================================
|
| 442 |
# Tab 0: Home
|
| 443 |
# ============================================
|
| 444 |
with gr.Tab("🏠 Home"):
|
| 445 |
gr.Markdown("""
|
| 446 |
🎯 Welcome to Synthetic Test Data Generator
|
| 447 |
+
... (المحتوى)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
""")
|
| 449 |
|
|
|
|
| 450 |
# Stats and Use Cases
|
|
|
|
| 451 |
with gr.Row():
|
| 452 |
with gr.Column():
|
| 453 |
gr.Markdown("### 📊 Quick Stats")
|
|
|
|
| 468 |
Demo Data Creation
|
| 469 |
""")
|
| 470 |
|
|
|
|
| 471 |
# Quick Action Button
|
|
|
|
| 472 |
gr.Markdown("---")
|
| 473 |
gr.Markdown("### 🔧 Quick Action")
|
| 474 |
quick_generate_btn = gr.Button("🚀 Go to Generator Tab", variant="primary")
|
| 475 |
|
|
|
|
| 476 |
quick_generate_btn.click(
|
| 477 |
fn=None,
|
| 478 |
inputs=[],
|
| 479 |
outputs=[],
|
| 480 |
js='() => { document.querySelector(\'[data-testid="tab-Generator"]\').click(); }'
|
| 481 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
|
| 483 |
+
# ============================================
|
| 484 |
+
# Tab 1: Generator (Main) - يجب أن يكون داخل كتلة demo
|
| 485 |
+
# ============================================
|
| 486 |
+
with gr.Tab("Generator") as generator_tab:
|
| 487 |
+
|
| 488 |
+
with gr.Row():
|
| 489 |
+
with gr.Column(scale=1):
|
| 490 |
+
gr.Markdown("### ⚙️ Configuration")
|
| 491 |
+
|
| 492 |
+
# Language Selection
|
| 493 |
+
data_language = gr.Dropdown(
|
| 494 |
+
choices=["python", "javascript", "java", "csharp"],
|
| 495 |
+
value="python",
|
| 496 |
+
label="🎯 Target Language"
|
| 497 |
+
)
|
| 498 |
+
|
| 499 |
+
# Format Selection
|
| 500 |
+
data_format = gr.Dropdown(
|
| 501 |
+
choices=["json", "csv", "sql", "xml", "python_dict", "yaml", "excel_style"],
|
| 502 |
+
value="json",
|
| 503 |
+
label="📄 Output Format"
|
| 504 |
+
)
|
| 505 |
+
|
| 506 |
+
# Format description
|
| 507 |
+
format_desc = gr.Markdown("Format Info: " + get_output_format_description("json"))
|
| 508 |
+
|
| 509 |
+
# Record count
|
| 510 |
+
data_count = gr.Slider(
|
| 511 |
+
minimum=1,
|
| 512 |
+
maximum=100,
|
| 513 |
+
value=10,
|
| 514 |
+
step=1,
|
| 515 |
+
label="📊 Number of Records"
|
| 516 |
+
)
|
| 517 |
+
|
| 518 |
+
gr.Markdown("### 📝 Schema Definition")
|
| 519 |
+
|
| 520 |
+
# Template selection
|
| 521 |
+
data_template = gr.Dropdown(
|
| 522 |
+
choices=[
|
| 523 |
+
"custom", "user_profile", "ecommerce_order", "api_request_log",
|
| 524 |
+
"contact_info", "financial_transaction", "healthcare_patient"
|
| 525 |
+
],
|
| 526 |
+
value="custom",
|
| 527 |
+
label="📁 Schema Template"
|
| 528 |
+
)
|
| 529 |
+
|
| 530 |
+
# Schema input
|
| 531 |
+
schema_input = gr.Textbox(
|
| 532 |
+
value='''{
|
| 533 |
"user_id": "uuid",
|
| 534 |
"full_name": "name",
|
| 535 |
"email": "email",
|
|
|
|
| 537 |
"is_active": "boolean",
|
| 538 |
"country": "country"
|
| 539 |
}''',
|
| 540 |
+
lines=15,
|
| 541 |
+
label="Schema Definition"
|
| 542 |
+
)
|
| 543 |
+
|
| 544 |
+
# Schema preview
|
| 545 |
+
preview_btn = gr.Button("🔍 Preview Schema", size="sm")
|
| 546 |
+
schema_preview = gr.Markdown("")
|
| 547 |
+
|
| 548 |
+
# Actions
|
| 549 |
+
generate_btn = gr.Button("✨ Generate Test Data", variant="primary", size="lg")
|
| 550 |
+
|
| 551 |
+
with gr.Column(scale=1):
|
| 552 |
+
gr.Markdown("### 📊 Generation Statistics")
|
| 553 |
+
data_stats = gr.Markdown("No data generated yet")
|
| 554 |
+
|
| 555 |
+
gr.Markdown("### 📝 Generated Data")
|
| 556 |
+
data_output = gr.Code(label="Test Data", language="json", lines=15)
|
| 557 |
+
|
| 558 |
+
gr.Markdown("### 💻 Ready-to-use Code Template")
|
| 559 |
+
code_output = gr.Code(label="Code Template", language="python", lines=12)
|
| 560 |
+
|
| 561 |
+
# تعريف الدوال المساعدة
|
| 562 |
+
def update_code_language(format_type):
|
| 563 |
+
lang_map = {
|
| 564 |
+
"json": "json",
|
| 565 |
+
"csv": "csv",
|
| 566 |
+
"sql": "sql",
|
| 567 |
+
"xml": "xml",
|
| 568 |
+
"python_dict": "python",
|
| 569 |
+
"yaml": "yaml",
|
| 570 |
+
"excel_style": "markdown"
|
| 571 |
+
}
|
| 572 |
+
return gr.update(language=lang_map.get(format_type, "text"))
|
| 573 |
|
| 574 |
+
# Event Handlers
|
| 575 |
+
data_template.change(
|
| 576 |
+
fn=load_schema_template,
|
| 577 |
+
inputs=[data_template],
|
| 578 |
+
outputs=[schema_input]
|
| 579 |
+
)
|
| 580 |
+
|
| 581 |
+
preview_btn.click(
|
| 582 |
+
fn=preview_schema,
|
| 583 |
+
inputs=[schema_input],
|
| 584 |
+
outputs=[schema_preview]
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
generate_btn.click(
|
| 588 |
+
fn=generate_synthetic_data,
|
| 589 |
+
inputs=[data_language, schema_input, data_count, data_format, data_template],
|
| 590 |
+
outputs=[data_output, code_output, data_stats, schema_input]
|
| 591 |
+
)
|
| 592 |
+
|
| 593 |
+
data_format.change(
|
| 594 |
+
fn=get_output_format_description,
|
| 595 |
+
inputs=[data_format],
|
| 596 |
+
outputs=[format_desc]
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
data_format.change(
|
| 600 |
+
fn=update_code_language,
|
| 601 |
+
inputs=[data_format],
|
| 602 |
+
outputs=[data_output]
|
| 603 |
+
)
|
| 604 |
|
| 605 |
+
# ============================================
|
| 606 |
+
# Tab 2: Templates Library
|
| 607 |
+
# ============================================
|
| 608 |
+
with gr.Tab("📚 Templates Library"):
|
| 609 |
+
gr.Markdown("# 📚 Schema Templates Library")
|
| 610 |
+
gr.Markdown("Browse and learn from these example schemas")
|
| 611 |
+
|
| 612 |
+
template_selector = gr.Dropdown(
|
| 613 |
+
choices=[
|
| 614 |
+
"user_profile", "ecommerce_order", "api_request_log",
|
| 615 |
+
"contact_info", "financial_transaction", "healthcare_patient"
|
| 616 |
+
],
|
| 617 |
+
value="user_profile",
|
| 618 |
+
label="Select Template to View"
|
| 619 |
+
)
|
| 620 |
|
| 621 |
+
template_display = gr.Code(label="Template Schema", language="json", lines=20)
|
| 622 |
+
template_description = gr.Markdown("")
|
| 623 |
+
|
| 624 |
+
def show_template_details(template_name):
|
| 625 |
+
templates_info = {
|
| 626 |
+
"user_profile": {
|
| 627 |
+
"desc": "User Profile Schema\n\nPerfect for testing user management systems, authentication, and profile features.\n\nUse Cases:\n- User registration tests\n- Profile management\n- User search/filtering\n- Data export features",
|
| 628 |
+
"schema": load_schema_template(template_name)
|
| 629 |
+
},
|
| 630 |
+
"ecommerce_order": {
|
| 631 |
+
"desc": "E-commerce Order Schema\n\nIdeal for testing shopping carts, checkout flows, and order management systems.\n\nUse Cases:\n- Order creation tests\n- Cart calculations\n- Inventory management\n- Order history features",
|
| 632 |
+
"schema": load_schema_template(template_name)
|
| 633 |
+
},
|
| 634 |
+
"api_request_log": {
|
| 635 |
+
"desc": "API Request Log Schema\n\nGreat for testing logging systems, analytics, and monitoring tools.\n\nUse Cases:\n- API monitoring tests\n- Log analysis\n- Performance metrics\n- Error tracking",
|
| 636 |
+
"schema": load_schema_template(template_name)
|
| 637 |
+
},
|
| 638 |
+
"contact_info": {
|
| 639 |
+
"desc": "Contact Information Schema\n\nUseful for CRM systems, address books, and contact management features.\n\nUse Cases:\n- Contact import/export\n- Address validation\n- Phone number formatting\n- Data enrichment tests",
|
| 640 |
+
"schema": load_schema_template(template_name)
|
| 641 |
+
},
|
| 642 |
+
"financial_transaction": {
|
| 643 |
+
"desc": "Financial Transaction Schema\n\nEssential for banking, payment systems, and financial applications.\n\nUse Cases:\n- Payment processing tests\n- Transaction history\n- Fraud detection\n- Statement generation",
|
| 644 |
+
"schema": load_schema_template(template_name)
|
| 645 |
+
},
|
| 646 |
+
"healthcare_patient": {
|
| 647 |
+
"desc": "Healthcare Patient Schema\n\nDesigned for healthcare systems, patient management, and medical records.\n\nUse Cases:\n- Patient registration\n- Medical records\n- Appointment scheduling\n- Insurance verification",
|
| 648 |
+
"schema": load_schema_template(template_name)
|
| 649 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
}
|
|
|
|
| 651 |
|
| 652 |
+
info = templates_info.get(template_name, templates_info["user_profile"])
|
| 653 |
+
return info["schema"], info["desc"]
|
| 654 |
+
|
| 655 |
+
template_selector.change(
|
| 656 |
+
fn=show_template_details,
|
| 657 |
+
inputs=[template_selector],
|
| 658 |
+
outputs=[template_display, template_description]
|
| 659 |
+
)
|
| 660 |
+
|
| 661 |
+
# Load initial template
|
| 662 |
+
initial_schema, initial_desc = show_template_details("user_profile")
|
| 663 |
+
template_display.value = initial_schema
|
| 664 |
+
template_description.value = initial_desc
|
| 665 |
+
|
| 666 |
+
gr.Markdown("---")
|
| 667 |
+
gr.Markdown("### 💡 Tips for Creating Custom Schemas")
|
| 668 |
+
gr.Markdown("""
|
|
|
|
|
|
|
| 669 |
- Use descriptive field names - The AI understands context (e.g., 'email' vs 'e')
|
| 670 |
- Specify data types - Include hints like 'string', 'integer', 'decimal', 'date'
|
| 671 |
- Add constraints - Use ranges like 'age: 18-80' or patterns like 'email format'
|
| 672 |
- Include enums - For fields with limited options (e.g., 'status: pending,active,closed')
|
| 673 |
- Structure nested data - Use JSON objects or arrays for complex relationships
|
| 674 |
""")
|
| 675 |
+
|
| 676 |
+
# ============================================
|
| 677 |
+
# Tab 3: About & Help
|
| 678 |
+
# ============================================
|
| 679 |
+
with gr.Tab("ℹ️ About & Help"):
|
| 680 |
+
gr.Markdown("""
|
|
|
|
| 681 |
ℹ️ **About Synthetic Test Data Generator**
|
| 682 |
|
| 683 |
**What is this tool?**
|
| 684 |
This tool uses AI (Groq's LLM) to generate realistic, production-like test data based on your schema definitions. It helps QA engineers and developers create comprehensive test datasets quickly and efficiently.
|
| 685 |
|
| 686 |
+
... (باقي المحتوى)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 687 |
""")
|
| 688 |
|
|
|
|
|
|
|
|
|
|
| 689 |
# ============================================
|
| 690 |
# Launch Application
|
| 691 |
# ============================================
|
|
|
|
| 694 |
print("🎲 Synthetic Test Data Generator")
|
| 695 |
print("=" * 60)
|
| 696 |
print("✅ All components loaded successfully!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 697 |
print("=" * 60)
|
| 698 |
print("🚀 Launching application...")
|
| 699 |
print("=" * 60)
|
| 700 |
|
|
|
|
| 701 |
demo.launch(
|
| 702 |
share=True,
|
| 703 |
debug=False,
|