Nithin1905 commited on
Commit
7eb6c7b
1 Parent(s): 9d06841

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +47 -92
main.py CHANGED
@@ -95,102 +95,57 @@ Output format:
95
  Take a deep breath and work on this problem step-by-step.
96
  """
97
 
98
- Investment = """You are a professional financial analyst with over 20 years of experience in evaluating sectors for investment potential. You specialize in providing comprehensive qualitative and quantitative analyses to assess the investment potential of various business sectors. Your expertise includes evaluating risk factors and potential returns to offer prudent investment advice.
99
 
100
- ### Objective:
101
- Your primary goal is to deliver an accurate, in-depth evaluation of the business sector described in the provided CONTEXT. You will critically analyze the key sections and provide a grade for each section on a scale from 1 to 10 based on its investment potential. A higher grade indicates a higher potential return on investment (ROI) or a higher Sharpe ratio, while a lower grade indicates higher risk or lower expected returns. Approach each section with a conservative mindset to ensure a realistic and prudent assessment.
 
 
 
102
 
103
- ---
104
-
105
- ### Instructions:
106
-
107
- ### Step 1: Sector Identification and Key Sections Extraction
108
-
109
- 1. **Identify the Sector:**
110
- - Determine the specific sector you will analyze.
111
- - Clearly state the sector name in your final output.
112
-
113
- 2. **Extract Sections to be Graded:**
114
- - Extract and list the sections to be evaluated from the provided CONTEXT, ensuring only the KEYS specified in the CONTEXT are used.
115
- - Validate that the extracted sections strictly match the keys from the CONTEXT, without adding or altering any sections.
116
-
117
- ### Step 2: Grading Each Section
118
-
119
- 1. **Assign a Grade for Each Key in the Context:**
120
- - Assign a grade between 1 and 10 for each section.
121
- - Higher grades should correspond to higher investment potential, considering ROI or Sharpe ratio, while lower grades reflect higher risks or lower returns.
122
- -Consider conversative approach for the grading because investment is a risk investors can loss money
123
-
124
- 2. **Provide Detailed Reasoning:**
125
- - Ensure the grades given are backed by comprehensive and in-depth explanations.
126
- - Incorporate detailed reasoning from both qualitative and quantitative perspectives.
127
- - Support your assessments with numerical data and statistical analysis if present.
128
- - Ensure your evaluations are robust and well-supported with concrete evidence and thorough analysis.
129
-
130
- 3. **Assign a Weight to Each Section:**
131
- - Determine the importance of each section relative to the overall investment potential. Assign a weight between 0 and 1 for each section, ensuring the total weights add up to 1.
132
- - Higher weights should be given to sections that are more critical to the investment decision-making process.
133
-
134
-
135
- ### Step 3: Overall Sector Score Calculation
136
-
137
- **Calculate Weighted Scores**:
138
- - **Weighted Score Calculation**: Multiply each score by its corresponding weight and sum these to get the total weighted score.
139
- \[
140
- \text{Total Score} = \sum (\text{Score}_i \times \text{Weight}_i)
141
- \]
142
- ### Output Format:
143
-
144
- 1. **JSON Structure:**
145
- - Ensure the output is in a valid JSON format with the following structure:
146
 
147
  ```json
148
  {
149
- "sector": "Insert Sector Name Here",
150
  "sections": [
151
  {
152
- "section": "Insert Key from Context Here",
153
- "score": "Insert Grade Here (1-10)",
154
- "weight": "Insert Weight Here (0-1)",
155
- "reasoning": "Insert detailed qualitative and quantitative analysis here"
156
- },
157
- {
158
- "section": "Insert Key from Context Here",
159
- "score": "Insert Grade Here (1-10)",
160
- "weight": "Insert Weight Here (0-1)",
161
- "reasoning": "Insert detailed qualitative and quantitative analysis here"
162
  }
163
  ],
164
- "overall_score": "Insert overall score here"// replace with calculated score using the formula
165
  }
166
  ```
167
 
168
- ### Key Requirements:
169
-
170
- 1. **Accuracy:**
171
- - Ensure each section’s grade is backed by comprehensive reasoning. Cross-verify each grade with both qualitative and quantitative justifications.
172
-
173
- 2. **Contextual Relevance:**
174
- - Use only the keys provided in the CONTEXT. Avoid introducing new sections or altering the provided keys.
175
-
176
- 3. **Conservativeness:**
177
- - Adopt a critical and conservative approach in grading, reflecting realistic and prudent investment potential. Lower scores should be preferred to emphasize investment risks and the possibility of capital loss.
178
-
179
- 4 . **Ensuring the total weights add up to 1.**
180
- ### Important Notes:
181
- - The CONTEXT will be provided in the following format:
182
- ```json
183
- {
184
- "key1": "value1",
185
- "key2": "value2",
186
- ...
187
- }
188
- ```
189
- - Only use the KEYS (e.g., key1, key2) to identify the sections to be graded. D0 NOT ADD or ALTER any sections beyond the KEYS present in the CONTEXT. Grade only the sections that match the KEYS provided in the CONTEXT.
190
- -If the CONTEXT has one or no KEY return a JSON with the 'keys are already graded'.
191
- Take a deep breath and work on this problem step-by-step.
192
-
193
- ---
194
  """
195
 
196
  queries = [
@@ -682,8 +637,8 @@ def further_split_chunk(chunk, token_limit):
682
 
683
 
684
  # Define the investment function
685
- def investment(queries, query_results, other_info_results):
686
- time.sleep(1)
687
  # Combine queries and query_results into a dictionary
688
  combined_results = {q: r for q, r in zip(queries[-4:], query_results[-4:])}
689
 
@@ -694,7 +649,7 @@ def investment(queries, query_results, other_info_results):
694
  else:
695
  combined_results[key] = value
696
  print(combined_results)
697
- message = f"CONTEXT:\n\n{json.dumps(combined_results, indent=4)}\n\n"
698
 
699
  sys_prompt = Investment
700
  encoding = tiktoken.encoding_for_model("gpt-3.5-turbo")
@@ -705,7 +660,7 @@ def investment(queries, query_results, other_info_results):
705
 
706
  chunks = split_into_chunks(message, token_limit=max_chunk_size)
707
 
708
- model = "meta-llama/llama-3-70b-instruct:nitro"
709
  responses = []
710
  tokens_used = 0
711
  max_tokens_per_minute = 7000
@@ -914,12 +869,12 @@ async def other_info(pdf_content, file_name):
914
  return results
915
 
916
  @cache(expire=604800)
917
- async def upload_pitchdeck(pdf_content: bytes, file_name: str):
918
 
919
  # Assuming process_queries and other_info are your own defined async functions
920
  query_results = await process_queries(queries, pdf_content, file_name)
921
  other_info_results = await other_info(pdf_content, file_name)
922
- grading_results = json.loads(investment(queries, query_results, other_info_results))
923
 
924
  return {
925
  "queries": queries,
@@ -931,14 +886,14 @@ async def upload_pitchdeck(pdf_content: bytes, file_name: str):
931
 
932
 
933
  @app.post("/investor")
934
- async def process_pitchdeck(file: UploadFile = File(...)):
935
  if not file:
936
  raise HTTPException(status_code=400, detail="PDF file not provided")
937
  pdf_content = await file.read()
938
  file_name = file.filename
939
 
940
 
941
- return await upload_pitchdeck(pdf_content, file_name)
942
 
943
  app.add_middleware(
944
  CORSMiddleware,
 
95
  Take a deep breath and work on this problem step-by-step.
96
  """
97
 
98
+ Investment = """You are a professional financial analyst evaluating sectors for investment potential. Your task is to:
99
 
100
+ 1. Identify the sector from the provided CONTEXT.
101
+ 2. Grade only the specified KEYS on a scale of 1-10, with higher grades indicating better investment potential. Take a conservative approach in grading.
102
+ 3. Provide reasoning for each grade considering both qualitative and quantitative factors, including the FUNDING information.
103
+ 4. Assign weights to each section (total should equal 1).
104
+ 5. Calculate an overall weighted score.
105
 
106
+ Use only the information given in the CONTEXT and the FUNDING provided. Be conservative in your grading to reflect investment risks. Output your analysis in the following JSON format:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  ```json
109
  {
110
+ "sector": "Sector name",
111
  "sections": [
112
  {
113
+ "section": "Key from Context",
114
+ "score": "Grade (1-10)",
115
+ "weight": "Weight (0-1)",
116
+ "reasoning": "Detailed analysis including funding considerations"
 
 
 
 
 
 
117
  }
118
  ],
119
+ "overall_score": "Calculated weighted score"
120
  }
121
  ```
122
 
123
+ Grade only these KEYS from the CONTEXT:
124
+ 1. "What are the company's projected revenue, expenses, and profits for the future and cash flow projections?"
125
+ 2. "What is the founder's experience and track record, along with the key team members' bios, background checks, and their roles and responsibilities?"
126
+ 3. "How does the company's product/service differentiate itself from competitors in the market?"
127
+ 4. "What issue or challenge is the company addressing?"
128
+ 5. "Risks Involved"
129
+ 6. "Barrier To Entry"
130
+ 7. "Competitors"
131
+ 8. "Challenges"
132
+
133
+ Additionally, consider the FUNDING provided by the user:
134
+ - The FUNDING will be classified as follows:
135
+ * Low: Less than $1 million
136
+ * Medium: $1 million to $10 million
137
+ * High: More than $10 million
138
+ - Adjust your scoring based on the funding classification:
139
+ * For Low funding: Reduce scores by 1-2 points where relevant.
140
+ * For Medium funding: Keep scores as they would be without considering funding.
141
+ * For High funding: Increase scores by 1-2 points where relevant.
142
+ - Incorporate the funding information into your analysis of each relevant key.
143
+ - Consider how the funding level impacts various aspects such as projected financials, ability to execute plans, competitive positioning, and risk mitigation.
144
+ - Reflect the impact of funding in your scoring and reasoning for each relevant key.
145
+ -Don't explicitly mention the original funding in the answer but use them to give reasoning.
146
+
147
+
148
+ Provide your analysis based on the CONTEXT and FUNDING that will be given.
149
  """
150
 
151
  queries = [
 
637
 
638
 
639
  # Define the investment function
640
+ def investment(queries, query_results, other_info_results,Funding):
641
+
642
  # Combine queries and query_results into a dictionary
643
  combined_results = {q: r for q, r in zip(queries[-4:], query_results[-4:])}
644
 
 
649
  else:
650
  combined_results[key] = value
651
  print(combined_results)
652
+ message = f"CONTEXT:\n\n{json.dumps(combined_results, indent=4)}\n\nFUNDING:\n\n{Funding}\n\n"
653
 
654
  sys_prompt = Investment
655
  encoding = tiktoken.encoding_for_model("gpt-3.5-turbo")
 
660
 
661
  chunks = split_into_chunks(message, token_limit=max_chunk_size)
662
 
663
+ model = "anthropic/claude-3.5-sonnet"
664
  responses = []
665
  tokens_used = 0
666
  max_tokens_per_minute = 7000
 
869
  return results
870
 
871
  @cache(expire=604800)
872
+ async def upload_pitchdeck(pdf_content: bytes, file_name: str, Funding: float):
873
 
874
  # Assuming process_queries and other_info are your own defined async functions
875
  query_results = await process_queries(queries, pdf_content, file_name)
876
  other_info_results = await other_info(pdf_content, file_name)
877
+ grading_results = json.loads(investment(queries, query_results, other_info_results,Funding))
878
 
879
  return {
880
  "queries": queries,
 
886
 
887
 
888
  @app.post("/investor")
889
+ async def process_pitchdeck(file: UploadFile = File(...),Funding: float = Form(...)):
890
  if not file:
891
  raise HTTPException(status_code=400, detail="PDF file not provided")
892
  pdf_content = await file.read()
893
  file_name = file.filename
894
 
895
 
896
+ return await upload_pitchdeck(pdf_content, file_name,Funding)
897
 
898
  app.add_middleware(
899
  CORSMiddleware,