Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
import json | |
# Function to call the first API and process the response | |
def get_investment_insights(company_name, work_phone, headquarters, asset_class, primary_location, | |
investment_vehicle_country, vehicle_currency, holding_period, esg_membership, | |
investment_structure, capital_target, target_irr, target_equity_multiple, | |
min_investment_size, investment_strategy, fund_status): | |
url = "https://01bpjt0euk.execute-api.us-east-1.amazonaws.com/default/investment_thesis_and_rationale" | |
payload = {'company_details': { | |
"company_name": company_name, | |
"work_phone": work_phone, | |
"headquarters": headquarters, | |
"asset_class": asset_class, | |
"primary_location": primary_location, | |
"investment_vehicle_country": investment_vehicle_country, | |
"vehicle_currency": vehicle_currency, | |
"holding_period": holding_period, | |
"esg_membership": esg_membership, | |
"investment_structure": investment_structure, | |
"capital_target": capital_target, | |
"target_irr": target_irr, | |
"target_equity_multiple": target_equity_multiple, | |
"min_investment_size": min_investment_size, | |
"investment_strategy": investment_strategy, | |
"fund_status": fund_status | |
}} | |
response = requests.post(url, json=payload) | |
print(response.json()) | |
if response.status_code == 200: | |
response_data = response.json() | |
return response_data.get('investment_rationale', ''), response_data.get('subsectors_of_focus', ''), response_data.get('investment_criteria_and_selection_process', '') | |
else: | |
return "API request failed", "", "" | |
# Function to call the second API and process the response | |
def call_second_api(name_of_project, amount_invested, irr, moic): | |
url = "https://l0rna45756.execute-api.us-east-1.amazonaws.com/default/case_study_description" | |
payload = { | |
"name_of_project": name_of_project, | |
"amount_invested": amount_invested, | |
"irr": irr, | |
"moic": moic | |
} | |
headers = {"Content-Type": "application/json"} | |
response = requests.post(url, headers=headers, data=json.dumps(payload)) | |
print(response.json()) | |
if response.status_code == 200: | |
response_data = response.json() | |
return response_data.get('case_study_description', '') | |
else: | |
return "API request failed" | |
# Function to call the third API and process the response | |
def call_third_api(name, title, company, company_hq, investor_type, investor_country, asset_class, investment_location): | |
url = "https://2r9ffx5cnf.execute-api.us-east-1.amazonaws.com/default/team_member_responsibilities" | |
payload = { | |
"name": name, | |
"title": title, | |
"company": company, | |
"company_hq": company_hq, | |
"investor_type": investor_type, | |
"investor_country": investor_country, | |
"asset_class": asset_class, | |
"investment_location": investment_location | |
} | |
headers = {"Content-Type": "application/json"} | |
response = requests.post(url, headers=headers, json=payload) | |
print(response.json()) | |
if response.status_code == 200: | |
response_data = response.json() | |
return response_data.get('bio', '') | |
else: | |
return "API request failed" | |
# Gradio interface | |
with gr.Blocks() as app: | |
gr.Markdown("# Marketing Materials API Tester") | |
with gr.Tabs(): | |
with gr.TabItem("Investments API"): | |
with gr.Row(): | |
with gr.Column(): | |
company_name = gr.Textbox(label="Your Company's Name", value="Example Company") | |
work_phone = gr.Textbox(label="Your Work Phone Number", value="+1234567890") | |
headquarters = gr.Textbox(label="Where are your company's headquarters?", value="New York, USA") | |
asset_class = gr.Textbox(label="In which Asset Class are you investing?", value="Private Equity") | |
primary_location = gr.Textbox(label="Where are you investing primarily?", value="North America") | |
investment_vehicle_country = gr.Textbox(label="In what Country is your investment vehicle domiciled?", value="USA") | |
vehicle_currency = gr.Textbox(label="What is the investment vehicle's currency?", value="USD") | |
holding_period = gr.Textbox(label="What is the expected holding period (in years)?", value="5") | |
esg_membership = gr.Dropdown(choices=["Yes", "No"], label="Are you a member of any ESG associations?", value="Yes") | |
investment_structure = gr.Textbox(label="What is your Investment Structure?", value="Fund") | |
capital_target = gr.Textbox(label="What is the total capital raising target for your offering (In USD Millions)?", value="100") | |
target_irr = gr.Textbox(label="What is your target gross return (IRR %)?", value="15") | |
target_equity_multiple = gr.Textbox(label="What is your target gross Equity Multiple / MOIC (x)?", value="2") | |
min_investment_size = gr.Textbox(label="What is the minimum investment ticket size acceptable (In USD Millions)?", value="1") | |
investment_strategy = gr.Textbox(label="Describe your investment strategy", value="Focus on growth-stage technology companies", lines=5) | |
fund_status = gr.Textbox(label="What is your fund status?", value="Open") | |
with gr.Column(): | |
investment_rationale = gr.Textbox(label="Investment Rationale", interactive=False) | |
subsectors_of_focus = gr.Textbox(label="Subsectors of Focus", interactive=False) | |
investment_criteria_and_selection_process = gr.Textbox(label="Investment Criteria and Selection Process", interactive=False) | |
submit_btn = gr.Button("Get Insights") | |
submit_btn.click(get_investment_insights, | |
[company_name, work_phone, headquarters, asset_class, primary_location, investment_vehicle_country, | |
vehicle_currency, holding_period, esg_membership, investment_structure, capital_target, | |
target_irr, target_equity_multiple, min_investment_size, investment_strategy, fund_status], | |
[investment_rationale, subsectors_of_focus, investment_criteria_and_selection_process]) | |
with gr.TabItem("Case Studies API"): | |
with gr.Row(): | |
with gr.Column(): | |
name_of_project = gr.Textbox(label="Name of Project", value="EnEx - Energy Expansion Project") | |
amount_invested = gr.Number(label="Amount Invested (in millions)", value=5.533) | |
irr = gr.Number(label="Internal Rate of Return (IRR %)", value=21.67) | |
moic = gr.Number(label="Multiple on Invested Capital (MOIC)", value=3.44) | |
with gr.Column(): | |
case_study_description = gr.Textbox(label="Case Study Description", interactive=False) | |
submit_btn2 = gr.Button("Generate Case Study") | |
submit_btn2.click(call_second_api, | |
[name_of_project, amount_invested, irr, moic], | |
[case_study_description]) | |
with gr.TabItem("Team Members API"): | |
with gr.Row(): | |
with gr.Column(): | |
name = gr.Textbox(label="Name", value="Jane Doe") | |
title = gr.Textbox(label="Title", value="Data Scientist") | |
company = gr.Textbox(label="Company", value="DataCorp") | |
company_hq = gr.Textbox(label="Company Headquarters", value="New York, USA") | |
investor_type = gr.Textbox(label="Investor Type", value="Institutional Investor") | |
investor_country = gr.Textbox(label="Investor Country", value="USA") | |
asset_class = gr.Textbox(label="Asset Class", value="Technology") | |
investment_location = gr.Textbox(label="Investment Location", value="Global") | |
with gr.Column(): | |
responsibilities = gr.Textbox(label="Responsibilities", interactive=False) | |
submit_btn3 = gr.Button("Get Responsibilities") | |
submit_btn3.click(call_third_api, | |
[name, title, company, company_hq, investor_type, investor_country, asset_class, investment_location], | |
[responsibilities]) | |
app.launch() | |