Spaces:
Configuration error
Configuration error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from pydantic import BaseModel
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
app = FastAPI()
|
6 |
+
|
7 |
+
generator = pipeline("text2text-generation", model="memorease/memorease-quizgen")
|
8 |
+
|
9 |
+
class Memory(BaseModel):
|
10 |
+
description: str
|
11 |
+
|
12 |
+
@app.post("/generate")
|
13 |
+
def generate(memory: Memory):
|
14 |
+
prompt = f"Soru üret: {memory.description}"
|
15 |
+
result = generator(prompt, max_length=64, do_sample=False)
|
16 |
+
return {"question": result[0]["generated_text"]}
|