Nebula icon indicating copy to clipboard operation
Nebula copied to clipboard

Create AI function wrappers/helpers to make it easier to interface with various AI APIs

Open chrisblakley opened this issue 10 months ago • 5 comments

First two will be OpenAI (PHP) and Gemini (JavaScript).

The OpenAI PHP function should also have an AJAX counterpart.

Then adjust existing AI functionality into these endpoints– Dashboard code review, and the three current AI tech demos.

chrisblakley avatar Jun 06 '25 17:06 chrisblakley

Note that some parameters such as temperature have set values that cannot be changed for certain models. So for example temperature can be changed to be like 0.2 for gpt-4.1-mini to be more deterministic, but for o4-mini it will error if the temperature is not 1.

chrisblakley avatar Jul 25 '25 19:07 chrisblakley

Update the prompt functionality itself to accept a $system_prompt, and $user_prompt parameter instead of just a user prompt.

Image

The order should be one of the following:

Option A:

  1. $user_prompt
  2. $model
  3. $system_prompt

Option B:

  1. $user_prompt
  2. $system_prompt
  3. $model

Option C: Use an associative array so that the order does not matter.

I'm leaning towards Option C because there will certainly be other options in the future.

chrisblakley avatar Jul 25 '25 19:07 chrisblakley

This has been started. Using Option C for parameters. AI functionality will be in its own Trait within /libs/Utilities/Ai.php

chrisblakley avatar Aug 08 '25 19:08 chrisblakley

Consider an Elevenlabs API function... Not sure if this would be all that useful, but may be worth having. Might also be worth adding a JavaScript browser-side text-to-speech functionality too (as a fallback for Elevenlabs). The Elevenlabs functionality should be server-side even though it would mostly be used client-side.

chrisblakley avatar Aug 08 '25 19:08 chrisblakley

Triggering this from JavaScript will include some interesting decisions. I'd like to have JS functions to make prompting the Gemini API and the OpenAI API easier, however I don't want to limit the flexibility of child theme developers while still making it convenient/easy to use.

Another thought is how do we prevent end-users from simply calling the JavaScript function in the console to run their own prompts using the OpenAI API? I think the main approach will be to limit the prompt itself in PHP and to cache any "like" prompt responses.

By limiting the prompt on the server-side, we would need to have the child theme PHP function call the Nebula prompt function, but the AJAX PHP function would need to call the child theme function... So what can Nebula even do here to conveniently wrap this? Other than just give an example in the documentation? hmmmm.....

chrisblakley avatar Aug 11 '25 02:08 chrisblakley