Spaces:
Runtime error
Runtime error
Nithin1905
commited on
Commit
•
7eb6c7b
1
Parent(s):
9d06841
Update main.py
Browse files
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
|
99 |
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
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": "
|
150 |
"sections": [
|
151 |
{
|
152 |
-
"section": "
|
153 |
-
"score": "
|
154 |
-
"weight": "
|
155 |
-
"reasoning": "
|
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": "
|
165 |
}
|
166 |
```
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
-
|
190 |
-
-
|
191 |
-
|
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 |
-
|
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 = "
|
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,
|