sbthesis commited on
Commit
857c438
·
1 Parent(s): cc5f086

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -1,8 +1,33 @@
1
  from transformers import pipeline
2
  import torch
 
 
 
 
 
3
 
4
  classifier = pipeline("zero-shot-classification")
5
- classifier(
6
- "This is a course about the Transformers library",
7
- candidate_labels=["education", "politics", "business"],
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
+