Simplify Claude prefill code

This commit is contained in:
Cohee 2023-08-20 19:26:49 +03:00
parent 6e6eb8f61e
commit be6fedd626
3 changed files with 12 additions and 14 deletions

View File

@ -1455,11 +1455,11 @@
</div>
</div>
<div class="range-block" data-source="claude">
<label for="exclude_assistant" title="Exclude Assistant prefix" class="checkbox_label widthFreeExpand">
<input id="exclude_assistant" type="checkbox" /><span data-i18n="Exclude Assistant prefix">Exclude Assistant prefix</span>
<label for="exclude_assistant" title="Exclude Assistant suffix" class="checkbox_label widthFreeExpand">
<input id="exclude_assistant" type="checkbox" /><span data-i18n="Exclude Assistant suffix">Exclude Assistant suffix</span>
</label>
<div class="toggle-description justifyLeft">
<span data-i18n="Exclude the assistant prefix from being added to the end of prompt.">Exclude the assistant prefix from being added to the end of prompt (Requires jailbreak with 'Assistant:' in it).</span>
<span data-i18n="Exclude the assistant suffix from being added to the end of prompt.">Exclude the assistant suffix from being added to the end of prompt (Requires jailbreak with 'Assistant:' in it).</span>
</div>
</div>
<div class="inline-drawer m-t-1 wide100p">
@ -1473,7 +1473,7 @@
<span data-i18n="Select a character to show quick edit options.">Select a character to show quick edit options.</span>
</div>
</div>
<div class="range-block" data-source="claude">
<div id="claude_assistant_prefill_block" data-source="claude" class="range-block">
<span id="claude_assistant_prefill_text" data-i18n="Assistant Prefill">Assistant Prefill</span>
<textarea id="claude_assistant_prefill" class="text_pole textarea_compact" name="assistant_prefill" rows="3" maxlength="5000" placeholder="Start Claude's answer with..."></textarea>
</div>

View File

@ -488,7 +488,7 @@ function populateChatHistory(prompts, chatCompletion, type = null, cyclePrompt =
// Reserve budget for group nudge
let groupNudgeMessage = null;
if(selected_group) {
if (selected_group) {
const groupNudgeMessage = new Message.fromPrompt(prompts.get('groupNudge'));
chatCompletion.reserveBudget(groupNudgeMessage);
}
@ -535,7 +535,7 @@ function populateChatHistory(prompts, chatCompletion, type = null, cyclePrompt =
chatCompletion.insertAtStart(newChatMessage, 'chatHistory');
// Reserve budget for group nudge
if(selected_group && groupNudgeMessage) {
if (selected_group && groupNudgeMessage) {
chatCompletion.freeBudget(groupNudgeMessage);
chatCompletion.insertAtEnd(groupNudgeMessage, 'chatHistory');
}
@ -2922,6 +2922,10 @@ function toggleChatCompletionForms() {
const validSources = $(this).data('source').split(',');
$(this).toggle(validSources.includes(oai_settings.chat_completion_source));
});
if (chat_completion_sources.CLAUDE == oai_settings.chat_completion_source) {
$('#claude_assistant_prefill_block').toggle(!oai_settings.exclude_assistant);
}
}
async function testApiConnection() {
@ -3028,13 +3032,7 @@ $(document).ready(async function () {
$('#exclude_assistant').on('change', function () {
oai_settings.exclude_assistant = !!$('#exclude_assistant').prop('checked');
if(oai_settings.exclude_assistant) {
$('#claude_assistant_prefill').css('display', 'none')
$('#claude_assistant_prefill_text').css('display', 'none')
} else {
$('#claude_assistant_prefill').css('display', '')
$('#claude_assistant_prefill_text').css('display', '')
}
$('#claude_assistant_prefill_block').toggle(!oai_settings.exclude_assistant);
saveSettingsDebounced();
});

View File

@ -37,7 +37,7 @@
--ivory: rgb(220, 220, 210);
--golden: rgb(248, 211, 0);
--warning: rgba(255, 0, 0, 0.9);
--active: rgb(75, 156, 0);
--active: rgb(88, 182, 0);
--preferred: rgb(244, 67, 54);