Very cool project @Andreas_Hegenberg ! I've been quite busy so I haven't had the time to fully explore your custom GPT.
As you know from our conversations, I've been exploring the possibility of creating BTT configurations using LLMs for some time. Here's a script I wrote in October 2024, I think you'll appreciate it 
// src/index.ts
import dotenv from "dotenv";
dotenv.config();
import OpenAI from "openai";
import { zodResponseFormat } from "openai/helpers/zod";
import { SimpleFormatSchema } from "./schemas";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
async function generateSimpleFormatItem(prompt: string) {
const responseFormat = zodResponseFormat(
SimpleFormatSchema,
"simple_format"
);
try {
const completion = await openai.beta.chat.completions.parse({
model: "gpt-4o-2024-08-06",
messages: [
{
role: "system",
content: `You are Andreas Hegenberg, the creator of BetterTouchTool.
Your objective is to help users use the new "Simple JSON Format" feature.
BetterTouchTool introduces a new "Simple JSON Format", which can currently be used
with the predefined action "Show Custom Context Menu (New)".
It allows to retrieve the content for those menus dynamically using JavaScript & JSON.
Your objective is to fully understand the user's request for a new Custom Context Menu
and then produce the JSON to implement their request.`,
},
{ role: "user", content: prompt },
],
response_format: responseFormat,
});
console.log("Completion:", completion);
const message = completion.choices[0].message;
if (message.parsed) {
const parsedData = message.parsed;
console.log("Parsed Data:", parsedData);
return parsedData;
} else if (message.refusal) {
console.log("Model refused to comply:", message.refusal);
}
} catch (error) {
if (
error instanceof Error &&
error.constructor.name === "LengthFinishReasonError"
) {
console.log(
"Response was cut off due to length. Consider increasing max tokens."
);
} else {
console.error("An error occurred:", error);
}
}
}
generateSimpleFormatItem("Create a test Custom Context Menu.");
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "SimpleFormatRoot",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/$defs/SimpleFormatItemBase"
}
}
},
"additionalProperties": false,
"required": ["items"],
"$defs": {
"Color": {
"type": "object",
"properties": {
"red": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"green": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"blue": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"alpha": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"additionalProperties": false,
"required": ["red", "green", "blue", "alpha"]
},
"SimpleFormatItemBase": {
"type": "object",
"properties": {
"title": {
"$ref": "#/$defs/AttributedText"
},
"type": {
"$ref": "#/$defs/SimpleFormatItemType"
},
"submenu": {
"type": ["array", "null"],
"items": {
"$ref": "#/$defs/SimpleFormatItemBase"
}
},
"background": {
"$ref": "#/$defs/Color"
},
"icon": {
"$ref": "#/$defs/IconDefinition"
},
"action": {
"$ref": "#/$defs/Action"
},
"setvariable": {
"$ref": "#/$defs/SetVariableDefinition"
}
},
"additionalProperties": false,
"required": ["title", "type"]
},
"SimpleFormatItemChooseFromList": {
"allOf": [
{
"$ref": "#/$defs/SimpleFormatItemBase"
},
{
"properties": {
"subtitle": {
"$ref": "#/$defs/AttributedText"
}
}
}
]
},
"SimpleFormatItemFloatingMenu": {
"allOf": [
{
"$ref": "#/$defs/SimpleFormatItemBase"
},
{
"properties": {
"width": {
"type": "number"
},
"height": {
"type": "number"
},
"templateitemuuid": {
"type": "string"
}
}
}
]
},
"AttributedText": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"color": {
"$ref": "#/$defs/Color"
},
"size": {
"type": "number"
}
},
"additionalProperties": false,
"required": ["text"]
},
"SimpleFormatItemType": {
"type": "string",
"enum": ["standard", "separator"]
},
"IconDefinition": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["sfsymbol", "path", "base64"]
},
"value": {
"type": "string"
},
"path": {
"type": "string"
},
"base64": {
"type": "string"
},
"weight": {
"type": "string"
},
"size": {
"type": "number"
},
"colors": {
"type": "array",
"items": {
"$ref": "#/$defs/Color"
}
},
"background": {
"$ref": "#/$defs/Color"
},
"width": {
"type": "number"
},
"height": {
"type": "number"
}
},
"required": ["type"]
},
"SetVariableDefinition": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": ["name", "value"]
},
"BaseAction": {
"type": "object",
"properties": {
"setvariable": {
"$ref": "#/$defs/SetVariableDefinition"
}
}
},
"NamedAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"named": {
"type": "string"
}
},
"required": ["named"]
}
]
},
"UUIDAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"uuid": {
"type": "string"
}
},
"required": ["uuid"]
}
]
},
"JSAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"js": {
"type": "string"
}
},
"required": ["js"]
}
]
},
"KeyboardAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"keyboard": {
"type": "string"
}
},
"required": ["keyboard"]
}
]
},
"ShortcutAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"shortcut": {
"type": "string"
},
"input": {
"type": "string"
}
},
"required": ["shortcut"]
}
]
},
"BTTAction": {
"allOf": [
{
"$ref": "#/$defs/BaseAction"
},
{
"properties": {
"btt": {
"type": "string"
},
"input": {},
"args": {},
"json": {}
},
"required": ["btt"]
}
]
},
"Action": {
"oneOf": [
{
"type": "string"
},
{
"$ref": "#/$defs/NamedAction"
},
{
"$ref": "#/$defs/UUIDAction"
},
{
"$ref": "#/$defs/JSAction"
},
{
"$ref": "#/$defs/KeyboardAction"
},
{
"$ref": "#/$defs/ShortcutAction"
},
{
"$ref": "#/$defs/BTTAction"
}
]
},
"ActionCategory": {
"type": "string",
"enum": [
"standard",
"hover",
"longpress",
"touchrelease",
"hoverend",
"hyperkeyrelease",
"rightclick",
"changetofalse",
"appear",
"disappear",
"ondrop"
]
}
}
}