hollywoodfrancis
commited on
Create main.py
Browse files
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"]}
|