A trivial version of a code generation API, built with FastAPI.
Refer to the documentation.
You can make POST requests to http://127.0.0.1:8000/api/v1/codegen/
to test the API locally.
Set the Content-Type
header to application/json
and pass in a JSON request body containing repoUrl
and prompt
fields, as shown in this example:
{
"repoUrl": "https://github.com/jayhack/llm.sh",
"prompt": "Add a comment in the readme with text 'Here is a self referential link.' linking to https://github.com/jayhack/llm.sh"
}
- Web framework FastAPI
- Production ASGI web server Uvicorn
- Interactive API documentation
- Environment variables file
.env
for the app configuration - Docker
docker-compose.yml
andDockerfile
to run the prodution server - Openapi generator openapi-generator-cli configured to generate clients
- Data validator Pydantic
- Unit test framework pytest
- Linter Flake8
- Code formatter Black
- Imports sorter isort
- Static type checker Mypy
Visual Studio Code is the recommended editor, please install the recommended extensions in .vscode/extensions.json
.
Install poetry.
Install dependencies:
poetry install
Start the development server with automatic reload:
poetry shell
dev
or
uvicorn app.main:app --reload
poetry shell
pytest
In openapi-generator
install the required packages:
npm install
Start the server then generate clients:
npm run generate
In the project root there is the docker-compose.yml
.
Run:
docker compose up -d --build
Stop:
docker compose down
poetry shell
uvicorn app.main:app