Merge branch 'staging' into webpack
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "sillytavern", |
| 3 | 3 | "version": "1.12.67", |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "sillytavern", |
| 9 | 9 | "version": "1.12.67", |
| 10 | 10 | "hasInstallScript": true, |
| 11 | 11 | "license": "AGPL-3.0", |
| 12 | 12 | "dependencies": { |
| @@ -84,7 +84,7 @@ | ||
| 84 | 84 | "type": "git", |
| 85 | 85 | "url": "https://github.com/SillyTavern/SillyTavern.git" |
| 86 | 86 | }, |
| 87 | 87 | "version": "1.12.67", |
| 88 | 88 | "scripts": { |
| 89 | 89 | "start": "node server.js", |
| 90 | 90 | "start:deno": "deno run --allow-run --allow-net --allow-read --allow-write --allow-sys --allow-env server.js", |
| @@ -2797,6 +2797,8 @@ | ||
| 2797 | 2797 | <h4 data-i18n="Claude Model">Claude Model</h4> |
| 2798 | 2798 | <select id="model_claude_select"> |
| 2799 | 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 | 2802 | <option value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> |
| 2801 | 2803 | <option value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 2802 | 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 | 2577 | if (_replaceCharacterCard) { |
| 2578 | 2578 | const fields = getCharacterCardFields(); |
| 2579 | 2579 | environment.charPrompt = fields.system || ''; |
| 2580 | 2580 | environment.charInstruction = environment.charJailbreak = fields.jailbreak || ''; |
| 2581 | 2581 | environment.description = fields.description || ''; |
| 2582 | 2582 | environment.personality = fields.personality || ''; |
| 2583 | 2583 | environment.scenario = fields.scenario || ''; |
| @@ -3847,7 +3847,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro | ||
| 3847 | 3847 | if (addUserAlignment) { |
| 3848 | 3848 | const alignmentMessage = { |
| 3849 | 3849 | name: name1, |
| 3850 | 3850 | mes: substituteParams(power_user.instruct.user_alignment_message), |
| 3851 | 3851 | is_user: true, |
| 3852 | 3852 | }; |
| 3853 | 3853 | userAlignmentMessage = formatMessageHistoryItem(alignmentMessage, isInstruct, force_output_sequence.FIRST); |
| @@ -8225,6 +8225,10 @@ window['SillyTavern'].getContext = function () { | ||
| 8225 | 8225 | substituteParams, |
| 8226 | 8226 | substituteParamsExtended, |
| 8227 | 8227 | SlashCommandParser, |
| 8228 | + SlashCommand, | |
| 8229 | + SlashCommandArgument, | |
| 8230 | + SlashCommandNamedArgument, | |
| 8231 | + ARGUMENT_TYPE, | |
| 8228 | 8232 | executeSlashCommandsWithOptions, |
| 8229 | 8233 | /** @deprecated Use SlashCommandParser.addCommandObject() instead */ |
| 8230 | 8234 | registerSlashCommand: registerSlashCommand, |
| @@ -1458,6 +1458,7 @@ jQuery(function () { | ||
| 1458 | 1458 | wrapper.classList.add('height100p', 'wide100p', 'flex-container'); |
| 1459 | 1459 | wrapper.classList.add('flexFlowColumn', 'justifyCenter', 'alignitemscenter'); |
| 1460 | 1460 | const textarea = document.createElement('textarea'); |
| 1461 | + textarea.dataset.for = broId; | |
| 1461 | 1462 | textarea.value = String(contentEditable ? bro[0].innerText : bro.val()); |
| 1462 | 1463 | textarea.classList.add('height100p', 'wide100p', 'maximized_textarea'); |
| 1463 | 1464 | bro.hasClass('monospace') && textarea.classList.add('monospace'); |
| @@ -43,6 +43,8 @@ | ||
| 43 | 43 | <option data-type="openai" value="gpt-4o">gpt-4o</option> |
| 44 | 44 | <option data-type="openai" value="gpt-4o-mini">gpt-4o-mini</option> |
| 45 | 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 | 48 | <option data-type="anthropic" value="claude-3-5-sonnet-20240620">claude-3-5-sonnet-20240620</option> |
| 47 | 49 | <option data-type="anthropic" value="claude-3-opus-20240229">claude-3-opus-20240229</option> |
| 48 | 50 | <option data-type="anthropic" value="claude-3-sonnet-20240229">claude-3-sonnet-20240229</option> |
| @@ -35,6 +35,7 @@ export const SECRET_KEYS = { | ||
| 35 | 35 | STABILITY: 'api_key_stability', |
| 36 | 36 | BLOCKENTROPY: 'api_key_blockentropy', |
| 37 | 37 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 38 | + TAVILY: 'api_key_tavily', | |
| 38 | 39 | }; |
| 39 | 40 | |
| 40 | 41 | const INPUT_MAP = { |
| @@ -1398,6 +1398,13 @@ export function initDefaultSlashCommands() { | ||
| 1398 | 1398 | returns: 'popup text', |
| 1399 | 1399 | namedArgumentList: [ |
| 1400 | 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 | 1408 | name: 'large', |
| 1402 | 1409 | description: 'show large popup', |
| 1403 | 1410 | typeList: [ARGUMENT_TYPE.BOOLEAN], |
| @@ -2093,7 +2100,7 @@ async function buttonsCallback(args, text) { | ||
| 2093 | 2100 | popupContainer.innerHTML = safeValue; |
| 2094 | 2101 | popupContainer.appendChild(buttonContainer); |
| 2095 | 2102 | |
| 2096 | 2103 | popup = new Popup(popupContainer, POPUP_TYPE.TEXT, '', { okButton: 'Cancel', allowVerticalScrolling: true }); |
| 2097 | 2104 | popup.show() |
| 2098 | 2105 | .then((result => resolve(typeof result === 'number' ? resultToButtonMap.get(result) ?? '' : ''))) |
| 2099 | 2106 | .catch(() => resolve('')); |
| @@ -2110,6 +2117,7 @@ async function popupCallback(args, value) { | ||
| 2110 | 2117 | |
| 2111 | 2118 | /** @type {import('./popup.js').PopupOptions} */ |
| 2112 | 2119 | const popupOptions = { |
| 2120 | + allowVerticalScrolling: !isFalseBoolean(args?.scroll), | |
| 2113 | 2121 | large: isTrueBoolean(args?.large), |
| 2114 | 2122 | wide: isTrueBoolean(args?.wide), |
| 2115 | 2123 | wider: isTrueBoolean(args?.wider), |
| @@ -9,7 +9,7 @@ | ||
| 9 | 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 | 10 | <li><tt>{{input}}</tt> – <span data-i18n="help_macros_6">the user input</span></li> |
| 11 | 11 | <li><tt>{{charPrompt}}</tt> – <span data-i18n="help_macros_7">the Character's Main Prompt override</span></li> |
| 12 | 12 | <li><tt>{{charJailbreakcharInstruction}}</tt> – <span data-i18n="help_macros_8">the Character's JailbreakPost-History PromptInstructions override</span></li> |
| 13 | 13 | <li><tt>{{description}}</tt> – <span data-i18n="help_macros_9">the Character's Description</span></li> |
| 14 | 14 | <li><tt>{{personality}}</tt> – <span data-i18n="help_macros_10">the Character's Personality</span></li> |
| 15 | 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 | 257 | router.post('/visit', jsonParser, async (request, response) => { |
| 210 | 258 | try { |
| 211 | 259 | const url = request.body.url; |
| @@ -47,6 +47,7 @@ export const SECRET_KEYS = { | ||
| 47 | 47 | STABILITY: 'api_key_stability', |
| 48 | 48 | BLOCKENTROPY: 'api_key_blockentropy', |
| 49 | 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 50 | + TAVILY: 'api_key_tavily', | |
| 50 | 51 | }; |
| 51 | 52 | |
| 52 | 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 | 397 | // similar story as claude |
| 398 | 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 | 406 | if (Array.isArray(message.content)) { |
| 400 | 407 | if (!message.content[0].text = .startsWith(`${message.name}: ${message.content[0].text}`;)) { |
| 408 | + message.content[0].text = `${message.name}: ${message.content[0].text}`; | |
| 409 | + } | |
| 401 | 410 | } else { |
| 402 | 411 | if (!message.content = .startsWith(`${message.name}: ${message.content}`;)) { |
| 412 | + message.content = `${message.name}: ${message.content}`; | |
| 413 | + } | |
| 403 | 414 | } |
| 415 | + | |
| 404 | 416 | delete message.name; |
| 405 | 417 | } |
| 406 | 418 | |