diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..5e9a7c6 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,37 @@ +# SillyBubble - Dynamic Chat Bubble Extension + +## Extension Purpose +- Creates dynamic chat bubble images from AI-provided text +- Uses a tool function called by the AI to generate markdown image links +- Properly URL-encodes the text parameter in the image URL + +## Build & Test Commands +- Extension Installation: Place in `extensions/` directory of SillyTavern +- No build process needed - extension is JavaScript-based +- Test in SillyTavern by verifying: + - Tool registration with the AI + - Proper URL encoding of parameters + - Markdown image rendering in chat + +## Code Style Guidelines + +### Structure +- Extension name: "SillyBubble" +- Key files: `index.js` (tool registration), `manifest.json`, `style.css` + +### Tool Implementation +- Register tool function `generateChatBubbleImage` for AI function calling +- Function should accept text input and return formatted markdown +- Use `encodeURIComponent()` for proper URL parameter encoding +- Return format: `` + +### JavaScript Patterns +- Use async/await for asynchronous operations +- Rely on jQuery for DOM manipulation +- Import required functions from SillyTavern's extensions.js +- Register event handlers in jQuery ready function + +### Extension Settings +- Store settings in `extension_settings[extensionName]` +- Allow configuration of image service URL +- Support style parameters (e.g., bubble style, colors) \ No newline at end of file diff --git a/Concept.md b/Concept.md new file mode 100644 index 0000000..a71c797 --- /dev/null +++ b/Concept.md @@ -0,0 +1,52 @@ +# SillyTavern Extension: Dynamic Chat Bubble Image Generation + +## **Objective** +The goal of this extension is to dynamically generate chat bubble images containing text provided by the AI in SillyTavern. The AI will generate markdown image links that point to an API, which will return a styled chat bubble containing the text. This enables a more immersive and visually enhanced roleplay experience. + +## **Functional Description** +1. **AI Markdown Output** + - The AI will include markdown-formatted image links in its responses. + - Example output from AI: + ```markdown +  + ``` + - The `q` parameter in the URL will be dynamically filled with text. + +2. **Dynamic Image Generation** + - The provided URL (`image.php`) will be queried whenever a markdown image is rendered. + - This PHP script will generate an image on the fly, styling the text as a chat bubble. + - Additional parameters (e.g., `style=modern`) could be used to define different visual styles. + +3. **Extension-Based Implementation** + - The solution should be built as a **SillyTavern extension** rather than modifying the core. + - This extension will: + - Provide a function that AI can call via tool/function calling. + - Process the AI's request and return a correctly formatted markdown image link. + - Handle URL encoding of the text. + +## **Implementation Strategy** +1. **Create a new SillyTavern extension** + - Place extension files in the `extensions/` directory. + - Define an `index.js` file that registers a tool function. + - Include a `manifest.json` to declare the extension. + +2. **Register a Tool for AI Function Calling** + - Define a function (e.g., `generateChatBubbleImage`) that constructs the correct markdown format. + - Ensure that the function properly encodes the text input. + - Return a formatted markdown string (``). + +3. **Ensure AI Utilization** + - Modify the system prompt (if necessary) to encourage the AI to call the function. + - Validate that the AI correctly generates responses containing image links. + +## **Expected Outcome** +Once implemented, SillyTavern will be able to dynamically generate chat bubble images within the AI conversation. The extension will work independently of the core system, making it easy to maintain and update. + +## **Next Steps** +- Develop the `index.js` script to register the tool. +- Ensure the extension follows SillyTavern’s extension framework. +- Test AI interactions to confirm correct markdown output. +- Refine the PHP image generator if necessary. + +This document serves as the foundational plan for implementing the extension. + diff --git a/README.md b/README.md index 1a4acae..1de842c 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,42 @@ -# SillyTavern Extension Example +# SillyBubble - Dynamic Chat Bubble Extension for SillyTavern -*Provide a brief description of how your extension works, what problem it aims to solve.* +SillyBubble is a SillyTavern extension that enables AI models to generate dynamic chat bubble images with text. The extension provides a function that AI models can call to create properly formatted markdown image links with URL-encoded text parameters. ## Features -*Describe some of the main selling points of your extension.* +- Provides a function for AI to generate markdown image links +- Properly URL-encodes text parameters for image generation +- Supports different bubble styles through style parameters +- Configurable image service URL +- Simple testing interface to preview bubble generation ## Installation and Usage ### Installation -*In most cases, this should just be using ST's inbuilt extension installer.* +1. Install the extension using SillyTavern's built-in extension installer +2. Configure the image service URL in the extension settings ### Usage -*Explain how to use this extension.* +1. The extension registers a custom function `generateChatBubbleImage` that AI models can call +2. When called, it returns a properly formatted markdown image link: + ```markdown +  + ``` +3. The function accepts two parameters: + - `text`: The text to display in the bubble (required) + - `style`: The visual style of the bubble (optional) ## Prerequisites -*Specify the version of ST necessary here.* +- SillyTavern with custom function support +- A properly configured image generation service that accepts text parameters ## Support and Contributions -*Where should someone ask for support?* - -*Consider including your own contact info for help/questions.* - -*How can people help add to this extension?* +For support or to contribute to this project, please visit the [GitHub repository](https://github.com/crystal/SillyBubble) or open an issue. ## License -*Be cool, use an open source license.* +MIT License diff --git a/example.html b/example.html index 340069a..783a985 100644 --- a/example.html +++ b/example.html @@ -1,19 +1,42 @@ - -
This extension provides a function for AI models to generate chat bubbles.
+Function name: generateChatBubbleImage
Parameters:
+text
: The text to display in the bubblestyle
: (Optional) Bubble styleGenerated Markdown:
+${markdown.replace(//g, '>')}+
Preview (if connected to image service):
+