Fix json schema use for openAI compat CUSTOM endpoints in several use paths (#5561)
* pass jsonSchema options through sendStreamingRequest in Generate * translate json_schema to response_format for CUSTOM chat completion source * pass jsonSchema through generateGroupWrapper params in group chat generation
This commit is contained in:
+2
-2
@@ -4290,7 +4290,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
if (selected_group && !is_group_generating) {
|
||||
if (!dryRun) {
|
||||
// Returns the promise that generateGroupWrapper returns; resolves when generation is done
|
||||
return generateGroupWrapper(false, type, { quiet_prompt, force_chid, signal: abortController.signal, quietImage });
|
||||
return generateGroupWrapper(false, type, { quiet_prompt, force_chid, signal: abortController.signal, quietImage, jsonSchema });
|
||||
}
|
||||
|
||||
const characterIndexMap = new Map(characters.map((char, index) => [char.avatar, index]));
|
||||
@@ -5330,7 +5330,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
streamingProcessor.firstMessageText = '';
|
||||
}
|
||||
|
||||
streamingProcessor.generator = await sendStreamingRequest(type, generate_data);
|
||||
streamingProcessor.generator = await sendStreamingRequest(type, generate_data, { jsonSchema });
|
||||
|
||||
hideSwipeButtons();
|
||||
let getMessage = await streamingProcessor.generate();
|
||||
|
||||
@@ -2319,6 +2319,16 @@ router.post('/generate', async function (request, response) {
|
||||
mergeObjectWithYaml(bodyParams, request.body.custom_include_body);
|
||||
mergeObjectWithYaml(headers, request.body.custom_include_headers);
|
||||
embedOpenRouterMedia(request.body.messages, { audio: true, video: false });
|
||||
if (request.body.json_schema) {
|
||||
bodyParams['response_format'] = {
|
||||
type: 'json_schema',
|
||||
json_schema: {
|
||||
name: request.body.json_schema.name,
|
||||
strict: request.body.json_schema.strict ?? true,
|
||||
schema: request.body.json_schema.value,
|
||||
},
|
||||
};
|
||||
}
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.PERPLEXITY) {
|
||||
apiUrl = API_PERPLEXITY;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.PERPLEXITY, request.body.secret_id);
|
||||
|
||||
Reference in New Issue
Block a user