Merge branch 'staging' into gork-ai

91fc50b82da98466a96d5cbebd278d66509b7c31

Cohee <18619528+Cohee1207@users.noreply.github.com>

6 files changed, +107 -29Showing whitespace changes
public/index.html+1 -1
@@ -1975,7 +1975,7 @@
19751975 <span data-i18n="enable_functions_desc_3">Can be utilized by various extensions to provide additional functionality.</span>
19761976 </div>
19771977 </div>
19781978 <div class="range-block" data-source="openai,openrouter,mistralai,makersuite,claude,custom,01ai,xai">
19791979 <label for="openai_image_inlining" class="checkbox_label flexWrap widthFreeExpand">
19801980 <input id="openai_image_inlining" type="checkbox" />
19811981 <span data-i18n="Send inline images">Send inline images</span>
public/scripts/custom-request.js+11 -5
@@ -43,10 +43,12 @@ import EventSourceStream from './sse-stream.js';
4343 * @property {boolean?} [stream=false] - Whether to stream the response
4444 * @property {ChatCompletionMessage[]} messages - Array of chat messages
4545 * @property {string} [model] - Optional model name to use for completion
4646 * @property {string} chat_completion_source - Source provider for chat completion
4747 * @property {number} max_tokens - Maximum number of tokens to generate
4848 * @property {number} [temperature] - Optional temperature parameter for response randomness
4949 * @property {string} [custom_url] - Optional custom URL for chat completion
50+ * @property {string} [reverse_proxy] - Optional reverse proxy URL
51+ * @property {string} [proxy_password] - Optional proxy password
5052 */
5153
5254/** @typedef {Record<string, any> & ChatCompletionPayloadBase} ChatCompletionPayload */
@@ -80,7 +82,6 @@ export class TextCompletionService {
8082 */
8183 static createRequestData({ stream = false, prompt, max_tokens, model, api_type, api_server, temperature, min_p, ...props }) {
8284 const payload = {
83- ...props,
8485 stream,
8586 prompt,
8687 max_tokens,
@@ -90,6 +91,7 @@ export class TextCompletionService {
9091 api_server: api_server ?? getTextGenServer(api_type),
9192 temperature,
9293 min_p,
94+ ...props,
9395 };
9496
9597 // Remove undefined values to avoid API errors
@@ -387,9 +389,8 @@ export class ChatCompletionService {
387389 * @param {ChatCompletionPayload} custom
388390 * @returns {ChatCompletionPayload}
389391 */
390392 static createRequestData({ stream = false, messages, model, chat_completion_source, max_tokens, temperature, custom_url, reverse_proxy, proxy_password, ...props }) {
391393 const payload = {
392- ...props,
393394 stream,
394395 messages,
395396 model,
@@ -397,6 +398,11 @@ export class ChatCompletionService {
397398 max_tokens,
398399 temperature,
399400 custom_url,
401+ reverse_proxy,
402+ proxy_password,
403+ use_makersuite_sysprompt: true,
404+ claude_use_sysprompt: true,
405+ ...props,
400406 };
401407
402408 // Remove undefined values to avoid API errors
public/scripts/extensions/shared.js+9 -2
@@ -1,7 +1,7 @@
11import { CONNECT_API_MAP, getRequestHeaders } from '../../script.js';
22import { extension_settings, openThirdPartyExtensionMenu } from '../extensions.js';
33import { t } from '../i18n.js';
44import { oai_settings, proxies } from '../openai.js';
55import { SECRET_KEYS, secret_state } from '../secrets.js';
66import { textgen_types, textgenerationwebui_settings } from '../textgen-settings.js';
77import { getTokenCountAsync } from '../tokenizers.js';
@@ -310,9 +310,10 @@ export class ConnectionManagerRequestService {
310310 * @param {boolean?} [custom.includePreset=true]
311311 * @param {boolean?} [custom.includeInstruct=true]
312312 * @param {Partial<InstructSettings>?} [custom.instructSettings] Override instruct settings
313+ * @param {Record<string, any>} [overridePayload] - Override payload for the request
313314 * @returns {Promise<import('../custom-request.js').ExtractedData | (() => AsyncGenerator<import('../custom-request.js').StreamResponse>)>} If not streaming, returns extracted data; if streaming, returns a function that creates an AsyncGenerator
314315 */
315316 static async sendRequest(profileId, prompt, maxTokens, custom = this.defaultSendRequestParams, overridePayload = {}) {
316317 const { stream, signal, extractData, includePreset, includeInstruct, instructSettings } = { ...this.defaultSendRequestParams, ...custom };
317318
318319 const context = SillyTavern.getContext();
@@ -330,6 +331,8 @@ export class ConnectionManagerRequestService {
330331 throw new Error(`API type ${selectedApiMap.selected} does not support chat completions`);
331332 }
332333
334+ const proxyPreset = proxies.find((p) => p.name === profile.proxy);
335+
333336 const messages = Array.isArray(prompt) ? prompt : [{ role: 'user', content: prompt }];
334337 return await context.ChatCompletionService.processRequest({
335338 stream,
@@ -338,6 +341,9 @@ export class ConnectionManagerRequestService {
338341 model: profile.model,
339342 chat_completion_source: selectedApiMap.source,
340343 custom_url: profile['api-url'],
344+ reverse_proxy: proxyPreset?.url,
345+ proxy_password: proxyPreset?.password,
346+ ...overridePayload,
341347 }, {
342348 presetName: includePreset ? profile.preset : undefined,
343349 }, extractData, signal);
@@ -354,6 +360,7 @@ export class ConnectionManagerRequestService {
354360 model: profile.model,
355361 api_type: selectedApiMap.type,
356362 api_server: profile['api-url'],
363+ ...overridePayload,
357364 }, {
358365 instructName: includeInstruct ? profile.instruct : undefined,
359366 presetName: includePreset ? profile.preset : undefined,
public/scripts/openai.js+79 -20
@@ -4193,6 +4193,80 @@ function getMaxContextWindowAI(value) {
41934193}
41944194
41954195/**
4196+ * Get the maximum context size for the Mistral model
4197+ * @param {string} model Model identifier
4198+ * @param {boolean} isUnlocked Whether context limits are unlocked
4199+ * @returns {number} Maximum context size in tokens
4200+ */
4201+function getMistralMaxContext(model, isUnlocked) {
4202+ if (isUnlocked) {
4203+ return unlocked_max;
4204+ }
4205+
4206+ if (Array.isArray(model_list) && model_list.length > 0) {
4207+ const contextLength = model_list.find((record) => record.id === model)?.max_context_length;
4208+ if (contextLength) {
4209+ return contextLength;
4210+ }
4211+ }
4212+
4213+ const contextMap = {
4214+ 'codestral-2411-rc5': 262144,
4215+ 'codestral-2412': 262144,
4216+ 'codestral-2501': 262144,
4217+ 'codestral-latest': 262144,
4218+ 'codestral-mamba-2407': 262144,
4219+ 'codestral-mamba-latest': 262144,
4220+ 'open-codestral-mamba': 262144,
4221+ 'ministral-3b-2410': 131072,
4222+ 'ministral-3b-latest': 131072,
4223+ 'ministral-8b-2410': 131072,
4224+ 'ministral-8b-latest': 131072,
4225+ 'mistral-large-2407': 131072,
4226+ 'mistral-large-2411': 131072,
4227+ 'mistral-large-latest': 131072,
4228+ 'mistral-large-pixtral-2411': 131072,
4229+ 'mistral-tiny-2407': 131072,
4230+ 'mistral-tiny-latest': 131072,
4231+ 'open-mistral-nemo': 131072,
4232+ 'open-mistral-nemo-2407': 131072,
4233+ 'pixtral-12b': 131072,
4234+ 'pixtral-12b-2409': 131072,
4235+ 'pixtral-12b-latest': 131072,
4236+ 'pixtral-large-2411': 131072,
4237+ 'pixtral-large-latest': 131072,
4238+ 'open-mixtral-8x22b': 65536,
4239+ 'open-mixtral-8x22b-2404': 65536,
4240+ 'codestral-2405': 32768,
4241+ 'mistral-embed': 32768,
4242+ 'mistral-large-2402': 32768,
4243+ 'mistral-medium': 32768,
4244+ 'mistral-medium-2312': 32768,
4245+ 'mistral-medium-latest': 32768,
4246+ 'mistral-moderation-2411': 32768,
4247+ 'mistral-moderation-latest': 32768,
4248+ 'mistral-ocr-2503': 32768,
4249+ 'mistral-ocr-latest': 32768,
4250+ 'mistral-saba-2502': 32768,
4251+ 'mistral-saba-latest': 32768,
4252+ 'mistral-small': 32768,
4253+ 'mistral-small-2312': 32768,
4254+ 'mistral-small-2402': 32768,
4255+ 'mistral-small-2409': 32768,
4256+ 'mistral-small-2501': 32768,
4257+ 'mistral-small-2503': 32768,
4258+ 'mistral-small-latest': 32768,
4259+ 'mistral-tiny': 32768,
4260+ 'mistral-tiny-2312': 32768,
4261+ 'open-mistral-7b': 32768,
4262+ 'open-mixtral-8x7b': 32768,
4263+ };
4264+
4265+ // Return context size if model found, otherwise default to 32k
4266+ return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || 32768;
4267+}
4268+
4269+/**
41964270 * Get the maximum context size for the Groq model
41974271 * @param {string} model Model identifier
41984272 * @param {boolean} isUnlocked Whether context limits are unlocked
@@ -4460,27 +4534,10 @@ async function onModelChange() {
44604534 }
44614535
44624536 if (oai_settings.chat_completion_source === chat_completion_sources.MISTRALAI) {
4463- if (oai_settings.max_context_unlocked) {
4537+ const maxContext = getMistralMaxContext(oai_settings.mistralai_model, oai_settings.max_context_unlocked);
44644538 $('#openai_max_context').attr('max', unlocked_maxmaxContext);
4465- } else if (['codestral-latest', 'codestral-mamba-2407', 'codestral-2411-rc5', 'codestral-2412', 'codestral-2501'].includes(oai_settings.mistralai_model)) {
4466- $('#openai_max_context').attr('max', max_256k);
4467- } else if (['mistral-large-2407', 'mistral-large-2411', 'mistral-large-pixtral-2411', 'mistral-large-latest'].includes(oai_settings.mistralai_model)) {
4468- $('#openai_max_context').attr('max', max_128k);
4469- } else if (oai_settings.mistralai_model.includes('mistral-nemo')) {
4470- $('#openai_max_context').attr('max', max_128k);
4471- } else if (oai_settings.mistralai_model.includes('mixtral-8x22b')) {
4472- $('#openai_max_context').attr('max', max_64k);
4473- } else if (oai_settings.mistralai_model.includes('pixtral')) {
4474- $('#openai_max_context').attr('max', max_128k);
4475- } else if (oai_settings.mistralai_model.includes('ministral')) {
4476- $('#openai_max_context').attr('max', max_32k);
4477- } else {
4478- $('#openai_max_context').attr('max', max_32k);
4479- }
44804539 oai_settings.openai_max_context = Math.min(oai_settings.openai_max_context, Number($('#openai_max_context').attr('max')));
44814540 $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
4482-
4483- //mistral also caps temp at 1.0
44844541 oai_settings.temp_openai = Math.min(claude_max_temp, oai_settings.temp_openai);
44854542 $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input');
44864543 }
@@ -5070,7 +5127,9 @@ export function isImageInliningSupported() {
50705127 'o1-2024-12-17',
50715128 'chatgpt-4o-latest',
50725129 'yi-vision',
50735130 'mistral-large-pixtral-latest2411',
5131+ 'mistral-small-2503',
5132+ 'mistral-small-latest',
50745133 'pixtral-12b-latest',
50755134 'pixtral-12b',
50765135 'pixtral-12b-2409',
public/scripts/textgen-models.js+5 -0
@@ -58,6 +58,8 @@ const OPENROUTER_PROVIDERS = [
5858 'Minimax',
5959 'Nineteen',
6060 'Liquid',
61+ 'Stealth',
62+ 'NCompass',
6163 'InferenceNet',
6264 'Friendli',
6365 'AionLabs',
@@ -69,6 +71,9 @@ const OPENROUTER_PROVIDERS = [
6971 'Targon',
7072 'Ubicloud',
7173 'Parasail',
74+ 'Phala',
75+ 'Cent-ML',
76+ 'Venice',
7277 '01.AI',
7378 'HuggingFace',
7479 'Mancer',
src/endpoints/stable-diffusion.js+2 -1
@@ -1166,7 +1166,8 @@ falai.post('/models', async (_request, response) => {
11661166 const models = data
11671167 .filter(x => !x.title.toLowerCase().includes('inpainting') &&
11681168 !x.title.toLowerCase().includes('control') &&
11691169 !x.title.toLowerCase().includes('upscale')) &&
1170+ !x.title.toLowerCase().includes('lora'))
11701171 .sort((a, b) => a.title.localeCompare(b.title))
11711172 .map(x => ({ value: x.modelUrl.split('fal-ai/')[1], text: x.title }));
11721173 return response.send(models);