@@ -113,7 +113,6 @@ def getProfileAndBio(pibIndexName, cik, step, symbol, temperature, llm, today):
113
113
s1Data .append (sData )
114
114
mergeDocs (SearchService , SearchKey , pibIndexName , step1Biography )
115
115
return s1Data
116
-
117
116
def processStep1 (pibIndexName , cik , step , symbol , temperature , llm , today , reProcess ):
118
117
s1Data = []
119
118
@@ -234,7 +233,6 @@ def processStep1(pibIndexName, cik, step, symbol, temperature, llm, today, rePro
234
233
s1Data = getProfileAndBio (pibIndexName , cik , step , symbol , temperature , llm , today )
235
234
236
235
return s1Data
237
-
238
236
def getEarningCalls (totalYears , historicalYear , symbol , today ):
239
237
# Call the paid data (FMP) API
240
238
# Get the earning call transcripts for the last 3 years and merge documents into the index.
@@ -294,7 +292,6 @@ def getEarningCalls(totalYears, historicalYear, symbol, today):
294
292
return earningsData [- 1 ]
295
293
except Exception as e :
296
294
logging .error (f"Error occured while processing { symbol } : { e } " )
297
-
298
295
def getPressReleases (today , symbol ):
299
296
# For now we are calling API to get data, but otherwise we need to ensure the data is not persisted in our
300
297
# index repository before calling again, if it is persisted then we need to delete it first
@@ -323,7 +320,6 @@ def getPressReleases(today, symbol):
323
320
324
321
mergeDocs (SearchService , SearchKey , pressReleaseIndexName , pressReleasesList )
325
322
return pressReleasesList
326
-
327
323
# Helper function to find the answer to a question
328
324
def findAnswer (chainType , topK , symbol , quarter , year , question , indexName , embeddingModelType , llm ):
329
325
# Since we already index our document, we can perform the search on the query to retrieve "TopK" documents
@@ -397,7 +393,6 @@ def findAnswer(chainType, topK, symbol, quarter, year, question, indexName, embe
397
393
outputAnswer = answer ['output_text' ]
398
394
399
395
return outputAnswer
400
-
401
396
def summarizeTopic (llm , query , embeddingModelType , indexName , symbol ):
402
397
403
398
promptTemplate = """You are an AI assistant tasked with summarizing documents from
@@ -432,8 +427,7 @@ def summarizeTopic(llm, query, embeddingModelType, indexName, symbol):
432
427
map_prompt = customPrompt , combine_prompt = customPrompt )
433
428
summary = summaryChain ({"input_documents" : resultsDoc }, return_only_outputs = True )
434
429
outputAnswer = summary ['output_text' ]
435
- return outputAnswer
436
-
430
+ return outputAnswer
437
431
def processTopicSummary (llm , symbol , cik , step , pibSummaryIndex , embeddingModelType , selectedTopics ,
438
432
earningVectorIndexName , docType ):
439
433
topicSummary = []
@@ -466,7 +460,6 @@ def processTopicSummary(llm, symbol, cik, step, pibSummaryIndex, embeddingModelT
466
460
})
467
461
mergeDocs (SearchService , SearchKey , pibSummaryIndex , topicSummary )
468
462
return topicSummary
469
-
470
463
def processSecTopicSummary (llm , symbol , cik , step , pibSummaryIndex , embeddingModelType , selectedTopics ,
471
464
earningVectorIndexName , docType , secFilingList ):
472
465
topicSummary = []
@@ -521,7 +514,6 @@ def processSecTopicSummary(llm, symbol, cik, step, pibSummaryIndex, embeddingMod
521
514
})
522
515
mergeDocs (SearchService , SearchKey , pibSummaryIndex , topicSummary )
523
516
return topicSummary
524
-
525
517
def processStep2 (pibIndexName , cik , step , symbol , llm , today , embeddingModelType , totalYears ,
526
518
historicalYear , reProcess , selectedTopics ):
527
519
r = findPibData (SearchService , SearchKey , pibIndexName , cik , step , returnFields = ['id' , 'symbol' , 'cik' , 'step' , 'description' , 'insertedDate' ,
@@ -750,7 +742,6 @@ def processStep2(pibIndexName, cik, step, symbol, llm, today, embeddingModelType
750
742
content = df .iloc [0 ]['content' ]
751
743
752
744
return s2Data , content , latestCallDate
753
-
754
745
def summarizePressReleases (llm , docs ):
755
746
promptTemplate = """You are an AI assistant tasked with summarizing company's press releases and performing sentiments on those.
756
747
Your summary should accurately capture the key information in the press-releases while avoiding the omission of any domain-specific words.
@@ -767,7 +758,6 @@ def summarizePressReleases(llm, docs):
767
758
summary = summaryChain ({"input_documents" : docs }, return_only_outputs = True )
768
759
outputAnswer = summary ['output_text' ]
769
760
return outputAnswer
770
-
771
761
def processStep3 (symbol , cik , step , llm , pibIndexName , today , reProcess ):
772
762
# With the data indexed, let's summarize the information
773
763
s3Data = []
@@ -837,7 +827,6 @@ def processStep3(symbol, cik, step, llm, pibIndexName, today, reProcess):
837
827
'pibData' : s ['pibData' ]
838
828
})
839
829
return s3Data
840
-
841
830
def generateSummaries (llm , docs ):
842
831
# With the data indexed, let's summarize the information
843
832
promptTemplate = """You are an AI assistant tasked with summarizing sections from the financial document like 10-K and 10-Q report.
@@ -854,7 +843,6 @@ def generateSummaries(llm, docs):
854
843
summaryChain = load_summarize_chain (llm , chain_type = chainType )
855
844
summary = summaryChain ({"input_documents" : docs }, return_only_outputs = True )
856
845
return summary
857
-
858
846
def processStep4 (symbol , cik , filingType , historicalYear , currentYear , embeddingModelType , llm , pibIndexName ,
859
847
step , today , reProcess , selectedTopics ):
860
848
@@ -1101,7 +1089,6 @@ def processStep4(symbol, cik, filingType, historicalYear, currentYear, embedding
1101
1089
mergeDocs (SearchService , SearchKey , pibIndexName , s4Data )
1102
1090
1103
1091
return s4Data
1104
-
1105
1092
def processStep5 (pibIndexName , cik , step , symbol , today , reProcess ):
1106
1093
s5Data = []
1107
1094
@@ -1260,7 +1247,6 @@ def processStep5(pibIndexName, cik, step, symbol, today, reProcess):
1260
1247
'pibData' : s ['pibData' ]
1261
1248
})
1262
1249
return s5Data
1263
-
1264
1250
def PibSteps (step , symbol , embeddingModelType , reProcess , overrides ):
1265
1251
logging .info ("Calling PibSteps Open AI for symbol " + symbol )
1266
1252
@@ -1349,8 +1335,6 @@ def PibSteps(step, symbol, embeddingModelType, reProcess, overrides):
1349
1335
return {"data_points" : "" , "answer" : "Exception during finding answers - Error : " + str (e ), "thoughts" : "" , "sources" : "" , "nextQuestions" : "" , "error" : str (e )}
1350
1336
1351
1337
#return answer
1352
-
1353
-
1354
1338
def main (req : func .HttpRequest , context : func .Context ) -> func .HttpResponse :
1355
1339
logging .info (f'{ context .function_name } HTTP trigger function processed a request.' )
1356
1340
if hasattr (context , 'retry_context' ):
@@ -1382,7 +1366,6 @@ def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
1382
1366
"Invalid body" ,
1383
1367
status_code = 400
1384
1368
)
1385
-
1386
1369
def ComposeResponse (step , symbol , embeddingModelType , reProcess , jsonData ):
1387
1370
values = json .loads (jsonData )['values' ]
1388
1371
@@ -1396,7 +1379,6 @@ def ComposeResponse(step, symbol, embeddingModelType, reProcess, jsonData):
1396
1379
if outputRecord != None :
1397
1380
results ["values" ].append (outputRecord )
1398
1381
return json .dumps (results , ensure_ascii = False )
1399
-
1400
1382
def TransformValue (step , symbol , embeddingModelType , reProcess , record ):
1401
1383
logging .info ("Calling Transform Value" )
1402
1384
try :
@@ -1444,4 +1426,4 @@ def TransformValue(step, symbol, embeddingModelType, reProcess, record):
1444
1426
{
1445
1427
"recordId" : recordId ,
1446
1428
"errors" : [ { "message" : "Could not complete operation for record." } ]
1447
- })
1429
+ })
0 commit comments