mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
tokenizer colorization underpinnings (inactive)
This commit is contained in:
@ -3,6 +3,19 @@ import { getContext } from "../../extensions.js";
|
|||||||
import { registerSlashCommand } from "../../slash-commands.js";
|
import { registerSlashCommand } from "../../slash-commands.js";
|
||||||
import { getTextTokens, getTokenCount, getTokenizerBestMatch, getTokenizerModel, tokenizers } from "../../tokenizers.js";
|
import { getTextTokens, getTokenCount, getTokenizerBestMatch, getTokenizerModel, tokenizers } from "../../tokenizers.js";
|
||||||
|
|
||||||
|
function rgb2hex(rgb) {
|
||||||
|
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
||||||
|
return (rgb && rgb.length === 4) ? "#" +
|
||||||
|
("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) +
|
||||||
|
("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) +
|
||||||
|
("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$('button').click(function () {
|
||||||
|
var hex = rgb2hex($('input').val());
|
||||||
|
$('.result').html(hex);
|
||||||
|
});
|
||||||
|
|
||||||
async function doTokenCounter() {
|
async function doTokenCounter() {
|
||||||
const tokenizerOption = $("#tokenizer").find(':selected');
|
const tokenizerOption = $("#tokenizer").find(':selected');
|
||||||
let tokenizerId = Number(tokenizerOption.val());
|
let tokenizerId = Number(tokenizerOption.val());
|
||||||
@ -65,7 +78,20 @@ async function doTokenCounter() {
|
|||||||
* @param {number[]} ids
|
* @param {number[]} ids
|
||||||
*/
|
*/
|
||||||
function drawChunks(chunks, ids) {
|
function drawChunks(chunks, ids) {
|
||||||
|
const main_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBodyColor').trim()))
|
||||||
|
const italics_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeEmColor').trim()))
|
||||||
|
const quote_text_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeQuoteColor').trim()))
|
||||||
|
const blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBlurTintColor').trim()))
|
||||||
|
const chat_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeChatTintColor').trim()))
|
||||||
|
const user_mes_blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeUserMesBlurTintColor').trim()))
|
||||||
|
const bot_mes_blur_tint_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBotMesBlurTintColor').trim()))
|
||||||
|
const shadow_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeShadowColor').trim()))
|
||||||
|
const border_color = rgb2hex((getComputedStyle(document.documentElement).getPropertyValue('--SmartThemeBorderColor').trim()))
|
||||||
|
|
||||||
const pastelRainbow = [
|
const pastelRainbow = [
|
||||||
|
//main_text_color,
|
||||||
|
//italics_text_color,
|
||||||
|
//quote_text_color,
|
||||||
'#FFB3BA',
|
'#FFB3BA',
|
||||||
'#FFDFBA',
|
'#FFDFBA',
|
||||||
'#FFFFBA',
|
'#FFFFBA',
|
||||||
|
Reference in New Issue
Block a user