Spaces:
Runtime error
Runtime error
metesttest001
commited on
Commit
•
60d9507
1
Parent(s):
a490c95
Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Carregando o modelo de chatbot do Hugging Face
|
5 |
+
model = pipeline("text-chat", device=0)
|
6 |
+
|
7 |
+
def chatbot_conversation(input_text):
|
8 |
+
# Resposta do chatbot
|
9 |
+
response = model(input_text)[0]['generated_text']
|
10 |
+
return response
|
11 |
+
|
12 |
+
# Interface do Gradio
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=chatbot_conversation,
|
15 |
+
inputs=gr.Textbox(lines=2, label="Pergunta"),
|
16 |
+
outputs=gr.Textbox(label="Resposta"),
|
17 |
+
title="Chatbot Simples",
|
18 |
+
description="Converse com o chatbot!"
|
19 |
+
)
|
20 |
+
|
21 |
+
# Executando a interface
|
22 |
+
iface.launch()
|