trescha-chatbot / app.py
deniandriancode's picture
initial commit
40a6fd6
raw
history blame
558 Bytes
import gradio as gr
from transformers import pipeline, Conversation
chatbot = pipeline("conversational", model="facebook/blenderbot-400M-distill")
converse = None
def model_generate(text, state = None):
if state == None:
converse = Conversation(text)
else:
converse.add_user_input(text)
converse = chatbot(converse)
return converse.generated_responses[-1]
def get_response(text, history) -> str:
output = model_generate(text, converse)
return output
interface = gr.ChatInterface(get_response)
interface.launch()