hollywoodfrancis commited on
Commit
1112483
·
verified ·
1 Parent(s): 70484fc

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +13 -0
main.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from transformers import pipeline
3
+
4
+ app = FastAPI()
5
+
6
+ # Load your model
7
+ model_name = "your-username/your-model-name"
8
+ qa_pipeline = pipeline("text-generation", model=model_name)
9
+
10
+ @app.post("/ask")
11
+ def ask(question: str):
12
+ response = qa_pipeline(question, max_length=100)
13
+ return {"answer": response[0]["generated_text"]}