from fastapi import FastAPI from transformers import pipeline app = FastAPI() # Load your model model_name = "your-username/your-model-name" qa_pipeline = pipeline("text-generation", model=model_name) @app.post("/ask") def ask(question: str): response = qa_pipeline(question, max_length=100) return {"answer": response[0]["generated_text"]}