Processing JSON - best practices?

I have a application where I want to process JSON-objects through the api.

I have experimented and got it to work decently with the chat functionality through the OpenAI nugget for .NET.

However, the AI still doesnt follow my instructions entirely in some cases.

Therefore, I have moved on to try the assistant API instead, but I find that this causes even more issues.
When the AI gives me a invalid response I try to write to it through the UI and tell it what it did wrong and how it should do it in the future, but it doesn’t really seem to help.

To describe what I want to do in short I have a JSON that looks something like:

“bookId”: “123123”,
“title”: “”,
“description”: "A description of the book that is quite long and tells information regarding what the book is about ",
“author”: “Allison Hubert”,
“authorId”: null,
“authorContactName”: null,
“authorContactPhone”: null,
“authorContactEmail”: null,
“publishedDate”: “2024-01-30T07:17:47.000Z”,
“category”: null,
“noOfPages”: “”,
“keywords”: ,
“cost”: “30”,

I want the AI to analyze the description and find keywords regarding the book, and put in the keywords array. I also want it to add a category of the book based on the description. I then want it format the description in Markup. And finally, return the new JSON to me.

Now, friends. I wonder if there is someone out there who have done something similar before, and can point me in a good direction…
What should I think about when writing the instructions to the AI? Which engine should should I use? Other general advises?

Many thanks in advance.

Not every job is a job for an LLM.

Use the model for what it’s good at, do the rest yourself.

  1. Extract the description from the JSON.
  2. Have the model generate the keywords and category from the description.
  3. Insert the keywords and the category into the JSON yourself.
1 Like