test2 / app.py
sbthesis's picture
Update app.py
412347c
raw
history blame
922 Bytes
from transformers import pipeline
import torch
import gradio as gr #this is in place of the streamlit of the HF video
title = "Saras second try at ChatBot"
description = "Based on a zero-shot-classification model (default facebook/bart-large-mnli)"
examples = [["The president was elected last week then convicted of ten crimes and imprisoned, though he was paid $10,000 for his trouble"]]
classifier = pipeline("zero-shot-classification")
#heres the prediction function tp predict the response and add it to history
def predict(input):
# generate a response
response = classifier(
input,
candidate_labels=["education", "politics", "business","law"],
)
return response
gr.Interface(
fn=predict,
title=title,
description=description,
examples=examples,
inputs=["text", "state"],
outputs=["text", "state"],
theme="finlaymacklon/boxy_violet",
).launch()