hra commited on
Commit
a0a3021
1 Parent(s): 6b6f1c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -23,12 +23,13 @@ from sec_edgar_downloader._utils import get_filing_urls_to_download
23
  listofcategories=["10-K", "10-Q","8-K"]
24
 
25
 
26
- def getstuff(openapikey,category_selector,ticker_input):
27
  dateforfilesave=datetime.today().strftime("%d-%m-%Y %I:%M%p")
28
  print(ticker_input)
 
29
  print(dateforfilesave)
30
  if openapikey=='':
31
- return pd.DataFrame(["Please provide OpenAPI Key"],columns=['ERROR']),pd.DataFrame(["Please provide OpenAPI Key"],columns=['ERROR']),'Error: Please provide OpenAPI key','Error: Please provide OpenAPI key'
32
 
33
  os.environ['OPENAI_API_KEY'] = str(openapikey)
34
 
@@ -41,7 +42,7 @@ def getstuff(openapikey,category_selector,ticker_input):
41
  else:
42
  num_filings_needed=1
43
  filings_temp=get_filing_urls_to_download(category_selector, ticker_input,num_filings_to_download=num_filings_needed,include_amends=False,before_date='2023-04-01',after_date='2022-01-01')
44
- files=[filings_temp[0].full_submission_url]
45
  print('Came here1')
46
  filetextcontentlist=[]
47
  for each in files:
@@ -95,7 +96,10 @@ def getstuff(openapikey,category_selector,ticker_input):
95
  index = GPTSimpleVectorIndex.from_documents(documents)
96
  print('Came here4')
97
  querylist=['What are the main products/ services mentioned?','What are the major risks?',"What are the top investment focus areas?","What is the financial outlook of the company?","What key technologies like AI, blockchain etc are mentioned?","What other company names/ competitors are mentioned?"]
98
-
 
 
 
99
 
100
 
101
  llm = ChatOpenAI(temperature=0)
@@ -146,6 +150,7 @@ with gr.Blocks() as demo:
146
  )
147
  input1 = gr.Textbox(placeholder='Enter ticker (USA only)', lines=1,label='Ticker')
148
  with gr.Column():
 
149
  textboxopenapi = gr.Textbox(placeholder="Enter OpenAPI Key...", lines=1,label='OpenAPI Key')
150
 
151
  with gr.Column():
@@ -167,7 +172,7 @@ with gr.Blocks() as demo:
167
  with gr.Column():
168
  output6 = gr.Textbox(placeholder='', lines=4,label='Snapshot 6')
169
 
170
- btn.click(getstuff, inputs=[textboxopenapi,category_selector,input1],outputs=[output1,output2,output3,output4,output5,output6])
171
 
172
 
173
  demo.launch(debug=True)
 
23
  listofcategories=["10-K", "10-Q","8-K"]
24
 
25
 
26
+ def getstuff(openapikey,category_selector,ticker_input,user_question):
27
  dateforfilesave=datetime.today().strftime("%d-%m-%Y %I:%M%p")
28
  print(ticker_input)
29
+ print(user_question)
30
  print(dateforfilesave)
31
  if openapikey=='':
32
+ return ["Please provide OpenAPI Key","Please provide OpenAPI Key","Please provide OpenAPI Key","Please provide OpenAPI Key","Please provide OpenAPI Key","Please provide OpenAPI Key",]
33
 
34
  os.environ['OPENAI_API_KEY'] = str(openapikey)
35
 
 
42
  else:
43
  num_filings_needed=1
44
  filings_temp=get_filing_urls_to_download(category_selector, ticker_input,num_filings_to_download=num_filings_needed,include_amends=False,before_date='2023-04-01',after_date='2022-01-01')
45
+ files=[filings_temp[i].full_submission_url for i in range(len(filings_temp))]
46
  print('Came here1')
47
  filetextcontentlist=[]
48
  for each in files:
 
96
  index = GPTSimpleVectorIndex.from_documents(documents)
97
  print('Came here4')
98
  querylist=['What are the main products/ services mentioned?','What are the major risks?',"What are the top investment focus areas?","What is the financial outlook of the company?","What key technologies like AI, blockchain etc are mentioned?","What other company names/ competitors are mentioned?"]
99
+ if user_question=='':
100
+ querylist.append('What is the key summary?')
101
+ else:
102
+ querylist.append(user_question)
103
 
104
 
105
  llm = ChatOpenAI(temperature=0)
 
150
  )
151
  input1 = gr.Textbox(placeholder='Enter ticker (USA only)', lines=1,label='Ticker')
152
  with gr.Column():
153
+ input2 = gr.Textbox(placeholder='Enter your question', lines=1,label='User Question')
154
  textboxopenapi = gr.Textbox(placeholder="Enter OpenAPI Key...", lines=1,label='OpenAPI Key')
155
 
156
  with gr.Column():
 
172
  with gr.Column():
173
  output6 = gr.Textbox(placeholder='', lines=4,label='Snapshot 6')
174
 
175
+ btn.click(getstuff, inputs=[textboxopenapi,category_selector,input1,input2],outputs=[output1,output2,output3,output4,output5,output6,input2])
176
 
177
 
178
  demo.launch(debug=True)