mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add OpenRouter as a text completion source
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
const { TEXTGEN_TYPES } = require('./constants');
|
||||
const { TEXTGEN_TYPES, OPENROUTER_HEADERS } = require('./constants');
|
||||
const { SECRET_KEYS, readSecret } = require('./endpoints/secrets');
|
||||
const { getConfigValue } = require('./util');
|
||||
|
||||
@ -27,6 +27,13 @@ function getInfermaticAIHeaders() {
|
||||
}) : {};
|
||||
}
|
||||
|
||||
function getOpenRouterHeaders() {
|
||||
const apiKey = readSecret(SECRET_KEYS.OPENROUTER);
|
||||
const baseHeaders = { ...OPENROUTER_HEADERS };
|
||||
|
||||
return apiKey ? Object.assign(baseHeaders, { 'Authorization': `Bearer ${apiKey}` }) : baseHeaders;
|
||||
}
|
||||
|
||||
function getAphroditeHeaders() {
|
||||
const apiKey = readSecret(SECRET_KEYS.APHRODITE);
|
||||
|
||||
@ -91,6 +98,9 @@ function setAdditionalHeaders(request, args, server) {
|
||||
case TEXTGEN_TYPES.INFERMATICAI:
|
||||
headers = getInfermaticAIHeaders();
|
||||
break;
|
||||
case TEXTGEN_TYPES.OPENROUTER:
|
||||
headers = getOpenRouterHeaders();
|
||||
break;
|
||||
default:
|
||||
headers = server ? getOverrideHeaders((new URL(server))?.host) : {};
|
||||
break;
|
||||
|
Reference in New Issue
Block a user