oik-ai is my AI tool. It uses OpenAI to respond to freeform prompts to generate or manipulate content for my WordPress websites.
It’s my experimental tool for playing with AI. I wanted to learn how to use AI to Enhance Search, but first I had to get to grips with the functionality that I’ve been cataloguing in this site. Wherever I refer to “my AI tool”, it’s this code that I’m talking about.
Text content generation and manipulation
prompts.json to add more standard prompts or change existing prompts.
The chat part of the implementation offers several Standard prompts that are passed to OpenAI as part of the Message structure.
If you choose None, leave the other fields empty, and press the Send button, then the response is
Hello! How can I assist you today?
Several of the other prompts will also result in an AI generated response that appears to have been plucked from nowhere. Others will say there’s something missing.
System message and User message
These fields are where you customise the prompt and provide the content to be manipulated. eg. For Translate to
oik-ai – the new – my AI tool
We get the response in the Assistant message.
oik-ai – le nouveau – mon outil d’IA
I then copy and paste the response into the relevant part of the website.
stop indicates the
finish_reason of the request.
When I want to manipulate content I write a System Message saying what I want done and paste the original content in the User Message.
Differences between oik-ai and ChatGPT tools
The OpenAI model allows you to pass multiple sets of User Message and Assistant Message, thereby implementing a conversation. If you use ChatGPT you can have a conversation. I’ve been using oik-ai instructively… I write what I want and expect the answer first time. If I don’t get the answer I wanted I modify my System and User messages and try again. Sometimes it works, sometimes it does.
DALL·E 3 can generate images in 3 different sizes:
- Square – use the button labelled `Image: 1024×1024
- Portrait: 1024×1792
- Landscape: 1792×1024
If you want a different sized image you’ll have to manipulate the generated image yourself.
To generate an image ( DALL·E 3 can only do one at time ),
- choose prompt of None,
- enter the first part of your request in the System Message
- and the details in the User Message.
- Press the button for the image size you want.
oik-ai uses the System Message to construct the filename for the generated image. Each image is automatically saved.
For a random image just click on an image button.
About the code in oik-ai
I started building oik-ai it in November 2023. Written in PHP it uses the OpenAI PHP client library. At present it’s not actually a WordPress plugin. It’s some standalone PHP that I run in my local development environment. I’ve only recently bundled the code into a WordPress plugin, but I’ve not actually integrated it with WordPress. It’s currently dependent upon some of my code which is in a private repository, so it’s not something you can download and try.
It uses some hardcoded directories to read and write files.
saved– to store the prompt/response history for both text and image requests as
ai– ( C:\apache\htdocs\ai ) where it stores images as