Spaces:
Running
Running
from fastapi import FastAPI | |
from huggingface_hub import InferenceClient | |
import os | |
app = FastAPI() | |
MODEL_NAME = "flax-community/t5-recipe-generation" | |
client = InferenceClient(model=MODEL_NAME, token=os.getenv('API_KEY')) | |
def generate_recipe(ingredients: str): | |
""" | |
Generate a recipe from ingredients. | |
:param ingredients: A comma-separated list of ingredients. | |
:return: AI-generated recipe text. | |
""" | |
prompt = f"recipe: {ingredients}" | |
# Query the Hugging Face Inference API | |
response = client.text_generation(prompt, max_new_tokens=100) | |
return {"ingredients": ingredients, "recipe": response} | |
def greet_json(): | |
return {"Hello": "World!"} | |