TC: Add a toggle for empty json schemas (#4807)
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"negative_prompt": "",
|
||||
"grammar_string": "",
|
||||
"json_schema": null,
|
||||
"json_schema_allow_empty": false,
|
||||
"banned_tokens": "",
|
||||
"sampler_priority": [
|
||||
"repetition_penalty",
|
||||
|
||||
@@ -1707,6 +1707,10 @@
|
||||
</a>
|
||||
</h4>
|
||||
<textarea id="tabby_json_schema" rows="4" class="text_pole textarea_compact monospace" data-i18n="[placeholder]Type in the desired JSON schema" placeholder="Type in the desired JSON schema"></textarea>
|
||||
<label for="json_schema_allow_empty_textgenerationwebui" class="checkbox_label" title="Treat empty JSON object as a valid JSON schema." data-tg-type="all">
|
||||
<input type="checkbox" id="json_schema_allow_empty_textgenerationwebui" />
|
||||
<small data-i18n="Allow empty schema objects">Allow empty schema objects</small>
|
||||
</label>
|
||||
</div>
|
||||
<div id="sampler_order_block_kcpp" data-tg-type="koboldcpp" data-tg-samplers="sampler_order" class="range-block flexFlowColumn wide100p">
|
||||
<hr class="wide100p">
|
||||
|
||||
@@ -193,6 +193,7 @@ const settings = {
|
||||
negative_prompt: '',
|
||||
grammar_string: '',
|
||||
json_schema: null,
|
||||
json_schema_allow_empty: false,
|
||||
banned_tokens: '',
|
||||
global_banned_tokens: '',
|
||||
send_banned_tokens: true,
|
||||
@@ -311,6 +312,7 @@ export const setting_names = [
|
||||
'min_keep',
|
||||
'generic_model',
|
||||
'extensions',
|
||||
'json_schema_allow_empty',
|
||||
];
|
||||
|
||||
const DYNATEMP_BLOCK = document.getElementById('dynatemp_block_ooba');
|
||||
@@ -1506,6 +1508,11 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso
|
||||
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
|
||||
const dynatemp = isDynamicTemperatureSupported();
|
||||
const { banned_tokens, banned_strings } = getCustomTokenBans();
|
||||
const jsonSchema = isObject(settings.json_schema)
|
||||
? settings.json_schema_allow_empty
|
||||
? settings.json_schema
|
||||
: Object.keys(settings.json_schema).length > 0 ? settings.json_schema : undefined
|
||||
: undefined;
|
||||
|
||||
let params = {
|
||||
'prompt': finalPrompt,
|
||||
@@ -1597,7 +1604,7 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso
|
||||
'guidance_scale': cfgValues?.guidanceScale?.value ?? settings.guidance_scale ?? 1,
|
||||
'negative_prompt': cfgValues?.negativePrompt ?? substituteParams(settings.negative_prompt) ?? '',
|
||||
'grammar_string': settings.grammar_string || undefined,
|
||||
'json_schema': [TABBY, LLAMACPP].includes(settings.type) && settings.json_schema ? settings.json_schema : undefined,
|
||||
'json_schema': [TABBY, LLAMACPP].includes(settings.type) ? jsonSchema : undefined,
|
||||
// llama.cpp aliases. In case someone wants to use LM Studio as Text Completion API
|
||||
'repeat_penalty': settings.rep_pen,
|
||||
'repeat_last_n': settings.rep_pen_range,
|
||||
@@ -1639,7 +1646,7 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso
|
||||
'skip_special_tokens': settings.skip_special_tokens,
|
||||
'spaces_between_special_tokens': settings.spaces_between_special_tokens,
|
||||
'guided_grammar': settings.grammar_string || undefined,
|
||||
'guided_json': settings.json_schema || undefined,
|
||||
'guided_json': jsonSchema || undefined,
|
||||
'early_stopping': false, // hacks
|
||||
'include_stop_str_in_output': false,
|
||||
'dynatemp_min': dynatemp ? settings.min_temp : undefined,
|
||||
@@ -1734,7 +1741,7 @@ export async function getTextGenGenerationData(finalPrompt, maxTokens, isImperso
|
||||
|
||||
// Grammar conflicts with with json_schema
|
||||
if ([LLAMACPP, APHRODITE].includes(settings.type)) {
|
||||
if (settings.json_schema && isObject(settings.json_schema)) {
|
||||
if (jsonSchema) {
|
||||
delete params.grammar_string;
|
||||
delete params.grammar;
|
||||
delete params.guided_grammar;
|
||||
|
||||
Reference in New Issue
Block a user