diff --git a/example.html b/example.html index 0867eec..75d8aea 100644 --- a/example.html +++ b/example.html @@ -92,12 +92,12 @@ generateChatBubbleImage("I'm thinking...", "thought") The function parameters are: - text: The text to display in the chat bubble (required string) -- character: The character to use for the bubble (optional string: "Example", "Bianca", etc.) +- character: The character to use for the bubble (required string: "Example", "Bianca", etc.) - bubble_type: The type of bubble to use (optional string: "speech" or "thought") -When you want to create a chat bubble, call this function with the text you want to display. +When you want to create a chat bubble, call this function with the text and character. Example usage: -generateChatBubbleImage("Hello world!") +generateChatBubbleImage("Hello world!", "Example") generateChatBubbleImage("Hello from Bianca", "Bianca") generateChatBubbleImage("I'm thinking...", "Example", "thought")

ALTERNATIVE: If the AI can't call the function directly, you can instruct it to respond with Markdown formatted like this:

diff --git a/index.js b/index.js index 52dd9bf..70688fb 100644 --- a/index.js +++ b/index.js @@ -219,12 +219,20 @@ function registerFunctionTool() { description: 'Legacy parameter: The visual style of the chat bubble (default, modern, retro, minimal).' }; + // Define required parameters + const requiredParams = ['text']; + + // Add character to required parameters if enabled + if (extension_settings[extensionName].use_character_param) { + requiredParams.push('character'); + } + // Define parameter schema following JSON schema format const bubbleSchema = Object.freeze({ $schema: 'http://json-schema.org/draft-04/schema#', type: 'object', properties: properties, - required: ['text'] + required: requiredParams }); // Register the function tool using SillyTavern's own API @@ -236,8 +244,16 @@ function registerFunctionTool() { action: async (args) => { if (!args?.text) return ''; - // Only pass character if the setting is enabled - const character = extension_settings[extensionName].use_character_param ? args.character : null; + let character; + + if (extension_settings[extensionName].use_character_param) { + // When the setting is enabled, character is required + // If not provided, use default + character = args.character || extension_settings[extensionName].default_character; + } else { + // When the setting is disabled, always use the default character + character = extension_settings[extensionName].default_character; + } return generateChatBubbleImage(args.text, args.style, character, args.bubble_type); },