from fastapi import FastAPI from transformers import pipeline app = FastAPI() pipe = pipeline("text-generation", model="MohamedSaeed-dev/gemma-2b-1500steps") @app.post("/generate/") async def generate_text(text:str): messages = [ {"role": "user", "content": text}, ] output = pipe(messages) return {"output": output[0]["generated_text"]} @app.get("/") async def root(): return {"message": "Welcome to the LLM API!"}