Substitute macro is LLM prompt
This commit is contained in:
parent
6dca8b28fe
commit
0ff5d0b5f1
|
@ -1,4 +1,4 @@
|
|||
import { callPopup, eventSource, event_types, generateQuietPrompt, getRequestHeaders, saveSettingsDebounced } from '../../../script.js';
|
||||
import { callPopup, eventSource, event_types, generateQuietPrompt, getRequestHeaders, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
||||
import { dragElement, isMobile } from '../../RossAscends-mods.js';
|
||||
import { getContext, getApiUrl, modules, extension_settings, ModuleWorkerWrapper, doExtrasFetch, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { loadMovingUIState, power_user } from '../../power-user.js';
|
||||
|
@ -988,7 +988,9 @@ async function getLlmPrompt(labels) {
|
|||
return '';
|
||||
}
|
||||
|
||||
const prompt = String(extension_settings.expressions.llmPrompt).replace(/{{labels}}/gi, labels.map(x => `"${x}"`).join(', '));
|
||||
const labelsString = labels.map(x => `"${x}"`).join(', ');
|
||||
const prompt = substituteParams(String(extension_settings.expressions.llmPrompt))
|
||||
.replace(/{{labels}}/gi, labelsString);
|
||||
return prompt;
|
||||
}
|
||||
|
||||
|
@ -1868,6 +1870,11 @@ function migrateSettings() {
|
|||
extension_settings.expressions.llmPrompt = $(this).val();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#expression_llm_prompt_restore').on('click', function () {
|
||||
$('#expression_llm_prompt').val(DEFAULT_LLM_PROMPT);
|
||||
extension_settings.expressions.llmPrompt = DEFAULT_LLM_PROMPT;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#expression_custom_add').on('click', onClickExpressionAddCustom);
|
||||
$('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);
|
||||
|
|
|
@ -28,9 +28,14 @@
|
|||
</select>
|
||||
</div>
|
||||
<div class="expression_llm_prompt_block m-b-1 m-t-1">
|
||||
<label for="expression_llm_prompt">LLM Prompt</label>
|
||||
<label for="expression_llm_prompt" class="title_restorable">
|
||||
<span>LLM Prompt</span>
|
||||
<div id="expression_llm_prompt_restore" title="Restore default value" class="right_menu_button">
|
||||
<i class="fa-solid fa-clock-rotate-left fa-sm"></i>
|
||||
</div>
|
||||
</label>
|
||||
<small>Will be used if the API doesn't support JSON schemas.</small>
|
||||
<textarea id="expression_llm_prompt" type="text" class="text_pole" rows="2"></textarea>
|
||||
<textarea id="expression_llm_prompt" type="text" class="text_pole textarea_compact" rows="2" placeholder="Use {{labels}} special macro."></textarea>
|
||||
</div>
|
||||
<div class="expression_fallback_block m-b-1 m-t-1">
|
||||
<label for="expression_fallback">Default / Fallback Expression</label>
|
||||
|
|
Loading…
Reference in New Issue