Chat with DB -> queries returned as JSON files for KB

We have a custom GPT that works wonderfully to take parameters for a DB query from the user which triggers an action to run the query on our server and produce a JSON file. The downside is we have to manually drag-and-drop the newly created JSON file into the prompt for analysis and comparison against the previous JSON we gave it.

We are STUMPED on getting this work programmatically with Assistants API. Everything we attempt via a function fails. It’s as though retrieval only works as KB when the assistant is created.

We need this to work mid-session multiple times depending on the parameters of the query from the user.

Surely we are missing something obvious.

Are you using GPT API or ChatGPT? If you were using GPT API, I think you could just add an assistant message and set the content as your JSON string, that should feed the new JSON file to GPT and it should be able to analyse/compare the data for you.

This sounds like a classic function tool call? You create a single function that takes the query as the parameter (or whatever your current GPT creates to create that query?) and then the function returns the JSON.

Follow the function calling example. You should be able to practive in the sandbox as well pasting the json manually.

Yes, it is a classic function tool call. However, the returned JSON from our server is returned to GPT as though a copy/paste into the prompt (since we are using the Post method with “Content-type”: “application/json”).

When passing JSON data as strings through the prompt, you are very limited on what you can send. But when you manually drag-and-drop a file into the prompt, the amount of data the GPT can process is MUCH bigger.

Essentially we need this to be a file loader that passes form data instead to recreate the same drag-and-drop experience of uploading a file to GPT