Add aggressive stop setting
This commit is contained in:
parent
b0812796a1
commit
1ef08110c3
|
@ -109,7 +109,6 @@ export const runPetalsCompletionRequest = async (
|
||||||
chatResponse.updateFromError(err.message)
|
chatResponse.updateFromError(err.message)
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
window.setTimeout(() => {
|
|
||||||
chatResponse.updateFromAsyncResponse(
|
chatResponse.updateFromAsyncResponse(
|
||||||
{
|
{
|
||||||
model,
|
model,
|
||||||
|
@ -122,7 +121,26 @@ export const runPetalsCompletionRequest = async (
|
||||||
}]
|
}]
|
||||||
} as any
|
} as any
|
||||||
)
|
)
|
||||||
}, 1)
|
if (chat.settings.aggressiveStop && !response.stop) {
|
||||||
|
// check if we should've stopped
|
||||||
|
const message = chatResponse.getMessages()[0]
|
||||||
|
const pad = 10 // look back 10 characters + stop sequence
|
||||||
|
if (message) {
|
||||||
|
const mc = (message.content).trim()
|
||||||
|
for (let i = 0, l = stopSequences.length; i < l; i++) {
|
||||||
|
const ss = stopSequences[i].trim()
|
||||||
|
const ind = mc.slice(0 - (ss.length + pad)).indexOf(ss)
|
||||||
|
if (ind > -1) {
|
||||||
|
const offset = (ss.length + pad) - ind
|
||||||
|
message.content = mc.slice(0, mc.length - offset)
|
||||||
|
response.stop = true
|
||||||
|
updateMessages(chat.id)
|
||||||
|
chatResponse.finish()
|
||||||
|
ws.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ws.onclose = () => {
|
ws.onclose = () => {
|
||||||
|
|
|
@ -110,6 +110,7 @@ const defaults:ChatSettings = {
|
||||||
hppWithSummaryPrompt: false,
|
hppWithSummaryPrompt: false,
|
||||||
imageGenerationSize: '',
|
imageGenerationSize: '',
|
||||||
stopSequence: '',
|
stopSequence: '',
|
||||||
|
aggressiveStop: false,
|
||||||
userMessageStart: '',
|
userMessageStart: '',
|
||||||
assistantMessageStart: '',
|
assistantMessageStart: '',
|
||||||
systemMessageStart: '',
|
systemMessageStart: '',
|
||||||
|
@ -524,6 +525,13 @@ const chatSettingsList: ChatSetting[] = [
|
||||||
},
|
},
|
||||||
hide: isNotPetals
|
hide: isNotPetals
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'aggressiveStop',
|
||||||
|
name: 'Use aggressive stop',
|
||||||
|
title: 'Sometimes generation con continue even after a stop sequence. This will stop generation client side if generation continues after stop sequence.',
|
||||||
|
type: 'boolean',
|
||||||
|
hide: isNotPetals
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'userMessageStart',
|
key: 'userMessageStart',
|
||||||
name: 'User Message Start Sequence',
|
name: 'User Message Start Sequence',
|
||||||
|
|
|
@ -114,6 +114,7 @@ export type ChatSettings = {
|
||||||
useResponseAlteration?: boolean;
|
useResponseAlteration?: boolean;
|
||||||
responseAlterations?: ResponseAlteration[];
|
responseAlterations?: ResponseAlteration[];
|
||||||
stopSequence: string;
|
stopSequence: string;
|
||||||
|
aggressiveStop: boolean;
|
||||||
userMessageStart: string;
|
userMessageStart: string;
|
||||||
assistantMessageStart: string;
|
assistantMessageStart: string;
|
||||||
systemMessageStart: string;
|
systemMessageStart: string;
|
||||||
|
|
Loading…
Reference in New Issue