Add {{maxPrompt}} macro

This commit is contained in:
Cohee
2023-12-02 22:47:43 +02:00
parent 6e09e45651
commit ff46a249d8
2 changed files with 17 additions and 15 deletions

View File

@@ -2023,6 +2023,7 @@ function substituteParams(content, _name1, _name2, _original, _group, _replaceCh
content = content.replace(/{{mesExamples}}/gi, fields.mesExamples || ''); content = content.replace(/{{mesExamples}}/gi, fields.mesExamples || '');
} }
content = content.replace(/{{maxPrompt}}/gi, () => String(getMaxContextSize()));
content = content.replace(/{{user}}/gi, _name1); content = content.replace(/{{user}}/gi, _name1);
content = content.replace(/{{char}}/gi, _name2); content = content.replace(/{{char}}/gi, _name2);
content = content.replace(/{{charIfNotGroup}}/gi, _group); content = content.replace(/{{charIfNotGroup}}/gi, _group);
@@ -4056,7 +4057,7 @@ function getMaxContextSize() {
this_max_context = this_max_context - amount_gen; this_max_context = this_max_context - amount_gen;
} }
if (main_api == 'openai') { if (main_api == 'openai') {
this_max_context = oai_settings.openai_max_context; this_max_context = oai_settings.openai_max_context - oai_settings.openai_max_tokens;
} }
return this_max_context; return this_max_context;
} }

View File

@@ -39,6 +39,7 @@
<small>(enabled in the Advanced Formatting settings)</small> <small>(enabled in the Advanced Formatting settings)</small>
</div> </div>
<ul> <ul>
<li><tt>&lcub;&lcub;maxPrompt&rcub;&rcub;</tt> max allowed prompt length in tokens = (context size - response length)</li>
<li><tt>&lcub;&lcub;exampleSeparator&rcub;&rcub;</tt> context template example dialogues separator</li> <li><tt>&lcub;&lcub;exampleSeparator&rcub;&rcub;</tt> context template example dialogues separator</li>
<li><tt>&lcub;&lcub;chatStart&rcub;&rcub;</tt> context template chat start line</li> <li><tt>&lcub;&lcub;chatStart&rcub;&rcub;</tt> context template chat start line</li>
<li><tt>&lcub;&lcub;instructSystem&rcub;&rcub;</tt> instruct system prompt</li> <li><tt>&lcub;&lcub;instructSystem&rcub;&rcub;</tt> instruct system prompt</li>