-
Notifications
You must be signed in to change notification settings - Fork 53
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
Show the default prompt as the first prompt in our settings #610
Conversation
…his prompt can't be edited or deleted
Note that there are some failing tests here due to these changes but wanted to get some feedback on if we think this is the right approach before spending time getting those fixed up (and adding some additional tests) |
@dkotter I exceed the daily query limit, so I cannot test this feature. I have following questions -
|
Yes, though we can update this if we think it's worth it. I didn't change any of the JS logic for that, just on the PHP side, so it only shows Edit: as part of the changes requested below, I've actually changed this to just always show |
Structurally I think this is good. As a future UI iteration, I'd like to see us collapse a good bit of the UI around the default (we don't need the full text field/area) so that it takes up less vertical space. Something more like this: However, I'm fine with the current implementation as it achieves the same purpose but a future tweak could make the UI a bit simpler/cleaner. |
…ag and hide the other fields. Remove a field description that isn't needed. Remove styling that is no longer needed.
Yeah, I like this and considered something similar before sticking with what we had. But it was easy enough to make this change so I've gone ahead and done that: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkotter I left a few minor comments which are not blockers. This pull request is working as expected.
<input type="hidden" | ||
name="<?php echo esc_attr( $field_name_prefix . "[$field_index][default]" ); ?>" | ||
value="<?php echo esc_attr( $prompt['default'] ?? '' ); ?>" | ||
class="js-setting-field__default"> | ||
<input type="hidden" | ||
name="<?php echo esc_attr( $field_name_prefix . "[$field_index][original]" ); ?>" | ||
value="<?php echo esc_attr( $prompt['original'] ?? '' ); ?>"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkotter I suggest use the trinary short syntax ?:
instead of the null coalescing operator??
, because original
value can not be null
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So short ternary's aren't allowed by our PHPCS config so we would need to change this to ! empty( $prompt['original'] ? $prompt['original'] : ''
which I'm fine with changing that if we feel it's better. The goal here was to be defensive for a situation where this array value wasn't set (which should never happen) and using the null coalescing operator would catch that.
Description of the Change
Following on from #602, this PR ensures that our default prompt within ClassifAI always shows as the first prompt in our settings. This prompt can't be edited and can't be removed. This makes it easier for someone to go back to using the ClassifAI default prompt.
Important to note that to keep things simple, this ClassifAI default prompt is added and saved just like any other prompt. This does mean the prompt itself is saved in the database. In order to support situations where we may change the default prompt at a code-level, if this prompt is selected, instead of using the prompt text that is stored in the database, we use the prompt that is in the code.
The new flow will be as follows:
When first setting up a feature that uses prompts (like Title Generation), the only prompt you'll see is the default that is included in ClassifAI. The prompt fields are there but hidden (this allows us to save this as the default prompt):
If a custom prompt is needed, instead of editing the default prompt (which is how things landed in #602), you'll now need to click the
Add new prompt
button and then set a custom prompt in the fields that are added. In addition, to use the new prompt, you'll need to set that as the default:You can add as many new prompts as needed, set whichever of those you want to be the default and delete any of those prompts. But you can't ever delete the ClassifAI default prompt but you can at any point set that as the default again.
How to test the Change
openai_chatgpt
option)Changelog Entry
Credits
Props @dkotter, @jeffpaul
Checklist: