An end-to-end project to generate, test, and optimize Python code for algorithms, data structures, and application boilerplates using the Euri AI Python SDK.
- Speed up building correct, well-tested Python code with AI assistance
- Focus on DSA (Data Structures & Algorithms) and extensible specs for new topics
- Enforce quality with tests, formatting, linting, typing, and benchmarks
- Provide a clean CLI and modular architecture you can extend
- List available DSA topics with precise requirements
- Generate Python modules and unit tests via Euri AI
- Optimize/refactor code for readability, performance, and memory
- Explain generated code and reasoning
- Run tests and optional micro-benchmarks
src/euri_codegen/cli.py
– Typer CLI entrypointsrc/euri_codegen/config.py
– Config, env, model defaultssrc/euri_codegen/euri_client.py
– Thin wrapper around Euri AI clientsrc/euri_codegen/codegen/generator.py
– LLM prompts and code generationsrc/euri_codegen/codegen/optimizer.py
– LLM + tooling optimizationssrc/euri_codegen/catalog/dsa_catalog.json
– Curated DSA specssrc/euri_codegen/prompts/
– Prompt templates (generation, optimization, explain)generated/
– Output folder (modules, tests)
- Python 3.10+ recommended.
- Create a virtual environment and install the package (editable) + deps:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e .[dev]
- Configure your Euri API key securely. Prefer environment variables:
- PowerShell (current session):
$env:EURI_API_KEY = "<your-key>"
- Or create a local
.env
file (not committed):
EURI_API_KEY=<your-key>
Optionally choose a default model via env:
EURI_MODEL=gpt-4.1-nano
List topics:
python -m euri_codegen list-topics
Generate a topic implementation (module + tests):
python -m euri_codegen generate --topic binary_search --out-dir generated
List all topics:
python -m euri_codegen list-topics
Run tests:
pytest -q
Optimize a file for performance and readability:
python -m euri_codegen optimize --path generated/binary_search.py --level all
Explain a file:
python -m euri_codegen explain --path generated/binary_search.py
Start the web UI:
streamlit run app.py
Features in UI:
- Generate one or all topics (module + tests) to the
generated/
folder - Optimize a Python file with code-fence sanitation
- Explain a Python file
- View and validate the DSA catalog
- Environment doctor panel
- Push this repo to GitHub (already done).
- In Streamlit Cloud, set Secrets with at least:
EURI_API_KEY = "your-euri-api-key"
EURI_MODEL = "gpt-4.1-nano"
- Deploy with main module:
app.py
. The app reads the key from secrets or environment. - Note: The UI will not ask for API keys. Keys must be configured on the backend (secrets/env) so shared users can use the app without seeing or entering them.
- Never commit your API key. Use environment variables or
.env
in local dev only. - This project will not print your key. It reads from
EURI_API_KEY
.
Add or edit specs in src/euri_codegen/catalog/dsa_catalog.json
. Each spec includes:
id
,title
,summary
function_signature
,inputs
,outputs
,constraints
examples
- Typer + Rich: ergonomic CLI & output
- Pydantic: robust config validation
- pytest + pytest-benchmark: correctness and perf checks
- black + ruff + mypy: readable, consistent, safe code
- Euri AI SDK: single integration point, easy model swaps
- Clean package layout under
src/
with explicit entry points and small modules - Prompt templates centralized in
src/euri_codegen/prompts/templates.py
- Catalog-driven generation using JSON specs in
src/euri_codegen/catalog/dsa_catalog.json
- CLI subcommands in
src/euri_codegen/cli.py
callinggenerator.py
andoptimizer.py
- Euri AI SDK wrapped by
src/euri_codegen/euri_client.py
for stable I/O
- Separation of concerns keeps prompts, SDK calls, and CLI logic independent
- JSON specs allow easy extension without changing code
- Tests ensure generated code remains correct and improvements don’t regress
- Optional dev tooling improves maintainability for long-term use
- If generation fails, ensure
EURI_API_KEY
is set and network access is available. - Use
python -m euri_codegen doctor
to run environment checks. - For large generations, increase
--max-tokens
.
You own your generated code. Dependencies follow their respective licenses.