Spaces:
Runtime error
Runtime error
| """ | |
| QUALITY PYTHON CODE GENERATOR | |
| π― Hochwertigen Python-Code generieren mit TODO-Planung | |
| Schnell Start & Integration Guide | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # OPTION 1: SUPER QUICK (3 Zeilen) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| from quality_code_generator import QualityCodeGenerator | |
| gen = QualityCodeGenerator() | |
| code, plan = gen.generate_code("Create a user authentication system") | |
| # FERTIG! Code ist bereit! | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # OPTION 2: INTERAKTIV (Kommandozeile) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| SCHRITT 1: Γffne Terminal | |
| $ cd c:\\Users\\noah1\\Desktop\\NoahsKI\\noahski_improved | |
| SCHRITT 2: Starte Test Suite | |
| $ python test_quality_code_generator.py | |
| SCHRITT 3: WΓ€hle Option | |
| Menu: | |
| 1. Full Test Suite | |
| 2. Simple Function | |
| 3. Class Generation | |
| 4. Data Processor | |
| 5. Plan Breakdown | |
| 6. Compare Implementations | |
| 7. Benchmark | |
| 8. Interactive β TU DIES! | |
| 9. Exit | |
| SCHRITT 4: Gib deine Anforderung ein | |
| "Create a REST API client with caching and retry logic" | |
| SCHRITT 5: BOOM! π₯ Code wird generiert in 5 Phasen! | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # OPTION 3: IN DEINEM PROJEKT INTEGRIEREN | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| from quality_code_generator import QualityCodeGenerator | |
| def generate_my_module(): | |
| '''Generate a custom module for my project''' | |
| gen = QualityCodeGenerator() | |
| requirement = ''' | |
| Create a database connection pool that: | |
| - Manages multiple database connections | |
| - Handles connection timeouts | |
| - Logs all operations | |
| - Automatically reconnects on failure | |
| - Thread-safe and efficient | |
| ''' | |
| # Generate with live progress (default verbose=True) | |
| code, plan = gen.generate_code(requirement) | |
| # Save to file | |
| with open("db_pool.py", "w", encoding="utf-8") as f: | |
| f.write(code) | |
| # Use immediately | |
| import sys | |
| sys.path.insert(0, '.') | |
| exec(code) # Code is fully functional! | |
| return code, plan | |
| # Run it! | |
| code, plan = generate_my_module() | |
| print(f"β Generated {len(code)} chars of production-ready code!") | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # WAS WIRD GENERIERT? (Die 5 Phasen) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| PHASE 1: π GENERATION PLAN ERSTELLEN | |
| β | |
| ββ Anforderungen analysieren | |
| ββ Architektur designen | |
| ββ 8 Tasks definieren (mit AbhΓ€ngigkeiten) | |
| ββ Zeiten-SchΓ€tzung (z.B. "~1 hour") | |
| ββ Quality Checklist (15 Punkte) | |
| ββ Complexity Level bestimmen | |
| OUTPUT: | |
| π REQUIREMENT: [Deine Anforderung] | |
| π PLAN OVERVIEW: | |
| β’ Estimated Lines: 600 | |
| β’ Number of Tasks: 8 | |
| β’ Estimated Time: ~1 hour | |
| π TASKS: | |
| 1. Setup & Imports (~30 lines) | |
| 2. Core Implementation (~150 lines) [depends on: [1]] | |
| ... [alle 8 Tasks mit Details] | |
| β QUALITY CHECKLIST (15 items) | |
| PHASE 2: π§ CODE GENERIEREN (Schritt fΓΌr Schritt) | |
| β | |
| ββ [1/5] Setting up imports and configuration... | |
| ββ [2/5] Generating core implementation... | |
| ββ [3/5] Adding error handling and utilities... | |
| ββ [4/5] Creating tests... | |
| ββ [5/5] Adding usage examples... | |
| OUTPUT: | |
| ββ Alle imports am Anfang | |
| ββ Logging setup | |
| ββ Constants definieren | |
| ββ Hauptklasse(n) mit full logic | |
| ββ Error handling & exceptions | |
| ββ Helper functions & utilities | |
| ββ Unit tests mit test runner | |
| ββ Usage examples & main | |
| RESULT: ~600 Zeilen hochwertiger Code | |
| PHASE 3: β QUALITΓT VALIDIEREN | |
| β | |
| ββ Syntax Check | |
| ββ Best Practices ΓberprΓΌfung | |
| ββ Documentation VollstΓ€ndigkeit | |
| ββ Type Hints Validierung | |
| OUTPUT: | |
| Quality Checklist: | |
| β All imports at top of file | |
| β Clear object-oriented structure | |
| β All functions/classes have docstrings | |
| β Type hints for all parameters | |
| β Error handling for edge cases | |
| β Logging statements | |
| β Following PEP-8 guidelines | |
| ... [15 Punkte insgesamt] | |
| β All quality checks passed! | |
| PHASE 4: πΎ SPEICHERN | |
| β | |
| ββ Code wird automatisch saving (mit UTF-8 encoding) | |
| OUTPUT: | |
| β Code saved to: generated_module.py | |
| Size: 8,246 characters | |
| Lines: 306 lines | |
| PHASE 5: π FERTIG! | |
| β | |
| ββ Code ist sofort verwendbar/deploybar | |
| Du kannst jetzt: | |
| - Code ausfΓΌhren: python generated_module.py | |
| - In Projekt integrieren: import generated_module | |
| - Modifizieren: Code ist Python, vollstΓ€ndig editierbar | |
| - Tests laufen: python -m pytest generated_module.py | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # BEISPIELE | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| BEISPIEL 1: Simple Function Generator | |
| βββββββββββββββββββββββββββββββββββββ | |
| from quality_code_generator import QualityCodeGenerator | |
| gen = QualityCodeGenerator() | |
| code, plan = gen.generate_code( | |
| "Create a text validation function that checks email and phone formats" | |
| ) | |
| # Output: ~400 Zeilen, mit Tests & Docs | |
| BEISPIEL 2: Class Generator | |
| βββββββββββββββββββββββββββ | |
| gen.generate_code(""" | |
| Create a ConfigManager class that: | |
| - Loads config from JSON/YAML files | |
| - Validates config schema | |
| - Caches in memory | |
| - Supports hot reload | |
| - Thread-safe operations | |
| """) | |
| # Output: ~600 Zeilen, komplett dokumentiert | |
| BEISPIEL 3: API Client | |
| ββββββββββββββββββββββ | |
| gen.generate_code(""" | |
| Build an async REST API client with: | |
| - Automatic retries on failure | |
| - Request rate limiting | |
| - Response caching | |
| - Detailed logging | |
| - Custom exception handling | |
| - Connection pooling | |
| """) | |
| # Output: ~800 Zeilen, produktionsbereit | |
| BEISPIEL 4: Data Pipeline | |
| βββββββββββββββββββββββββ | |
| gen.generate_code(""" | |
| Create a data processing pipeline that: | |
| - Reads data from multiple sources | |
| - Validates and cleans | |
| - Transforms for analysis | |
| - Handles errors gracefully | |
| - Logs all operations | |
| - Exports in multiple formats | |
| """) | |
| # Output: ~1000 Zeilen, mit full error handling | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # QUALITY CHECKLIST (Was wird alles ΓΌberprΓΌft) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| 1. β All imports at top of file | |
| 2. β Clear object-oriented structure or functional design | |
| 3. β All functions/classes have docstrings | |
| 4. β Type hints for all parameters and returns | |
| 5. β Error handling for all edge cases | |
| 6. β Logging statements for debugging | |
| 7. β Following PEP-8 style guidelines | |
| 8. β DRY principle (Don't Repeat Yourself) | |
| 9. β Separation of concerns | |
| 10. β Unit tests with good coverage | |
| 11. β Comprehensive comments where needed | |
| 12. β No hardcoded values (use constants) | |
| 13. β Proper exception handling | |
| 14. β Code is readable and maintainable | |
| 15. β Performance optimizations applied | |
| β Alle 15 Punkte werden fΓΌr JEDEN generierten Code ΓΌberprΓΌft! | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # DIE 8 TASKS (Was genau wird generiert) | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| Task 1: Setup & Imports (~30 Zeilen) | |
| ββ Alle imports am Anfang | |
| ββ Logging konfigurieren | |
| ββ Constants definieren | |
| ββ Type imports | |
| Task 2: Core Implementation (~150 Zeilen) | |
| ββ Hauptklasse oder Funktionen | |
| ββ GeschΓ€ftslogik | |
| ββ Execute/Process Methoden | |
| ββ Zentrale Features | |
| Task 3: Error Handling & Validation (~80 Zeilen) | |
| ββ Custom Exceptions | |
| ββ Try-catch BlΓΆcke | |
| ββ Input validation | |
| ββ Error messages | |
| Task 4: Configuration & Constants (~40 Zeilen) | |
| ββ Constants Section | |
| ββ Default values | |
| ββ Configuration management | |
| ββ Settings | |
| Task 5: Documentation & Comments (~50 Zeilen) | |
| ββ Docstrings auf ALLES | |
| ββ Type hints ΓΌberall | |
| ββ Inline comments | |
| ββ Module documentation | |
| Task 6: Helper Functions & Utilities (~100 Zeilen) | |
| ββ Support functions | |
| ββ Reusable utilities | |
| ββ Helper methods | |
| ββ Convenience functions | |
| Task 7: Testing (~120 Zeilen) | |
| ββ Unit tests | |
| ββ Test suite | |
| ββ Test runner | |
| ββ Edge cases | |
| Task 8: Usage Examples (~30 Zeilen) | |
| ββ Basic usage | |
| ββ Advanced usage | |
| ββ Error examples | |
| ββ Main entry point | |
| βββββββββββββββββββββββββββββββββββββββββββββ | |
| TOTAL: ~600 Zeilen hochwertiger, getesteter Python-Code! | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # HΓUFIGE FRAGEN | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| F: Wie lange dauert die Generierung? | |
| A: <1 Sekunde fΓΌr den Code. Zeigest den Plan, generiert Code, validiert. | |
| F: Kann ich die generierten Tasks Γ€ndern? | |
| A: Nein, aber du kannst den Code danach editieren - it's Python! | |
| F: Wo wird der Code saved? | |
| A: Wo DU willst! Du controllierst das, nicht der Generator. | |
| F: Kann ich das in mein Projekt integrieren? | |
| A: Ja! Ganz einfach - 3 Zeilen Code (siehe Option 1 oben). | |
| F: Ist der generierte Code produktionsbereit? | |
| A: Ja! Der Code folgt allen Best Practices und hat Tests. | |
| F: Kann ich Anforderungen auf Deutsch schreiben? | |
| A: Ja! Der Generator versteht Deutsch & English. | |
| F: Was wenn ich detaillierte Requirements habe? | |
| A: Perfekt! Je detaillierter, desto besser der generierte Code. | |
| F: Funktioniert das mit komplexem Code? | |
| A: Ja! Der Generator kann alles von simple utils bis complex systems. | |
| F: Kann ich den Code direkt verwenden? | |
| A: Ja! Er ist komplett funktional und testbar. | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # WICHTIGE DATEIEN | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """ | |
| quality_code_generator.py (800+ Zeilen) | |
| β Main module mit CodeGenerationPlanner & QualityCodeGenerator | |
| β Imports: logging, typing, dataclasses, enum, re | |
| test_quality_code_generator.py (350+ Zeilen) | |
| β 8 verschiedene Tests/Demos | |
| β Interaktiver Mode | |
| β Benchmark & Comparison | |
| QUALITY_CODE_GENERATOR_GUIDE.md (2000+ Worte) | |
| β Komplette Dokumentation | |
| β Verwendungsbeispiele | |
| β Best Practices & FAQs | |
| QUALITY_CODE_GENERATOR_SUMMARY.md | |
| β Quick Reference | |
| β Was wurde kreiert | |
| β Next Steps | |
| quick_test_generator.py | |
| β Quick test script | |
| β Schnelles Demo | |
| β File saving example | |
| generated_config_manager.py | |
| β Beispiel output | |
| β ~300 Zeilen echter Code | |
| β Komplett funktional | |
| """ | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # LOS GEHT'S! | |
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| if __name__ == "__main__": | |
| print(""" | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| β β | |
| β π QUALITY PYTHON CODE GENERATOR π β | |
| β β | |
| β Hochwertigen Code generieren mit TODO-Planung β | |
| β Plan β Tasks β Step-by-Step Implementation β | |
| β β | |
| β START HIER: β | |
| β $ python test_quality_code_generator.py β | |
| β β | |
| β ODER DIREKT NUTZEN: β | |
| β from quality_code_generator import QualityCodeGenerator β | |
| β gen = QualityCodeGenerator() β | |
| β code, plan = gen.generate_code("Your requirement") β | |
| β β | |
| β DOCUMENTATION: β | |
| β β QUALITY_CODE_GENERATOR_GUIDE.md β | |
| β β QUALITY_CODE_GENERATOR_SUMMARY.md β | |
| β β | |
| β β Status: PRODUCTION READY β | |
| β β¨ Features: 5-Phase Generation, 8-Task System, QA Checks β | |
| β π Quality: 15-point validation checklist β | |
| β π― Output: ~600 lines of high-quality Python β | |
| β β | |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| """) | |
| print("π Ready to generate high-quality Python code?") | |
| print("\nChoose your path:") | |
| print(" 1. python test_quality_code_generator.py β Full test suite") | |
| print(" 2. python quick_test_generator.py β Quick demo") | |
| print(" 3. Read QUALITY_CODE_GENERATOR_GUIDE.md β Learn more") | |
| print("\nβΆ START NOW!\n") | |