Added event after generate data, export sendStreamingRequest and sendGenerationRequest
This commit is contained in:
parent
31470f93d2
commit
89ca8329b7
|
@ -439,6 +439,7 @@ export const event_types = {
|
||||||
GROUP_CHAT_CREATED: 'group_chat_created',
|
GROUP_CHAT_CREATED: 'group_chat_created',
|
||||||
GENERATE_BEFORE_COMBINE_PROMPTS: 'generate_before_combine_prompts',
|
GENERATE_BEFORE_COMBINE_PROMPTS: 'generate_before_combine_prompts',
|
||||||
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
||||||
|
GENERATE_AFTER_DATA: 'generate_after_data',
|
||||||
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
||||||
WORLD_INFO_ACTIVATED: 'world_info_activated',
|
WORLD_INFO_ACTIVATED: 'world_info_activated',
|
||||||
TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready',
|
TEXT_COMPLETION_SETTINGS_READY: 'text_completion_settings_ready',
|
||||||
|
@ -4215,6 +4216,8 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await eventSource.emit(event_types.GENERATE_AFTER_DATA, generate_data);
|
||||||
|
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
generatedPromptCache = '';
|
generatedPromptCache = '';
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -5078,7 +5081,7 @@ function setInContextMessages(lastmsg, type) {
|
||||||
* @param {object} data Generation data
|
* @param {object} data Generation data
|
||||||
* @returns {Promise<object>} Response data from the API
|
* @returns {Promise<object>} Response data from the API
|
||||||
*/
|
*/
|
||||||
async function sendGenerationRequest(type, data) {
|
export async function sendGenerationRequest(type, data) {
|
||||||
if (main_api === 'openai') {
|
if (main_api === 'openai') {
|
||||||
return await sendOpenAIRequest(type, data.prompt, abortController.signal);
|
return await sendOpenAIRequest(type, data.prompt, abortController.signal);
|
||||||
}
|
}
|
||||||
|
@ -5110,7 +5113,7 @@ async function sendGenerationRequest(type, data) {
|
||||||
* @param {object} data Generation data
|
* @param {object} data Generation data
|
||||||
* @returns {Promise<any>} Streaming generator
|
* @returns {Promise<any>} Streaming generator
|
||||||
*/
|
*/
|
||||||
async function sendStreamingRequest(type, data) {
|
export async function sendStreamingRequest(type, data) {
|
||||||
if (abortController?.signal?.aborted) {
|
if (abortController?.signal?.aborted) {
|
||||||
throw new Error('Generation was aborted.');
|
throw new Error('Generation was aborted.');
|
||||||
}
|
}
|
||||||
|
@ -7921,6 +7924,8 @@ window['SillyTavern'].getContext = function () {
|
||||||
eventTypes: event_types,
|
eventTypes: event_types,
|
||||||
addOneMessage: addOneMessage,
|
addOneMessage: addOneMessage,
|
||||||
generate: Generate,
|
generate: Generate,
|
||||||
|
sendStreamingRequest: sendStreamingRequest,
|
||||||
|
sendGenerationRequest: sendGenerationRequest,
|
||||||
stopGeneration: stopGeneration,
|
stopGeneration: stopGeneration,
|
||||||
getTokenCount: getTokenCount,
|
getTokenCount: getTokenCount,
|
||||||
extensionPrompts: extension_prompts,
|
extensionPrompts: extension_prompts,
|
||||||
|
|
Loading…
Reference in New Issue