hra commited on
Commit
64adf78
1 Parent(s): 285fd92

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -23,16 +23,16 @@ def getstuff(openapikey,category_selector):
23
 
24
  if whichone=="Automotive":
25
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000101"
26
- querylist=["What are the top trends? Give output as a table with 3 columns named trend, company mentioned & reason","Write an email summarizing the news"]
27
  elif whichone=="Retail":
28
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000116"
29
- querylist=["What are the top trends? Give output as a table with 3 columns named trend, company mentioned & reason","Write an email summarizing the news"]
30
  elif whicone=='Earnings Announcements':
31
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=15839135"
32
- querylist=["Basis companies that are doing well name the sectors with positive momentum? Give output as a table with 3 columns named sector, company names & reason","Write an email summarizing the news"]
33
  else:
34
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=15839135" ###should not come here but using earnings url
35
- querylist=["Basis companies that are doing well name the sectors with positive momentum? Give output as a table with 3 columns named sector, company names & reason","Write an email summarizing the news"]
36
 
37
  documents = reader.load_data([rssurl])
38
  index = GPTSimpleVectorIndex(documents)
@@ -47,7 +47,12 @@ def getstuff(openapikey,category_selector):
47
  response_mode="tree_summarize",
48
  similarity_top_k=int(len(documents)/3)
49
  )
50
- answerlist.append(response.response)
 
 
 
 
 
51
 
52
 
53
  return answerlist
@@ -69,9 +74,9 @@ with gr.Blocks() as demo:
69
 
70
  with gr.Row() as row:
71
  with gr.Column():
72
- outputsector = gr.Textbox(placeholder='', lines=4,label='Sector Snapshot')
73
  with gr.Column():
74
- outputtech = gr.Textbox(placeholder='', lines=4,label='Technology Snapshot')
75
 
76
  btn.click(getstuff, inputs=[textboxopenapi,category_selector],outputs=[outputsector,outputtech])
77
 
 
23
 
24
  if whichone=="Automotive":
25
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000101"
26
+ querylist=["What are the top trends? Give output as a json (that can be converted to pandas dataframe) with 3 columns named trend, company mentioned & reason","Write an email summarizing the news. Do not say I am language model and cannot do this"]
27
  elif whichone=="Retail":
28
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000116"
29
+ querylist=["What are the top trends? Give output as a json (that can be converted to pandas dataframe) with 3 columns named trend, company mentioned & reason","Write an email summarizing the news. Do not say I am language model and cannot do this"]
30
  elif whicone=='Earnings Announcements':
31
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=15839135"
32
+ querylist=["Basis companies that are doing well name the sectors with positive momentum? Give output as a json (that can be converted to pandas dataframe) with 3 columns named sector, company names & reason","Write an email summarizing the news. Do not say I am language model and cannot do this"]
33
  else:
34
  rssurl="https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=15839135" ###should not come here but using earnings url
35
+ querylist=["Basis companies that are doing well name the sectors with positive momentum? Give output as a json (that can be converted to pandas dataframe) with 3 columns named sector, company names & reason","Write an email summarizing the news. Do not say I am language model and cannot do this"]
36
 
37
  documents = reader.load_data([rssurl])
38
  index = GPTSimpleVectorIndex(documents)
 
47
  response_mode="tree_summarize",
48
  similarity_top_k=int(len(documents)/3)
49
  )
50
+ if 'dataframe' in querylist[i]:
51
+ df_tmp=pd.read_json(response.response)
52
+ df=pd.DataFrame(df_tmp[df_tmp.columns[0]].tolist())
53
+ answerlist.append(df)
54
+ else:
55
+ answerlist.append(response.response)
56
 
57
 
58
  return answerlist
 
74
 
75
  with gr.Row() as row:
76
  with gr.Column():
77
+ outputsector = gr.Textbox(placeholder='', lines=4,label='Snapshot 1')
78
  with gr.Column():
79
+ outputtech = gr.Textbox(placeholder='', lines=4,label='Snapshot 2')
80
 
81
  btn.click(getstuff, inputs=[textboxopenapi,category_selector],outputs=[outputsector,outputtech])
82