Jayeshbhaal commited on
Commit
9072761
1 Parent(s): 4252e62
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -14,6 +14,7 @@ newsapi = NewsApiClient(api_key=HF_TOKEN)
14
  classifier = pipeline(model="cardiffnlp/twitter-roberta-base-sentiment")
15
  today = str(date.today())
16
 
 
17
  print(f"HF_TOKEN is - {HF_TOKEN}")
18
 
19
  #times of india
@@ -64,11 +65,13 @@ def inference(newssource): #, date):
64
  url = [entry['url'] for entry in all_articles['articles']]
65
  urlToImage = [entry['urlToImage'] for entry in all_articles['articles']]
66
 
67
- print(f"description length is {len(description)}")
68
- print(f"content length is {len(content)}")
69
- print(f"url length is {len(url)}")
70
- print(f"urlToImage length is {len(urlToImage)}")
71
- print(f"sentiment length is {len(sentiment)}")
 
 
72
 
73
  dictnews = { 'description' : description, 'content' : content, 'url' : url, 'urlToImage' : urlToImage, 'sentiment' : sentiment,}
74
  #dictnews = { 'description' : [entry['description'] for entry in all_articles['articles']],
@@ -98,6 +101,6 @@ with gr.Blocks() as demo:
98
  out_dataframe = gr.Dataframe(wrap=True, datatype = ["str", "str", "markdown", "markdown", "str"])
99
 
100
  b1.click(fn=inference, inputs=in_newssource, outputs=[out_dataframe, out_news])
101
- b2.click(fn=inference, inputs=in_newssource, outputs=out_dataframe)
102
 
103
  demo.launch(debug=True, show_error=True)
 
14
  classifier = pipeline(model="cardiffnlp/twitter-roberta-base-sentiment")
15
  today = str(date.today())
16
 
17
+ print("******** Outside Inference function ********")
18
  print(f"HF_TOKEN is - {HF_TOKEN}")
19
 
20
  #times of india
 
65
  url = [entry['url'] for entry in all_articles['articles']]
66
  urlToImage = [entry['urlToImage'] for entry in all_articles['articles']]
67
 
68
+ print("********************************************************")
69
+ print(f"Newssource is - {newssource}")
70
+ print(f"description length is - {len(description)}")
71
+ print(f"content length is - {len(content)}")
72
+ print(f"url length is - {len(url)}")
73
+ print(f"urlToImage length is - {len(urlToImage)}")
74
+ print(f"sentiment length is - {len(sentiment)}")
75
 
76
  dictnews = { 'description' : description, 'content' : content, 'url' : url, 'urlToImage' : urlToImage, 'sentiment' : sentiment,}
77
  #dictnews = { 'description' : [entry['description'] for entry in all_articles['articles']],
 
101
  out_dataframe = gr.Dataframe(wrap=True, datatype = ["str", "str", "markdown", "markdown", "str"])
102
 
103
  b1.click(fn=inference, inputs=in_newssource, outputs=[out_dataframe, out_news])
104
+ b2.click(fn=inference, inputs=in_newssource, outputs=[out_dataframe, out_news])
105
 
106
  demo.launch(debug=True, show_error=True)