Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Waiting to run
Test / Core Tests (push) Waiting to run
Test / Offline Coverage Tests (Python 3.10) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.11) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.12) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.13) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.9) (push) Waiting to run
Test / Full Coverage (Python 3.11) (push) Waiting to run
Test / Core Provider Tests (OpenAI) (push) Blocked by required conditions
Test / Core Provider Tests (Anthropic) (push) Blocked by required conditions
Test / Core Provider Tests (Google) (push) Blocked by required conditions
Test / Core Provider Tests (Other) (push) Blocked by required conditions
Test / Anthropic Tests (push) Blocked by required conditions
Test / Gemini Tests (push) Blocked by required conditions
Test / Google GenAI Tests (push) Blocked by required conditions
Test / Vertex AI Tests (push) Blocked by required conditions
Test / OpenAI Tests (push) Blocked by required conditions
Test / Writer Tests (push) Blocked by required conditions
Test / Auto Client Tests (push) Blocked by required conditions
ty / type-check (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00
..

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:

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.