awinml commited on
Commit
868b330
1 Parent(s): 4b19adc
Files changed (1) hide show
  1. utils/prompts.py +23 -7
utils/prompts.py CHANGED
@@ -1,18 +1,19 @@
1
  def generate_multi_doc_context(context_group):
2
- multi_doc_context = ""
3
- for context_text_list, year, quarter in context_group:
4
- print((context_text_list, year, quarter))
 
5
  if context_text_list == []:
6
  break
7
  else:
8
- multi_doc_context = (
9
- multi_doc_context
10
  + "\n"
11
- + f"Document: {quarter} {year}"
12
  + "\n"
13
  + " ".join(context_text_list)
14
  )
15
- return multi_doc_context
16
 
17
 
18
  def generate_gpt_prompt_alpaca(query_text, context_list):
@@ -44,6 +45,21 @@ Context: {multi_doc_context}
44
  ### Response:"""
45
  return prompt
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  def generate_gpt_prompt_original(query_text, context_list):
49
  context = " ".join(context_list)
 
1
  def generate_multi_doc_context(context_group):
2
+ # Extract ticker
3
+ multi_doc_text = ""
4
+ for context_text_list, year, quarter, ticker in context_group:
5
+ print((context_text_list, year, quarter, ticker))
6
  if context_text_list == []:
7
  break
8
  else:
9
+ multi_doc_text = (
10
+ multi_doc_text
11
  + "\n"
12
+ + f"Source: {quarter} {ticker} Earnings Call {year}"
13
  + "\n"
14
  + " ".join(context_text_list)
15
  )
16
+ return multi_doc_text
17
 
18
 
19
  def generate_gpt_prompt_alpaca(query_text, context_list):
 
45
  ### Response:"""
46
  return prompt
47
 
48
+ def generate_gpt_prompt_alpaca_multi_doc_multi_company(query_text, context_group_first, context_group_second):
49
+ multi_doc_context_first = generate_multi_doc_context(context_group_first)
50
+ multi_doc_context_second = generate_multi_doc_context(context_group_second)
51
+ prompt = f"""Below is an instruction that describes a task, paired with an input that provides further context. Use the following guidelines to write a response that that appropriately completes the request:
52
+ ### Instruction:
53
+ - Write a detailed paragraph consisting of exactly five complete sentences that answer the question based on the provided context.
54
+ - Focus on addressing the specific question posed, providing as much relevant information and detail as possible.
55
+ - Only use details from the provided context that directly address the question; do not include any additional information that is not explicitly stated.
56
+ - Aim to provide a clear and concise summary that fully addresses the question.
57
+
58
+ Question: {query_text}
59
+ Context: {multi_doc_context_first} {multi_doc_context_second}
60
+ ### Response:"""
61
+ return prompt
62
+
63
 
64
  def generate_gpt_prompt_original(query_text, context_list):
65
  context = " ".join(context_list)