{
  "settings": {
    "type": "object",
    "title": "OpenAI API Settings",
    "additionalProperties": false,
    "properties": {
      "api": {
        "type": "string",
        "title": "api hash",
        "required": true,
        "minLength": 1,
        "description": "create / find your API Key on platform.openai.com"
      }
    }
  },
  "collections": {
    "assistants": {
      "type": "object",
      "title": "Assistant",
      "description": " Control a GPT Assistant",
      "required": ["name", "settings"],
      "properties": {
        "name": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "readOnly": true
        },
        "settings": {
          "type": "object",
          "additionalProperties": false,
          "required": ["instructions", "temperature", "model", "description"],
          "properties": {
            "instructions": {
              "type": "string"
            },
            "description": {
              "type": "string"
            },
            "temperature": {
              "type": "number",
              "description": "A high temperature (1.0) leads to more creative outputs, while a low temperature (0.1) produces more focused and repetitive responses"
            },
            "model": {
              "type": "string",
              "enum": [
                "gpt-4o",
                "gpt-4o-2024-05-13",
                "gpt-4o-mini",
                "gpt-4o-mini-2024-06-20",
                "gpt-4-turbo",
                "gpt-4-turbo-2024-04-09",
                "gpt-4",
                "gpt-3.5-turbo",
                "gpt-3.5-turbo-0125",
                "gpt-3.5-turbo-1106"
              ]
            }
          }
        }
      },
      "additionalProperties": false
    }
  },
  "data_variables": {
    "threads": {
      "name": {
        "type": "string"
      },
      "id": {
        "type": "string",
        "pattern": "^thread_[a-zA-Z0-9]+$"
      }
    }
  },
  "action_variables": {
    "sendPrompt": {
      "response": {
        "type": "string"
      }
    }
  },
  "actions": {
    "sendPrompt": {
      "type": "object",
      "title": "Send prompt",
      "description": "prompt message to GPT Assistant",
      "documentation": "https://docs.adaptorex.org/basics/actions/openai/sendPrompt.html",
      "template": "{ return { title: `openai ${action.name}`, body: [{ text: ` ${payload.assistant || 'Prompt'}: '${payload.prompt}'${ payload.instructions ? `, with instructions: '${payload.instructions}'` : '' }` }]} }",
      "required": ["prompt"],
      "additionalProperties": false,
      "properties": {
        "assistant": {
          "title": "Assistant",
          "$ref": "#/definitions/openai_assistants"
        },
        "prompt": {
          "title": "Prompt",
          "type": "string",
          "format": "textarea"
        },
        "instructions": {
          "title": "Additional instructions",
          "type": "string",
          "format": "textarea"
        },
        "thread": {
          "title": "Thread",
          "description": "can be Thread Object, name or ID",
          "type": "string"
        },
        "model": {
          "title": "Model",
          "type": "string",
          "enum": [
            "gpt-4o",
            "gpt-4o-2024-05-13",
            "gpt-4o-mini",
            "gpt-4o-mini-2024-06-20",
            "gpt-4-turbo",
            "gpt-4-turbo-2024-04-09",
            "gpt-4",
            "gpt-3.5-turbo",
            "gpt-3.5-turbo-0125",
            "gpt-3.5-turbo-1106"
          ],
          "default": "gpt-4o"
        }
      }
    },
    "createThread": {
      "type": "object",
      "title": "Create Thread",
      "description": "start a persistent conversation with gpt",
      "documentation": "https://docs.adaptorex.org/basics/actions/openai/createThread.html",
      "template": "{return { title:`openai ${action.name}`, body:[{ text: `Add Thread '${payload.name}' ${payload.assistant ? `with '${payload.assistant}'` : ''} ${payload.reference ? `as '${payload.reference}'` : ''} `}]} }",
      "required": ["name"],
      "additionalProperties": false,
      "properties": {
        "assistant": {
          "$ref": "#/definitions/openai_assistants",
          "description": "Optionally assign a assistant to the thread"
        },
        "name": {
          "description": "give the conversation a meaningful name",
          "type": "string"
        },
        "reference": {
          "type": "string",
          "minLength": 1,
          "description": "Set an optional name reference to easily access the thread in this level."
        }
      }
    }
  }
}
