Seeking Guidance on Where To Start

Good evening.
I am a complete noob looking to create an API for a “new scripting language” - let’s call the scripting language ~G~ for the purposes of this discussion. I’ve asked ChatGPT for advice but “he” is all over the place …or… more likely, I’m too thick to work it out. Perhaps one of you kind folks could point me in the right direction to at least get started.

Here is the current “app”:

  1. User pastes their business requirement into a " workings of ~G~ template"
  2. User copy / pastes the above template-wrapped requirement into ChatGPT prompt
  3. ChatGPT responds with ~G~ script

And here is the improved “app”
A user types his or her business requirement into the app input box and my “OpenAI ~G~ model” returns ~G~ script.

For clarity, please assume:
~G~ extends ~CommercialProduct~ ~X~

I’ve constructed the following Q+A about “~G~” to educate the base model - there is much more but the sample Q+A sample shows the format that I can easily parse into something - what that something is exactly, I have no idea.

Again, any help or pointers getting started would be much appreciated

Wors.

SAMPLE Q+A::


Q-BEG:
What is ~G-Script~?
Q-END
A-BEG:
~G-Script~ is a scripting language that has a PowerShell-like syntax.
A-END


Q-BEG:
In which environment is ~G-Script~ used?
Q-END
A-BEG:
~G-Script~ is hosted and used inside ~CommercialProduct~ ~X~
A-END


Q-BEG:
When specific ~G-Script~ guidance is unavailable, which alternative scripting language MUST be used to finalize the prompt completion?
Q-END
A-BEG:
PowerShell
A-END


Q-BEG:
What directive appears at the top of a script to indicate that the script is ~G-Script~?
Q-END
A-BEG:
All ~G-Script~ scripts MUST begin with # ~G-Script~
A-END


Q-BEG:
What is the first line of every ~G-Script~?
Q-END
A-BEG:
All ~G-Script~ scripts MUST begin with # ~G-Script~
A-END


Q-BEG:
Is the semi-colon ; mandatory as a statement terminator?
Q-END
A-BEG:
The semi-colon is optional.
This is valid:

# ~G-Script~ 
$a = 22; 
$b = 13; 

This is also valid:

# ~G-Script~ 
$a = 22 
$b = 13 

A-END

etc, etc …

Using Q&A sections might increase the input size quickly. So one suggestion is to create a documentation of ~G~ and pass that whole documentation to chatgpt as the system prompt before answering user’s request. Something looks like this might work:

"messages": [
        {
          "role": "system",
          "content": `You are the assistant who will convert any natural language from user to a programming language called '~G-Script~'.
Here is the documentation of ~G-Script~:
- ~G-Script~ is a scripting language that has a PowerShell-like syntax.

- All ~G-Script~ scripts MUST begin with # ~G-Script~

... (and many more rules you may add)`
        },
        {
        "role": "user",
        "content": "write a program that output the sum of 1 to 1000"
        }
]

I tried to run the above prompt in my computer and got the following response from chatgpt:

Sure! Here’s the ~G-Script~ code for that:

# ~G-Script~
$sum = 0
for ($i = 1; $i -le 1000; $i++) {
    $sum += $i
}
write-host $sum

This code first initializes a variable $sum to 0. It then loops through a for loop 1000 times, adding each number from 1 to 1000 to $sum. Finally, it outputs $sum using the write-host cmdlet.

Not sure if that’s what you want :slightly_smiling_face:

1 Like

Thanks for that. I have one question relating to

… (and many more rules you may add) …

Is there some kind of “token limit” on how many rules can be sent along in the system role that supports the user prompt ?
I assume the more rules you send along, the more tokens and the higher the cost per API request

wors.

Yes, there is a limit for the token. If you want to use “gpt-3.5-turbo” (which is what I used in the above example), then the token limit is 4096 (about 3500 to 4000 words).

The price for “gpt-3.5-turbo” is $0.002 per 1000 tokens, so it costs around $0.008 for each request even if you have a documentation for ~G-Script~ that is more than 3000 words long (which I think is not a lot).

If you have a very large document and want to save cost and don’t mind some trouble, maybe you can create several pages for different functions/classes for ~G-Script~. Then you can “teach” the AI how to search those pages to get what it needs before writing the answer. (Something like Bing Chat searching the internet before answering the question)

Thanks - I’ll start with your approach.