Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,33 @@
|
|
1 |
from transformers import pipeline
|
2 |
import torch
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
classifier = pipeline("zero-shot-classification")
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import torch
|
3 |
+
import gradio as gr #this is in place of the streamlit of the HF video
|
4 |
+
|
5 |
+
title = "Saras second try at ChatBot"
|
6 |
+
description = "Based on a zero-shot-classification model (default facebook/bart-large-mnli)"
|
7 |
+
|
8 |
|
9 |
classifier = pipeline("zero-shot-classification")
|
10 |
+
|
11 |
+
#heres the prediction function tp predict the response and add it to history
|
12 |
+
def predict(input, history=[]):
|
13 |
+
# generate a response
|
14 |
+
response = classifier(
|
15 |
+
input,
|
16 |
+
candidate_labels=["education", "politics", "business"],
|
17 |
+
)
|
18 |
+
return response
|
19 |
+
|
20 |
+
|
21 |
+
gr.Interface(
|
22 |
+
fn=predict,
|
23 |
+
title=title,
|
24 |
+
description=description,
|
25 |
+
inputs=["text", "state"],
|
26 |
+
outputs=["chatbot", "state"],
|
27 |
+
theme="finlaymacklon/boxy_violet",
|
28 |
+
).launch()
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
|