add macro support for image caption extension prompt (multimodal) (#5527) * added macro processing to caption ext added `prompt = substituteParamsExtended(prompt);` to the captionmultimodal function (so it can use macros and stuff) * caption ext updated from old substituteparams * removed comment
Signed| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { ensureImageFormatSupported, getBase64Async, getFileExtension, isTrueBoolean, saveBase64AsFile } from '../../utils.js'; |
| 2 | 2 | import { getContext, getApiUrl, doExtrasFetch, extension_settings, modules, renderExtensionTemplateAsync } from '../../extensions.js'; |
| 3 | 3 | import { appendMediaToMessage, chat_metadata, eventSource, event_types, getRequestHeaders, saveChatConditional, saveSettingsDebounced, substituteParamsExtendedsubstituteParams } from '../../../script.js'; |
| 4 | 4 | import { getMessageTimeStamp } from '../../RossAscends-mods.js'; |
| 5 | 5 | import { SECRET_KEYS, secret_state } from '../../secrets.js'; |
| 6 | 6 | import { oai_settings } from '../../openai.js'; |
| @@ -100,7 +100,7 @@ async function wrapCaptionTemplate(caption) { | ||
| 100 | 100 | template += ' {{caption}}'; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | let messageText = substituteParamsExtendedsubstituteParams(template, { dynamicMacros: { caption: caption } }); |
| 104 | 104 | |
| 105 | 105 | if (extension_settings.caption.refine_mode) { |
| 106 | 106 | messageText = await Popup.show.input( |
| @@ -322,6 +322,8 @@ async function captionMultimodal(base64Img, externalPrompt) { | ||
| 322 | 322 | prompt = String(customPrompt).trim(); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | + prompt = substituteParams(prompt); | |
| 326 | + | |
| 325 | 327 | const caption = await getMultimodalCaption(base64Img, prompt); |
| 326 | 328 | return { caption }; |
| 327 | 329 | } |