Remove Scale Spellbook from CC sources (#4293)
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
---
|
||||
|
||||
モバイルデバイスにも適したレイアウト・マルチAPI(KoboldAI/CPP、Horde、NovelAI、Ooba、OpenAI、OpenRouter、Claude、Scale)、VN ライクな Waifu モード、Stable Diffusion、TTS、WorldInfo(伝承本)、カスタマイズ可能なUI、自動翻訳、大量のプロンプトオプション+サードパーティの拡張機能をインストールする機能
|
||||
モバイルデバイスにも適したレイアウト・マルチAPI(KoboldAI/CPP、Horde、NovelAI、Ooba、OpenAI、OpenRouter、Claude)、VN ライクな Waifu モード、Stable Diffusion、TTS、WorldInfo(伝承本)、カスタマイズ可能なUI、自動翻訳、大量のプロンプトオプション+サードパーティの拡張機能をインストールする機能
|
||||
|
||||
[TavernAI](https://github.com/TavernAI/TavernAI) v.1.2.8 のフォークに基づいています。
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
---
|
||||
|
||||
Мобайл-френдли интерфейс, поддержка множества API (KoboldAI/CPP, Horde, NovelAI, Ooba, OpenAI, OpenRouter, Claude, Scale), ВН-образный режим Вайфу, Stable Diffusion, TTS, поддержка миров (лорбуков), кастомизируемый UI, автоперевод, тончайшая настройка промптов + возможность устанавливать расширения.
|
||||
Мобайл-френдли интерфейс, поддержка множества API (KoboldAI/CPP, Horde, NovelAI, Ooba, OpenAI, OpenRouter, Claude), ВН-образный режим Вайфу, Stable Diffusion, TTS, поддержка миров (лорбуков), кастомизируемый UI, автоперевод, тончайшая настройка промптов + возможность устанавливать расширения.
|
||||
|
||||
Основано на форке [TavernAI](https://github.com/TavernAI/TavernAI) версии 1.2.8
|
||||
|
||||
|
||||
@@ -225,12 +225,10 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"api_url_scale": "",
|
||||
"show_external_models": false,
|
||||
"assistant_prefill": "",
|
||||
"assistant_impersonation": "",
|
||||
"claude_use_sysprompt": false,
|
||||
"use_alt_scale": false,
|
||||
"squash_system_messages": false,
|
||||
"image_inlining": false,
|
||||
"bypass_status_check": false,
|
||||
|
||||
+3
-34
@@ -691,7 +691,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,scale,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">
|
||||
<div class="range-block-title" data-i18n="Temperature">
|
||||
Temperature
|
||||
</div>
|
||||
@@ -743,7 +743,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,scale,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">
|
||||
<div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,01ai,nanogpt,deepseek,xai,pollinations">
|
||||
<div class="range-block-title" data-i18n="Top P">
|
||||
Top P
|
||||
</div>
|
||||
@@ -2132,7 +2132,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block m-t-1" data-source="openai,aimlapi,openrouter,scale,custom">
|
||||
<div class="range-block m-t-1" data-source="openai,aimlapi,openrouter,custom">
|
||||
<div id="logit_bias_openai" class="range-block-title openai_restorable" data-i18n="Logit Bias">
|
||||
Logit Bias
|
||||
</div>
|
||||
@@ -2802,7 +2802,6 @@
|
||||
<option value="openrouter">OpenRouter</option>
|
||||
<option value="perplexity">Perplexity</option>
|
||||
<option value="pollinations">Pollinations</option>
|
||||
<option value="scale">Scale</option>
|
||||
<option value="xai">xAI (Grok)</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
@@ -3099,36 +3098,6 @@
|
||||
<span data-i18n="To use instruct formatting, switch to OpenRouter under Text Completion API.">To use instruct formatting, switch to OpenRouter under Text Completion API.</span>
|
||||
</small>
|
||||
</form>
|
||||
<form id="scale_form" data-source="scale" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<div id="normal_scale_form">
|
||||
<h4 data-i18n="Scale API Key">Scale API Key</h4>
|
||||
<div class="flex-container">
|
||||
<input id="api_key_scale" name="api_key_scale" class="text_pole flex1" value="" autocomplete="off">
|
||||
<div title="Manage API keys" data-i18n="[title]Manage API keys" class="menu_button fa-solid fa-key fa-fw manage-api-keys" data-key="api_key_scale"></div>
|
||||
</div>
|
||||
<div data-for="api_key_scale" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you click 'Connect'.">
|
||||
For privacy reasons, your API key will be hidden after you click 'Connect'.
|
||||
</div>
|
||||
<h4>Scale API URL</h4>
|
||||
<input id="api_url_scale" name="api_url_scale" class="text_pole" value="" autocomplete="off" placeholder="https://dashboard.scale.com/spellbook/api/v2/deploy/xxxxxxx">
|
||||
</div>
|
||||
<div id="alt_scale_form">
|
||||
<h4>Scale Cookie (_jwt)</h4>
|
||||
<div class="flex-container">
|
||||
<input id="scale_cookie" name="scale_cookie" class="text_pole flex1" value="" autocomplete="off">
|
||||
<div title="Clear your cookie" data-i18n="[title]Clear your cookie" class="menu_button fa-solid fa-key fa-fw manage-api-keys" data-key="scale_cookie"></div>
|
||||
</div>
|
||||
<div data-for="scale_cookie" class="neutral_warning">
|
||||
For privacy reasons, your cookie will be hidden after you click 'Connect'.
|
||||
</div>
|
||||
</div>
|
||||
<!-- Its only purpose is to trigger max context size check -->
|
||||
<select id="model_scale_select" class="displayNone"></select>
|
||||
<label for="scale-alt" class="checkbox_label">
|
||||
<input id="scale-alt" type="checkbox" checked>
|
||||
<span data-i18n="Alt Method">Alt Method</span>
|
||||
</label>
|
||||
</form>
|
||||
<form id="ai21_form" data-source="ai21" action="javascript:void(null);" method="post" enctype="multipart/form-data">
|
||||
<h4 data-i18n="AI21 API Key">AI21 API Key</h4>
|
||||
<div class="flex-container">
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "ضع نماذج OpenAI في مجموعة واحدة، والنماذج الإنسانية في مجموعة أخرى، وما إلى ذلك. ويمكن دمجها مع الفرز.",
|
||||
"Allow fallback routes": "السماح بمسارات الاحتياط",
|
||||
"Allow fallback routes Description": "يختار النموذج البديل تلقائيًا إذا كان النموذج المحدد غير قادر على تلبية طلبك.",
|
||||
"Scale API Key": "مفتاح API لـ Scale",
|
||||
"Clear your cookie": "امسح ملف تعريف الارتباط الخاص بك",
|
||||
"Alt Method": "طريقة بديلة",
|
||||
"AI21 API Key": "مفتاح API لـ AI21",
|
||||
"AI21 Model": "نموذج AI21",
|
||||
"Google AI Studio API Key": "مفتاح واجهة برمجة تطبيقات Google AI Studio",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Platzieren Sie OpenAI-Modelle in einer Gruppe, anthropogene Modelle in einer anderen Gruppe usw. Kann mit Sortierung kombiniert werden.",
|
||||
"Allow fallback routes": "Fallback-Routen zulassen",
|
||||
"Allow fallback routes Description": "Das alternative Modell wird automatisch ausgewählt, wenn das ausgewählte Modell Ihre Anfrage nicht erfüllen kann.",
|
||||
"Scale API Key": "Scale API-Schlüssel",
|
||||
"Clear your cookie": "Löschen Sie Ihre Cookies",
|
||||
"Alt Method": "Alternative Methode",
|
||||
"AI21 API Key": "AI21 API-Schlüssel",
|
||||
"AI21 Model": "AI21-Modell",
|
||||
"Google AI Studio API Key": "Google AI Studio API-Schlüssel",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Coloque los modelos OpenAI en un grupo, los modelos antrópicos en otro grupo, etc. Se puede combinar con la clasificación.",
|
||||
"Allow fallback routes": "Permitir rutas de respaldo",
|
||||
"Allow fallback routes Description": "El modelo alternativo se elige automáticamente si el modelo seleccionado no puede cumplir con tu solicitud.",
|
||||
"Scale API Key": "Clave API de Scale",
|
||||
"Clear your cookie": "Limpia tu cookie",
|
||||
"Alt Method": "Método alternativo",
|
||||
"AI21 API Key": "Clave API de AI21",
|
||||
"AI21 Model": "Modelo de AI21",
|
||||
"Google AI Studio API Key": "Clave API de Google AI Studio",
|
||||
|
||||
@@ -355,9 +355,6 @@
|
||||
"Group by vendors": "Regrouper par fournisseurs",
|
||||
"Group by vendors Description": "Placez les modèles OpenAI dans un groupe, les modèles Anthropic dans un autre groupe, etc. Peut être combiné avec le tri.",
|
||||
"Allow fallback routes Description": "Le modèle alternatif est automatiquement sélectionné si le modèle choisi ne peut pas répondre à votre demande.",
|
||||
"Scale API Key": "Clé API Scale",
|
||||
"Clear your cookie": "Effacer vos cookies",
|
||||
"Alt Method": "Méthode alternative",
|
||||
"AI21 API Key": "Clé API AI21",
|
||||
"AI21 Model": "Modèle AI21",
|
||||
"Google AI Studio API Key": "Clé API Google AI Studio",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Setjið OpenAI módel í einn hóp, Anthropic módel í annan hóp osfrv. Hægt að sameina við flokkun.",
|
||||
"Allow fallback routes": "Leyfa bakfallssvæði",
|
||||
"Allow fallback routes Description": "Veldur hlutleysa vélbúnaðarinn við val þinn ef valið módel getur ekki uppfyllt beiðni þína.",
|
||||
"Scale API Key": "Lykill API fyrir Scale",
|
||||
"Clear your cookie": "Hreinsaðu kökuna þína",
|
||||
"Alt Method": "Aðferð Bakmenn",
|
||||
"AI21 API Key": "Lykill API fyrir AI21",
|
||||
"AI21 Model": "AI21 Módel",
|
||||
"Google AI Studio API Key": "Google AI Studio API lykill",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Metti i modelli OpenAI in un gruppo, i modelli antropici in un altro gruppo, ecc. Può essere combinato con l'ordinamento.",
|
||||
"Allow fallback routes": "Consenti percorsi alternativi",
|
||||
"Allow fallback routes Description": "Il modello alternativo viene automaticamente scelto se il modello selezionato non può soddisfare la tua richiesta.",
|
||||
"Scale API Key": "Chiave API di Scale",
|
||||
"Clear your cookie": "Cancella il tuo cookie",
|
||||
"Alt Method": "Metodo alternativo",
|
||||
"AI21 API Key": "Chiave API di AI21",
|
||||
"AI21 Model": "Modello AI21",
|
||||
"Google AI Studio API Key": "Chiave API Google AI Studio",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "OpenAI モデルを 1 つのグループに、Anthropic モデルを別のグループに配置するなどします。ソートと組み合わせることができます。",
|
||||
"Allow fallback routes": "フォールバックルートを許可",
|
||||
"Allow fallback routes Description": "選択したモデルが要求を満たせない場合、代替モデルが自動的に選択されます。",
|
||||
"Scale API Key": "ScaleのAPIキー",
|
||||
"Clear your cookie": "クッキーを消去する",
|
||||
"Alt Method": "代替手法",
|
||||
"AI21 API Key": "AI21のAPIキー",
|
||||
"AI21 Model": "AI21モデル",
|
||||
"Google AI Studio API Key": "Google AI Studio APIキー",
|
||||
|
||||
@@ -384,9 +384,6 @@
|
||||
"LEGACY": "유산",
|
||||
"Force Instruct Mode formatting": "강제 지시 모드 형식",
|
||||
"Force_Instruct_Mode_formatting_Description": "Instruct Mode와 이 모드가 모두 활성화된 경우 프롬프트는 SillyTavern에 의해 현재 형식을 사용하여 형식화됩니다.\n 고급 형식 설정(시스템 프롬프트 지시 제외) 비활성화된 경우 프롬프트는 OpenRouter에 의해 형식화됩니다.",
|
||||
"Scale API Key": "Scale API 키",
|
||||
"Clear your cookie": "쿠키 지우기",
|
||||
"Alt Method": "대체 방법",
|
||||
"AI21 API Key": "AI21 API 키",
|
||||
"AI21 Model": "AI21 모델",
|
||||
"Google AI Studio API Key": "Google AI Studio API 키",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Plaats OpenAI-modellen in één groep, antropische modellen in een andere groep, enz. Kan worden gecombineerd met sorteren.",
|
||||
"Allow fallback routes": "Fallback-routes toestaan",
|
||||
"Allow fallback routes Description": "Het alternatieve model wordt automatisch gekozen als het geselecteerde model niet aan uw verzoek kan voldoen.",
|
||||
"Scale API Key": "Scale API-sleutel",
|
||||
"Clear your cookie": "Wis uw cookie",
|
||||
"Alt Method": "Alternatieve methode",
|
||||
"AI21 API Key": "AI21 API-sleutel",
|
||||
"AI21 Model": "AI21-model",
|
||||
"MakerSuite API Key": "MakerSuite API-sleutel",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Coloque os modelos OpenAI em um grupo, os modelos antrópicos em outro grupo, etc.",
|
||||
"Allow fallback routes": "Permitir rotas de fallback",
|
||||
"Allow fallback routes Description": "O modelo alternativo será escolhido automaticamente se o modelo selecionado não puder atender à sua solicitação.",
|
||||
"Scale API Key": "Chave da API Scale",
|
||||
"Clear your cookie": "Limpe seu cookie",
|
||||
"Alt Method": "Método Alternativo",
|
||||
"AI21 API Key": "Chave da API AI21",
|
||||
"AI21 Model": "Modelo AI21",
|
||||
"Google AI Studio API Key": "Chave API Google AI Studio",
|
||||
|
||||
@@ -142,8 +142,6 @@
|
||||
"Get your key from": "Получите ключ в",
|
||||
"Anthropic's developer console": "консоли разработчика Anthropic",
|
||||
"Claude Model": "Модель Claude",
|
||||
"Scale API Key": "Ключ от Scale API",
|
||||
"Alt Method": "Альтернативный метод",
|
||||
"AI21 API Key": "Ключ от API AI21",
|
||||
"AI21 Model": "Модель AI21",
|
||||
"View API Usage Metrics": "Посмотреть статистику использования API",
|
||||
@@ -1255,7 +1253,6 @@
|
||||
"vLLM Model": "Модель vLLM",
|
||||
"Aphrodite Model": "Модель Aphrodite",
|
||||
"Peek a password": "Посмотреть пароль",
|
||||
"Clear your cookie": "Clear your cookie",
|
||||
"Add Chat Start and Example Separator to a list of stopping strings.": "Использовать Начало чата и Разделитель примеров сообщений в качестве стоп-строк.",
|
||||
"Context Order": "Context Order",
|
||||
"Summary": "Summary",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Помістіть моделі OpenAI в одну групу, моделі Anthropic в іншу групу тощо. Можна поєднати з сортуванням.",
|
||||
"Allow fallback routes": "Дозволити резервні маршрути",
|
||||
"Allow fallback routes Description": "Автоматично вибирає альтернативну модель, якщо вибрана модель не може задовольнити ваш запит.",
|
||||
"Scale API Key": "Ключ API для Scale",
|
||||
"Clear your cookie": "Очистіть файл cookie",
|
||||
"Alt Method": "Альтернативний метод",
|
||||
"AI21 API Key": "Ключ API для AI21",
|
||||
"AI21 Model": "Модель AI21",
|
||||
"Google AI Studio API Key": "Ключ API Google AI Studio",
|
||||
|
||||
@@ -375,9 +375,6 @@
|
||||
"Group by vendors Description": "Xếp các mô hình OpenAI vào một nhóm, các mô hình Anthropic vào một nhóm khác, v.v. Có thể kết hợp với việc sắp xếp.",
|
||||
"Allow fallback routes": "Cho phép các tuyến đường phụ",
|
||||
"Allow fallback routes Description": "Bot thay thế tự động nếu mô hình được chọn không thể đáp ứng yêu cầu của bạn.",
|
||||
"Scale API Key": "Scale API Key",
|
||||
"Clear your cookie": "Xóa cookie",
|
||||
"Alt Method": "Phương pháp thay thế",
|
||||
"AI21 API Key": "AI21 API Key",
|
||||
"AI21 Model": "Model của AI21",
|
||||
"Google AI Studio API Key": "Google AI Studio API Key",
|
||||
|
||||
@@ -429,9 +429,6 @@
|
||||
"Group by vendors": "按厂商分组",
|
||||
"Group by vendors Description": "将 OpenAI 模型放在一组,将 Anthropic 模型放在另一组,等等。可以与排序结合。",
|
||||
"To use instruct formatting, switch to OpenRouter under Text Completion API.": "To use instruct formatting, switch to OpenRouter under Text Completion API.",
|
||||
"Scale API Key": "Scale API密钥",
|
||||
"Clear your cookie": "清除你的 Cookie",
|
||||
"Alt Method": "备用方法",
|
||||
"AI21 API Key": "AI21 API 密钥",
|
||||
"AI21 Model": "AI21 模型",
|
||||
"Google AI Studio API Key": "Google AI Studio API 密钥",
|
||||
|
||||
@@ -376,9 +376,6 @@
|
||||
"Group by vendors Description": "將 OpenAI、Anthropic 等模型放各自供應商的群組中。可以與排序功能結合使用。",
|
||||
"Allow fallback routes": "允許備援路徑",
|
||||
"Allow fallback routes Description": "如果選擇的模型無法滿足要求,會自動選擇替代模型。",
|
||||
"Scale API Key": "Scale API 金鑰",
|
||||
"Clear your cookie": "清除您的 Cookie",
|
||||
"Alt Method": "替代方法",
|
||||
"AI21 API Key": "AI21 API 金鑰",
|
||||
"AI21 Model": "AI21 模型",
|
||||
"Google AI Studio API Key": "Google AI Studio API 金鑰",
|
||||
|
||||
@@ -2689,11 +2689,9 @@ export function parseMesExamples(examplesStr, isInstruct) {
|
||||
}
|
||||
|
||||
export function isStreamingEnabled() {
|
||||
const noStreamSources = [chat_completion_sources.SCALE];
|
||||
return (
|
||||
(main_api == 'openai' &&
|
||||
oai_settings.stream_openai &&
|
||||
!noStreamSources.includes(oai_settings.chat_completion_source) &&
|
||||
!(oai_settings.chat_completion_source == chat_completion_sources.OPENAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model))
|
||||
)
|
||||
|| (main_api == 'kobold' && kai_settings.streaming_kobold && kai_flags.can_use_streaming)
|
||||
|
||||
@@ -397,7 +397,6 @@ function RA_autoconnect(PrevApi) {
|
||||
case 'openai':
|
||||
if (((secret_state[SECRET_KEYS.OPENAI] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.OPENAI)
|
||||
|| ((secret_state[SECRET_KEYS.CLAUDE] || oai_settings.reverse_proxy) && oai_settings.chat_completion_source == chat_completion_sources.CLAUDE)
|
||||
|| ((secret_state[SECRET_KEYS.SCALE] || secret_state[SECRET_KEYS.SCALE_COOKIE]) && oai_settings.chat_completion_source == chat_completion_sources.SCALE)
|
||||
|| (secret_state[SECRET_KEYS.OPENROUTER] && oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER)
|
||||
|| (secret_state[SECRET_KEYS.AI21] && oai_settings.chat_completion_source == chat_completion_sources.AI21)
|
||||
|| (secret_state[SECRET_KEYS.MAKERSUITE] && oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE)
|
||||
|
||||
+2
-142
@@ -15,14 +15,12 @@ import {
|
||||
Generate,
|
||||
getExtensionPrompt,
|
||||
getExtensionPromptMaxDepth,
|
||||
getNextMessageId,
|
||||
getRequestHeaders,
|
||||
getStoppingStrings,
|
||||
is_send_press,
|
||||
main_api,
|
||||
name1,
|
||||
name2,
|
||||
replaceItemizedPromptText,
|
||||
resultCheckStatus,
|
||||
saveSettingsDebounced,
|
||||
setOnlineStatus,
|
||||
@@ -129,7 +127,6 @@ const max_200k = 200 * 1000;
|
||||
const max_256k = 256 * 1000;
|
||||
const max_1mil = 1000 * 1000;
|
||||
const max_2mil = 2000 * 1000;
|
||||
const scale_max = 8191;
|
||||
const claude_max = 9000; // We have a proper tokenizer, so theoretically could be larger (up to 9k)
|
||||
const claude_100k_max = 99000;
|
||||
const unlocked_max = max_2mil;
|
||||
@@ -172,7 +169,6 @@ export let model_list = [];
|
||||
export const chat_completion_sources = {
|
||||
OPENAI: 'openai',
|
||||
CLAUDE: 'claude',
|
||||
SCALE: 'scale',
|
||||
OPENROUTER: 'openrouter',
|
||||
AI21: 'ai21',
|
||||
MAKERSUITE: 'makersuite',
|
||||
@@ -305,7 +301,6 @@ export const settingsToUpdate = {
|
||||
stream_openai: ['#stream_toggle', 'stream_openai', true, false],
|
||||
prompts: ['', 'prompts', false, false],
|
||||
prompt_order: ['', 'prompt_order', false, false],
|
||||
api_url_scale: ['#api_url_scale', 'api_url_scale', false, true],
|
||||
show_external_models: ['#openai_show_external_models', 'show_external_models', true, true],
|
||||
proxy_password: ['#openai_proxy_password', 'proxy_password', false, true],
|
||||
assistant_prefill: ['#claude_assistant_prefill', 'assistant_prefill', false, false],
|
||||
@@ -315,7 +310,6 @@ export const settingsToUpdate = {
|
||||
vertexai_auth_mode: ['#vertexai_auth_mode', 'vertexai_auth_mode', false, true],
|
||||
vertexai_region: ['#vertexai_region', 'vertexai_region', false, true],
|
||||
vertexai_express_project_id: ['#vertexai_express_project_id', 'vertexai_express_project_id', false, true],
|
||||
use_alt_scale: ['#use_alt_scale', 'use_alt_scale', true, true],
|
||||
squash_system_messages: ['#squash_system_messages', 'squash_system_messages', true, false],
|
||||
image_inlining: ['#openai_image_inlining', 'image_inlining', true, false],
|
||||
inline_image_quality: ['#openai_inline_image_quality', 'inline_image_quality', false, false],
|
||||
@@ -391,7 +385,6 @@ const default_settings = {
|
||||
reverse_proxy: '',
|
||||
chat_completion_source: chat_completion_sources.OPENAI,
|
||||
max_context_unlocked: false,
|
||||
api_url_scale: '',
|
||||
show_external_models: false,
|
||||
proxy_password: '',
|
||||
assistant_prefill: '',
|
||||
@@ -401,7 +394,6 @@ const default_settings = {
|
||||
vertexai_auth_mode: 'express',
|
||||
vertexai_region: 'us-central1',
|
||||
vertexai_express_project_id: '',
|
||||
use_alt_scale: false,
|
||||
squash_system_messages: false,
|
||||
image_inlining: false,
|
||||
inline_image_quality: 'low',
|
||||
@@ -480,7 +472,6 @@ const oai_settings = {
|
||||
reverse_proxy: '',
|
||||
chat_completion_source: chat_completion_sources.OPENAI,
|
||||
max_context_unlocked: false,
|
||||
api_url_scale: '',
|
||||
show_external_models: false,
|
||||
proxy_password: '',
|
||||
assistant_prefill: '',
|
||||
@@ -490,7 +481,6 @@ const oai_settings = {
|
||||
vertexai_auth_mode: 'express',
|
||||
vertexai_region: 'us-central1',
|
||||
vertexai_express_project_id: '',
|
||||
use_alt_scale: false,
|
||||
squash_system_messages: false,
|
||||
image_inlining: false,
|
||||
inline_image_quality: 'low',
|
||||
@@ -1599,8 +1589,6 @@ export function getChatCompletionModel(source = null) {
|
||||
return oai_settings.claude_model;
|
||||
case chat_completion_sources.OPENAI:
|
||||
return oai_settings.openai_model;
|
||||
case chat_completion_sources.SCALE:
|
||||
return '';
|
||||
case chat_completion_sources.MAKERSUITE:
|
||||
return oai_settings.google_model;
|
||||
case chat_completion_sources.VERTEXAI:
|
||||
@@ -2007,54 +1995,6 @@ function getAimlapiModelTemplate(option) {
|
||||
`));
|
||||
}
|
||||
|
||||
async function sendAltScaleRequest(messages, logit_bias, signal, type) {
|
||||
const generate_url = '/api/backends/scale-alt/generate';
|
||||
|
||||
let firstSysMsgs = [];
|
||||
for (let msg of messages) {
|
||||
if (msg.role === 'system') {
|
||||
firstSysMsgs.push(substituteParams(msg.name ? msg.name + ': ' + msg.content : msg.content));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let subsequentMsgs = messages.slice(firstSysMsgs.length);
|
||||
|
||||
const joinedSysMsgs = substituteParams(firstSysMsgs.join('\n'));
|
||||
const joinedSubsequentMsgs = subsequentMsgs.reduce((acc, obj) => {
|
||||
return acc + obj.role + ': ' + obj.content + '\n';
|
||||
}, '');
|
||||
|
||||
messages = substituteParams(joinedSubsequentMsgs);
|
||||
const messageId = getNextMessageId(type);
|
||||
replaceItemizedPromptText(messageId, messages);
|
||||
|
||||
const generate_data = {
|
||||
sysprompt: joinedSysMsgs,
|
||||
prompt: messages,
|
||||
temp: Number(oai_settings.temp_openai),
|
||||
top_p: Number(oai_settings.top_p_openai),
|
||||
max_tokens: Number(oai_settings.openai_max_tokens),
|
||||
logit_bias: logit_bias,
|
||||
};
|
||||
|
||||
const response = await fetch(generate_url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(generate_data),
|
||||
headers: getRequestHeaders(),
|
||||
signal: signal,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
tryParseStreamingError(response, await response.text());
|
||||
throw new Error('Scale response does not indicate success.');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
return data.output;
|
||||
}
|
||||
|
||||
function getReasoningEffort() {
|
||||
// These sources expect the effort as string.
|
||||
const reasoningEffortSources = [
|
||||
@@ -2109,7 +2049,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
let logit_bias = {};
|
||||
const isClaude = oai_settings.chat_completion_source == chat_completion_sources.CLAUDE;
|
||||
const isOpenRouter = oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER;
|
||||
const isScale = oai_settings.chat_completion_source == chat_completion_sources.SCALE;
|
||||
const isGoogle = oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE;
|
||||
const isVertexAI = oai_settings.chat_completion_source == chat_completion_sources.VERTEXAI;
|
||||
const isOAI = oai_settings.chat_completion_source == chat_completion_sources.OPENAI;
|
||||
@@ -2128,11 +2067,11 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
const isQuiet = type === 'quiet';
|
||||
const isImpersonate = type === 'impersonate';
|
||||
const isContinue = type === 'continue';
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !isScale && !(isOAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model));
|
||||
const stream = oai_settings.stream_openai && !isQuiet && !(isOAI && ['o1-2024-12-17', 'o1'].includes(oai_settings.openai_model));
|
||||
const useLogprobs = !!power_user.request_token_probabilities;
|
||||
const canMultiSwipe = oai_settings.n > 1 && !isContinue && !isImpersonate && !isQuiet && (isOAI || isCustom || isXAI || isAimlapi);
|
||||
|
||||
const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.SCALE, chat_completion_sources.CUSTOM];
|
||||
const logitBiasSources = [chat_completion_sources.OPENAI, chat_completion_sources.OPENROUTER, chat_completion_sources.CUSTOM];
|
||||
if (oai_settings.bias_preset_selected
|
||||
&& logitBiasSources.includes(oai_settings.chat_completion_source)
|
||||
&& Array.isArray(oai_settings.bias_presets[oai_settings.bias_preset_selected])
|
||||
@@ -2145,10 +2084,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
logit_bias = undefined;
|
||||
}
|
||||
|
||||
if (isScale && oai_settings.use_alt_scale) {
|
||||
return sendAltScaleRequest(messages, logit_bias, signal, type);
|
||||
}
|
||||
|
||||
const model = getChatCompletionModel();
|
||||
const generate_data = {
|
||||
'messages': messages,
|
||||
@@ -2230,10 +2165,6 @@ async function sendOpenAIRequest(type, messages, signal, { jsonSchema = null } =
|
||||
}
|
||||
}
|
||||
|
||||
if (isScale) {
|
||||
generate_data['api_url_scale'] = oai_settings.api_url_scale;
|
||||
}
|
||||
|
||||
if (isGoogle || isVertexAI) {
|
||||
const stopStringsLimit = 5;
|
||||
generate_data['top_k'] = Number(oai_settings.top_k_openai);
|
||||
@@ -3446,7 +3377,6 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.google_model = settings.google_model ?? default_settings.google_model;
|
||||
oai_settings.vertexai_model = settings.vertexai_model ?? default_settings.vertexai_model;
|
||||
oai_settings.chat_completion_source = settings.chat_completion_source ?? default_settings.chat_completion_source;
|
||||
oai_settings.api_url_scale = settings.api_url_scale ?? default_settings.api_url_scale;
|
||||
oai_settings.show_external_models = settings.show_external_models ?? default_settings.show_external_models;
|
||||
oai_settings.proxy_password = settings.proxy_password ?? default_settings.proxy_password;
|
||||
oai_settings.assistant_prefill = settings.assistant_prefill ?? default_settings.assistant_prefill;
|
||||
@@ -3495,9 +3425,7 @@ function loadOpenAISettings(data, settings) {
|
||||
if (settings.vertexai_auth_mode !== undefined) oai_settings.vertexai_auth_mode = settings.vertexai_auth_mode;
|
||||
if (settings.vertexai_region !== undefined) oai_settings.vertexai_region = settings.vertexai_region;
|
||||
if (settings.vertexai_express_project_id !== undefined) oai_settings.vertexai_express_project_id = settings.vertexai_express_project_id;
|
||||
if (settings.use_alt_scale !== undefined) { oai_settings.use_alt_scale = !!settings.use_alt_scale; updateScaleForm(); }
|
||||
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
||||
$('#api_url_scale').val(oai_settings.api_url_scale);
|
||||
$('#openai_proxy_password').val(oai_settings.proxy_password);
|
||||
$('#claude_assistant_prefill').val(oai_settings.assistant_prefill);
|
||||
$('#claude_assistant_impersonation').val(oai_settings.assistant_impersonation);
|
||||
@@ -3558,7 +3486,6 @@ function loadOpenAISettings(data, settings) {
|
||||
// Don't display Service Account JSON in textarea - it's stored in backend secrets
|
||||
$('#vertexai_service_account_json').val('');
|
||||
updateVertexAIServiceAccountStatus();
|
||||
$('#scale-alt').prop('checked', oai_settings.use_alt_scale);
|
||||
$('#openrouter_use_fallback').prop('checked', oai_settings.openrouter_use_fallback);
|
||||
$('#openrouter_group_models').prop('checked', oai_settings.openrouter_group_models);
|
||||
$('#openrouter_allow_fallbacks').prop('checked', oai_settings.openrouter_allow_fallbacks);
|
||||
@@ -3701,7 +3628,6 @@ function setContinuePostfixControls() {
|
||||
|
||||
async function getStatusOpen() {
|
||||
const noValidateSources = [
|
||||
chat_completion_sources.SCALE,
|
||||
chat_completion_sources.CLAUDE,
|
||||
chat_completion_sources.AI21,
|
||||
chat_completion_sources.VERTEXAI,
|
||||
@@ -3851,7 +3777,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
stream_openai: settings.stream_openai,
|
||||
prompts: settings.prompts,
|
||||
prompt_order: settings.prompt_order,
|
||||
api_url_scale: settings.api_url_scale,
|
||||
show_external_models: settings.show_external_models,
|
||||
assistant_prefill: settings.assistant_prefill,
|
||||
assistant_impersonation: settings.assistant_impersonation,
|
||||
@@ -3860,7 +3785,6 @@ async function saveOpenAIPreset(name, settings, triggerUi = true) {
|
||||
vertexai_auth_mode: settings.vertexai_auth_mode,
|
||||
vertexai_region: settings.vertexai_region,
|
||||
vertexai_express_project_id: settings.vertexai_express_project_id,
|
||||
use_alt_scale: settings.use_alt_scale,
|
||||
squash_system_messages: settings.squash_system_messages,
|
||||
image_inlining: settings.image_inlining,
|
||||
inline_image_quality: settings.inline_image_quality,
|
||||
@@ -4663,17 +4587,6 @@ async function onModelChange() {
|
||||
oai_settings.xai_model = value;
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else {
|
||||
$('#openai_max_context').attr('max', scale_max);
|
||||
}
|
||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if ([chat_completion_sources.MAKERSUITE, chat_completion_sources.VERTEXAI].includes(oai_settings.chat_completion_source)) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', max_2mil);
|
||||
@@ -5003,34 +4916,6 @@ async function onConnectButtonClick(e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
|
||||
const api_key_scale = String($('#api_key_scale').val()).trim();
|
||||
const scale_cookie = String($('#scale_cookie').val()).trim();
|
||||
|
||||
if (api_key_scale.length) {
|
||||
await writeSecret(SECRET_KEYS.SCALE, api_key_scale);
|
||||
}
|
||||
|
||||
if (scale_cookie.length) {
|
||||
await writeSecret(SECRET_KEYS.SCALE_COOKIE, scale_cookie);
|
||||
}
|
||||
|
||||
if (!oai_settings.api_url_scale && !oai_settings.use_alt_scale) {
|
||||
console.log('No API URL saved for Scale');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!secret_state[SECRET_KEYS.SCALE] && !oai_settings.use_alt_scale) {
|
||||
console.log('No secret key saved for Scale');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!secret_state[SECRET_KEYS.SCALE_COOKIE] && oai_settings.use_alt_scale) {
|
||||
console.log('No cookie set for Scale');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {
|
||||
const api_key_makersuite = String($('#api_key_makersuite').val()).trim();
|
||||
|
||||
@@ -5250,9 +5135,6 @@ function toggleChatCompletionForms() {
|
||||
$('#model_openai_select').trigger('change');
|
||||
}
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
|
||||
$('#model_scale_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.MAKERSUITE) {
|
||||
$('#model_google_select').trigger('change');
|
||||
}
|
||||
@@ -5338,16 +5220,6 @@ function onProxyPasswordShowClick() {
|
||||
$(this).toggleClass('fa-eye-slash fa-eye');
|
||||
}
|
||||
|
||||
function updateScaleForm() {
|
||||
if (oai_settings.use_alt_scale) {
|
||||
$('#normal_scale_form').css('display', 'none');
|
||||
$('#alt_scale_form').css('display', '');
|
||||
} else {
|
||||
$('#normal_scale_form').css('display', '');
|
||||
$('#alt_scale_form').css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
async function onCustomizeParametersClick() {
|
||||
const template = $(await renderTemplateAsync('customEndpointAdditionalParameters'));
|
||||
|
||||
@@ -5762,12 +5634,6 @@ export function initOpenAI() {
|
||||
|
||||
$('#test_api_button').on('click', testApiConnection);
|
||||
|
||||
$('#scale-alt').on('change', function () {
|
||||
oai_settings.use_alt_scale = !!$('#scale-alt').prop('checked');
|
||||
saveSettingsDebounced();
|
||||
updateScaleForm();
|
||||
});
|
||||
|
||||
$('#temp_openai').on('input', function () {
|
||||
oai_settings.temp_openai = Number($(this).val());
|
||||
$('#temp_counter_openai').val(Number($(this).val()).toFixed(2));
|
||||
@@ -5982,11 +5848,6 @@ export function initOpenAI() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#api_url_scale').on('input', function () {
|
||||
oai_settings.api_url_scale = String($(this).val());
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#openai_show_external_models').on('input', function () {
|
||||
oai_settings.show_external_models = !!$(this).prop('checked');
|
||||
$('#openai_external_category').toggle(oai_settings.show_external_models);
|
||||
@@ -6220,7 +6081,6 @@ export function initOpenAI() {
|
||||
$('#openai_reverse_proxy').on('input', onReverseProxyInput);
|
||||
$('#model_openai_select').on('change', onModelChange);
|
||||
$('#model_claude_select').on('change', onModelChange);
|
||||
$('#model_scale_select').on('change', onModelChange);
|
||||
$('#model_google_select').on('change', onModelChange);
|
||||
$('#model_vertexai_select').on('change', onModelChange);
|
||||
$('#vertexai_auth_mode').on('change', onVertexAIAuthModeChange);
|
||||
|
||||
@@ -28,9 +28,7 @@ export const SECRET_KEYS = {
|
||||
LIBRE_URL: 'libre_url',
|
||||
LINGVA_URL: 'lingva_url',
|
||||
OPENROUTER: 'api_key_openrouter',
|
||||
SCALE: 'api_key_scale',
|
||||
AI21: 'api_key_ai21',
|
||||
SCALE_COOKIE: 'scale_cookie',
|
||||
ONERING_URL: 'oneringtranslator_url',
|
||||
DEEPLX_URL: 'deeplx_url',
|
||||
MAKERSUITE: 'api_key_makersuite',
|
||||
@@ -73,9 +71,7 @@ const FRIENDLY_NAMES = {
|
||||
[SECRET_KEYS.NOVEL]: 'NovelAI',
|
||||
[SECRET_KEYS.CLAUDE]: 'Claude',
|
||||
[SECRET_KEYS.OPENROUTER]: 'OpenRouter',
|
||||
[SECRET_KEYS.SCALE]: 'Scale',
|
||||
[SECRET_KEYS.AI21]: 'AI21',
|
||||
[SECRET_KEYS.SCALE_COOKIE]: 'Scale (Cookie)',
|
||||
[SECRET_KEYS.MAKERSUITE]: 'Google AI Studio',
|
||||
[SECRET_KEYS.VERTEXAI]: 'Google Vertex AI (Express Mode)',
|
||||
[SECRET_KEYS.VLLM]: 'vLLM',
|
||||
@@ -125,9 +121,7 @@ const INPUT_MAP = {
|
||||
[SECRET_KEYS.NOVEL]: '#api_key_novel',
|
||||
[SECRET_KEYS.CLAUDE]: '#api_key_claude',
|
||||
[SECRET_KEYS.OPENROUTER]: '.api_key_openrouter',
|
||||
[SECRET_KEYS.SCALE]: '#api_key_scale',
|
||||
[SECRET_KEYS.AI21]: '#api_key_ai21',
|
||||
[SECRET_KEYS.SCALE_COOKIE]: '#scale_cookie',
|
||||
[SECRET_KEYS.MAKERSUITE]: '#api_key_makersuite',
|
||||
[SECRET_KEYS.VERTEXAI]: '#api_key_vertexai',
|
||||
[SECRET_KEYS.VLLM]: '#api_key_vllm',
|
||||
@@ -191,12 +185,6 @@ export function resolveSecretKey() {
|
||||
}
|
||||
}
|
||||
|
||||
if (chatCompletionSource === chat_completion_sources.SCALE) {
|
||||
return chatCompletionSettings.use_alt_scale
|
||||
? SECRET_KEYS.SCALE_COOKIE
|
||||
: SECRET_KEYS.SCALE;
|
||||
}
|
||||
|
||||
const [key] = Object.entries(chat_completion_sources).find(([, value]) => value === chatCompletionSource) ?? [null];
|
||||
if (key && SECRET_KEYS[key]) {
|
||||
return SECRET_KEYS[key];
|
||||
|
||||
@@ -586,11 +586,6 @@ export function getTokenizerModel() {
|
||||
const nemoTokenizer = 'nemo';
|
||||
const deepseekTokenizer = 'deepseek';
|
||||
|
||||
// Assuming no one would use it for different models.. right?
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.SCALE) {
|
||||
return gpt4Tokenizer;
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.DEEPSEEK) {
|
||||
return deepseekTokenizer;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ export const GEMINI_SAFETY = [
|
||||
export const CHAT_COMPLETION_SOURCES = {
|
||||
OPENAI: 'openai',
|
||||
CLAUDE: 'claude',
|
||||
SCALE: 'scale',
|
||||
OPENROUTER: 'openrouter',
|
||||
AI21: 'ai21',
|
||||
MAKERSUITE: 'makersuite',
|
||||
|
||||
@@ -275,58 +275,6 @@ async function sendClaudeRequest(request, response) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Scale Spellbook API.
|
||||
* @param {import("express").Request} request Express request
|
||||
* @param {import("express").Response} response Express response
|
||||
*/
|
||||
async function sendScaleRequest(request, response) {
|
||||
const apiUrl = new URL(request.body.api_url_scale).toString();
|
||||
const apiKey = readSecret(request.user.directories, SECRET_KEYS.SCALE);
|
||||
|
||||
if (!apiKey) {
|
||||
console.warn('Scale API key is missing.');
|
||||
return response.status(400).send({ error: true });
|
||||
}
|
||||
|
||||
const requestPrompt = convertTextCompletionPrompt(request.body.messages);
|
||||
console.debug('Scale request:', requestPrompt);
|
||||
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
request.socket.removeAllListeners('close');
|
||||
request.socket.on('close', function () {
|
||||
controller.abort();
|
||||
});
|
||||
|
||||
const generateResponse = await fetch(apiUrl, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ input: { input: requestPrompt } }),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Basic ${apiKey}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!generateResponse.ok) {
|
||||
console.warn(`Scale API returned error: ${generateResponse.status} ${generateResponse.statusText} ${await generateResponse.text()}`);
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const generateResponseJson = await generateResponse.json();
|
||||
console.debug('Scale response:', generateResponseJson);
|
||||
|
||||
const reply = { choices: [{ 'message': { 'content': generateResponseJson.output } }] };
|
||||
return response.send(reply);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (!response.headersSent) {
|
||||
return response.status(500).send({ error: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a request to Google AI API.
|
||||
* @param {express.Request} request Express request
|
||||
@@ -1492,7 +1440,6 @@ router.post('/generate', function (request, response) {
|
||||
|
||||
switch (request.body.chat_completion_source) {
|
||||
case CHAT_COMPLETION_SOURCES.CLAUDE: return sendClaudeRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.SCALE: return sendScaleRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.AI21: return sendAI21Request(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.MAKERSUITE: return sendMakerSuiteRequest(request, response);
|
||||
case CHAT_COMPLETION_SOURCES.VERTEXAI: return sendMakerSuiteRequest(request, response);
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
import express from 'express';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
import { readSecret, SECRET_KEYS } from '../secrets.js';
|
||||
|
||||
export const router = express.Router();
|
||||
|
||||
router.post('/generate', async function (request, response) {
|
||||
if (!request.body) return response.sendStatus(400);
|
||||
|
||||
try {
|
||||
const cookie = readSecret(request.user.directories, SECRET_KEYS.SCALE_COOKIE);
|
||||
|
||||
if (!cookie) {
|
||||
console.error('No Scale cookie found');
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
const body = {
|
||||
json: {
|
||||
variant: {
|
||||
name: 'New Variant',
|
||||
appId: '',
|
||||
taxonomy: null,
|
||||
},
|
||||
prompt: {
|
||||
id: '',
|
||||
template: '{{input}}\n',
|
||||
exampleVariables: {},
|
||||
variablesSourceDataId: null,
|
||||
systemMessage: request.body.sysprompt,
|
||||
},
|
||||
modelParameters: {
|
||||
id: '',
|
||||
modelId: 'GPT4',
|
||||
modelType: 'OpenAi',
|
||||
maxTokens: request.body.max_tokens,
|
||||
temperature: request.body.temp,
|
||||
stop: 'user:',
|
||||
suffix: null,
|
||||
topP: request.body.top_p,
|
||||
logprobs: null,
|
||||
logitBias: request.body.logit_bias,
|
||||
},
|
||||
inputs: [
|
||||
{
|
||||
index: '-1',
|
||||
valueByName: {
|
||||
input: request.body.prompt,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
meta: {
|
||||
values: {
|
||||
'variant.taxonomy': ['undefined'],
|
||||
'prompt.variablesSourceDataId': ['undefined'],
|
||||
'modelParameters.suffix': ['undefined'],
|
||||
'modelParameters.logprobs': ['undefined'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
console.debug('Scale request:', body);
|
||||
|
||||
const result = await fetch('https://dashboard.scale.com/spellbook/api/trpc/v2.variant.run', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'cookie': `_jwt=${cookie}`,
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
const text = await result.text();
|
||||
console.error('Scale request failed', result.statusText, text);
|
||||
return response.status(500).send({ error: { message: result.statusText } });
|
||||
}
|
||||
|
||||
/** @type {any} */
|
||||
const data = await result.json();
|
||||
const output = data?.result?.data?.json?.outputs?.[0] || '';
|
||||
|
||||
console.debug('Scale response:', data);
|
||||
|
||||
if (!output) {
|
||||
console.warn('Scale response is empty');
|
||||
return response.sendStatus(500).send({ error: { message: 'Empty response' } });
|
||||
}
|
||||
|
||||
return response.json({ output });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return response.sendStatus(500);
|
||||
}
|
||||
});
|
||||
@@ -21,9 +21,7 @@ export const SECRET_KEYS = {
|
||||
LIBRE_URL: 'libre_url',
|
||||
LINGVA_URL: 'lingva_url',
|
||||
OPENROUTER: 'api_key_openrouter',
|
||||
SCALE: 'api_key_scale',
|
||||
AI21: 'api_key_ai21',
|
||||
SCALE_COOKIE: 'scale_cookie',
|
||||
ONERING_URL: 'oneringtranslator_url',
|
||||
DEEPLX_URL: 'deeplx_url',
|
||||
MAKERSUITE: 'api_key_makersuite',
|
||||
|
||||
@@ -43,7 +43,6 @@ import { router as openRouterRouter } from './endpoints/openrouter.js';
|
||||
import { router as chatCompletionsRouter } from './endpoints/backends/chat-completions.js';
|
||||
import { router as koboldRouter } from './endpoints/backends/kobold.js';
|
||||
import { router as textCompletionsRouter } from './endpoints/backends/text-completions.js';
|
||||
import { router as scaleAltRouter } from './endpoints/backends/scale-alt.js';
|
||||
import { router as speechRouter } from './endpoints/speech.js';
|
||||
import { router as azureRouter } from './endpoints/azure.js';
|
||||
import { router as dataMaidRouter } from './endpoints/data-maid.js';
|
||||
@@ -171,7 +170,6 @@ export function setupPrivateEndpoints(app) {
|
||||
app.use('/api/openrouter', openRouterRouter);
|
||||
app.use('/api/backends/kobold', koboldRouter);
|
||||
app.use('/api/backends/chat-completions', chatCompletionsRouter);
|
||||
app.use('/api/backends/scale-alt', scaleAltRouter);
|
||||
app.use('/api/speech', speechRouter);
|
||||
app.use('/api/azure', azureRouter);
|
||||
app.use('/api/data-maid', dataMaidRouter);
|
||||
|
||||
Reference in New Issue
Block a user