dfinel commited on
Commit
4bdcdfd
1 Parent(s): 1e7e1bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -15,13 +15,12 @@ import asyncio
15
 
16
  os.environ["OPENAI_API_KEY"] = "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"
17
 
18
- app = Flask(__name__)
19
 
20
  nlp = spacy.load('spacy_model')
21
  sentiment_pipeline = pipeline("sentiment-analysis", model='my_sentiment_model')
22
  classifier = pipeline(task="zero-shot-classification", model="my_zero_shot")
23
 
24
- product_url = 'https://www.amazon.co.uk/product-reviews/B0B21DW5DL/ref=cm_cr_arp_d_viewopt_sr?ie=UTF8&reviewerType=all_review'
25
  custom_headers = {
26
  # Eliminating non-english reviews
27
  "Accept-language": "en;q=1.0",
@@ -233,7 +232,6 @@ Feel free to put many feed lines
233
  """
234
  llm = OpenAI(temperature = temperature, max_tokens = 1000)
235
  generated_text = llm(text)
236
- #return generated_text.strip().replace('\n',' ')
237
  return generated_text.strip()
238
 
239
 
@@ -256,11 +254,11 @@ def get_reviews(url):
256
 
257
  #print(get_reviews(url))
258
 
259
- if __name__ == '__main__':
260
- asyncio.set_event_loop(asyncio.new_event_loop())
261
- interface = gr.Interface(fn=get_reviews, inputs=gr.Textbox(), outputs=[gr.Textbox(label = 'Real ratings'),gr.Textbox(label = 'Actionable insights')], title='The Topic Magnet',
262
- description='Enter the url of your Amazon reviews to get real ratings and valuable insights')
263
- interface.launch()
264
  #app.run(host = '0.0.0.0', debug = True, port = 5000)
265
 
266
 
 
15
 
16
  os.environ["OPENAI_API_KEY"] = "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"
17
 
 
18
 
19
  nlp = spacy.load('spacy_model')
20
  sentiment_pipeline = pipeline("sentiment-analysis", model='my_sentiment_model')
21
  classifier = pipeline(task="zero-shot-classification", model="my_zero_shot")
22
 
23
+
24
  custom_headers = {
25
  # Eliminating non-english reviews
26
  "Accept-language": "en;q=1.0",
 
232
  """
233
  llm = OpenAI(temperature = temperature, max_tokens = 1000)
234
  generated_text = llm(text)
 
235
  return generated_text.strip()
236
 
237
 
 
254
 
255
  #print(get_reviews(url))
256
 
257
+
258
+ asyncio.set_event_loop(asyncio.new_event_loop())
259
+ interface = gr.Interface(fn=get_reviews, inputs=gr.Textbox(), outputs=[gr.Textbox(label = 'Real ratings'),gr.Textbox(label = 'Actionable insights')], title='The Topic Magnet',
260
+ description='Enter the url of your Amazon reviews to get real ratings and valuable insights')
261
+ interface.launch()
262
  #app.run(host = '0.0.0.0', debug = True, port = 5000)
263
 
264