Assistant always call a function

Is there a way to do few shot prompting to teach a model to NOT call a function ?

I have a chat completion model which is allowed one tool with tool_choice set to ‘auto’
But it seems that whatever the system prompt I give it, it will always try to call the function even if I ask it to not call it in the user prompt.

My system prompt is the following:

"You are a DM helper. You help dungeon master to modify already written pieces of lore for places. When asked to modify a place, you modify only the piece of lore provided to you and labeled “to_modify”. You provide the modification in the same format as you received it: the population number of the place if known. -a detailed description of the place in about 10 sentences. -a summary of this lore in 2 or 3 sentences. The summary must always contain the name of the place. You always give all those requested informations. You never great the user. You call the function if the user asks to save. You NEVER call the function if the user did not ask to save.

user query:
can you write a description for a mysterious forest and save the description

assistant:
Function(arguments=‘{\n “name”: “Shadow wood”,\n “summary”: “The Shadow wood is a dense and enchanted woodland located in the mystical region of Eldoria. It is home to ancient trees, magical creatures, and hidden treasures.”,\n “detailed”: “The Shadow wood is shrouded in an ethereal mist that gives it an otherworldly appearance. The trees are tall and gnarled, their branches reaching out like skeletal fingers. The forest floor is covered in a thick carpet of moss and fallen leaves, muffling the sound of footsteps. Strange and colorful mushrooms grow in abundance, their glow illuminating the darkness. The air is heavy with the scent of earth and magic, and whispers can be heard carried by the wind. It is said that those who enter the forest may never find their way out, as the paths constantly shift and change. Only those with a pure heart and a keen sense of direction can navigate its treacherous depths.”,\n “region”: “Eldoria”,\n “population”: “Unknown”\n}’, name=‘save_place’)

user query:
can you write a description for a mysterious forest

assistant:
name: Shadow wood
region: Eldoria
population: Unknown
detailed Description: The Shadow wood is shrouded in an ethereal mist that gives it an otherworldly appearance. The trees are tall and gnarled, their branches reaching out like skeletal fingers. The forest floor is covered in a thick carpet of moss and fallen leaves, muffling the sound of footsteps. Strange and colorful mushrooms grow in abundance, their glow illuminating the darkness. The air is heavy with the scent of earth and magic, and whispers can be heard carried by the wind. It is said that those who enter the forest may never find their way out, as the paths constantly shift and change. Only those with a pure heart and a keen sense of direction can navigate its treacherous depths.
summary: The Shadow wood is a dense and enchanted woodland located in the mystical region of Eldoria. It is home to ancient trees, magical creatures, and hidden treasures."

Is there something I could do ?

Can you share the description of the function you are passing to the model? That is where you should probably add the info about “Only call this function if the user says to save the description”.

2 Likes

Yes that’s already present in the function description. Maybe not good enough.

custom_tools.append(
{“type”: “function”,
“function”: {
‘name’: ‘save_place’,
‘description’: ‘Saves the newly created place. Only use when the user asks to save the place.’,
‘parameters’: {
‘type’: ‘object’,
‘properties’: {
‘name’: {
‘type’: ‘string’,
‘description’: ‘Name of the place’
},
‘summary’: {
‘type’: ‘string’,
‘description’: ‘summary of the description of the place’
},
‘detailed’: {
‘type’: ‘string’,
‘description’: ‘A detailed description of the place’
},
‘region’: {
‘type’: ‘string’,
‘description’: ‘The region in which the place is located.’
},
‘population’: {
‘type’: ‘string’,
‘description’: ‘The population of the place.’
}
}
},
“required”: [“name”, “summary”, “detailed”, “region”, “population”],
}
}
)