Spaces:
Runtime error
Runtime error
refactor(app): add multiple generation method
Browse files
app.py
CHANGED
@@ -37,4 +37,12 @@ def generate(text: str):
|
|
37 |
output = pipe(text)
|
38 |
|
39 |
# Return the generated text in a JSON response
|
40 |
-
return {"output": output[0]["generated_text"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
output = pipe(text)
|
38 |
|
39 |
# Return the generated text in a JSON response
|
40 |
+
return {"output": output[0]["generated_text"]}
|
41 |
+
|
42 |
+
@app.get("/generates")
|
43 |
+
def generate(topic: str,question:str,context:str,n: int):
|
44 |
+
text = "Tópico: {} Questão: {} Context: {}".format(topic,question,context)
|
45 |
+
output = pipe(text,num_return_sequences=n,num_beams=n)
|
46 |
+
|
47 |
+
# Return the generated text in a JSON response
|
48 |
+
return {"output": [output[i]["generated_text"] for i in range(len(output))]}
|