mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Caption - allow custom endpoint for xAI
This commit is contained in:
@ -416,6 +416,7 @@ jQuery(async function () {
|
|||||||
'google': SECRET_KEYS.MAKERSUITE,
|
'google': SECRET_KEYS.MAKERSUITE,
|
||||||
'vertexai': SECRET_KEYS.VERTEXAI,
|
'vertexai': SECRET_KEYS.VERTEXAI,
|
||||||
'anthropic': SECRET_KEYS.CLAUDE,
|
'anthropic': SECRET_KEYS.CLAUDE,
|
||||||
|
'xai': SECRET_KEYS.XAI,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (reverseProxyApis[api]) {
|
if (reverseProxyApis[api]) {
|
||||||
@ -429,7 +430,6 @@ jQuery(async function () {
|
|||||||
'zerooneai': SECRET_KEYS.ZEROONEAI,
|
'zerooneai': SECRET_KEYS.ZEROONEAI,
|
||||||
'groq': SECRET_KEYS.GROQ,
|
'groq': SECRET_KEYS.GROQ,
|
||||||
'cohere': SECRET_KEYS.COHERE,
|
'cohere': SECRET_KEYS.COHERE,
|
||||||
'xai': SECRET_KEYS.XAI,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (chatCompletionApis[api] && secret_state[chatCompletionApis[api]]) {
|
if (chatCompletionApis[api] && secret_state[chatCompletionApis[api]]) {
|
||||||
|
@ -181,7 +181,7 @@
|
|||||||
<div data-type="ollama">
|
<div data-type="ollama">
|
||||||
The model must be downloaded first! Do it with the <code>ollama pull</code> command or <a href="#" id="caption_ollama_pull">click here</a>.
|
The model must be downloaded first! Do it with the <code>ollama pull</code> command or <a href="#" id="caption_ollama_pull">click here</a>.
|
||||||
</div>
|
</div>
|
||||||
<label data-type="openai,anthropic,google,vertexai,mistral" class="checkbox_label flexBasis100p" for="caption_allow_reverse_proxy" title="Allow using reverse proxy if defined and valid.">
|
<label data-type="openai,anthropic,google,vertexai,mistral,xai" class="checkbox_label flexBasis100p" for="caption_allow_reverse_proxy" title="Allow using reverse proxy if defined and valid.">
|
||||||
<input id="caption_allow_reverse_proxy" type="checkbox" class="checkbox">
|
<input id="caption_allow_reverse_proxy" type="checkbox" class="checkbox">
|
||||||
<span data-i18n="Allow reverse proxy">Allow reverse proxy</span>
|
<span data-i18n="Allow reverse proxy">Allow reverse proxy</span>
|
||||||
</label>
|
</label>
|
||||||
|
@ -15,7 +15,7 @@ import { createThumbnail, isValidUrl } from '../utils.js';
|
|||||||
*/
|
*/
|
||||||
export async function getMultimodalCaption(base64Img, prompt) {
|
export async function getMultimodalCaption(base64Img, prompt) {
|
||||||
const useReverseProxy =
|
const useReverseProxy =
|
||||||
(['openai', 'anthropic', 'google', 'mistral', 'vertexai'].includes(extension_settings.caption.multimodal_api))
|
(['openai', 'anthropic', 'google', 'mistral', 'vertexai', 'xai'].includes(extension_settings.caption.multimodal_api))
|
||||||
&& extension_settings.caption.allow_reverse_proxy
|
&& extension_settings.caption.allow_reverse_proxy
|
||||||
&& oai_settings.reverse_proxy
|
&& oai_settings.reverse_proxy
|
||||||
&& isValidUrl(oai_settings.reverse_proxy);
|
&& isValidUrl(oai_settings.reverse_proxy);
|
||||||
@ -157,7 +157,7 @@ function throwIfInvalidModel(useReverseProxy) {
|
|||||||
throw new Error('Cohere API key is not set.');
|
throw new Error('Cohere API key is not set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension_settings.caption.multimodal_api === 'xai' && !secret_state[SECRET_KEYS.XAI]) {
|
if (extension_settings.caption.multimodal_api === 'xai' && !secret_state[SECRET_KEYS.XAI] && !useReverseProxy) {
|
||||||
throw new Error('xAI API key is not set.');
|
throw new Error('xAI API key is not set.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,12 @@ router.post('/caption-image', async (request, response) => {
|
|||||||
key = readSecret(request.user.directories, SECRET_KEYS.OPENAI);
|
key = readSecret(request.user.directories, SECRET_KEYS.OPENAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.body.api === 'openrouter' && !request.body.reverse_proxy) {
|
if (request.body.api === 'xai' && !request.body.reverse_proxy) {
|
||||||
key = readSecret(request.user.directories, SECRET_KEYS.OPENROUTER);
|
key = readSecret(request.user.directories, SECRET_KEYS.XAI);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.body.api === 'mistral' && !request.body.reverse_proxy) {
|
||||||
|
key = readSecret(request.user.directories, SECRET_KEYS.MISTRALAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.body.reverse_proxy && request.body.proxy_password) {
|
if (request.body.reverse_proxy && request.body.proxy_password) {
|
||||||
@ -36,6 +40,10 @@ router.post('/caption-image', async (request, response) => {
|
|||||||
mergeObjectWithYaml(headers, request.body.custom_include_headers);
|
mergeObjectWithYaml(headers, request.body.custom_include_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.body.api === 'openrouter') {
|
||||||
|
key = readSecret(request.user.directories, SECRET_KEYS.OPENROUTER);
|
||||||
|
}
|
||||||
|
|
||||||
if (request.body.api === 'ooba') {
|
if (request.body.api === 'ooba') {
|
||||||
key = readSecret(request.user.directories, SECRET_KEYS.OOBA);
|
key = readSecret(request.user.directories, SECRET_KEYS.OOBA);
|
||||||
bodyParams.temperature = 0.1;
|
bodyParams.temperature = 0.1;
|
||||||
@ -57,10 +65,6 @@ router.post('/caption-image', async (request, response) => {
|
|||||||
key = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
key = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.body.api === 'mistral') {
|
|
||||||
key = readSecret(request.user.directories, SECRET_KEYS.MISTRALAI);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.body.api === 'groq') {
|
if (request.body.api === 'groq') {
|
||||||
key = readSecret(request.user.directories, SECRET_KEYS.GROQ);
|
key = readSecret(request.user.directories, SECRET_KEYS.GROQ);
|
||||||
}
|
}
|
||||||
@ -69,10 +73,6 @@ router.post('/caption-image', async (request, response) => {
|
|||||||
key = readSecret(request.user.directories, SECRET_KEYS.COHERE);
|
key = readSecret(request.user.directories, SECRET_KEYS.COHERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.body.api === 'xai') {
|
|
||||||
key = readSecret(request.user.directories, SECRET_KEYS.XAI);
|
|
||||||
}
|
|
||||||
|
|
||||||
const noKeyTypes = ['custom', 'ooba', 'koboldcpp', 'vllm', 'llamacpp', 'pollinations'];
|
const noKeyTypes = ['custom', 'ooba', 'koboldcpp', 'vllm', 'llamacpp', 'pollinations'];
|
||||||
if (!key && !request.body.reverse_proxy && !noKeyTypes.includes(request.body.api)) {
|
if (!key && !request.body.reverse_proxy && !noKeyTypes.includes(request.body.api)) {
|
||||||
console.warn('No key found for API', request.body.api);
|
console.warn('No key found for API', request.body.api);
|
||||||
|
Reference in New Issue
Block a user