Jump to content

PW 3.0.209 – Core updates and an AI that knows ProcessWire


ryan
 Share

Recommended Posts

Happy New Year! This week we've got ProcessWire 3.0.209 released on the dev branch. Consider this version a release candidate (RC1) for the master/main branch. Relative to 3.0.208, this version contains primarily issue resolutions and minor improvements (commit log). If you have a chance to test it, please let us know if you run into any major issues by reporting them here. So long as no new major issues surface, by this time next week my hope is that we'll have the dev branch merged to the master/main branch for version 3.0.210.

This week one of my clients pointed me to https://chat.openai.com/ which is really quite interesting. It's an artificial intelligence that you can chat with, and it knows quite a lot about ProcessWire and how to code in ProcessWire. Though it knows a lot about a lot of different APIs, and actually a lot about everything, not just development related stuff. But I mention it here because of how it appears it's been trained fairly well in ProcessWire. 

When I asked it for examples of what CMSs it knows how to code for it told me WordPress, Joomla, Drupal and ProcessWire. I'd encourage you to get an OpenAI account to try it out, it can blow your mind. Ask it questions like how to develop a ProcessWire module, how to build a search engine in ProcessWire, how to use pagination in ProcessWire, or anything you can think of. It seems to have an answer for everything. The client that told me about it is currently using it to write AWS scripts for him, and he said it's saving him a lot of development time. 

What I also find interesting is not just how it seems to have an answer for everything, and that it knows how to code, but also that it makes mistakes pretty regularly, and recognizes those mistakes when you point them out... and apparently learns from them. That's basically how we work. For example, I asked it how to resize an image in ProcessWire and it explained through text and code examples how to use the size() method on image fields. But it also told me that I could use the $options argument to specify the type of resize interpolation (bicubic, linear, nearest, etc.) and ProcessWire has no such option. When I told it that, it apologized and corrected its code example, and also explained more details about the size() method's $options argument. 

There was another instance where it made a mistake (trying to do a PHP math operation within a string) and I explained that PHP doesn't support that. It essentially said "I know that, but my example doesn't do that". Then I asked it to double check its example because it didn't look right to me, and then it replied (paraphrased) "Oops, sorry, you are right, here's a corrected version." Anyway, it's just kind of funny to me that I'm talking to a computer with these kinds of interactions, and how it seems to "think" and learn a lot like we do. 

It will be interesting to see where this technology leads. Currently it is a free research preview, where I suppose we are helping to test the AI and help it learn, but it's very interesting and engaging just to talk with it. Also worth noting is that it does not have internet access (other than to chat with people). So it can't go and hunt down information from websites, actually making it that much more impressive in my mind.

  • Like 20
  • Thanks 6
Link to comment
Share on other sites

@ryan Thank you for one more year with PW. It would be great to hear about the PW roadmap for 2023. 

Been playing with GPT chat for almost a week, crazy stuff. AI will definitely affect humanity more than the invention of manufacturing and electricity

  • Like 6
Link to comment
Share on other sites

1 hour ago, ryan said:

Ask it questions like how to develop a ProcessWire module, how to build a search engine in ProcessWire, how to use pagination in ProcessWire, or anything you can think of. It seems to have an answer for everything.

Probably because ProcessWire has such a nice well-documented API ?. I played with it a bit and it knows how to build modules, but when I asked it to build an inputfield module, the code was what you might use for an inputfield on a page. I am trying to think of how to educate it with the correct context ?

  • Like 5
Link to comment
Share on other sites

So, I'm currently having a conversation with ChatGPT about a new module ?

Feels weird to be honest: it's quick to answer, especially at first seemed absolutely certain that every answer was the correct one, and kept making obvious mistakes. But that being said: I could've taken the initial code, made a few changes here and there, and it would've been a functional module. Now, after some iterations, it's looking almost perfect.

One problem I'm having is that the bot keeps stopping halfway through the answer. When I tried to confront if it about that, this is how it responded:

image.png.1faa258caebc25c54a23bf76c797bed1.png

Not sure we're quite on the same page here ?

Anyway, it looks like I might be able to take the code provided by the bot, polish it a bit, and put it in use. Sure it required us a dozen tries or so to get here, I had to patiently keep pointing out mistakes and suggest actual hookable methods instead of the non-existing ones that it pulled out of thin air, but that is very impressive nevertheless.

I can definitely see how this would be useful for something a little simpler ?

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

@teppo This thing is apparently kind of an alpha or beta test, but it seems full of potential and kind of cool to imagine where it's headed when the issues are worked out. At the moment, it's odd and kind of funny with the mistakes that it makes. It seemingly just makes stuff up when it doesn't know the answer to something. It's like it has some kind of creative element to it or something, which made the behavior fascinating. It's completely different from any kind of computer interaction I've had before. I love the fact that it seems to know how to code ProcessWire stuff even if it's prone to mistakes. I've not experimented with AI, machine learning, neural networks, etc., but it makes me want to learn more about it. 

  • Like 3
Link to comment
Share on other sites

Parallel projects also look very promising (and stunning), such as generating/manipulating images with DALL•E-2 or creating programming code from natural language with Codex...

Just for playing:
https://beta.openai.com/codex-javascript-sandbox

I have wrote in italian (you can copy/paste):
Crea una form con un input numerico chiamato "a" ed una select chiamata "b". alla select aggiungi due opzioni: la prima con valore 1, la seconda con valore 2. Aggiungi ora un pulsante per calcolare la somma dell'input e della select e alla pressione del bottone, visualizza il risultato in un div dal bordo rosso con spessore 1 px ed il carattere in grassetto*.

Spoiler

* Translated, is something like:
Create a form with a numeric input called "a" and a select called "b". To the select add two options: the first with value 1, the second with value 2. Now add a button to calculate the sum of the input and the select. When the button is clicked, insert the sum result in a div with a red border with thickness 1 px and bold font.

Also can create correct code in JQuery (not loaded in sandbox mode):


Command: /* Create a form with two selects in JQuery */

Response:
var form = $('<form></form>');
var select1 = $('<select></select>');
var select2 = $('<select></select>');
form.append(select1);
form.append(select2);
$('body').append(form);

 

How much coding time could be saved? Even just for the backbone of the script...

 ?

Link to comment
Share on other sites

I have been using Github Copilot for a month now and I love it. It is actually very close to pair coding. Colleague who point out your mistakes, remembers function names better than you do, does actually know regexp and also makes silly suggestions and mistakes.

With Chatgpt I noticed great use case with a list of numbers I had. They were copy pasted from somewhere and formatting those, reading into code/excel and doing some needed calculations (like avg, median and range) would have taken 5-15 mins of my time.

Now it was super fast and easy. AI didn't care about extra spaces and quotes, it did just understand the numbers and knew the math. I just delegated the task and got response back.

It did made one silly and strange mistake (427,00 => 4270,00), but after pointing that out everything was correct.

  • Like 3
Link to comment
Share on other sites

And, for me, this is totally insane: open playground (need to be logged) and copy/paste the following (or "make your own wish").

Quote

In proceswire, find all pages with "foo" template, only with parent "FOO" and "bar" greater than January the first, 2021 and having a .jpg or .pdf File. Then, with php code, echo a bootstrap responsive and striped table with id linked to admin edit  if the page is editable, title, bar and the files columns for all these pages.

This is the mind blowing response that appeared to me (except for a little error in the "files" selector):

// find all pages with "foo" template, only with parent "FOO" and "bar" greater than January the first, 2021 and having a .jpg or .pdf File 
$pages = $pages->find("template=foo, parent=FOO, bar>='2021-01-01', files.ext=jpg|pdf");

// echo a bootstrap responsive table with id linked to admin edit 
echo '<table class="table table-responsive table-striped">';
echo '<thead>';
echo ' <tr>';
echo '  <th>ID</th>';
echo '  <th>Title</th>';
echo '  <th>Bar</th>';
echo '  <th>Files</th>';
echo ' </tr>';
echo '</thead>';
echo '<tbody>';

// for each page
foreach($pages as $page) {
    echo '<tr>';
    // if editable, echo link to admin edit
    if($page->editable()) {
        echo '<td><a href="'.$page->editUrl().'">'.$page->id.'</a></td>';
    } else {
        echo '<td>'.$page->id.'</td>';
    }
    echo '<td>'.$page->title.'</td>';
    echo '<td>'.$page->bar.'</td>';
    echo '<td>';
    // for each file
    foreach($page->files as $file) {
        echo '<a href="'.$file->url.'">'.$file->name.'</a><br>';
    }
    echo '</td>';
    echo '</tr>';
}

echo '</tbody>';
echo '</table>';

speachless...

N.B. Performed in a second moment, the code is added with:

$files = $page->files;
  foreach($files as $file) {
    if($file->ext == "jpg" || $file->ext == "pdf") {
      echo '<a href="' . $file->url . '">' . $file->name . '</a>';
    }

 

Edited by Cybermano
Second moment perform
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...