@automagik/omni 2.260921.2 → 2.260921.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/server/index.js +324 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -115973,7 +115973,7 @@ var require_client2 = __commonJS((exports) => {
|
|
|
115973
115973
|
|
|
115974
115974
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js
|
|
115975
115975
|
var require_esmLoader = __commonJS((exports) => {
|
|
115976
|
-
var __filename = "/home/runner/work/omni/omni
|
|
115976
|
+
var __filename = "/home/runner/work/omni/omni/node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js";
|
|
115977
115977
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
115978
115978
|
var core = require_cjs();
|
|
115979
115979
|
var importInTheMiddle = require_import_in_the_middle();
|
|
@@ -137424,7 +137424,7 @@ import { fileURLToPath } from "url";
|
|
|
137424
137424
|
// package.json
|
|
137425
137425
|
var package_default = {
|
|
137426
137426
|
name: "@automagik/omni",
|
|
137427
|
-
version: "2.260921.
|
|
137427
|
+
version: "2.260921.3",
|
|
137428
137428
|
repository: {
|
|
137429
137429
|
type: "git",
|
|
137430
137430
|
url: "git+https://github.com/automagik-dev/omni.git",
|
package/dist/server/index.js
CHANGED
|
@@ -77148,7 +77148,7 @@ var require_ClientVoiceManager = __commonJS((exports, module) => {
|
|
|
77148
77148
|
|
|
77149
77149
|
// ../../node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist/index.js
|
|
77150
77150
|
var require_dist9 = __commonJS((exports, module) => {
|
|
77151
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
77151
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@discordjs+ws@1.2.3/node_modules/@discordjs/ws/dist";
|
|
77152
77152
|
var __create2 = Object.create;
|
|
77153
77153
|
var __defProp2 = Object.defineProperty;
|
|
77154
77154
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -161661,7 +161661,7 @@ var require_indexes = __commonJS((exports, module) => {
|
|
|
161661
161661
|
|
|
161662
161662
|
// ../../node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream/index.js
|
|
161663
161663
|
var require_thread_stream = __commonJS((exports, module) => {
|
|
161664
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
161664
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/thread-stream@3.1.0/node_modules/thread-stream";
|
|
161665
161665
|
var { version } = require_package5();
|
|
161666
161666
|
var { EventEmitter: EventEmitter3 } = __require("events");
|
|
161667
161667
|
var { Worker } = __require("worker_threads");
|
|
@@ -162082,7 +162082,7 @@ var require_thread_stream = __commonJS((exports, module) => {
|
|
|
162082
162082
|
|
|
162083
162083
|
// ../../node_modules/.bun/pino@9.14.0/node_modules/pino/lib/transport.js
|
|
162084
162084
|
var require_transport2 = __commonJS((exports, module) => {
|
|
162085
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
162085
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/pino@9.14.0/node_modules/pino/lib";
|
|
162086
162086
|
var { createRequire: createRequire2 } = __require("module");
|
|
162087
162087
|
var getCallers = require_caller();
|
|
162088
162088
|
var { join: join8, isAbsolute, sep: sep2 } = __require("path");
|
|
@@ -243889,7 +243889,7 @@ var require_client3 = __commonJS((exports) => {
|
|
|
243889
243889
|
|
|
243890
243890
|
// ../../node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js
|
|
243891
243891
|
var require_esmLoader = __commonJS((exports) => {
|
|
243892
|
-
var __filename = "/home/runner/work/omni/omni
|
|
243892
|
+
var __filename = "/home/runner/work/omni/omni/node_modules/.bun/@sentry+node-core@10.52.0+2c50d7e904f6cfd7/node_modules/@sentry/node-core/build/cjs/sdk/esmLoader.js";
|
|
243893
243893
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
243894
243894
|
var core3 = require_cjs6();
|
|
243895
243895
|
var importInTheMiddle = require_import_in_the_middle();
|
|
@@ -251115,7 +251115,7 @@ var init_sentry_scrub = __esm(() => {
|
|
|
251115
251115
|
var require_package7 = __commonJS((exports, module) => {
|
|
251116
251116
|
module.exports = {
|
|
251117
251117
|
name: "@omni/api",
|
|
251118
|
-
version: "2.260921.
|
|
251118
|
+
version: "2.260921.3",
|
|
251119
251119
|
private: true,
|
|
251120
251120
|
type: "module",
|
|
251121
251121
|
exports: {
|
|
@@ -278217,7 +278217,7 @@ var require_src45 = __commonJS((exports) => {
|
|
|
278217
278217
|
|
|
278218
278218
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
278219
278219
|
var require_channelz = __commonJS((exports) => {
|
|
278220
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
278220
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
278221
278221
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
278222
278222
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
278223
278223
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -283620,7 +283620,7 @@ var require_duration = __commonJS((exports) => {
|
|
|
283620
283620
|
|
|
283621
283621
|
// ../../node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src/orca.js
|
|
283622
283622
|
var require_orca = __commonJS((exports) => {
|
|
283623
|
-
var __dirname = "/home/runner/work/omni/omni
|
|
283623
|
+
var __dirname = "/home/runner/work/omni/omni/node_modules/.bun/@grpc+grpc-js@1.14.3/node_modules/@grpc/grpc-js/build/src";
|
|
283624
283624
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
283625
283625
|
exports.OrcaOobMetricsSubchannelWrapper = exports.GRPC_METRICS_HEADER = exports.ServerMetricRecorder = exports.PerRequestMetricRecorder = undefined;
|
|
283626
283626
|
exports.createOrcaClient = createOrcaClient;
|
|
@@ -362264,7 +362264,319 @@ function buildWhatsAppMessageContext(rawPayload, chatId, instance4, text3) {
|
|
|
362264
362264
|
return { isDirectMessage, mentionsBot, isReplyToBot, text: text3 };
|
|
362265
362265
|
}
|
|
362266
362266
|
|
|
362267
|
+
// ../api/src/services/model-catalog.ts
|
|
362268
|
+
var exports_model_catalog = {};
|
|
362269
|
+
__export(exports_model_catalog, {
|
|
362270
|
+
fetchOpenAiCatalog: () => fetchOpenAiCatalog,
|
|
362271
|
+
fetchGeminiCatalog: () => fetchGeminiCatalog
|
|
362272
|
+
});
|
|
362273
|
+
function defaultFetch(url, init5) {
|
|
362274
|
+
return fetch(url, init5);
|
|
362275
|
+
}
|
|
362276
|
+
function readId(record2) {
|
|
362277
|
+
if (typeof record2 !== "object" || record2 === null)
|
|
362278
|
+
return;
|
|
362279
|
+
const id = record2.id ?? record2.name;
|
|
362280
|
+
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
362281
|
+
}
|
|
362282
|
+
function parseGeminiCatalog(payload) {
|
|
362283
|
+
const raw2 = payload?.models;
|
|
362284
|
+
if (!Array.isArray(raw2))
|
|
362285
|
+
return [];
|
|
362286
|
+
const models = [];
|
|
362287
|
+
const seen = new Set;
|
|
362288
|
+
for (const entry of raw2) {
|
|
362289
|
+
const rawId = readId(entry);
|
|
362290
|
+
if (!rawId)
|
|
362291
|
+
continue;
|
|
362292
|
+
const id = rawId.replace(/^models\//, "");
|
|
362293
|
+
if (!id || seen.has(id))
|
|
362294
|
+
continue;
|
|
362295
|
+
const declared = entry.supportedGenerationMethods;
|
|
362296
|
+
const methods = Array.isArray(declared) ? declared.filter((method) => typeof method === "string") : [];
|
|
362297
|
+
seen.add(id);
|
|
362298
|
+
models.push({ id, methods });
|
|
362299
|
+
}
|
|
362300
|
+
return models;
|
|
362301
|
+
}
|
|
362302
|
+
function parseOpenAiCatalog(payload) {
|
|
362303
|
+
const raw2 = payload?.data;
|
|
362304
|
+
if (!Array.isArray(raw2))
|
|
362305
|
+
return [];
|
|
362306
|
+
const models = [];
|
|
362307
|
+
const seen = new Set;
|
|
362308
|
+
for (const entry of raw2) {
|
|
362309
|
+
const id = readId(entry);
|
|
362310
|
+
if (!id || seen.has(id))
|
|
362311
|
+
continue;
|
|
362312
|
+
seen.add(id);
|
|
362313
|
+
models.push({ id, methods: [] });
|
|
362314
|
+
}
|
|
362315
|
+
return models;
|
|
362316
|
+
}
|
|
362317
|
+
async function fetchGeminiCatalog(apiKey, deps = {}) {
|
|
362318
|
+
if (!apiKey)
|
|
362319
|
+
return null;
|
|
362320
|
+
const doFetch = deps.fetchImpl ?? defaultFetch;
|
|
362321
|
+
const timeoutMs = deps.timeoutMs ?? CATALOG_TIMEOUT_MS;
|
|
362322
|
+
const collected = [];
|
|
362323
|
+
let pageToken;
|
|
362324
|
+
try {
|
|
362325
|
+
for (let page = 0;page < MAX_GEMINI_PAGES; page += 1) {
|
|
362326
|
+
const url = new URL(GEMINI_MODELS_URL);
|
|
362327
|
+
url.searchParams.set("key", apiKey);
|
|
362328
|
+
url.searchParams.set("pageSize", String(GEMINI_PAGE_SIZE));
|
|
362329
|
+
if (pageToken)
|
|
362330
|
+
url.searchParams.set("pageToken", pageToken);
|
|
362331
|
+
const res = await doFetch(url.toString(), { signal: AbortSignal.timeout(timeoutMs) });
|
|
362332
|
+
if (!res.ok)
|
|
362333
|
+
return null;
|
|
362334
|
+
const payload = await res.json();
|
|
362335
|
+
collected.push(...parseGeminiCatalog(payload));
|
|
362336
|
+
const next = payload?.nextPageToken;
|
|
362337
|
+
if (typeof next !== "string" || next.length === 0)
|
|
362338
|
+
break;
|
|
362339
|
+
pageToken = next;
|
|
362340
|
+
}
|
|
362341
|
+
} catch {
|
|
362342
|
+
return null;
|
|
362343
|
+
}
|
|
362344
|
+
return collected;
|
|
362345
|
+
}
|
|
362346
|
+
async function fetchOpenAiCatalog(apiKey, deps = {}) {
|
|
362347
|
+
if (!apiKey)
|
|
362348
|
+
return null;
|
|
362349
|
+
const doFetch = deps.fetchImpl ?? defaultFetch;
|
|
362350
|
+
const timeoutMs = deps.timeoutMs ?? CATALOG_TIMEOUT_MS;
|
|
362351
|
+
try {
|
|
362352
|
+
const res = await doFetch(OPENAI_MODELS_URL, {
|
|
362353
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
362354
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
362355
|
+
});
|
|
362356
|
+
if (!res.ok)
|
|
362357
|
+
return null;
|
|
362358
|
+
const payload = await res.json();
|
|
362359
|
+
return parseOpenAiCatalog(payload);
|
|
362360
|
+
} catch {
|
|
362361
|
+
return null;
|
|
362362
|
+
}
|
|
362363
|
+
}
|
|
362364
|
+
var GEMINI_MODELS_URL = "https://generativelanguage.googleapis.com/v1beta/models", OPENAI_MODELS_URL = "https://api.openai.com/v1/models", CATALOG_TIMEOUT_MS = 5000, GEMINI_PAGE_SIZE = 200, MAX_GEMINI_PAGES = 10;
|
|
362365
|
+
|
|
362366
|
+
// ../api/src/services/model-resolver.ts
|
|
362367
|
+
var exports_model_resolver = {};
|
|
362368
|
+
__export(exports_model_resolver, {
|
|
362369
|
+
resolveModel: () => resolveModel2,
|
|
362370
|
+
parseVersion: () => parseVersion
|
|
362371
|
+
});
|
|
362372
|
+
function parseVersion(id) {
|
|
362373
|
+
const match2 = id.match(/(?:^|[-_/])(\d+(?:\.\d+)*)(?=[-_/.]|$)/);
|
|
362374
|
+
const captured = match2?.[1];
|
|
362375
|
+
if (!captured)
|
|
362376
|
+
return [];
|
|
362377
|
+
return captured.split(".").map((part) => Number.parseInt(part, 10)).filter((n2) => Number.isFinite(n2));
|
|
362378
|
+
}
|
|
362379
|
+
function compareVersionDesc(a, b3) {
|
|
362380
|
+
const len = Math.max(a.length, b3.length);
|
|
362381
|
+
for (let i = 0;i < len; i += 1) {
|
|
362382
|
+
const left = a[i];
|
|
362383
|
+
const right = b3[i];
|
|
362384
|
+
if (left === undefined)
|
|
362385
|
+
return 1;
|
|
362386
|
+
if (right === undefined)
|
|
362387
|
+
return -1;
|
|
362388
|
+
if (left !== right)
|
|
362389
|
+
return right - left;
|
|
362390
|
+
}
|
|
362391
|
+
return 0;
|
|
362392
|
+
}
|
|
362393
|
+
function isVariantId(id) {
|
|
362394
|
+
const tokens = idTokens(id);
|
|
362395
|
+
const last = tokens.at(-1) ?? "";
|
|
362396
|
+
return VARIANT_SUFFIX_TOKENS.includes(last);
|
|
362397
|
+
}
|
|
362398
|
+
function nameTier(id, version3) {
|
|
362399
|
+
if (version3.length > 0)
|
|
362400
|
+
return 1;
|
|
362401
|
+
return isVariantId(id) ? 2 : 0;
|
|
362402
|
+
}
|
|
362403
|
+
function idTokens(id) {
|
|
362404
|
+
return id.toLowerCase().split(/[-_/]+/).filter((token) => token.length > 0);
|
|
362405
|
+
}
|
|
362406
|
+
function isRejected(id) {
|
|
362407
|
+
const tokens = idTokens(id);
|
|
362408
|
+
return REJECTED_TOKENS.some((token) => tokens.includes(token));
|
|
362409
|
+
}
|
|
362410
|
+
function previewTier(id) {
|
|
362411
|
+
return idTokens(id).includes("preview") ? 1 : 0;
|
|
362412
|
+
}
|
|
362413
|
+
function aliasTier(id) {
|
|
362414
|
+
return idTokens(id).includes("latest") ? 1 : 0;
|
|
362415
|
+
}
|
|
362416
|
+
function compareCandidateDesc(a, b3, cheapFirst) {
|
|
362417
|
+
if (a.alias !== b3.alias)
|
|
362418
|
+
return a.alias - b3.alias;
|
|
362419
|
+
if (a.tier !== b3.tier)
|
|
362420
|
+
return a.tier - b3.tier;
|
|
362421
|
+
if (a.name !== b3.name)
|
|
362422
|
+
return a.name - b3.name;
|
|
362423
|
+
const byExtra = compareExtraAsc(a.extra, b3.extra);
|
|
362424
|
+
const byVersion = compareVersionDesc(a.version, b3.version);
|
|
362425
|
+
if (cheapFirst) {
|
|
362426
|
+
if (byExtra !== 0)
|
|
362427
|
+
return byExtra;
|
|
362428
|
+
if (byVersion !== 0)
|
|
362429
|
+
return byVersion;
|
|
362430
|
+
} else {
|
|
362431
|
+
if (byVersion !== 0)
|
|
362432
|
+
return byVersion;
|
|
362433
|
+
if (byExtra !== 0)
|
|
362434
|
+
return byExtra;
|
|
362435
|
+
}
|
|
362436
|
+
if (a.id.length !== b3.id.length)
|
|
362437
|
+
return a.id.length - b3.id.length;
|
|
362438
|
+
return a.id.localeCompare(b3.id);
|
|
362439
|
+
}
|
|
362440
|
+
function compareExtraAsc(a, b3) {
|
|
362441
|
+
const len = Math.max(a.length, b3.length);
|
|
362442
|
+
for (let i = 0;i < len; i += 1) {
|
|
362443
|
+
const left = a[i] ?? Number.POSITIVE_INFINITY;
|
|
362444
|
+
const right = b3[i] ?? Number.POSITIVE_INFINITY;
|
|
362445
|
+
if (left !== right)
|
|
362446
|
+
return left - right;
|
|
362447
|
+
}
|
|
362448
|
+
return 0;
|
|
362449
|
+
}
|
|
362450
|
+
function hasMethod(model, method) {
|
|
362451
|
+
if (model.methods.length === 0)
|
|
362452
|
+
return true;
|
|
362453
|
+
return model.methods.includes(method);
|
|
362454
|
+
}
|
|
362455
|
+
function resolveOpenAi(catalog, role) {
|
|
362456
|
+
const pattern = OPENAI_ROLE_PATTERNS[role];
|
|
362457
|
+
if (!pattern)
|
|
362458
|
+
return null;
|
|
362459
|
+
const scored = [];
|
|
362460
|
+
for (const model of catalog) {
|
|
362461
|
+
const id = model.id;
|
|
362462
|
+
if (isRejected(id))
|
|
362463
|
+
continue;
|
|
362464
|
+
if (!pattern.test(id))
|
|
362465
|
+
continue;
|
|
362466
|
+
scored.push({
|
|
362467
|
+
id,
|
|
362468
|
+
alias: aliasTier(id),
|
|
362469
|
+
tier: previewTier(id),
|
|
362470
|
+
name: nameTier(id, parseVersion(id)),
|
|
362471
|
+
version: parseVersion(id),
|
|
362472
|
+
extra: []
|
|
362473
|
+
});
|
|
362474
|
+
}
|
|
362475
|
+
if (scored.length === 0)
|
|
362476
|
+
return null;
|
|
362477
|
+
scored.sort((a, b3) => compareCandidateDesc(a, b3, role === "chat-fast"));
|
|
362478
|
+
return scored[0]?.id ?? null;
|
|
362479
|
+
}
|
|
362480
|
+
function geminiExtra(role, id) {
|
|
362481
|
+
if (role !== "chat-fast")
|
|
362482
|
+
return [];
|
|
362483
|
+
return [idTokens(id).includes("lite") ? 0 : 1];
|
|
362484
|
+
}
|
|
362485
|
+
function resolveGemini(catalog, role) {
|
|
362486
|
+
const fragment2 = GEMINI_ROLE_FRAGMENT[role];
|
|
362487
|
+
if (!fragment2)
|
|
362488
|
+
return null;
|
|
362489
|
+
const requiredMethod = GEMINI_ROLE_METHOD[role];
|
|
362490
|
+
const isChatStyle = role === "chat-fast" || role === "chat" || role === "vision" || role === "transcribe";
|
|
362491
|
+
const scored = [];
|
|
362492
|
+
for (const model of catalog) {
|
|
362493
|
+
const lower = model.id.toLowerCase();
|
|
362494
|
+
if (!lower.includes(fragment2))
|
|
362495
|
+
continue;
|
|
362496
|
+
if (isRejected(model.id))
|
|
362497
|
+
continue;
|
|
362498
|
+
if (isChatStyle && GEMINI_NON_CHAT_FRAGMENTS.some((family) => lower.includes(family)))
|
|
362499
|
+
continue;
|
|
362500
|
+
if (requiredMethod && !hasMethod(model, requiredMethod))
|
|
362501
|
+
continue;
|
|
362502
|
+
scored.push({
|
|
362503
|
+
id: model.id,
|
|
362504
|
+
alias: aliasTier(model.id),
|
|
362505
|
+
tier: previewTier(model.id),
|
|
362506
|
+
name: nameTier(model.id, parseVersion(model.id)),
|
|
362507
|
+
version: parseVersion(model.id),
|
|
362508
|
+
extra: geminiExtra(role, model.id)
|
|
362509
|
+
});
|
|
362510
|
+
}
|
|
362511
|
+
if (scored.length === 0)
|
|
362512
|
+
return null;
|
|
362513
|
+
scored.sort((a, b3) => compareCandidateDesc(a, b3, role === "chat-fast"));
|
|
362514
|
+
return scored[0]?.id ?? null;
|
|
362515
|
+
}
|
|
362516
|
+
function resolveModel2(catalog, provider, role) {
|
|
362517
|
+
if (!catalog || catalog.length === 0)
|
|
362518
|
+
return null;
|
|
362519
|
+
const model = provider === "openai" ? resolveOpenAi(catalog, role) : resolveGemini(catalog, role);
|
|
362520
|
+
if (!model)
|
|
362521
|
+
return null;
|
|
362522
|
+
return { model, role, provider, source: "catalog" };
|
|
362523
|
+
}
|
|
362524
|
+
var GEMINI_SPECIAL_FAMILIES, VARIANT_SUFFIX_TOKENS, REJECTED_TOKENS, OPENAI_ROLE_PATTERNS, GEMINI_ROLE_FRAGMENT, GEMINI_ROLE_METHOD, GEMINI_NON_CHAT_FRAGMENTS;
|
|
362525
|
+
var init_model_resolver = __esm(() => {
|
|
362526
|
+
GEMINI_SPECIAL_FAMILIES = ["lyria", "veo", "embedding", "embed", "aqa", "imagen", "gemma"];
|
|
362527
|
+
VARIANT_SUFFIX_TOKENS = ["turbo", "diarize", "mini", "lite", "nano", "hd", "flash", "pro", "max", "fast"];
|
|
362528
|
+
REJECTED_TOKENS = ["exp", "experimental", "deprecated", "legacy", "alpha", "beta"];
|
|
362529
|
+
OPENAI_ROLE_PATTERNS = {
|
|
362530
|
+
"chat-fast": null,
|
|
362531
|
+
chat: null,
|
|
362532
|
+
transcribe: /^(?:gpt-[\w.-]*transcribe[\w.-]*|whisper-[\w.-]+)$/,
|
|
362533
|
+
tts: /-tts$/,
|
|
362534
|
+
image: /^gpt-image-[\w.-]+$/,
|
|
362535
|
+
music: null,
|
|
362536
|
+
video: null,
|
|
362537
|
+
vision: null
|
|
362538
|
+
};
|
|
362539
|
+
GEMINI_ROLE_FRAGMENT = {
|
|
362540
|
+
"chat-fast": "flash",
|
|
362541
|
+
chat: "flash",
|
|
362542
|
+
transcribe: "transcribe",
|
|
362543
|
+
tts: "tts",
|
|
362544
|
+
image: "image",
|
|
362545
|
+
music: "lyria",
|
|
362546
|
+
video: "veo",
|
|
362547
|
+
vision: "flash"
|
|
362548
|
+
};
|
|
362549
|
+
GEMINI_ROLE_METHOD = {
|
|
362550
|
+
"chat-fast": "generateContent",
|
|
362551
|
+
chat: "generateContent",
|
|
362552
|
+
transcribe: "generateContent",
|
|
362553
|
+
tts: "generateContent",
|
|
362554
|
+
image: "generateContent",
|
|
362555
|
+
music: null,
|
|
362556
|
+
video: "predictLongRunning",
|
|
362557
|
+
vision: "generateContent"
|
|
362558
|
+
};
|
|
362559
|
+
GEMINI_NON_CHAT_FRAGMENTS = [...GEMINI_SPECIAL_FAMILIES, "tts", "image"];
|
|
362560
|
+
});
|
|
362561
|
+
|
|
362267
362562
|
// ../api/src/services/response-gate.ts
|
|
362563
|
+
async function resolveGateModelFromCatalog(provider, settings) {
|
|
362564
|
+
const fallback = provider === "openai" ? DEFAULT_GATE_MODEL_OPENAI : DEFAULT_GATE_MODEL_GEMINI;
|
|
362565
|
+
try {
|
|
362566
|
+
const { fetchGeminiCatalog: fetchGeminiCatalog2, fetchOpenAiCatalog: fetchOpenAiCatalog2 } = await Promise.resolve().then(() => exports_model_catalog);
|
|
362567
|
+
const { resolveModel: resolveModel3 } = await Promise.resolve().then(() => (init_model_resolver(), exports_model_resolver));
|
|
362568
|
+
const key = provider === "openai" ? await settings.getSecret("openai.api_key", "OPENAI_API_KEY") : await settings.getSecret("gemini.api_key", "GEMINI_API_KEY");
|
|
362569
|
+
if (!key)
|
|
362570
|
+
return { model: fallback, source: "constant" };
|
|
362571
|
+
const catalog = provider === "openai" ? await fetchOpenAiCatalog2(key) : await fetchGeminiCatalog2(key);
|
|
362572
|
+
const resolved = resolveModel3(catalog, provider, "chat-fast");
|
|
362573
|
+
if (!resolved)
|
|
362574
|
+
return { model: fallback, source: "constant" };
|
|
362575
|
+
return { model: resolved.model, source: "catalog" };
|
|
362576
|
+
} catch {
|
|
362577
|
+
return { model: fallback, source: "constant" };
|
|
362578
|
+
}
|
|
362579
|
+
}
|
|
362268
362580
|
async function resolveGateProvider(settings) {
|
|
362269
362581
|
const configured = await settings.getString("gate.provider", "GATE_PROVIDER");
|
|
362270
362582
|
return configured?.trim().toLowerCase() === "openai" ? "openai" : DEFAULT_GATE_PROVIDER;
|
|
@@ -362272,10 +362584,11 @@ async function resolveGateProvider(settings) {
|
|
|
362272
362584
|
async function resolveGateModel(provider, instanceModel, settings) {
|
|
362273
362585
|
if (instanceModel)
|
|
362274
362586
|
return instanceModel;
|
|
362275
|
-
|
|
362276
|
-
|
|
362277
|
-
|
|
362278
|
-
|
|
362587
|
+
const configured = provider === "openai" ? await settings.getString("gate.openai.model", "GATE_OPENAI_MODEL") : await settings.getString("gate.gemini.model", "GATE_GEMINI_MODEL");
|
|
362588
|
+
if (configured)
|
|
362589
|
+
return configured;
|
|
362590
|
+
const discovered = await resolveGateModelFromCatalog(provider, settings);
|
|
362591
|
+
return discovered.model;
|
|
362279
362592
|
}
|
|
362280
362593
|
async function callGeminiGate(prompt, model, settings, signal2) {
|
|
362281
362594
|
const apiKey = await settings.getSecret("gemini.api_key", "GEMINI_API_KEY");
|