Merge branch 'staging' into webpack
| @@ -1,12 +1,12 @@ | |||
| 1 | { | 1 | { |
| 2 | "name": "sillytavern", | 2 | "name": "sillytavern", |
| 3 | "version": "1.12.6", | 3 | "version": "1.12.7", |
| 4 | "lockfileVersion": 3, | 4 | "lockfileVersion": 3, |
| 5 | "requires": true, | 5 | "requires": true, |
| 6 | "packages": { | 6 | "packages": { |
| 7 | "": { | 7 | "": { |
| 8 | "name": "sillytavern", | 8 | "name": "sillytavern", |
| 9 | "version": "1.12.6", | 9 | "version": "1.12.7", |
| 10 | "hasInstallScript": true, | 10 | "hasInstallScript": true, |
| 11 | "license": "AGPL-3.0", | 11 | "license": "AGPL-3.0", |
| 12 | "dependencies": { | 12 | "dependencies": { |
| @@ -84,7 +84,7 @@ | |||
| 84 | "type": "git", | 84 | "type": "git", |
| 85 | "url": "https://github.com/SillyTavern/SillyTavern.git" | 85 | "url": "https://github.com/SillyTavern/SillyTavern.git" |
| 86 | }, | 86 | }, |
| 87 | "version": "1.12.6", | 87 | "version": "1.12.7", |
| 88 | "scripts": { | 88 | "scripts": { |
| 89 | "start": "node server.js", | 89 | "start": "node server.js", |
| 90 | "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js", | 90 | "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js", |
| @@ -2797,6 +2797,8 @@ | |||
| 2797 | <h4 data-i18n="Claude Model">Claude Model</h4> | 2797 | <h4 data-i18n="Claude Model">Claude Model</h4> |
| 2798 | <select id="model_claude_select"> | 2798 | <select id="model_claude_select"> |
| 2799 | <optgroup label="Versions"> | 2799 | <optgroup label="Versions"> |
| 2800 | <option value="claude-3-5-sonnet-latest">claude-3-5-sonnet-latest</option> | ||
| 2801 | <option value="claude-3-5-sonnet-20241022">claude-3-5-sonnet-20241022</option> | ||
| 2800 | <option value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> | 2802 | <option value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> |
| 2801 | <option value="claude-3-opus-20240229">claude-3-opus-20240229</option> | 2803 | <option value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 2802 | <option value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> | 2804 | <option value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> |
| @@ -2577,7 +2577,7 @@ export function substituteParams(content, _name1, _name2, _original, _group, _re | |||
| 2577 | if (_replaceCharacterCard) { | 2577 | if (_replaceCharacterCard) { |
| 2578 | const fields = getCharacterCardFields(); | 2578 | const fields = getCharacterCardFields(); |
| 2579 | environment.charPrompt = fields.system || ''; | 2579 | environment.charPrompt = fields.system || ''; |
| 2580 | environment.charJailbreak = fields.jailbreak || ''; | 2580 | environment.charInstruction = environment.charJailbreak = fields.jailbreak || ''; |
| 2581 | environment.description = fields.description || ''; | 2581 | environment.description = fields.description || ''; |
| 2582 | environment.personality = fields.personality || ''; | 2582 | environment.personality = fields.personality || ''; |
| 2583 | environment.scenario = fields.scenario || ''; | 2583 | environment.scenario = fields.scenario || ''; |
| @@ -3847,7 +3847,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | |||
| 3847 | if (addUserAlignment) { | 3847 | if (addUserAlignment) { |
| 3848 | const alignmentMessage = { | 3848 | const alignmentMessage = { |
| 3849 | name: name1, | 3849 | name: name1, |
| 3850 | mes: power_user.instruct.user_alignment_message, | 3850 | mes: substituteParams(power_user.instruct.user_alignment_message), |
| 3851 | is_user: true, | 3851 | is_user: true, |
| 3852 | }; | 3852 | }; |
| 3853 | userAlignmentMessage = formatMessageHistoryItem(alignmentMessage, isInstruct, force_output_sequence.FIRST); | 3853 | userAlignmentMessage = formatMessageHistoryItem(alignmentMessage, isInstruct, force_output_sequence.FIRST); |
| @@ -8225,6 +8225,10 @@ window['SillyTavern'].getContext = function () { | |||
| 8225 | substituteParams, | 8225 | substituteParams, |
| 8226 | substituteParamsExtended, | 8226 | substituteParamsExtended, |
| 8227 | SlashCommandParser, | 8227 | SlashCommandParser, |
| 8228 | SlashCommand, | ||
| 8229 | SlashCommandArgument, | ||
| 8230 | SlashCommandNamedArgument, | ||
| 8231 | ARGUMENT_TYPE, | ||
| 8228 | executeSlashCommandsWithOptions, | 8232 | executeSlashCommandsWithOptions, |
| 8229 | /** @deprecated Use SlashCommandParser.addCommandObject() instead */ | 8233 | /** @deprecated Use SlashCommandParser.addCommandObject() instead */ |
| 8230 | registerSlashCommand: registerSlashCommand, | 8234 | registerSlashCommand: registerSlashCommand, |
| @@ -1458,6 +1458,7 @@ jQuery(function () { | |||
| 1458 | wrapper.classList.add('height100p', 'wide100p', 'flex-container'); | 1458 | wrapper.classList.add('height100p', 'wide100p', 'flex-container'); |
| 1459 | wrapper.classList.add('flexFlowColumn', 'justifyCenter', 'alignitemscenter'); | 1459 | wrapper.classList.add('flexFlowColumn', 'justifyCenter', 'alignitemscenter'); |
| 1460 | const textarea = document.createElement('textarea'); | 1460 | const textarea = document.createElement('textarea'); |
| 1461 | textarea.dataset.for = broId; | ||
| 1461 | textarea.value = String(contentEditable ? bro[0].innerText : bro.val()); | 1462 | textarea.value = String(contentEditable ? bro[0].innerText : bro.val()); |
| 1462 | textarea.classList.add('height100p', 'wide100p', 'maximized_textarea'); | 1463 | textarea.classList.add('height100p', 'wide100p', 'maximized_textarea'); |
| 1463 | bro.hasClass('monospace') && textarea.classList.add('monospace'); | 1464 | bro.hasClass('monospace') && textarea.classList.add('monospace'); |
| @@ -43,6 +43,8 @@ | |||
| 43 | <option data-type="openai" value="gpt-4o">gpt-4o</option> | 43 | <option data-type="openai" value="gpt-4o">gpt-4o</option> |
| 44 | <option data-type="openai" value="gpt-4o-mini">gpt-4o-mini</option> | 44 | <option data-type="openai" value="gpt-4o-mini">gpt-4o-mini</option> |
| 45 | <option data-type="openai" value="chatgpt-4o-latest">chatgpt-4o-latest</option> | 45 | <option data-type="openai" value="chatgpt-4o-latest">chatgpt-4o-latest</option> |
| 46 | <option data-type="anthropic" value="claude-3-5-sonnet-latest">claude-3-5-sonnet-latest</option> | ||
| 47 | <option data-type="anthropic" value="claude-3-5-sonnet-20241022">claude-3-5-sonnet-20241022</option> | ||
| 46 | <option data-type="anthropic" value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> | 48 | <option data-type="anthropic" value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> |
| 47 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> | 49 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 48 | <option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> | 50 | <option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> |
| @@ -35,6 +35,7 @@ export const SECRET_KEYS = { | |||
| 35 | STABILITY: 'api_key_stability', | 35 | STABILITY: 'api_key_stability', |
| 36 | BLOCKENTROPY: 'api_key_blockentropy', | 36 | BLOCKENTROPY: 'api_key_blockentropy', |
| 37 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', | 37 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 38 | TAVILY: 'api_key_tavily', | ||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | const INPUT_MAP = { | 41 | const INPUT_MAP = { |
| @@ -1398,6 +1398,13 @@ export function initDefaultSlashCommands() { | |||
| 1398 | returns: 'popup text', | 1398 | returns: 'popup text', |
| 1399 | namedArgumentList: [ | 1399 | namedArgumentList: [ |
| 1400 | SlashCommandNamedArgument.fromProps({ | 1400 | SlashCommandNamedArgument.fromProps({ |
| 1401 | name: 'scroll', | ||
| 1402 | description: 'allows vertical scrolling of the content', | ||
| 1403 | typeList: [ARGUMENT_TYPE.BOOLEAN], | ||
| 1404 | enumList: commonEnumProviders.boolean('trueFalse')(), | ||
| 1405 | defaultValue: 'true', | ||
| 1406 | }), | ||
| 1407 | SlashCommandNamedArgument.fromProps({ | ||
| 1401 | name: 'large', | 1408 | name: 'large', |
| 1402 | description: 'show large popup', | 1409 | description: 'show large popup', |
| 1403 | typeList: [ARGUMENT_TYPE.BOOLEAN], | 1410 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| @@ -2093,7 +2100,7 @@ async function buttonsCallback(args, text) { | |||
| 2093 | popupContainer.innerHTML = safeValue; | 2100 | popupContainer.innerHTML = safeValue; |
| 2094 | popupContainer.appendChild(buttonContainer); | 2101 | popupContainer.appendChild(buttonContainer); |
| 2095 | 2102 | ||
| 2096 | popup = new Popup(popupContainer, POPUP_TYPE.TEXT, '', { okButton: 'Cancel' }); | 2103 | popup = new Popup(popupContainer, POPUP_TYPE.TEXT, '', { okButton: 'Cancel', allowVerticalScrolling: true }); |
| 2097 | popup.show() | 2104 | popup.show() |
| 2098 | .then((result => resolve(typeof result === 'number' ? resultToButtonMap.get(result) ?? '' : ''))) | 2105 | .then((result => resolve(typeof result === 'number' ? resultToButtonMap.get(result) ?? '' : ''))) |
| 2099 | .catch(() => resolve('')); | 2106 | .catch(() => resolve('')); |
| @@ -2110,6 +2117,7 @@ async function popupCallback(args, value) { | |||
| 2110 | 2117 | ||
| 2111 | /** @type {import('./popup.js').PopupOptions} */ | 2118 | /** @type {import('./popup.js').PopupOptions} */ |
| 2112 | const popupOptions = { | 2119 | const popupOptions = { |
| 2120 | allowVerticalScrolling: !isFalseBoolean(args?.scroll), | ||
| 2113 | large: isTrueBoolean(args?.large), | 2121 | large: isTrueBoolean(args?.large), |
| 2114 | wide: isTrueBoolean(args?.wide), | 2122 | wide: isTrueBoolean(args?.wide), |
| 2115 | wider: isTrueBoolean(args?.wider), | 2123 | wider: isTrueBoolean(args?.wider), |
| @@ -9,7 +9,7 @@ | |||
| 9 | <li><tt>{{original}}</tt> – <span data-i18n="help_macros_5">global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</span></li> | 9 | <li><tt>{{original}}</tt> – <span data-i18n="help_macros_5">global prompts defined in API settings. Only valid in Advanced Definitions prompt overrides.</span></li> |
| 10 | <li><tt>{{input}}</tt> – <span data-i18n="help_macros_6">the user input</span></li> | 10 | <li><tt>{{input}}</tt> – <span data-i18n="help_macros_6">the user input</span></li> |
| 11 | <li><tt>{{charPrompt}}</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li> | 11 | <li><tt>{{charPrompt}}</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li> |
| 12 | <li><tt>{{charJailbreak}}</tt> – <span data-i18n="help_macros_8">the Character's Jailbreak Prompt override</span></li> | 12 | <li><tt>{{charInstruction}}</tt> – <span data-i18n="help_macros_8">the Character's Post-History Instructions override</span></li> |
| 13 | <li><tt>{{description}}</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li> | 13 | <li><tt>{{description}}</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li> |
| 14 | <li><tt>{{personality}}</tt> – <span data-i18n="help_macros_10">the Character's Personality</span></li> | 14 | <li><tt>{{personality}}</tt> – <span data-i18n="help_macros_10">the Character's Personality</span></li> |
| 15 | <li><tt>{{scenario}}</tt> – <span data-i18n="help_macros_11">the Character's Scenario</span></li> | 15 | <li><tt>{{scenario}}</tt> – <span data-i18n="help_macros_11">the Character's Scenario</span></li> |
| @@ -206,6 +206,54 @@ router.post('/searxng', jsonParser, async (request, response) => { | |||
| 206 | } | 206 | } |
| 207 | }); | 207 | }); |
| 208 | 208 | ||
| 209 | router.post('/tavily', jsonParser, async (request, response) => { | ||
| 210 | try { | ||
| 211 | const apiKey = readSecret(request.user.directories, SECRET_KEYS.TAVILY); | ||
| 212 | |||
| 213 | if (!apiKey) { | ||
| 214 | console.log('No Tavily key found'); | ||
| 215 | return response.sendStatus(400); | ||
| 216 | } | ||
| 217 | |||
| 218 | const { query } = request.body; | ||
| 219 | |||
| 220 | const body = { | ||
| 221 | query: query, | ||
| 222 | api_key: apiKey, | ||
| 223 | search_depth: 'basic', | ||
| 224 | topic: 'general', | ||
| 225 | include_answer: true, | ||
| 226 | include_raw_content: false, | ||
| 227 | include_images: false, | ||
| 228 | include_image_descriptions: false, | ||
| 229 | include_domains: [], | ||
| 230 | max_results: 10, | ||
| 231 | }; | ||
| 232 | |||
| 233 | const result = await fetch('https://api.tavily.com/search', { | ||
| 234 | method: 'POST', | ||
| 235 | headers: { | ||
| 236 | 'Content-Type': 'application/json', | ||
| 237 | }, | ||
| 238 | body: JSON.stringify(body), | ||
| 239 | }); | ||
| 240 | |||
| 241 | console.log('Tavily query', query); | ||
| 242 | |||
| 243 | if (!result.ok) { | ||
| 244 | const text = await result.text(); | ||
| 245 | console.log('Tavily request failed', result.statusText, text); | ||
| 246 | return response.status(500).send(text); | ||
| 247 | } | ||
| 248 | |||
| 249 | const data = await result.json(); | ||
| 250 | return response.json(data); | ||
| 251 | } catch (error) { | ||
| 252 | console.log(error); | ||
| 253 | return response.sendStatus(500); | ||
| 254 | } | ||
| 255 | }); | ||
| 256 | |||
| 209 | router.post('/visit', jsonParser, async (request, response) => { | 257 | router.post('/visit', jsonParser, async (request, response) => { |
| 210 | try { | 258 | try { |
| 211 | const url = request.body.url; | 259 | const url = request.body.url; |
| @@ -47,6 +47,7 @@ export const SECRET_KEYS = { | |||
| 47 | STABILITY: 'api_key_stability', | 47 | STABILITY: 'api_key_stability', |
| 48 | BLOCKENTROPY: 'api_key_blockentropy', | 48 | BLOCKENTROPY: 'api_key_blockentropy', |
| 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', | 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 50 | TAVILY: 'api_key_tavily', | ||
| 50 | }; | 51 | }; |
| 51 | 52 | ||
| 52 | // These are the keys that are safe to expose, even if allowKeysExposure is false | 53 | // These are the keys that are safe to expose, even if allowKeysExposure is false |
| @@ -396,11 +396,23 @@ export function convertGooglePrompt(messages, model, useSysPrompt = false, charN | |||
| 396 | 396 | ||
| 397 | // similar story as claude | 397 | // similar story as claude |
| 398 | if (message.name) { | 398 | if (message.name) { |
| 399 | if (userName && message.name === 'example_user') { | ||
| 400 | message.name = userName; | ||
| 401 | } | ||
| 402 | if (charName && message.name === 'example_assistant') { | ||
| 403 | message.name = charName; | ||
| 404 | } | ||
| 405 | |||
| 399 | if (Array.isArray(message.content)) { | 406 | if (Array.isArray(message.content)) { |
| 400 | message.content[0].text = `${message.name}: ${message.content[0].text}`; | 407 | if (!message.content[0].text.startsWith(`${message.name}: `)) { |
| 408 | message.content[0].text = `${message.name}: ${message.content[0].text}`; | ||
| 409 | } | ||
| 401 | } else { | 410 | } else { |
| 402 | message.content = `${message.name}: ${message.content}`; | 411 | if (!message.content.startsWith(`${message.name}: `)) { |
| 412 | message.content = `${message.name}: ${message.content}`; | ||
| 413 | } | ||
| 403 | } | 414 | } |
| 415 | |||
| 404 | delete message.name; | 416 | delete message.name; |
| 405 | } | 417 | } |
| 406 | 418 | ||