Spaces:
Sleeping
Sleeping
3ssem0
fix: configuration error - aligned entry point to app.py and enforced LF/BOM-less encoding
ec47953 | import os | |
| import sys | |
| import json | |
| from dotenv import load_dotenv | |
| # Add the 'Ai model part' directory to sys.path so we can import modules | |
| sys.path.append(r'c:\Users\assem\Desktop\On-Going\nextJS\GP WC\WebCraft_F\Ai model part') | |
| from ai_planner import get_planner | |
| # Load env for API key | |
| load_dotenv(r'c:\Users\assem\Desktop\On-Going\nextJS\GP WC\WebCraft_F\Ai model part\.env') | |
| def test_generation(): | |
| print("Initializing Planner...") | |
| try: | |
| planner = get_planner() | |
| except Exception as e: | |
| print(f"Failed to initialize planner: {e}") | |
| return | |
| prompt = "Create a contact form with a name input, email input, and a blue submit button." | |
| print(f"\nTesting Prompt: '{prompt}'") | |
| try: | |
| # Mock an empty existing workspace context | |
| context = json.dumps({"blocks": [], "connections": []}) | |
| workspace = planner.generate_blocks(prompt, current_workspace=context) | |
| print("\nGenerated Workspace JSON (saving to verification_result.json)...") | |
| with open('verification_result.json', 'w', encoding='utf-8') as f: | |
| json.dump(workspace, f, indent=2) | |
| print("\nVerifying Connections...") | |
| blocks = {b['id']: b for b in workspace['blocks']} | |
| connections = workspace['connections'] | |
| # Check for specific blocks | |
| has_form = any(b['type'] == 'form' for b in blocks.values()) | |
| has_button = any(b['type'] == 'html_button' for b in blocks.values()) | |
| has_tailwind = any(b['type'] == 'html_attr_class' for b in blocks.values()) | |
| print(f"- Has Form: {has_form}") | |
| print(f"- Has Button: {has_button}") | |
| print(f"- Has Tailwind: {has_tailwind}") | |
| # Check basic hierarchy | |
| # e.g. root -> body -> ... | |
| root = next((b for b in blocks.values() if b['type'] == 'html_html'), None) | |
| if root: | |
| print("- Root block found.") | |
| # Check if anything connects to root.CONTENT | |
| root_connected = any(c[0] == f"{root['id']}.CONTENT" for c in connections) | |
| print(f"- Root content connected: {root_connected}") | |
| else: | |
| print("- CRITICAL: No root html_html block found.") | |
| except Exception as e: | |
| print(f"Generation failed: {e}") | |
| if __name__ == "__main__": | |
| test_generation() | |