text-generation / app.py
AnishKumbhar's picture
Update app.py
3d04546
raw
history blame contribute delete
No virus
1.4 kB
from fastapi import FastAPI
from transformers import pipeline
app = FastAPI(docs_url="/")
@app.get("/calculate-food")
def calculate_food_endpoint(activity: str, weight: int):
score = 0
if activity == "Typical" :
score = 110
elif activity == "Active" :
score = 125
elif activity == "Overweight" :
score = 70
elif activity == "Highly Active" :
score = 175
elif activity == "Senior, neutered, inactive" :
score = 90
elif activity == "Working Dog (light duty)" :
score = 130
elif activity == "Working Dog (moderate duty)" :
score = 150
elif activity == "Working Dog (heavy duty)" :
score = 175
else :
score = 110
return round( score / weight, 2)
"""
Calculates the recommended amount of dog food based on activity level and weight.
Args:
activity: The dog's activity level, as a number from 1 to 5.
weight: The dog's weight in kilograms.
Returns:
A JSON object containing the recommended amount of food in cups.
"""
# Check if the activity and weight parameters are present in the API request.
if activity is None or weight is None:
return {"error": "Please provide both activity level and weight."}
# Calculate the recommended amount of food.
result = calculate_food(activity, weight)
# Respond with the result as JSON.
return result