What I would do is make a new R (I assume Ruby) file.
Then use R’s comment system and write out.
=begin
Use Ruby
Take "section A" and convert it to Ruby
section A = [Paste your code Here]
=end
With that it tells the AI to use Ruby (comments help it understand language and allows you to speak to the AI.)
This is not tested but I have written a codedesc.py link to a bat file to allow me to load any code file into with comments and it seems to try its best.
codedesc.py (written by OpenAI, and me - 60/20)
import os
import json
import wget
import argparse
import random
parser = argparse.ArgumentParser(description='OpenAI Codex Code Description')
parser.add_argument('--file', action="store", dest='file', default="")
parser.add_argument('--text', action="store", dest='text', default="")
parser.add_argument('--output', action="store", dest='output', default="")
args = parser.parse_args()
def overwrite_file(file_path, string):
with open(file_path, 'w') as f:
f.write(string)
"""
2.create a function to append the string in a the file path sent to it
"""
def append_file(file_path, string):
with open(file_path, 'a') as f:
f.write(string)
"""
3.create a function to read the string in a the file path sent to it
"""
def read_file(file_path):
with open(file_path, 'r') as f:
return f.read()
import openai
openai.api_key = "[Your-Key]"
if args.file != "":
with open(args.file, "r") as text_file:
inputCode = text_file.read()
response = openai.Completion.create(
engine="davinci-codex",
prompt=inputCode,
temperature=0.2,
max_tokens=3090,
top_p=1,
frequency_penalty=0.3,
presence_penalty=0.1,
)
append_file(args.file, response["choices"][0]["text"])
elif args.text != "" and args.output != "":
response = openai.Completion.create(
engine="davinci-codex",
prompt=args.text,
temperature=0.2,
max_tokens=3090,
top_p=1.0,
frequency_penalty=0.3,
presence_penalty=0.1,
)
overwrite_file(args.output, response["choices"][0]["text"])
else:
print("use '--file [filepath]' to get description of code file.", "use --text [test] and --output [filepath] to convert text into a code file.")
Good luck
(On other thing, it might get confused and just dump code that keeps going, if so change the prompt a little more clearer, and it helps a lot.)