Spaces:
No application file
No application file
| from fastapi import FastApi | |
| from transformers import pipeline | |
| #create fastapi instance | |
| app = FastApi() | |
| #initilize the text pipeline | |
| # Use a pipeline as a high-level helper | |
| pipe = pipeline("text2text-generation", model="google/flan-t5-small") | |
| def home(): | |
| return {"retuen mess : hello world"} | |
| #defin function get handle the get requests | |
| def generate(text:str): | |
| #using the pipeline | |
| output = pipe(text) | |
| ##retuen the text in json | |
| return{"output":output[0]["generate_text"]} | |