import streamlit as st import os import math import google.generativeai as genai GOOGLE_API_KEY= os.getenv('GEMINI_API_KEY') genai.configure(api_key=GOOGLE_API_KEY) model = genai.GenerativeModel(model_name = "gemini-pro") from utils import findTop3MoneyNeeds, findTop3Topologies, findTop3CustomerExperienceNeeds, findTop3SustainabilityNeeds # Create a banner using Markdown st.markdown( """

Blue AI

Welcome to the Proposition Management Tool

""", unsafe_allow_html=True ) selectedCity = st.selectbox("Please select the City and the Bank Product for Your Proposition.", ["CharlesTown", "Limburg"]) selectedProduct = st.selectbox("Please select the Product", ["Current", "Mortage", "Credit Card", "Crypto"]) subscriberTakeOut = st.number_input("Please enter your subscriber take out") moneyNeeds = st.text_area("Describe money needs of your target audience. For example do they spend a lot on education, healthcare, gym, eating out etc.") customerExperience = st.text_area("Describe the customer experience needs of your target audience.") sutainabilityNeeds = st.text_area("Describe the sutainability needs of your target audience.") userProposal = st.text_area("Enter your final Proposition for Select City and Product") submit_button = st.button("Submit") pre_prompt = '''You are a business analyser bot. I will give you data and references and you will analyse the propositions and will give them scoring on particular criterias. An example is below Proposition - Culture bank Student – the Young Professionals Credit Card! Description: Culture bank is offering Limburg residents a Credit card for students and under 30’s with special discounts at major online stores. The card offers a 1% off on all purchases from Amazon and 10% off all travel purchases all available through our Mobile App. You will also get a free current account to use for your everyday savings too! This group are short on cash but not afraid to be in debt as they will pay it off in the future. They want a product that is easy to use and not complicated. They want connect on Social Media sites. They want great deals and want to manage things independantly. They want the brand to be fun and positive The card is free with no annual fee and available via our online portal Some more details about proposition Question: What are their money needs? Answer: This group are short on cash but not afraid to be in debt as they will pay it off in the future Question: What is thee customer experience Answer: They want a product that is easy to use and not complicated Question: what is the key demographic behaviour? Answer: They want connect on Social Media sites Question: Prime Money Attitudes? Answer: They want great deals and want to manage things independantly Question: Brand needs?sss Answer: They want the brand to be fun and positive Analyse this proposition and score it on the below criteria based upon its popularity within the audience 'Living of today' Refer the barometer goals being set for 'Living for today people' I want to feel socially responsible 67 I want to feel in control of my future 58 I want the bank to help me understand what I can afford 93 I do active charity work 99 I want to manage my carbon footprint 112 Being rich is a priority for me 86 I have achieved all I need in life 52 I feel out of depth with my finances 103 Helps me gain control over my future 97 The brand is fun 120 Rank the proposition on all the above barometers based upon how much they match with the barometer with semantic similarity. Rank should be decided by this logic- 1. Score should be between 0 - 200. 2. On the basis of score then rank the proposition on all benchmark goals from 1(low) to 5(high). 3. If the score of proposition differ from the goal within the range 0-10 then it should have higher rank. Similarly as the difference increases from goal value the rank should be lower. Show the rank between 1 to 5 and the score between 0-200 for every goal in a tabular format with a sum total and average rank at the end of table. Only show the table and conclusion remarks if the proposition suits the target audience or not. Do not show the barometers or any other part of the prompt {{0}} ''' CharlesTownDemographic = '''CharlesTown city people are Living for today people mostly with a population of 10000. Out of this 65% are between the age of 18-25.''' LimburgTownDemographic = '''Limburg city people are young families people mostly with a population of 20000. Out of this 65% are between the age of 30-45. Most of them have kids aged between 0-15''' CharlesTownPopulation = 10000 LimburgTownPopulation = 20000 demographic = '' population = 0 if selectedCity: if selectedCity == 'CharlesTown': st.write(CharlesTownDemographic) demographic = CharlesTownDemographic population = CharlesTownPopulation if selectedCity == 'Limburg': st.write(LimburgTownDemographic) demographic = LimburgTownDemographic population = LimburgTownPopulation if submit_button: proposal = '''Given proposal is for the city {} with product {}. The propsal is as below. {}''' proposal = proposal.format(selectedCity, selectedProduct, userProposal) st.write("Entered proposal:", proposal) st.write("Analyzing your proposition") topMoneyNeeds, topMoneyNeedsDict = findTop3MoneyNeeds(moneyNeeds) topCustomerExp, topCustomerExpDict = findTop3CustomerExperienceNeeds(customerExperience) topSustainabilityNeeds, topSustainabilityNeedsDict = findTop3SustainabilityNeeds(sutainabilityNeeds) matchingTopologies, topologyDetails = findTop3Topologies(proposal, demographic) response = model.generate_content([pre_prompt.format(proposal)]) st.write("As per your money needs your product is mostly targeting the below spending patterns",) for idx, need in enumerate(topMoneyNeeds): st.write("{}. {}".format(idx+1, need)) st.write("As per your money needs your product is mostly targeting the below spending patterns",) for idx, exp in enumerate(topCustomerExp): st.write("{}. {}".format(idx+1, exp)) st.write("As per your sustainability needs your product is mostly targeting the below spending patterns",) for idx, need in enumerate(topSustainabilityNeeds): st.write("{}. {}".format(idx+1, need)) st.write("As per your demographic and your proposition here are the three topologies you are targeting",) for idx, topology in enumerate(matchingTopologies): st.write("{}. {}".format(idx+1, topology)) topologySumDict = {} for topology in matchingTopologies: sumTopology = 0 for moneyNeed in topMoneyNeedsDict: sumTopology = sumTopology+int(moneyNeed[topology]) for customerExp in topCustomerExpDict: sumTopology = sumTopology+int(customerExp[topology]) for sustainabilityNeed in topSustainabilityNeedsDict: sumTopology = sumTopology+int(sustainabilityNeed[topology]) topologySumDict[topology] = math.floor(sumTopology/3) for topology in matchingTopologies: st.write("{}. {}".format(topology, topologySumDict[topology])) totalSubscriberTakeOut = 0 for topology in matchingTopologies: proportion = int(topologyDetails[topology]['Proportion Sample'].replace('%', '')) topologyPopulation = math.floor((proportion * population) / 100) topologyScore = topologySumDict[topology] topologyPopulation = math.floor(topologyPopulation/2) if topologyScore <=250: topologyPopulation = topologyPopulation/2 elif topologyScore >250 and topologyScore<=260: topologyPopulation = math.floor(topologyPopulation/1.8) elif topologyScore >260 and topologyScore<=270: topologyPopulation = math.floor(topologyPopulation/1.6) elif topologyScore >270 and topologyScore<=280: topologyPopulation = math.floor(topologyPopulation/1.4) elif topologyScore >280 and topologyScore<=300: topologyPopulation = topologyPopulation elif topologyScore >300 and topologyScore<=310: topologyPopulation = math.floor(topologyPopulation * 1.2) elif topologyScore >310 and topologyScore<=320: topologyPopulation = math.floor(topologyPopulation * 1.4) elif topologyScore >320 and topologyScore<=340: topologyPopulation = math.floor(topologyPopulation * 1.5) elif topologyScore >340 and topologyScore<=360: topologyPopulation = math.floor(topologyPopulation * 1.6) else: topologyPopulation = math.floor(topologyPopulation * 2) totalSubscriberTakeOut = totalSubscriberTakeOut + topologyPopulation st.write("{}. {} and has subscriber takeout of {}".format(topology, topologySumDict[topology], topologyPopulation)) st.write(" Target Subscriber takeout = {}".format(totalSubscriberTakeOut)) st.write(" Total Subscriber takeout = {}".format(subscriberTakeOut)) if totalSubscriberTakeOut