INNER CODE UNIT · Python

convert_pydantic_model_to_google_schema

openfoodfacts/openfoodfacts-ai · category-detection/main.py:145

def convert_pydantic_model_to_google_schema(schema: type[BaseModel]) -> dict[str, Any]:
    """Google doesn't support natively OpenAPI schemas, so we convert them to
    Google `Schema` (a subset of OpenAPI)."""
    return GoogleSchema.from_json_schema(
        json_schema=GoogleJSONSchema.model_validate(schema.model_json_schema())
    ).model_dump(mode="json", exclude_none=True, exclude_unset=True)


@app.command()
def generate_dataset(
    parquet_path: Path,
    output_path: Path,
    country_filter: str | None = None,
    remove_duplicates_from_dataset: Path | None = None,
):
    """Generate a dataset file in JSONL format to be used for batch
    processing, using Gemini Batch Inference.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…