Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
pipeline = pipeline(task="text-generation", model="HiTZ/Mistral-7B-MedExpQA-EN")
|
5 |
+
|
6 |
+
@app.get("/generate")
|
7 |
+
def generate(text: str):
|
8 |
+
"""
|
9 |
+
Using the text-generation pipeline from `transformers`, generate text
|
10 |
+
from the given input text. The base model is Mistral7b.
|
11 |
+
"""
|
12 |
+
output = pipeline(text)
|
13 |
+
return {"output": output[0]["generated_text"]}
|
14 |
+
|
15 |
+
gradio_app = gr.Interface(fn=generate, inputs="text", outputs="text")
|
16 |
+
|
17 |
+
#demo.launch()
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
gradio_app.launch()
|