Chat3.5 API function - aware, but not called

Telling a word-generation algorithm “be thoughtful” is the first step towards failure.

And then I don’t understand what you’re trying to do or show with the roles you have in the code. If you run that, you show that the email was sent - and you’ve provided the answer for the AI yourself.

Inputs to the AI should be:
history + user input

After function is invoked:
Same input and user question as before, but with:
assistant: function_name(function_parameters)
function: {output of API return}

then the combination of user question, assistant calling function, function answering, then gives the final ability for the user question to be fulfilled.