How to make assistant read document before running a function?

Hi there I am using assistant with a function and retrieval.

How do I make it so that it reads the document that I attach into the thread and only then uses the function? At the moment it simply just generates random output and fills in the function. (The function is just structure for how I want the output to be) and the document is a multi-page document which I want it to basically summarize and rate.

I tried using the prompt and saying: after reading the document using the data run the function to return the data. No dice.

In the instructions, make sure to be very clear and concise about the order of actions that it should take.

Long instructions texts can make the GPT confused, so if you’re having issues try reducing the instructions to its minimum version, with the order of actions it should take.

Have you managed to get it to work before? Could you share some prompts?

1 Like

Since you are adding it in the thread, try including the file id in the additional_instructions.

Also you can include this in the assistants instructions telling it to consider checking the file ( mention file id) before invoking functions.

Can you show me an example of your prompt?

My function is simply the JSON format I want it to return data as however, at the moment it creates its own data while ignoring the uploaded file despite me telling it the id of the file and giving it a clear order of instructions.

Sure, here’s the full project: Explained Intuitively - Transform Your Travel: How to Build a Personalised Planner with OpenAI Assistants API