fabianbeigang commited on
Commit
6556f92
1 Parent(s): c43e57f

New tabs for other APIS

Browse files
Files changed (1) hide show
  1. app.py +109 -99
app.py CHANGED
@@ -1,76 +1,8 @@
1
- # import gradio as gr
2
- # import requests
3
-
4
- # # Function to call the API and process the response
5
- # def get_investment_insights(company_name, work_phone, headquarters, asset_class, primary_location,
6
- # investment_vehicle_country, vehicle_currency, holding_period, esg_membership,
7
- # investment_structure, capital_target, target_irr, target_equity_multiple,
8
- # min_investment_size, investment_strategy, fund_status):
9
- # url = "https://01bpjt0euk.execute-api.us-east-1.amazonaws.com/default/investment_thesis_and_rationale"
10
- # payload = {'company_details': {
11
- # "company_name": company_name,
12
- # "work_phone": work_phone,
13
- # "headquarters": headquarters,
14
- # "asset_class": asset_class,
15
- # "primary_location": primary_location,
16
- # "investment_vehicle_country": investment_vehicle_country,
17
- # "vehicle_currency": vehicle_currency,
18
- # "holding_period": holding_period,
19
- # "esg_membership": esg_membership,
20
- # "investment_structure": investment_structure,
21
- # "capital_target": capital_target,
22
- # "target_irr": target_irr,
23
- # "target_equity_multiple": target_equity_multiple,
24
- # "min_investment_size": min_investment_size,
25
- # "investment_strategy": investment_strategy,
26
- # "fund_status": fund_status
27
- # }}
28
- # response = requests.post(url, json=payload)
29
- # print(response.json())
30
- # if response.status_code == 200:
31
- # response_data = response.json()
32
- # return response_data.get('investment_rationale', ''), response_data.get('subsectors_of_focus', ''), response_data.get('investment_criteria_and_selection_process', '')
33
- # else:
34
- # return "API request failed", "", ""
35
-
36
- # # Gradio interface
37
- # with gr.Blocks() as app:
38
- # gr.Markdown("# Investment Insights Extractor")
39
-
40
- # company_name = gr.Textbox(label="Your Company's Name", value="Example Company")
41
- # work_phone = gr.Textbox(label="Your Work Phone Number", value="+1234567890")
42
- # headquarters = gr.Textbox(label="Where are your company's headquarters?", value="New York, USA")
43
- # asset_class = gr.Textbox(label="In which Asset Class are you investing?", value="Private Equity")
44
- # primary_location = gr.Textbox(label="Where are you investing primarily?", value="North America")
45
- # investment_vehicle_country = gr.Textbox(label="In what Country is your investment vehicle domiciled?", value="USA")
46
- # vehicle_currency = gr.Textbox(label="What is the investment vehicle's currency?", value="USD")
47
- # holding_period = gr.Textbox(label="What is the expected holding period (in years)?", value="5")
48
- # esg_membership = gr.Dropdown(choices=["Yes", "No"], label="Are you a member of any ESG associations?", value="Yes")
49
- # investment_structure = gr.Textbox(label="What is your Investment Structure?", value="Fund")
50
- # capital_target = gr.Textbox(label="What is the total capital raising target for your offering (In USD Millions)?", value="100")
51
- # target_irr = gr.Textbox(label="What is your target gross return (IRR %)?", value="15")
52
- # target_equity_multiple = gr.Textbox(label="What is your target gross Equity Multiple / MOIC (x)?", value="2")
53
- # min_investment_size = gr.Textbox(label="What is the minimum investment ticket size acceptable (In USD Millions)?", value="1")
54
- # investment_strategy = gr.Textbox(label="Describe your investment strategy", value="Focus on growth-stage technology companies", lines=5)
55
- # fund_status = gr.Textbox(label="What is your fund status?", value="Open")
56
-
57
- # investment_rationale = gr.Textbox(label="Investment Rationale", interactive=False)
58
- # subsectors_of_focus = gr.Textbox(label="Subsectors of Focus", interactive=False)
59
- # investment_criteria_and_selection_process = gr.Textbox(label="Investment Criteria and Selection Process", interactive=False)
60
-
61
- # submit_btn = gr.Button("Get Insights")
62
- # submit_btn.click(get_investment_insights,
63
- # [company_name, work_phone, headquarters, asset_class, primary_location, investment_vehicle_country,
64
- # vehicle_currency, holding_period, esg_membership, investment_structure, capital_target,
65
- # target_irr, target_equity_multiple, min_investment_size, investment_strategy, fund_status],
66
- # [investment_rationale, subsectors_of_focus, investment_criteria_and_selection_process])
67
-
68
- # app.launch()
69
-
70
  import gradio as gr
71
  import requests
 
72
 
73
- # Function to call the API and process the response
74
  def get_investment_insights(company_name, work_phone, headquarters, asset_class, primary_location,
75
  investment_vehicle_country, vehicle_currency, holding_period, esg_membership,
76
  investment_structure, capital_target, target_irr, target_equity_multiple,
@@ -102,39 +34,117 @@ def get_investment_insights(company_name, work_phone, headquarters, asset_class,
102
  else:
103
  return "API request failed", "", ""
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  # Gradio interface
106
  with gr.Blocks() as app:
107
- gr.Markdown("# Investment Insights Extractor")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- with gr.Row():
110
- with gr.Column():
111
- company_name = gr.Textbox(label="Your Company's Name", value="Example Company")
112
- work_phone = gr.Textbox(label="Your Work Phone Number", value="+1234567890")
113
- headquarters = gr.Textbox(label="Where are your company's headquarters?", value="New York, USA")
114
- asset_class = gr.Textbox(label="In which Asset Class are you investing?", value="Private Equity")
115
- primary_location = gr.Textbox(label="Where are you investing primarily?", value="North America")
116
- investment_vehicle_country = gr.Textbox(label="In what Country is your investment vehicle domiciled?", value="USA")
117
- vehicle_currency = gr.Textbox(label="What is the investment vehicle's currency?", value="USD")
118
- holding_period = gr.Textbox(label="What is the expected holding period (in years)?", value="5")
119
- esg_membership = gr.Dropdown(choices=["Yes", "No"], label="Are you a member of any ESG associations?", value="Yes")
120
- investment_structure = gr.Textbox(label="What is your Investment Structure?", value="Fund")
121
- capital_target = gr.Textbox(label="What is the total capital raising target for your offering (In USD Millions)?", value="100")
122
- target_irr = gr.Textbox(label="What is your target gross return (IRR %)?", value="15")
123
- target_equity_multiple = gr.Textbox(label="What is your target gross Equity Multiple / MOIC (x)?", value="2")
124
- min_investment_size = gr.Textbox(label="What is the minimum investment ticket size acceptable (In USD Millions)?", value="1")
125
- investment_strategy = gr.Textbox(label="Describe your investment strategy", value="Focus on growth-stage technology companies", lines=5)
126
- fund_status = gr.Textbox(label="What is your fund status?", value="Open")
127
 
128
- with gr.Column():
129
- investment_rationale = gr.Textbox(label="Investment Rationale", interactive=False)
130
- subsectors_of_focus = gr.Textbox(label="Subsectors of Focus", interactive=False)
131
- investment_criteria_and_selection_process = gr.Textbox(label="Investment Criteria and Selection Process", interactive=False)
132
 
133
- submit_btn = gr.Button("Get Insights")
134
- submit_btn.click(get_investment_insights,
135
- [company_name, work_phone, headquarters, asset_class, primary_location, investment_vehicle_country,
136
- vehicle_currency, holding_period, esg_membership, investment_structure, capital_target,
137
- target_irr, target_equity_multiple, min_investment_size, investment_strategy, fund_status],
138
- [investment_rationale, subsectors_of_focus, investment_criteria_and_selection_process])
139
 
140
  app.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import requests
3
+ import json
4
 
5
+ # Function to call the first API and process the response
6
  def get_investment_insights(company_name, work_phone, headquarters, asset_class, primary_location,
7
  investment_vehicle_country, vehicle_currency, holding_period, esg_membership,
8
  investment_structure, capital_target, target_irr, target_equity_multiple,
 
34
  else:
35
  return "API request failed", "", ""
36
 
37
+ # Function to call the second API and process the response
38
+ def call_second_api(name_of_project, amount_invested, irr, moic):
39
+ url = "https://l0rna45756.execute-api.us-east-1.amazonaws.com/default/case_study_description"
40
+ payload = {
41
+ "name_of_project": name_of_project,
42
+ "amount_invested": amount_invested,
43
+ "irr": irr,
44
+ "moic": moic
45
+ }
46
+ headers = {"Content-Type": "application/json"}
47
+ response = requests.post(url, headers=headers, data=json.dumps(payload))
48
+ print(response.json())
49
+ if response.status_code == 200:
50
+ response_data = response.json()
51
+ return response_data.get('case_study_description', '')
52
+ else:
53
+ return "API request failed"
54
+
55
+ # Function to call the third API and process the response
56
+ def call_third_api(name, title, company, company_hq, investor_type, investor_country, asset_class, investment_location):
57
+ url = "https://2r9ffx5cnf.execute-api.us-east-1.amazonaws.com/default/team_member_responsibilities"
58
+ payload = {
59
+ "name": name,
60
+ "title": title,
61
+ "company": company,
62
+ "company_hq": company_hq,
63
+ "investor_type": investor_type,
64
+ "investor_country": investor_country,
65
+ "asset_class": asset_class,
66
+ "investment_location": investment_location
67
+ }
68
+ headers = {"Content-Type": "application/json"}
69
+ response = requests.post(url, headers=headers, json=payload)
70
+ print(response.json())
71
+ if response.status_code == 200:
72
+ response_data = response.json()
73
+ return response_data.get('bio', '')
74
+ else:
75
+ return "API request failed"
76
+
77
  # Gradio interface
78
  with gr.Blocks() as app:
79
+ gr.Markdown("# Marketing Materials API Tester")
80
+
81
+ with gr.Tabs():
82
+ with gr.TabItem("Investments API"):
83
+ with gr.Row():
84
+ with gr.Column():
85
+ company_name = gr.Textbox(label="Your Company's Name", value="Example Company")
86
+ work_phone = gr.Textbox(label="Your Work Phone Number", value="+1234567890")
87
+ headquarters = gr.Textbox(label="Where are your company's headquarters?", value="New York, USA")
88
+ asset_class = gr.Textbox(label="In which Asset Class are you investing?", value="Private Equity")
89
+ primary_location = gr.Textbox(label="Where are you investing primarily?", value="North America")
90
+ investment_vehicle_country = gr.Textbox(label="In what Country is your investment vehicle domiciled?", value="USA")
91
+ vehicle_currency = gr.Textbox(label="What is the investment vehicle's currency?", value="USD")
92
+ holding_period = gr.Textbox(label="What is the expected holding period (in years)?", value="5")
93
+ esg_membership = gr.Dropdown(choices=["Yes", "No"], label="Are you a member of any ESG associations?", value="Yes")
94
+ investment_structure = gr.Textbox(label="What is your Investment Structure?", value="Fund")
95
+ capital_target = gr.Textbox(label="What is the total capital raising target for your offering (In USD Millions)?", value="100")
96
+ target_irr = gr.Textbox(label="What is your target gross return (IRR %)?", value="15")
97
+ target_equity_multiple = gr.Textbox(label="What is your target gross Equity Multiple / MOIC (x)?", value="2")
98
+ min_investment_size = gr.Textbox(label="What is the minimum investment ticket size acceptable (In USD Millions)?", value="1")
99
+ investment_strategy = gr.Textbox(label="Describe your investment strategy", value="Focus on growth-stage technology companies", lines=5)
100
+ fund_status = gr.Textbox(label="What is your fund status?", value="Open")
101
+
102
+ with gr.Column():
103
+ investment_rationale = gr.Textbox(label="Investment Rationale", interactive=False)
104
+ subsectors_of_focus = gr.Textbox(label="Subsectors of Focus", interactive=False)
105
+ investment_criteria_and_selection_process = gr.Textbox(label="Investment Criteria and Selection Process", interactive=False)
106
+
107
+ submit_btn = gr.Button("Get Insights")
108
+ submit_btn.click(get_investment_insights,
109
+ [company_name, work_phone, headquarters, asset_class, primary_location, investment_vehicle_country,
110
+ vehicle_currency, holding_period, esg_membership, investment_structure, capital_target,
111
+ target_irr, target_equity_multiple, min_investment_size, investment_strategy, fund_status],
112
+ [investment_rationale, subsectors_of_focus, investment_criteria_and_selection_process])
113
+
114
+ with gr.TabItem("Case Studies API"):
115
+ with gr.Row():
116
+ with gr.Column():
117
+ name_of_project = gr.Textbox(label="Name of Project", value="EnEx - Energy Expansion Project")
118
+ amount_invested = gr.Number(label="Amount Invested (in millions)", value=5.533)
119
+ irr = gr.Number(label="Internal Rate of Return (IRR %)", value=21.67)
120
+ moic = gr.Number(label="Multiple on Invested Capital (MOIC)", value=3.44)
121
+
122
+ with gr.Column():
123
+ case_study_description = gr.Textbox(label="Case Study Description", interactive=False)
124
+
125
+ submit_btn2 = gr.Button("Generate Case Study")
126
+ submit_btn2.click(call_second_api,
127
+ [name_of_project, amount_invested, irr, moic],
128
+ [case_study_description])
129
 
130
+ with gr.TabItem("Team Members API"):
131
+ with gr.Row():
132
+ with gr.Column():
133
+ name = gr.Textbox(label="Name", value="Jane Doe")
134
+ title = gr.Textbox(label="Title", value="Data Scientist")
135
+ company = gr.Textbox(label="Company", value="DataCorp")
136
+ company_hq = gr.Textbox(label="Company Headquarters", value="New York, USA")
137
+ investor_type = gr.Textbox(label="Investor Type", value="Institutional Investor")
138
+ investor_country = gr.Textbox(label="Investor Country", value="USA")
139
+ asset_class = gr.Textbox(label="Asset Class", value="Technology")
140
+ investment_location = gr.Textbox(label="Investment Location", value="Global")
 
 
 
 
 
 
 
141
 
142
+ with gr.Column():
143
+ responsibilities = gr.Textbox(label="Responsibilities", interactive=False)
 
 
144
 
145
+ submit_btn3 = gr.Button("Get Responsibilities")
146
+ submit_btn3.click(call_third_api,
147
+ [name, title, company, company_hq, investor_type, investor_country, asset_class, investment_location],
148
+ [responsibilities])
 
 
149
 
150
  app.launch()