GemmaLLM / app.py
MohamedSaeed-dev's picture
Upload 3 files
362b7c9 verified
raw
history blame
468 Bytes
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!"}