Skip to content

Conversation

@aaronchantrill
Copy link
Contributor

This program was written primarily by ChatGPT to help users build speechhandler plugins for Naomi, and then submit them to the Naomi Plugin Exchange. I'm very interested to hear about anyone's experience with it, good or bad, any issues encountered, etc. or any suggestions about how to improve the instructions in the README.md file.

Here was my first request to ChatGPT to get it to generate a
plugin generator specifically for generating speechhandler plugins
in the Naomi style:

"I would love your help in creating a tool in python to help people
create new speechhandler plugins for Naomi. Here is an example
speechhandler plugin:
https://github.com/aaronchantrill/NaomiNetworkCheck

"One of the big issues with the Naomi project is making it easy for
people to register their plugins with the project. Right now, you
have to create a plugin.info file with your plugin that includes
the url of the repository that will be hosting it (on github,
gitlab, etc.) then when you "publish" your plugin, you have to
create a new pull request where you insert a new line into the CSV
file at
https://github.com/NaomiProject/naomi-plugins/blob/master/plugins.csv
which includes a lot of the information in the plugin.info file,
plus the actual commit signature of the current version. This
information is hard to synchronize. What I would like would be a
GUI for adding a bunch of intent keywords and templates, then the
name, description and license to generate a simple plugin that
just repeats back what it hears. The user then edits the python in
whatever ide they like, then when they are ready to publish, they
reopen the GUI, select the project, and hit a publish button.
This will automatically collect the information from the
plugin.info file, push the current version to github, then make a
pull request with the new line in the CSV file. Does that make
sense?"

This pull request is what ChatGPT first came up with. I wasn't
specific about what packages to use for the GUI part, both
because I assumed it would use something normal like tkinter
and because I was interested to see what it would choose if it
chose something else. It chose to use PySimpleGUI. When I
tried to pip install it, I got a EULA informing me that the
package requires registration and for non-hobbyist users it
also requires a paid subscription. This was a non-starter for
me since I can imagine that business users might want to
create plugins, and forcing them to license a Python package
due to an arbitrary choice by ChatGPT just didn't seem
reasonable. Requiring users to register is also problematic
for me from a privacy perspective. It looks like PySimpleGUI
is in the process of shutting down anyway. I never actually
tried to run this version.
shutting down completely anyway.
Here is my next request:

    "I don't want to use PySimpleGUI since it would require my
    users to license their package. Could you write the GUI in
    tkinter instead?"

and ChatGPT's response is what I am committing. This version ran,
but it was obvious that ChatGPT did not understand the actual
structure of a Naomi intent.
Here is my third request to ChatGPT:

    A Naomi intent needs to have both templates and keywords.
    Right now you only have the keywords, and that is as a comma
    separated list. The keywords actually need to be a list of
    dicts that contain lists. I think the example I gave you
    before was too simple. Here's a better example which has
    a more complete intents structure:
    https://github.com/aaronchantrill/naomi_nws_weather.git

The response is this version. ChatGPT did provide spaces for
entering an intent name, a comma-separated list of templates and
a comma-separated list of keywords, although it did not get
how the keywords are meant to be used.
Here is my fourth request to ChatGPT:

    Okay, but the keywords are still just a simple list. The
    keywords should be a dictionary. This is so the keyword name
    can be used to pass the value in the resulting user intent.
    For instance, if the user says "What is the forecast for
    tomorrow?" the intent sent to the handler would be something
    like this:

        intent: {
            "matches": {
                [
                    'WeatherKeyword': ['forecast'],
                    'DayKeyword': ['tomorrow']
                ]
            },
            'text': "What is the forecast tomorrow"
        }

    That way the plugin just has to check the value of
    intent['matches']['DayKeyword'] to know what day(s) the user
    is asking about.

    "Also, a 'publish' tab sounds great. Please go ahead and
    add that functionality"

The response is this version, which finally got the actual intent
structure correct, but it did contain a couple of other minor
errors that prevented it from running. The next commit will
contain the fixes for those issues.
A couple of these issues showed up when I first ran the code, but most of them
showed up when I tried testing the plugin that the code generated. The actual
process of pushing the generated plugin, forking the naomi-plugins repository,
adding a line to plugins.csv, pushing that to the forked repository and then
creating a pull request all appears to have gone fine except for the fact that
the master branch of my forked repository had diverged. I've since learned the
importance of always committing my changes to a temporary branch so I can keep
my master/main branch synchronized with upstream.

main.py - Added a shebang and set the execute bit in permissions so it can be
run directly rather than as a python argument. Added logging and fixed the
name of an imported function that I had to change.

plugin_editor.py - It bothered me that the background colors of the form
controls where inconsistent for no good reason. I decided I wanted to use
white for controls that the user can type directly into, and grey for
controls that are read-only or have to be modified using the side-buttons.

plugin_generator.py - This was where I found most of the issues, and mostly
with the plugin that the system generated rather than with the program itself
running.

First, it imported the SpeechHandlerPlugin class directly, which caused an
issue where the plugin system was only expecting one class to be directly
defined. I had to change it to import plugin rather than the
SpeechHandlerPlugin class directly.

Second, I really didn't like the way it formatted the intents it was defining.
It was using pprint.pformat for formatting the intent structure, but this was
doing odd stuff like inserting single quotes into the wrong places, causing
the resulting plugin to generate syntax errors. I much prefer the formatting
of json.dumps, so I switched to using that. I was also able to simplify the
generation code, as the program was doing unnecessary processing.

Third, a simple handle script like this should always return True. It would
only return False if the handler determined that it was unable to handle the
request. This is generally used with expect() and confirm().

The keywords were being defined with self.gettext() around them, which is not
necessary or desireable here because we are defining different locales, and
there may be more ways a user might choose to say something in one language
than another. GetText is more for translating interface labels to different
languages. This is probably because of one of the examples that I showed to
ChatGPT.

Finally, the request text is gotten using the 'input' property of the intent,
not the 'text' property.

publisher.py - the "Plugin" section and "Name" and "License" values must be
capitalized in order to be used by Naomi. Also, the repository url belongs
in the "URL" value, not "repo_url". Finally, ChatGPT both imported a
read_plugin_info function from storage and then defined a read_plugin_info
function that called it, resulting in an infinite loop/stack overflow.

This was an interesting experiment. Most of the mistakes that ChatGPT
made were similar to things I would expect a junior programmer to have
trouble with also, but I don't know that I can explain why things
should have been written differently to ChatGPT or if that would be
worthwhile. It was motivating to see the application come together
so quickly, and I enjoy debugging so I think it was helpful.
@aaronchantrill aaronchantrill changed the title Initial commit Second commit (usable application) Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant