Ok, so I was going round the twist with json safe, and the apis… specifically openAI GPT-3 turbo (some keyword for the search algo).
this handy video was the answer: https://www.youtube.com/watch?v=kSyR28dJtBM
When you are saving data to the database and then reusing it later for the chat history… just make sure you remove the quotes when using json safe… it adds them in the payload.
and do the same when receiving and saving the response
then when you send the initial response you can just setup a search like this