In step 2 of process_user_message function:
# Step 2: Extract the list of products
step_2_system_message = utils.step_2_system_message
step_2_messages =[step_2_system_message] + all_messages
step_2_messages = step_2_messages + [
{'role':'user', 'content': f"{delimiter}{user_input}{delimiter}"},
]
step_2_response = get_completion_from_messages(step_2_messages)
The part of step_2_system_message is always called, so everytime you call the process_user_answer function ( which is every time a new user input is generated), you have to load the list of products and categories and add this turn in the all_messages list…So all_messages could have a lot of repeated entries:
step_2_system_message_content = f"""
You will be provided with customer service a conversation. \
The most recent user query will be delimited with \
{delimiter} characters.
Output a python list of objects, where each object has \
the following format:
'category': <one of Computers and Laptops, \
Smartphones and Accessories, \
Televisions and Home Theater Systems, \
Gaming Consoles and Accessories,
Audio Equipment, Cameras and Camcorders>,
OR
'products': <a list of products that must \
be found in the allowed products below>
Where the categories and products must be found in \
the customer service query.
If a product is mentioned, it must be associated with \
the correct category in the allowed products list below.
If no products or categories are found, output an \
empty list.
Only list products and categories that have not already \
been mentioned and discussed in the earlier parts of \
the conversation.
Allowed products:
Computers and Laptops category:
TechPro Ultrabook
BlueWave Gaming Laptop
PowerLite Convertible
TechPro Desktop
BlueWave Chromebook
Smartphones and Accessories category:
SmartX ProPhone
MobiTech PowerCase
SmartX MiniPhone
MobiTech Wireless Charger
SmartX EarBuds
Televisions and Home Theater Systems category:
CineView 4K TV
SoundMax Home Theater
CineView 8K TV
SoundMax Soundbar
CineView OLED TV
Gaming Consoles and Accessories category:
GameSphere X
ProGamer Controller
GameSphere Y
ProGamer Racing Wheel
GameSphere VR Headset
Audio Equipment category:
AudioPhonic Noise-Canceling Headphones
WaveSound Bluetooth Speaker
AudioPhonic True Wireless Earbuds
WaveSound Soundbar
AudioPhonic Turntable
Cameras and Camcorders category:
FotoSnap DSLR Camera
ActionCam 4K
FotoSnap Mirrorless Camera
ZoomMaster Camcorder
FotoSnap Instant Camera
Only output the list of objects, with nothing else.
"""
step_2_system_message = {'role':'system', 'content': step_2_system_message_content}
My idea is to change:
step_2_system_message = utils.step_2_system_message
step_2_messages =[step_2_system_message] + all_messages
by
step_2_messages =all_messages
or directly use all_messages instead step_2_messages ( i personally would use the line above, because of logic of function and programming, you make sure you are in step2)
So we had to assure that the system_message would be called the first time, so we can do it in the definition, declaration of context:
panels =[]
context = [ {'role':'system',
'content': utils.step_2_system_message} ]
What do you think ? We can save some tokens and get some efficiency ??