97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
35 lines
818 B
Markdown
35 lines
818 B
Markdown
# FastAPI Code Generator
|
|
|
|
## Overview
|
|
|
|
Generates FastAPI application code from API path, task name, JSON schema path, and Jinja2 prompt template. Also creates a `models.py` file for Pydantic models.
|
|
|
|
## Dependencies
|
|
|
|
- FastAPI
|
|
- Pydantic
|
|
- Jinja2
|
|
- datamodel-code-generator
|
|
|
|
## Functions
|
|
|
|
### `create_app(api_path: str, task_name: str, json_schema_path: str, prompt_template: str) -> str`
|
|
|
|
Main function to generate FastAPI application code.
|
|
|
|
## Usage
|
|
|
|
Run the script with required parameters.
|
|
|
|
Example:
|
|
|
|
```python
|
|
fastapi_code = create_app(
|
|
api_path="/api/v1/extract_person",
|
|
task_name="extract_person",
|
|
json_schema_path="./input.json",
|
|
prompt_template="Extract the person from the following: {{biography}}",
|
|
)
|
|
```
|
|
|
|
Outputs FastAPI application code to `./run.py` and a Pydantic model to `./models.py`. |