Download GETTING_STARTED.md from 2008robocode-crypto/code-generation-system: direct link, hf CLI and curl.
- Browser
- Download file 7.62 kB
-
https://huggingface.co/spaces/2008robocode-crypto/code-generation-system/resolve/main/GETTING_STARTED.md
- Command line
-
hf download hf://spaces/2008robocode-crypto/code-generation-system/GETTING_STARTED.md
-
curl -L -o GETTING_STARTED.md https://huggingface.co/spaces/2008robocode-crypto/code-generation-system/resolve/main/GETTING_STARTED.md
Getting Started Guide
Quick Start (5 minutes)
1. Install Dependencies
cd "ai intern project"
pip install -r requirements.txt
2. Run Demo
python quickstart.py
You should see output like:
π€ AI PLATFORM ENGINEER - CODE GENERATION SYSTEM
β Generation Status: success
β Executable: YES β
β Database Tables: 3
β API Endpoints: 15
3. Try the Web Interface
python web/app.py
Open your browser: http://localhost:5000
- Enter a prompt in the input box
- Click "Generate Configuration"
- See the JSON output with validation report
Installation Details
Requirements
- Python 3.8+
- pip (Python package manager)
Step-by-Step Setup
1. Create Virtual Environment (Optional but Recommended)
# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activate
2. Install Dependencies
pip install -r requirements.txt
This installs:
flask- Web frameworkflask-cors- Cross-origin supportanthropic- LLM API (optional)python-dotenv- Environment variables
3. (Optional) Set Up Anthropic API
For LLM-powered generation (optional):
# Windows
set ANTHROPIC_API_KEY=your-key-here
# Linux/Mac
export ANTHROPIC_API_KEY=your-key-here
Or create .env file:
ANTHROPIC_API_KEY=your-key-here
Usage Modes
Mode 1: Quick Start Demo
Generate 3 example configurations:
python quickstart.py
Output: Demonstrates pipeline stages and validation
Mode 2: Web Interface
Interactive UI for generation:
python web/app.py
Features:
- Enter natural language prompts
- Real-time JSON output
- Validation reports
- Example generation
Access: http://localhost:5000
Mode 3: Evaluation Framework
Run comprehensive tests (20 prompts):
python run_evaluation.py
Output:
- Success rates (100% in current version)
- Performance metrics
- Cost analysis
- JSON report saved to
evaluation_report_*.json
Mode 4: Python Library
Use the system programmatically:
from src.pipeline import Pipeline
from src.runtime_simulator import validate_config_executable
# Initialize
pipeline = Pipeline(use_llm=False) # Rule-based
# pipeline = Pipeline(use_llm=True) # LLM-based (requires API key)
# Generate
prompt = "Build a CRM with login, contacts, dashboard"
config, exec_log = pipeline.generate(prompt)
# Validate
is_executable, report = validate_config_executable(config)
print(f"Success: {exec_log['final_status']}")
print(f"Executable: {is_executable}")
Project Structure
ai intern project/
βββ src/
β βββ schemas.py # Data structures
β βββ pipeline.py # Main 4-stage pipeline
β βββ validator.py # Validation engine
β βββ repair_engine.py # Repair system
β βββ runtime_simulator.py # Executability checks
β
βββ web/
β βββ app.py # Flask API server
β βββ templates/
β β βββ index.html # Web interface
β βββ static/ # Assets (CSS, JS)
β
βββ evaluation/
β βββ test_dataset.py # 20 test prompts
β βββ evaluator.py # Evaluation framework
β
βββ quickstart.py # Demo script
βββ run_evaluation.py # Evaluation runner
βββ requirements.txt # Dependencies
βββ README.md # Main documentation
βββ ARCHITECTURE.md # System design
βββ API.md # API documentation
βββ GETTING_STARTED.md # This file
Common Tasks
Generate a Configuration
Option 1: Via Web UI
- Open http://localhost:5000
- Enter your prompt
- Click "Generate"
- See JSON output
Option 2: Via API
curl -X POST http://localhost:5000/api/generate \
-H "Content-Type: application/json" \
-d '{"prompt":"Build a todo app"}'
Option 3: Via Python
from src.pipeline import Pipeline
pipeline = Pipeline()
config, log = pipeline.generate("Build a todo app")
Check System Status
# Web interface
curl http://localhost:5000/api/health
# Quick demo
python quickstart.py
# Full evaluation
python run_evaluation.py
Customize the System
Edit intent extraction patterns: src/pipeline.py β IntentExtractor
Add new validation rules: src/validator.py β Validator
Modify repair logic: src/repair_engine.py β RepairEngine
Add test prompts: evaluation/test_dataset.py β TEST_PROMPTS
Troubleshooting
Issue: Module not found error
ModuleNotFoundError: No module named 'flask'
Solution:
pip install -r requirements.txt
Issue: Port 5000 already in use
Address already in use
Solution:
# Option 1: Kill the process using port 5000
# Windows
netstat -ano | findstr :5000
taskkill /PID <PID> /F
# Option 2: Use different port in app.py
app.run(port=5001)
Issue: Anthropic API errors
Error: Invalid API key
Solution:
- Check your API key is valid
- Verify it's set in environment:
echo $ANTHROPIC_API_KEY - System will fall back to rule-based generation automatically
Issue: Slow generation
Generation should take <1 second per stage.
Debug:
from src.pipeline import Pipeline
import time
pipeline = Pipeline(use_llm=False) # Use fast rule-based
start = time.time()
config, log = pipeline.generate("Your prompt")
print(f"Took {time.time() - start:.2f}s")
Performance Optimization
For Speed
pipeline = Pipeline(use_llm=False) # Rule-based (fastest)
For Quality
pipeline = Pipeline(use_llm=True) # LLM-based (slower, better quality)
For Cost
- Use rule-based generation
- Cache common patterns
- Batch requests
Next Steps
- Understand the Pipeline: Read
ARCHITECTURE.md - Explore the API: Check
API.md - Run Evaluation: Execute
python run_evaluation.py - Deploy Locally: Start
python web/app.py - Customize: Modify
src/pipeline.pyfor your needs
Learning Resources
- Architecture Deep Dive: See
ARCHITECTURE.md - API Reference: See
API.md - Code Examples: See
quickstart.pyandrun_evaluation.py - System Design: Read comments in
src/pipeline.py
Support
Debug Output
Enable detailed logging:
import logging
logging.basicConfig(level=logging.DEBUG)
pipeline = Pipeline(use_llm=False)
config, log = pipeline.generate("Your prompt")
print("Execution log:")
for stage, details in log["stages"].items():
print(f" {stage}: {details}")
Common Questions
Q: What's the success rate?
A: 100% on all 20 test cases (10 real + 10 edge). See run_evaluation.py.
Q: Can I use this in production?
A: Yes, with monitoring. See API.md for deployment considerations.
Q: How do I extend it? A: Add validators, repair logic, and LLM providers. See source code.
Q: Is it free? A: Rule-based: Yes. LLM-based: ~$0.01-0.02 per generation with Anthropic.
Deployment
Local Development
python web/app.py
# Runs on http://localhost:5000
Production Deployment
With Gunicorn:
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:8000 web.app
With Docker:
FROM python:3.9
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "web/app.py"]
Happy generating! π