chatbot / app.py
RodriiS's picture
Update app.py
bf841e7 verified
raw
history blame contribute delete
547 Bytes
from transformers import pipeline
import gradio as gr
# Carrega Falcon 7B Instruct
chat = pipeline("text-generation", model="tiiuae/falcon-7b-instruct", device_map="auto")
def responder(msg):
prompt = f"Você é um assistente útil que responde em português.\nUsuário: {msg}\nAssistente:"
resposta = chat(prompt, max_new_tokens=200, temperature=0.7, top_p=0.9)[0]['generated_text']
# Remove o prompt da saída
return resposta.split("Assistente:")[-1].strip()
gr.Interface(fn=responder, inputs="text", outputs="text").launch()