Question about the "auto" keyword for function calling

Hello,
I have a naive question about how function_calling is used.
As far as I understand, one can used

  • tool_choice={"type": "function", "function": {"name": "my_func"}} to force the use of the tool at every call or

  • use the auto keyword for the model decides whether or not a function should be called.

My question is to know, in the case of the auto use, what are the conditions that trigger the use of the function.
Does it depend on the name and description of the tool ?

Thanks in advance

As the documentation says, when set to “auto” the model will pick which function, if any, to call. You would set it to something other than “auto” if you wanted it to always call a specific function? When would you do that? When your using the model as a transform to map a natural language string to function arguments.

1 Like

thanks for the reply @stevenic.
My question was more specific on the use of a given function, for example in the following case:

tools = [
    {
          'type': 'function',
          'function': {'name': 'func_1',
          'description': "use this function for <condition_1>",
          ...
    },
     {
          'type': 'function',
          'function': {'name': 'func_2',
          'description': "use this function for <condition_2>",
          ...
    },
]

What is the mechanism, when using auto, that will trigger either func_1, func_2 or no function at all.

It’s up to the model. It will generally go off the description and where the user is in the conversation but you can actually steer the model some via your prompt. I often tell the model what I want it to do and then what functions I want it to call

2 Likes

thanks.
I also tried this solution, i.e to prompt the model to use a given function and it seems to give better results indeed.

The other thing you can do is provide a fake set of user, assistant, and tool messages after your prompt, that show the model an example of how to call the function. This will dramatically improve the reliability of the model’s function calling ability. I say this a lot on here but these models are pattern matchers. If you show them an example of the behavior you expect they will follow that example.

2 Likes