mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add support for nsfw avoidance prompt
This commit is contained in:
@ -2,6 +2,14 @@ import {countTokens} from "./openai.js";
|
||||
import {DraggablePromptListModule as DraggableList} from "./DraggableList.js";
|
||||
import {substituteParams} from "../script.js";
|
||||
|
||||
// Thrown by ChatCompletion when a requested prompt couldn't be found.
|
||||
class IdentifierNotFoundError extends Error {
|
||||
constructor(identifier) {
|
||||
super(`Identifier ${identifier} not found`);
|
||||
this.name = 'IdentifierNotFoundError';
|
||||
}
|
||||
}
|
||||
|
||||
// OpenAI API chat message handling
|
||||
// const map = [{identifier: 'example', message: {role: 'system', content: 'exampleContent'}}, ...];
|
||||
const ChatCompletion = {
|
||||
@ -12,6 +20,10 @@ const ChatCompletion = {
|
||||
this.map.push({ identifier, message });
|
||||
return this;
|
||||
},
|
||||
get(identifier) {
|
||||
const index = this.getMessageIndex(identifier);
|
||||
return this.assertIndex(index, identifier).map[index];
|
||||
},
|
||||
insertBefore(identifier, insertIdentifier, insert) {
|
||||
const index = this.getMessageIndex(identifier);
|
||||
this.map.splice(this.assertIndex(index, identifier), 0, { identifier: insertIdentifier, message: insert });
|
||||
|
Reference in New Issue
Block a user