Skip to content

Instantly share code, notes, and snippets.

@4OH4
Created January 24, 2021 14:40
Show Gist options
  • Save 4OH4/b0ac2645efe6bc396f402de35180de01 to your computer and use it in GitHub Desktop.
Save 4OH4/b0ac2645efe6bc396f402de35180de01 to your computer and use it in GitHub Desktop.
Output class that defines the fields and data types of the API response
from pydantic import BaseModel, Field
class MessageOutput(BaseModel):
message1: str = Field(..., title="Greeting")
message2: str = Field(..., title="Calculation result")
n: int = Field(..., title="n: a large integer")
largest_prime_factor: int = Field(..., title="Largest prime factor of n")
elapsed_time: float = Field(..., title="Calculation time (seconds)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment