| # Begin here with the core Evolutionary search, then get down to structures | |
| # Path: src/evolution.py | |
| # Game Plan | |
| # 1. Take textbook data for the sales agent | |
| # 2. Sales agent evolves to be better at selling | |
| # 3. Customer needs to evolve to be better at judging the sales agent and decide against buying | |
| # then we see what happens... | |
| # I guess we will just focus on various iteration methodologies here | |
| # the dataset will be used in interesting ways only | |
| # Parse the sales_textbook.txt data || use each subpoint as a Tip Unit | |
| file_path = '../data/open-source/sales_textbook.txt' | |
| with open(file_path, 'r') as f: | |
| sales_textbook = f.read() | |
| # crude filtering | |
| sales_tips = [] | |
| for subpoint in sales_textbook.split('Subpoint:'): | |
| sales_tips += [p for p in subpoint.split('\n') if len(p)>400] | |
| # print('Tip 1: ', sales_tips[1]) | |
| # print('Tip 2: ', sales_tips[2]) | |
| # from conversation import SalesSimulator | |
| # only evolve the sales agent, the customer will require extra computation & selection | |
| # --- basically the most hard-to-sell customer responses survive and form a DPO AIFT | |
| # --- the sales agent will select the best prompts to use against the customer | |
| import numpy as np | |
| tip_indices = np.random.choice(len(sales_tips), 5, replace=False) | |
| tips = 'Reference the following tips: \n <tip> \n' + '\n'.join([sales_tips[i] for i in tip_indices]) + '\n' + '</tip>' | |
| print(tips) | |
| # equip sales agent with tips | |