Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
-
import requests
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
response = query({
|
13 |
-
"inputs": question
|
14 |
-
})
|
15 |
-
generated_text = response[0]["generated_text"].strip()
|
16 |
-
return generated_text
|
17 |
-
|
18 |
-
iface = gr.Interface(
|
19 |
-
fn=chatbot,
|
20 |
-
inputs=gr.inputs.Textbox(),
|
21 |
-
outputs=gr.outputs.Textbox(),
|
22 |
-
live=True,
|
23 |
-
title="Chatbot de Vestibular",
|
24 |
-
description="Digite sua pergunta sobre vestibulares e receba respostas do nosso assistente de vestibular.",
|
25 |
-
)
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
def create_gradio_app(model, tokenizer):
|
4 |
+
def gradio_fn(question):
|
5 |
+
inputs = tokenizer(question, return_tensors="pt")
|
6 |
+
outputs = model(inputs)[0]
|
7 |
+
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
8 |
+
return generated_text
|
9 |
|
10 |
+
iface = gr.Interface(
|
11 |
+
fn=gradio_fn,
|
12 |
+
inputs=gr.inputs.Textbox(),
|
13 |
+
outputs=gr.outputs.Textbox(),
|
14 |
+
live=True,
|
15 |
+
title="Gradio App",
|
16 |
+
description="Create a gradio app using the Quokka-7b model.",
|
17 |
+
)
|
18 |
+
return iface
|
19 |
|
20 |
+
iface = create_gradio_app(model, tokenizer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
iface.launch()
|