Jofthomas HF staff commited on
Commit
d446780
1 Parent(s): dc47da3

app changes

Browse files
Files changed (1) hide show
  1. app.py +42 -44
app.py CHANGED
@@ -28,50 +28,6 @@ llm = HuggingFaceHub(huggingfacehub_api_token=HUGGINGFACEHUB_API_TOKEN,
28
 
29
  class Sentiment(BaseModel):
30
  label: str = Field(description="Is a the above rview sentiment 'Good', or 'Bad' ?")
31
-
32
-
33
-
34
-
35
- def sentence_builder(Model,Text):
36
- if Model=="Sentiment analysis pipeline":
37
- good_label,bad_label=pipeline_sentiment(Text)
38
- if Model=="Falcon-7b-instruct":
39
- good_label,bad_label=falcon_sentiment(Text)
40
- if Model=="GPT-4 Function call":
41
- good_label,bad_label=gpt4_sentiment(Text)
42
-
43
- print({"Good": good_label, "Bad": bad_label})
44
- return {"Good": good_label, "Bad": bad_label}
45
-
46
-
47
- demo = gr.Interface(
48
- sentence_builder,
49
- [
50
-
51
- gr.Dropdown(
52
- ["Sentiment analysis pipeline","Falcon-7b-instruct","GPT-4 Function call"], label="Model", info="Wich model to use"
53
- ),
54
- gr.Textbox(
55
- label="Text",
56
- info="Review text",
57
- lines=2,
58
- value="I'm not sure about the origin of this product, it seems suspicious.",
59
- ),
60
-
61
- ],
62
- "label",
63
- examples=[
64
-
65
- ["Sentiment analysis pipeline","The product broke ! Great ..."],
66
- ["Sentiment analysis pipeline","Not sure if I like it or not."],
67
- ["Sentiment analysis pipeline","This product is just a toy."],
68
- ["Sentiment analysis pipeline","Bought a TV, received an Ipad..."],
69
- ["Sentiment analysis pipeline","Could have found the same on wish.com ."],
70
- ["Sentiment analysis pipeline","They did a wonderfull job at ripping us."],
71
- ["Sentiment analysis pipeline","Is it dropshipping ?"],
72
- ]
73
- )
74
-
75
  def pipeline_sentiment(text):
76
  out = classifier(text)
77
  print(out)
@@ -154,6 +110,48 @@ def Find_sentiment(sentence):
154
  def gpt4_sentiment(text):
155
  out=Find_sentiment(text)
156
  return out=="Good",out=='Bad'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  if __name__ == "__main__":
158
 
159
  demo.launch()
 
28
 
29
  class Sentiment(BaseModel):
30
  label: str = Field(description="Is a the above rview sentiment 'Good', or 'Bad' ?")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  def pipeline_sentiment(text):
32
  out = classifier(text)
33
  print(out)
 
110
  def gpt4_sentiment(text):
111
  out=Find_sentiment(text)
112
  return out=="Good",out=='Bad'
113
+
114
+
115
+
116
+ def sentence_builder(Model,Text):
117
+ if Model=="Sentiment analysis pipeline":
118
+ good_label,bad_label=pipeline_sentiment(Text)
119
+ if Model=="Falcon-7b-instruct":
120
+ good_label,bad_label=falcon_sentiment(Text)
121
+ if Model=="GPT-4 Function call":
122
+ good_label,bad_label=gpt4_sentiment(Text)
123
+
124
+ print({"Good": good_label, "Bad": bad_label})
125
+ return {"Good": good_label, "Bad": bad_label}
126
+
127
+
128
+ demo = gr.Interface(
129
+ sentence_builder,
130
+ [
131
+
132
+ gr.Dropdown(
133
+ ["Sentiment analysis pipeline","Falcon-7b-instruct","GPT-4 Function call"], label="Model", info="Wich model to use"
134
+ ),
135
+ gr.Textbox(
136
+ label="Text",
137
+ info="Review text",
138
+ lines=2,
139
+ value="I'm not sure about the origin of this product, it seems suspicious.",
140
+ ),
141
+
142
+ ],
143
+ "label",
144
+ examples=[
145
+
146
+ ["Sentiment analysis pipeline","The product broke ! Great ..."],
147
+ ["Sentiment analysis pipeline","Not sure if I like it or not."],
148
+ ["Sentiment analysis pipeline","This product is just a toy."],
149
+ ["Sentiment analysis pipeline","Bought a TV, received an Ipad..."],
150
+ ["Sentiment analysis pipeline","Could have found the same on wish.com ."],
151
+ ["Sentiment analysis pipeline","They did a wonderfull job at ripping us."],
152
+ ["Sentiment analysis pipeline","Is it dropshipping ?"],
153
+ ]
154
+ )
155
  if __name__ == "__main__":
156
 
157
  demo.launch()