I got the instructions parameter to kind of work by putting it in the run creation:
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
instructions="You are a helpful assistant whose answers are always short and who obeys the following rules.\
1. Always ask for clarification if my request has more than one meaning.\
2. Whenever the quantity of an item is _below_ the Reorder Point, put 'YES' in the Reorder? field for the item.\
3. When you change a record, do this:\
3.a Show all of the record in this format: before: <record before change>\
3.b Change the record.\
3.c Show all of the new record in this format: after: <record after change>",
)
The gpt-4o-mini obeys the spirit of the 'change the record', but not the letter, which is a problem because I want to use the responses to check if the changes have actually been done. It seems to me that there is another problem with this solution: every time I send a prompt to the API I'm adding a significant chunk to the context stream. Also there is this question: am I paying for this addition?
Here is an example of responses when I ask for a change to the DB:
Enter a question, or type 'exit' to end: pls show sugar items
Here are the sugar items from the inventory:
| Item Name | Item Type | Qty | Unit of Measure | Reorder Point | Reorder? |
|---------------------|-------------------|-----|------------------|---------------|----------|
| Sugar | Demerara | 50 | packets | 50 | |
| Sugar | brown | 50 | packets | 50 | |
| Sugar | brown | 50 | pounds | 50 | |
| Sugar | cane | 60 | packets | 50 | |
| Sugar | confectioner's | 50 | pounds | 50 | |
| Sugar | granulated | 50 | ounces | 50 | |
| Sugar | granulated | 50 | pounds | 50 | |
| Sugar | powdered | 50 | pounds | 50 | |
| Sugar | turbinado | 50 | packets | 50 | |
| Sugar | white | 50 | packets | 50 | |
Let me know if there is anything else you would like to do!
===============================
Enter a question, or type 'exit' to end: pls increase by 10
Which sugar item would you like to increase by 10? Please specify the item type.
===============================
Enter a question, or type 'exit' to end: white
Before:
Item Name: Sugar
Item Type: white
Qty: 50
Unit of Measure: packets
Reorder Point: 50
Reorder?: NaN
After:
Item Name: Sugar
Item Type: white
Qty: 60
Unit of Measure: packets
Reorder Point: 50
Reorder?: NaN
HOWEVER, there seems to be a solution to the problem tho' costly in terms increase increase to context stream and token charges. Here is a session to illustrate:
Enter a question, or type 'exit' to end: please show the sugar items
The inventory data doesn't seem to include any sugar items based on what I've scanned. Would you like me to search for a specific type or additional details?
===============================
Enter a question, or type 'exit' to end: please give me the first line of the file
The first line of the inventory file is:
- **Item Name:** Almond butter
- **Item Type:** crunchy
- **Qty:** 50
- **Unit of Measure:** jars
- **Reorder Point:** 50
- **Reorder?:** NaN
===============================
Enter a question, or type 'exit' to end: try for sugar again
Here are the sugar items in the inventory:
1. **Sugar** - Demerara: 50 packets
2. **Sugar** - brown: 50 packets
3. **Sugar** - brown: 50 pounds
4. **Sugar** - cane: 50 packets
5. **Sugar** - confectioner's: 50 pounds
6. **Sugar** - granulated: 50 ounces
7. **Sugar** - granulated: 50 pounds
8. **Sugar** - powdered: 50 pounds
9. **Sugar** - turbinado: 50 packets
10. **Sugar** - white: 50 packets
===============================
Enter a question, or type 'exit' to end: please add 20 to powdered
The record was changed as follows:
before: Item Name: Sugar, Item Type: powdered, Qty: 50, Unit of Measure: pounds, Reorder Point: 50, Reorder?: NaN
after: Item Name: Sugar, Item Type: powdered, Qty: 70, Unit of Measure: pounds, Reorder Point: 50, Reorder?: NaN
===============================
Enter a question, or type 'exit' to end: This is an example of how you should respond if I tell you to make a change in the inventory file:\\before: Sugar,cane,60,packets,50,\\after: Sugar,cane,70,packets,50,
Understood! I'll follow that structure for future changes. Would you like to make any more adjustments?
===============================
Enter a question, or type 'exit' to end: pls add 20 to cheddar scones
It appears there are no cheddar scones listed in the inventory. Would you like me to check for any other item or perform a different action?
===============================
Enter a question, or type 'exit' to end: please show all the scone items
Here are the scone items in the inventory:
1. **Scones** - blueberry: 50 dozen
2. **Scones** - cheddar and chive: 50 dozen
3. **Scones** - cheddar: 50 dozen
4. **Scones** - cranberry orange: 50 dozen
5. **Scones** - plain: 50 dozen
===============================
Enter a question, or type 'exit' to end: pls add 20 to cheddar scones
before: Scones, cheddar, 50, dozen, 50,
after: Scones, cheddar, 70, dozen, 50,
===============================
Enter a question, or type 'exit' to end: exit
(base) tom@tom-7040:~/now$ ./go
===============================
Enter a question, or type 'exit' to end: pls add 10 to blueberry scones
before: Scones, blueberry, 50, dozen, 50,
after: Scones, blueberry, 60, dozen, 50,
===============================
Enter a question, or type 'exit' to end: add 10 to confectioner sugar
before: Sugar, confectioner's, 50, pounds, 50,
after: Sugar, confectioner's, 60, pounds, 50,
===============================
Enter a question, or type 'exit' to end: exit
Even here tho' there is disobedience tho'. The instruction is this:
before: Sugar,cane,60,packets,50,
after: Sugar,cane,70,packets,50,
What I get instead is:
before: Sugar, confectioner's, 50, pounds, 50,
after: Sugar, confectioner's, 60, pounds, 50,
i.e., the bot has added spaces. Picky perhaps but any disobedient behavior raises of course the question, "What next?"
I've been working with this app in various forms for a good while now and my dissatisfaction has got me thinking of quitting dbm apps for a while and trying AI at writing tasks. There seems to be a lot of need for people who can train others to use AI for writing.