-
Notifications
You must be signed in to change notification settings - Fork 1
Second commit (usable application) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aaronchantrill
wants to merge
5
commits into
NaomiProject:main
Choose a base branch
from
aaronchantrill:ChatGPT_iterations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Second commit (usable application) #1
aaronchantrill
wants to merge
5
commits into
NaomiProject:main
from
aaronchantrill:ChatGPT_iterations
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.