Force using GPT for tasks in assistants API

Hey, i use the assistants api for data which also contains text. On the text i also want to perform NLP tasks like sentiment analysis in by the assistant. I realized, that this works much better by using the GPT itself instead of the code interepreter. However, i have to enable code interpreter in the assistant for other tasks. How can I enforce in the instructions, that the assistant uses code interpreter to read the data from a json and then does sentiment analysis using GPT-4 itself? A workaround would be to use a custom function and do a seperate api call to chatpgt without code interpreter, but i want to avoid this.

It is not guaranteed but you can use prompt engineering in the message and instructions to condition the assistant.

Another idea is that you enable and disable the tools that you need in the thread. Partition the tasks for the assistant, ask it first to compute the data. Then, remove code interpreter and ask it to estimate sentiment.

Still, for this use-case as it seems you’re not really using code-interpreter for something code-heavy, you can load the json inside an .md file or attached to the instructions and skip the code interpreter step altogether.

Code interpreter as a means to access data is not ideal. Retrieval also doesn’t ensure that the AI sees all information at once.

If you have processing of text you want to do, I would instead place it directly in the instructions yourself. And then the use of assistants that keeps on sending back conversation history to the AI model at increasing costs doesn’t seem budget friendly to continue inquiries about new data in the same thread.

Consider the additional steps: The AI must write code simply to read a file using python and then write the notebook line that will output the text into AI function return language. The amount of text that can be returned as language to an AI I haven’t explored, but truncation rather than error is going to be likely.

Then for sentiment analysis, you’ve got a bunch of file text that is not batch-oriented.

For this particular task, individual API calls to a completions endpoint to “extract sentiment: {document item}” are going to have much higher quality at understood costs, and can then easily be integrated alongside the information itself in a database.

The AI has the skill to write code for data processing from files to send individual entities to a get_sentiment() function - that you run in your own environment.