Make character parameter required when AI character selection is enabled
- Add character to required parameters when setting is enabled - Update documentation to clarify character is required - Ensure handler logic provides default character if missing - Maintain backward compatibility 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c8af3ab3cb
commit
7380391424
@ -92,12 +92,12 @@ generateChatBubbleImage("I'm thinking...", "thought")</pre>
|
||||
|
||||
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")</pre>
|
||||
<p><strong>ALTERNATIVE:</strong> If the AI can't call the function directly, you can instruct it to respond with Markdown formatted like this:</p>
|
||||
|
22
index.js
22
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);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user