Developing a Conversational AI System for a Custom Scripting Language with Schema Validation

Hello dev’s,

Introduction

I’m currently engaged in the development of a conversational AI, wherein the challenge lies in translating user language into a custom scripting language. This process involves accessing variables according to a predefined list of schemas. Seeking insights and recommendations from the community on effective approaches for this endeavor.

Example

SCHEMA

[
  {
    "name": "user",
    "schema": {
      "name": {
        "type": "String"
      },
      "age": {
        "type": "Number"
      },
      "isApproved": {
        "type": "Boolean"
      },
      "credit": {
        "type": "Number"
      }
    }
  },
  {
    "name": "ticket",
    "schema": {
      "movie": {
        "type": "String"
      },
      "ticketNumber": {
        "type": "Number"
      },
      "isAdult": {
        "type": "Boolean"
      },
      "credit": {
        "type": "Number"
      }
    }
  }
]

USER INPUT

Don't approve the user if user's age is under 18 when it is adult movie

MODEL OUTPUT

if (user.age < 18 and movie.isAdult == true) 
then (user.isApproved = true) 
else (user.isApproved = false)

Notes:
In the given example, the user input and the model output reflect the desired outcome. Notably, I omitted references to “user.age” and “ticket.isAdult” in the user input, yet the output seamlessly incorporates these variables based on our custom scripting with the specified schema. I’ve successfully implemented custom scripting through fine-tuning, but without schema validation, requiring direct inclusion of “user.age” in the user input

Question: How can I achieve this scenario using the OpenAI API? Looking for insights and advice from the community!