Customizing Assistant's Response After Function Call in Python Chatbot with Function Calling API

Hello everyone,

I’m working on a chatbot using Python and Vue, and I’m leveraging function calling APIs for various actions. I’m facing an issue where I want the assistant to return only a JSON response after a function call, without any additional natural language messages.

Here’s what I’m trying to accomplish:

I have a function (send_email) that processes an email action and returns a result.
Instead of the assistant adding a default message (e.g., “Your request has been successfully submitted…”), I need the response to be strictly a JSON object, such as:
json
Copia codice
{“status”: “success”, “message”: “Email sent successfully”}
What I’ve tried:

I modified tool_outputs to return the JSON object directly, but the assistant still responds with a default message along with it.
Since client.messages.create isn’t available, I also considered adding a secondary function (e.g., send_custom_message) to send only the JSON, but I’m not sure if this is the best approach.
Has anyone successfully configured a chatbot using function calling to return only a JSON output after a function call? Any guidance or insights would be greatly appreciated!

Thanks in advance!