@ax-llm/ax 11.0.34 → 11.0.35
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/index.cjs +140 -81
- package/index.cjs.map +1 -1
- package/index.d.cts +33 -16
- package/index.d.ts +33 -16
- package/index.js +140 -81
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -884,8 +884,8 @@ var AxBaseAI = class {
|
|
|
884
884
|
this.modelInfo = modelInfo;
|
|
885
885
|
this.models = models;
|
|
886
886
|
this.id = crypto.randomUUID();
|
|
887
|
-
const model = this.
|
|
888
|
-
const embedModel = defaults.embedModel;
|
|
887
|
+
const model = this.getModel(defaults.model) ?? defaults.model;
|
|
888
|
+
const embedModel = this.getEmbedModel(defaults.embedModel);
|
|
889
889
|
this.defaults = { model, embedModel };
|
|
890
890
|
if (!defaults.model || typeof defaults.model !== "string" || defaults.model === "") {
|
|
891
891
|
throw new Error("No model defined");
|
|
@@ -951,18 +951,10 @@ var AxBaseAI = class {
|
|
|
951
951
|
this.headers = headers;
|
|
952
952
|
}
|
|
953
953
|
setOptions(options) {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
this.rt = options.rateLimiter;
|
|
959
|
-
}
|
|
960
|
-
if (options.fetch) {
|
|
961
|
-
this.fetch = options.fetch;
|
|
962
|
-
}
|
|
963
|
-
if (options.tracer) {
|
|
964
|
-
this.tracer = options.tracer;
|
|
965
|
-
}
|
|
954
|
+
this.debug = options.debug ?? false;
|
|
955
|
+
this.rt = options.rateLimiter;
|
|
956
|
+
this.fetch = options.fetch;
|
|
957
|
+
this.tracer = options.tracer;
|
|
966
958
|
}
|
|
967
959
|
getOptions() {
|
|
968
960
|
return {
|
|
@@ -973,11 +965,27 @@ var AxBaseAI = class {
|
|
|
973
965
|
};
|
|
974
966
|
}
|
|
975
967
|
getModelList() {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
968
|
+
const models = [];
|
|
969
|
+
for (const model of this.models ?? []) {
|
|
970
|
+
if (model.isInternal) {
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
if ("model" in model && model.model) {
|
|
974
|
+
models.push({
|
|
975
|
+
key: model.key,
|
|
976
|
+
description: model.description,
|
|
977
|
+
model: model.model
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
if ("embedModel" in model && model.embedModel) {
|
|
981
|
+
models.push({
|
|
982
|
+
key: model.key,
|
|
983
|
+
description: model.description,
|
|
984
|
+
embedModel: model.embedModel
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
return models;
|
|
981
989
|
}
|
|
982
990
|
getDefaultModels() {
|
|
983
991
|
return {
|
|
@@ -1038,7 +1046,7 @@ var AxBaseAI = class {
|
|
|
1038
1046
|
}
|
|
1039
1047
|
}
|
|
1040
1048
|
async _chat1(req, options) {
|
|
1041
|
-
const model =
|
|
1049
|
+
const model = this.getModel(req.model) ?? req.model ?? this.defaults.model;
|
|
1042
1050
|
const modelConfig = {
|
|
1043
1051
|
...this.aiImpl.getModelConfig(),
|
|
1044
1052
|
...req.modelConfig
|
|
@@ -1102,6 +1110,7 @@ var AxBaseAI = class {
|
|
|
1102
1110
|
if (!this.aiImpl.createChatReq) {
|
|
1103
1111
|
throw new Error("generateChatReq not implemented");
|
|
1104
1112
|
}
|
|
1113
|
+
const debug = options?.debug ?? this.debug;
|
|
1105
1114
|
let functions;
|
|
1106
1115
|
if (chatReq.functions && chatReq.functions.length > 0) {
|
|
1107
1116
|
functions = chatReq.functions.map((fn2) => this.cleanupFunctionSchema(fn2));
|
|
@@ -1123,7 +1132,7 @@ var AxBaseAI = class {
|
|
|
1123
1132
|
url: this.apiURL,
|
|
1124
1133
|
headers: await this.buildHeaders(apiConfig.headers),
|
|
1125
1134
|
stream: modelConfig.stream,
|
|
1126
|
-
debug
|
|
1135
|
+
debug,
|
|
1127
1136
|
fetch: this.fetch,
|
|
1128
1137
|
span
|
|
1129
1138
|
},
|
|
@@ -1131,7 +1140,7 @@ var AxBaseAI = class {
|
|
|
1131
1140
|
);
|
|
1132
1141
|
return res2;
|
|
1133
1142
|
};
|
|
1134
|
-
if (
|
|
1143
|
+
if (debug) {
|
|
1135
1144
|
logChatRequest(req.chatPrompt, options?.debugHideSystemPrompt);
|
|
1136
1145
|
}
|
|
1137
1146
|
const rt = options?.rateLimiter ?? this.rt;
|
|
@@ -1150,13 +1159,13 @@ var AxBaseAI = class {
|
|
|
1150
1159
|
if (span?.isRecording()) {
|
|
1151
1160
|
setResponseAttr(res2, span);
|
|
1152
1161
|
}
|
|
1153
|
-
if (
|
|
1162
|
+
if (debug) {
|
|
1154
1163
|
logResponse(res2);
|
|
1155
1164
|
}
|
|
1156
1165
|
return res2;
|
|
1157
1166
|
};
|
|
1158
1167
|
const doneCb = async (_values) => {
|
|
1159
|
-
if (
|
|
1168
|
+
if (debug) {
|
|
1160
1169
|
process.stdout.write("\n");
|
|
1161
1170
|
}
|
|
1162
1171
|
};
|
|
@@ -1179,7 +1188,7 @@ var AxBaseAI = class {
|
|
|
1179
1188
|
if (span?.isRecording()) {
|
|
1180
1189
|
setResponseAttr(res, span);
|
|
1181
1190
|
}
|
|
1182
|
-
if (
|
|
1191
|
+
if (debug) {
|
|
1183
1192
|
logResponse(res);
|
|
1184
1193
|
}
|
|
1185
1194
|
span?.end();
|
|
@@ -1200,7 +1209,7 @@ var AxBaseAI = class {
|
|
|
1200
1209
|
}
|
|
1201
1210
|
}
|
|
1202
1211
|
async _embed1(req, options) {
|
|
1203
|
-
const embedModel = req.embedModel ?? this.defaults.embedModel;
|
|
1212
|
+
const embedModel = this.getEmbedModel(req.embedModel) ?? req.embedModel ?? this.defaults.embedModel;
|
|
1204
1213
|
if (!embedModel) {
|
|
1205
1214
|
throw new Error("No embed model defined");
|
|
1206
1215
|
}
|
|
@@ -1232,6 +1241,7 @@ var AxBaseAI = class {
|
|
|
1232
1241
|
if (!this.aiImpl.createEmbedResp) {
|
|
1233
1242
|
throw new Error("generateEmbedResp not implemented");
|
|
1234
1243
|
}
|
|
1244
|
+
const debug = options?.debug ?? this.debug;
|
|
1235
1245
|
const req = {
|
|
1236
1246
|
...embedReq,
|
|
1237
1247
|
embedModel
|
|
@@ -1243,7 +1253,7 @@ var AxBaseAI = class {
|
|
|
1243
1253
|
name: apiConfig.name,
|
|
1244
1254
|
url: this.apiURL,
|
|
1245
1255
|
headers: await this.buildHeaders(apiConfig.headers),
|
|
1246
|
-
debug
|
|
1256
|
+
debug,
|
|
1247
1257
|
fetch: this.fetch,
|
|
1248
1258
|
span
|
|
1249
1259
|
},
|
|
@@ -1269,6 +1279,21 @@ var AxBaseAI = class {
|
|
|
1269
1279
|
async buildHeaders(headers = {}) {
|
|
1270
1280
|
return { ...headers, ...await this.headers() };
|
|
1271
1281
|
}
|
|
1282
|
+
getModelByKey(modelName) {
|
|
1283
|
+
if (!modelName) {
|
|
1284
|
+
return void 0;
|
|
1285
|
+
}
|
|
1286
|
+
const item = this.models?.find((v) => v.key === modelName);
|
|
1287
|
+
return item;
|
|
1288
|
+
}
|
|
1289
|
+
getModel(modelName) {
|
|
1290
|
+
const item = this.getModelByKey(modelName);
|
|
1291
|
+
return item && "model" in item ? item.model : void 0;
|
|
1292
|
+
}
|
|
1293
|
+
getEmbedModel(modelName) {
|
|
1294
|
+
const item = this.getModelByKey(modelName);
|
|
1295
|
+
return item && "embedModel" in item ? item.embedModel : void 0;
|
|
1296
|
+
}
|
|
1272
1297
|
};
|
|
1273
1298
|
function setResponseAttr(res, span) {
|
|
1274
1299
|
if (res.modelUsage) {
|
|
@@ -1795,10 +1820,12 @@ function mapFinishReason(stopReason) {
|
|
|
1795
1820
|
// ai/openai/types.ts
|
|
1796
1821
|
var AxAIOpenAIModel = /* @__PURE__ */ ((AxAIOpenAIModel2) => {
|
|
1797
1822
|
AxAIOpenAIModel2["O1"] = "o1";
|
|
1823
|
+
AxAIOpenAIModel2["O3"] = "o3";
|
|
1798
1824
|
AxAIOpenAIModel2["O1Mini"] = "o1-mini";
|
|
1799
1825
|
AxAIOpenAIModel2["O3Mini"] = "o3-mini";
|
|
1826
|
+
AxAIOpenAIModel2["O4Mini"] = "o4-mini";
|
|
1800
1827
|
AxAIOpenAIModel2["GPT4"] = "gpt-4";
|
|
1801
|
-
AxAIOpenAIModel2["
|
|
1828
|
+
AxAIOpenAIModel2["GPT41"] = "gpt-4.1";
|
|
1802
1829
|
AxAIOpenAIModel2["GPT4O"] = "gpt-4o";
|
|
1803
1830
|
AxAIOpenAIModel2["GPT4OMini"] = "gpt-4o-mini";
|
|
1804
1831
|
AxAIOpenAIModel2["GPT4ChatGPT4O"] = "chatgpt-4o-latest";
|
|
@@ -1819,12 +1846,6 @@ var AxAIOpenAIEmbedModel = /* @__PURE__ */ ((AxAIOpenAIEmbedModel2) => {
|
|
|
1819
1846
|
|
|
1820
1847
|
// ai/openai/info.ts
|
|
1821
1848
|
var axModelInfoOpenAI = [
|
|
1822
|
-
{
|
|
1823
|
-
name: "gpt-4.5-preview" /* GPT45 */,
|
|
1824
|
-
currency: "usd",
|
|
1825
|
-
promptTokenCostPer1M: 75,
|
|
1826
|
-
completionTokenCostPer1M: 150
|
|
1827
|
-
},
|
|
1828
1849
|
{
|
|
1829
1850
|
name: "o1" /* O1 */,
|
|
1830
1851
|
currency: "usd",
|
|
@@ -1843,12 +1864,24 @@ var axModelInfoOpenAI = [
|
|
|
1843
1864
|
promptTokenCostPer1M: 1.1,
|
|
1844
1865
|
completionTokenCostPer1M: 4.4
|
|
1845
1866
|
},
|
|
1867
|
+
{
|
|
1868
|
+
name: "o4-mini" /* O4Mini */,
|
|
1869
|
+
currency: "usd",
|
|
1870
|
+
promptTokenCostPer1M: 1.1,
|
|
1871
|
+
completionTokenCostPer1M: 4.4
|
|
1872
|
+
},
|
|
1846
1873
|
{
|
|
1847
1874
|
name: "gpt-4" /* GPT4 */,
|
|
1848
1875
|
currency: "usd",
|
|
1849
1876
|
promptTokenCostPer1M: 30,
|
|
1850
1877
|
completionTokenCostPer1M: 60
|
|
1851
1878
|
},
|
|
1879
|
+
{
|
|
1880
|
+
name: "gpt-4.1" /* GPT41 */,
|
|
1881
|
+
currency: "usd",
|
|
1882
|
+
promptTokenCostPer1M: 2,
|
|
1883
|
+
completionTokenCostPer1M: 8
|
|
1884
|
+
},
|
|
1852
1885
|
{
|
|
1853
1886
|
name: "gpt-4o" /* GPT4O */,
|
|
1854
1887
|
currency: "usd",
|
|
@@ -2653,8 +2686,8 @@ var AxAIDeepSeek = class extends AxAIOpenAIBase {
|
|
|
2653
2686
|
|
|
2654
2687
|
// ai/google-gemini/types.ts
|
|
2655
2688
|
var AxAIGoogleGeminiModel = /* @__PURE__ */ ((AxAIGoogleGeminiModel2) => {
|
|
2656
|
-
AxAIGoogleGeminiModel2["Gemini25Pro"] = "gemini-2.5-pro-
|
|
2657
|
-
AxAIGoogleGeminiModel2["
|
|
2689
|
+
AxAIGoogleGeminiModel2["Gemini25Pro"] = "gemini-2.5-pro-preview-03-25";
|
|
2690
|
+
AxAIGoogleGeminiModel2["Gemini25Flash"] = "gemini-2.5-flash-preview-04-17";
|
|
2658
2691
|
AxAIGoogleGeminiModel2["Gemini20Flash"] = "gemini-2.0-flash";
|
|
2659
2692
|
AxAIGoogleGeminiModel2["Gemini20FlashLite"] = "gemini-2.0-flash-lite-preview-02-05";
|
|
2660
2693
|
AxAIGoogleGeminiModel2["Gemini20FlashThinking"] = "gemini-2.0-flash-thinking-exp-01-21";
|
|
@@ -2702,11 +2735,18 @@ var AxAIGoogleGeminiEmbedTypes = /* @__PURE__ */ ((AxAIGoogleGeminiEmbedTypes2)
|
|
|
2702
2735
|
// ai/google-gemini/info.ts
|
|
2703
2736
|
var axModelInfoGoogleGemini = [
|
|
2704
2737
|
{
|
|
2705
|
-
name: "gemini-2.
|
|
2738
|
+
name: "gemini-2.5-pro-preview-03-25" /* Gemini25Pro */,
|
|
2706
2739
|
currency: "usd",
|
|
2707
2740
|
characterIsToken: false,
|
|
2708
|
-
promptTokenCostPer1M:
|
|
2709
|
-
completionTokenCostPer1M:
|
|
2741
|
+
promptTokenCostPer1M: 2.5,
|
|
2742
|
+
completionTokenCostPer1M: 15
|
|
2743
|
+
},
|
|
2744
|
+
{
|
|
2745
|
+
name: "gemini-2.5-flash-preview-04-17" /* Gemini25Flash */,
|
|
2746
|
+
currency: "usd",
|
|
2747
|
+
characterIsToken: false,
|
|
2748
|
+
promptTokenCostPer1M: 15,
|
|
2749
|
+
completionTokenCostPer1M: 3.5
|
|
2710
2750
|
},
|
|
2711
2751
|
{
|
|
2712
2752
|
name: "gemini-2.0-flash" /* Gemini20Flash */,
|
|
@@ -2960,7 +3000,10 @@ var AxAIGoogleGeminiImpl = class {
|
|
|
2960
3000
|
frequencyPenalty: req.modelConfig?.frequencyPenalty ?? this.config.frequencyPenalty,
|
|
2961
3001
|
candidateCount: 1,
|
|
2962
3002
|
stopSequences: req.modelConfig?.stopSequences ?? this.config.stopSequences,
|
|
2963
|
-
responseMimeType: "text/plain"
|
|
3003
|
+
responseMimeType: "text/plain",
|
|
3004
|
+
...this.config.thinkingConfig && {
|
|
3005
|
+
thinkingConfig: this.config.thinkingConfig
|
|
3006
|
+
}
|
|
2964
3007
|
};
|
|
2965
3008
|
const safetySettings2 = this.config.safetySettings;
|
|
2966
3009
|
const reqValue = {
|
|
@@ -6574,10 +6617,8 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
6574
6617
|
const maxRetries = options.maxRetries ?? this.options?.maxRetries ?? 10;
|
|
6575
6618
|
const maxSteps = options.maxSteps ?? this.options?.maxSteps ?? 10;
|
|
6576
6619
|
const debug = options.debug ?? ai.getOptions().debug;
|
|
6577
|
-
const
|
|
6578
|
-
|
|
6579
|
-
debugHideSystemPrompt: options.debugHideSystemPrompt
|
|
6580
|
-
};
|
|
6620
|
+
const debugHideSystemPrompt = options.debugHideSystemPrompt;
|
|
6621
|
+
const memOptions = { debug, debugHideSystemPrompt };
|
|
6581
6622
|
const mem = options.mem ?? this.options?.mem ?? new AxMemory(1e4, memOptions);
|
|
6582
6623
|
let err;
|
|
6583
6624
|
if (options?.functions && options.functions.length > 0) {
|
|
@@ -6655,7 +6696,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
6655
6696
|
return false;
|
|
6656
6697
|
}
|
|
6657
6698
|
async *_forward1(ai, values, options) {
|
|
6658
|
-
const tracer =
|
|
6699
|
+
const tracer = options?.tracer ?? this.options?.tracer;
|
|
6659
6700
|
let functions = this.functions;
|
|
6660
6701
|
if (options?.functions) {
|
|
6661
6702
|
functions = parseFunctions(options.functions, this.functions);
|
|
@@ -6691,9 +6732,7 @@ var AxGen = class extends AxProgramWithSignature {
|
|
|
6691
6732
|
}
|
|
6692
6733
|
}
|
|
6693
6734
|
async forward(ai, values, options) {
|
|
6694
|
-
const generator = this._forward1(ai, values, {
|
|
6695
|
-
...options
|
|
6696
|
-
});
|
|
6735
|
+
const generator = this._forward1(ai, values, options ?? {});
|
|
6697
6736
|
let buffer = {};
|
|
6698
6737
|
let currentVersion = 0;
|
|
6699
6738
|
for await (const item of generator) {
|
|
@@ -9357,7 +9396,7 @@ var AxMockAIService = class {
|
|
|
9357
9396
|
}
|
|
9358
9397
|
};
|
|
9359
9398
|
|
|
9360
|
-
// dsp/
|
|
9399
|
+
// dsp/classifier.ts
|
|
9361
9400
|
var colorLog6 = new ColorLog();
|
|
9362
9401
|
var AxSimpleClassifierClass = class {
|
|
9363
9402
|
name;
|
|
@@ -11166,6 +11205,7 @@ var AxMCPStdioTransport = class {
|
|
|
11166
11205
|
|
|
11167
11206
|
// ai/multiservice.ts
|
|
11168
11207
|
var AxMultiServiceRouter = class {
|
|
11208
|
+
options;
|
|
11169
11209
|
services = /* @__PURE__ */ new Map();
|
|
11170
11210
|
/**
|
|
11171
11211
|
* Constructs a new multi-service router.
|
|
@@ -11186,9 +11226,7 @@ var AxMultiServiceRouter = class {
|
|
|
11186
11226
|
this.services.set(item.key, {
|
|
11187
11227
|
service,
|
|
11188
11228
|
description,
|
|
11189
|
-
isInternal
|
|
11190
|
-
model: item.service.getDefaultModels().model,
|
|
11191
|
-
useDefaultModel: true
|
|
11229
|
+
isInternal
|
|
11192
11230
|
});
|
|
11193
11231
|
} else {
|
|
11194
11232
|
const modelList = item.getModelList();
|
|
@@ -11197,18 +11235,31 @@ var AxMultiServiceRouter = class {
|
|
|
11197
11235
|
`Service ${index} \`${item.getName()}\` has no model list.`
|
|
11198
11236
|
);
|
|
11199
11237
|
}
|
|
11200
|
-
for (const
|
|
11201
|
-
if (this.services.has(key)) {
|
|
11202
|
-
const otherService = this.services.get(key)?.service;
|
|
11238
|
+
for (const v of modelList) {
|
|
11239
|
+
if (this.services.has(v.key)) {
|
|
11240
|
+
const otherService = this.services.get(v.key)?.service;
|
|
11203
11241
|
throw new Error(
|
|
11204
|
-
`Service ${index} \`${item.getName()}\` has duplicate model key: ${key} as service ${otherService?.getName()}`
|
|
11242
|
+
`Service ${index} \`${item.getName()}\` has duplicate model key: ${v.key} as service ${otherService?.getName()}`
|
|
11205
11243
|
);
|
|
11244
|
+
} else {
|
|
11245
|
+
if ("model" in v && typeof v.model) {
|
|
11246
|
+
this.services.set(v.key, {
|
|
11247
|
+
description: v.description,
|
|
11248
|
+
service: item,
|
|
11249
|
+
model: v.model
|
|
11250
|
+
});
|
|
11251
|
+
} else if ("embedModel" in v && v.embedModel) {
|
|
11252
|
+
this.services.set(v.key, {
|
|
11253
|
+
description: v.description,
|
|
11254
|
+
service: item,
|
|
11255
|
+
embedModel: v.embedModel
|
|
11256
|
+
});
|
|
11257
|
+
} else {
|
|
11258
|
+
throw new Error(
|
|
11259
|
+
`Key ${v.key} in model list for service ${index} \`${item.getName()}\` is missing a model or embedModel property.`
|
|
11260
|
+
);
|
|
11261
|
+
}
|
|
11206
11262
|
}
|
|
11207
|
-
this.services.set(key, {
|
|
11208
|
-
description,
|
|
11209
|
-
service: item,
|
|
11210
|
-
model
|
|
11211
|
-
});
|
|
11212
11263
|
}
|
|
11213
11264
|
}
|
|
11214
11265
|
}
|
|
@@ -11225,25 +11276,32 @@ var AxMultiServiceRouter = class {
|
|
|
11225
11276
|
if (!item) {
|
|
11226
11277
|
throw new Error(`No service found for model key: ${modelKey}`);
|
|
11227
11278
|
}
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11279
|
+
if (!item.model) {
|
|
11280
|
+
const { model, ...reqWithoutModel } = req;
|
|
11281
|
+
return await item.service.chat(reqWithoutModel, options);
|
|
11282
|
+
}
|
|
11283
|
+
return await item.service.chat({ model: modelKey, ...req }, options);
|
|
11231
11284
|
}
|
|
11232
11285
|
/**
|
|
11233
11286
|
* Delegates the embed call to the service matching the provided embed model key.
|
|
11234
11287
|
*/
|
|
11235
11288
|
async embed(req, options) {
|
|
11236
|
-
const
|
|
11237
|
-
if (!
|
|
11289
|
+
const embedModelKey = req.embedModel;
|
|
11290
|
+
if (!embedModelKey) {
|
|
11238
11291
|
throw new Error("Embed model key must be specified for multi-service");
|
|
11239
11292
|
}
|
|
11240
|
-
const item = this.services.get(
|
|
11293
|
+
const item = this.services.get(embedModelKey);
|
|
11241
11294
|
if (!item) {
|
|
11242
|
-
throw new Error(`No service found for embed model key: ${
|
|
11295
|
+
throw new Error(`No service found for embed model key: ${embedModelKey}`);
|
|
11296
|
+
}
|
|
11297
|
+
if (!item.model) {
|
|
11298
|
+
const { embedModel, ...reqWithoutEmbedModel } = req;
|
|
11299
|
+
return await item.service.embed(reqWithoutEmbedModel, options);
|
|
11243
11300
|
}
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11301
|
+
return await item.service.embed(
|
|
11302
|
+
{ embedModel: embedModelKey, ...req },
|
|
11303
|
+
options
|
|
11304
|
+
);
|
|
11247
11305
|
}
|
|
11248
11306
|
/**
|
|
11249
11307
|
* Returns a composite ID built from the IDs of the underlying services.
|
|
@@ -11261,11 +11319,15 @@ var AxMultiServiceRouter = class {
|
|
|
11261
11319
|
* Aggregates all available models across the underlying services.
|
|
11262
11320
|
*/
|
|
11263
11321
|
getModelList() {
|
|
11264
|
-
return Array.from(this.services).filter(([, value]) => !value.isInternal).map(([key,
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11322
|
+
return Array.from(this.services).filter(([, value]) => !value.isInternal).map(([key, v]) => {
|
|
11323
|
+
if (v.model) {
|
|
11324
|
+
return { key, description: v.description, model: v.model };
|
|
11325
|
+
} else if (v.embedModel) {
|
|
11326
|
+
return { key, description: v.description, embedModel: v.embedModel };
|
|
11327
|
+
} else {
|
|
11328
|
+
throw new Error(`Service ${key} has no model or embedModel`);
|
|
11329
|
+
}
|
|
11330
|
+
});
|
|
11269
11331
|
}
|
|
11270
11332
|
getDefaultModels() {
|
|
11271
11333
|
throw new Error(
|
|
@@ -11304,17 +11366,14 @@ var AxMultiServiceRouter = class {
|
|
|
11304
11366
|
for (const service of this.services.values()) {
|
|
11305
11367
|
service.service.setOptions(options);
|
|
11306
11368
|
}
|
|
11369
|
+
this.options = options;
|
|
11307
11370
|
}
|
|
11308
11371
|
/**
|
|
11309
11372
|
* Returns the options from the last used service,
|
|
11310
11373
|
* or falls back to the first service if none has been used.
|
|
11311
11374
|
*/
|
|
11312
11375
|
getOptions() {
|
|
11313
|
-
|
|
11314
|
-
if (!service) {
|
|
11315
|
-
throw new Error("No service available to get options.");
|
|
11316
|
-
}
|
|
11317
|
-
return service.service.getOptions();
|
|
11376
|
+
return this.options ?? {};
|
|
11318
11377
|
}
|
|
11319
11378
|
};
|
|
11320
11379
|
|