Best practice for describing function enum choices

What are some best practices for describing to the Assistant the different choices in an enum, so that it can determine which value the user wants without having to make a literal match?

For example, I have a function, and the parameter choices are custom terms that are specific to some use case.

{
	"name": "load_box",
	"description": "Load the box with a special thing.",
	"parameters": {
		"type": "object",
		"required": [ "thing" ],
		"properties": {
			"thing": {
				"type": "string",
				"description": "The special thing to load into the box",
				"enum": [
					"foozle",
					"bartingus",
					"gherp",
					"krenket"
				]
			}
		}
	}
}

Now I want to empower the Assistant to make choices based on descriptions of those terms. I don’t see support in the JSON schema for describing them. I tried file_search, uploading this text file:

This document describes special things that can be loaded in a box.  
•	A foozle is a round red squishy thing.
•	A bartingus is a square green squishy thing.
•	A gherp is a round blue hard thing.
•	A krenket is a square yellow hard vegetable.

It didn’t really work. For example, “load the box with a blue thing” would result in it picking one of the choices arbitrarily then attaching the adjective - e.g. “I loaded the box with a blue foozle”.

In one test, I asked it a question that triggered retrieval, and once the choice descriptions were in the chat history, it started working. That suggests that one workaround would be to add a hidden message to the history with the descriptions, but that doesn’t seem practical since it would fall out of the context window.

One time I was it actually do retrieval first, then it ran the function call, which makes me thing that describing things through retrieval perhaps isn’t the best approach.

The way that a description of a property is presented to the AI is like:

// The special thing to load into the box
thing:str "fougasse" | "maritozzo" | "paratha" | "lepeshka" | "rugbrød"

Therefore you could place a better description:

"description": "Possible items for bread box, use the one that best fulfills the user needs, one of:\n{\"fougasse\":\"A French flatbread often shaped like a leaf and filled with herbs, olives, or cheese.\",\"maritozzo\":\"A Roman sweet bun filled with whipped cream.\",\"paratha\":\"An Indian flatbread made with whole wheat flour, often layered or stuffed.\",\"lepeshka\":\"A round, flat Central Asian bread, typically baked in a tandoor.\",\"rugbrød\":\"A dense Danish rye bread made with whole grains and seeds.\"}"

The function is the place to describe the function. The names also should be instructive.

2 Likes

I tried this and it worked perfectly. It’s good to know that the descriptions can be quite detailed. Thank you.

1 Like