@elizaos/core 0.1.7 → 0.1.8
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.d.ts +436 -79
- package/dist/index.js +1954 -576
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -62,11 +62,12 @@ var composeContext = ({
|
|
|
62
62
|
template,
|
|
63
63
|
templatingEngine
|
|
64
64
|
}) => {
|
|
65
|
+
const templateStr = typeof template === "function" ? template({ state }) : template;
|
|
65
66
|
if (templatingEngine === "handlebars") {
|
|
66
|
-
const templateFunction = handlebars.compile(
|
|
67
|
+
const templateFunction = handlebars.compile(templateStr);
|
|
67
68
|
return templateFunction(state);
|
|
68
69
|
}
|
|
69
|
-
const out =
|
|
70
|
+
const out = templateStr.replace(/{{\w+}}/g, (match) => {
|
|
70
71
|
const key = match.replace(/{{|}}/g, "");
|
|
71
72
|
return state[key] ?? "";
|
|
72
73
|
});
|
|
@@ -443,6 +444,7 @@ var ModelProviderName = /* @__PURE__ */ ((ModelProviderName2) => {
|
|
|
443
444
|
ModelProviderName2["TOGETHER"] = "together";
|
|
444
445
|
ModelProviderName2["LLAMALOCAL"] = "llama_local";
|
|
445
446
|
ModelProviderName2["GOOGLE"] = "google";
|
|
447
|
+
ModelProviderName2["MISTRAL"] = "mistral";
|
|
446
448
|
ModelProviderName2["CLAUDE_VERTEX"] = "claude_vertex";
|
|
447
449
|
ModelProviderName2["REDPILL"] = "redpill";
|
|
448
450
|
ModelProviderName2["OPENROUTER"] = "openrouter";
|
|
@@ -456,8 +458,12 @@ var ModelProviderName = /* @__PURE__ */ ((ModelProviderName2) => {
|
|
|
456
458
|
ModelProviderName2["NANOGPT"] = "nanogpt";
|
|
457
459
|
ModelProviderName2["HYPERBOLIC"] = "hyperbolic";
|
|
458
460
|
ModelProviderName2["VENICE"] = "venice";
|
|
461
|
+
ModelProviderName2["NINETEEN_AI"] = "nineteen_ai";
|
|
459
462
|
ModelProviderName2["AKASH_CHAT_API"] = "akash_chat_api";
|
|
460
463
|
ModelProviderName2["LIVEPEER"] = "livepeer";
|
|
464
|
+
ModelProviderName2["LETZAI"] = "letzai";
|
|
465
|
+
ModelProviderName2["DEEPSEEK"] = "deepseek";
|
|
466
|
+
ModelProviderName2["INFERA"] = "infera";
|
|
461
467
|
return ModelProviderName2;
|
|
462
468
|
})(ModelProviderName || {});
|
|
463
469
|
var Clients = /* @__PURE__ */ ((Clients2) => {
|
|
@@ -469,6 +475,7 @@ var Clients = /* @__PURE__ */ ((Clients2) => {
|
|
|
469
475
|
Clients2["LENS"] = "lens";
|
|
470
476
|
Clients2["AUTO"] = "auto";
|
|
471
477
|
Clients2["SLACK"] = "slack";
|
|
478
|
+
Clients2["GITHUB"] = "github";
|
|
472
479
|
return Clients2;
|
|
473
480
|
})(Clients || {});
|
|
474
481
|
var CacheStore = /* @__PURE__ */ ((CacheStore2) => {
|
|
@@ -492,6 +499,18 @@ var Service = class _Service {
|
|
|
492
499
|
return this.constructor.serviceType;
|
|
493
500
|
}
|
|
494
501
|
};
|
|
502
|
+
var IrysMessageType = /* @__PURE__ */ ((IrysMessageType2) => {
|
|
503
|
+
IrysMessageType2["REQUEST"] = "REQUEST";
|
|
504
|
+
IrysMessageType2["DATA_STORAGE"] = "DATA_STORAGE";
|
|
505
|
+
IrysMessageType2["REQUEST_RESPONSE"] = "REQUEST_RESPONSE";
|
|
506
|
+
return IrysMessageType2;
|
|
507
|
+
})(IrysMessageType || {});
|
|
508
|
+
var IrysDataType = /* @__PURE__ */ ((IrysDataType2) => {
|
|
509
|
+
IrysDataType2["FILE"] = "FILE";
|
|
510
|
+
IrysDataType2["IMAGE"] = "IMAGE";
|
|
511
|
+
IrysDataType2["OTHER"] = "OTHER";
|
|
512
|
+
return IrysDataType2;
|
|
513
|
+
})(IrysDataType || {});
|
|
495
514
|
var ServiceType = /* @__PURE__ */ ((ServiceType3) => {
|
|
496
515
|
ServiceType3["IMAGE_DESCRIPTION"] = "image_description";
|
|
497
516
|
ServiceType3["TRANSCRIPTION"] = "transcription";
|
|
@@ -504,6 +523,9 @@ var ServiceType = /* @__PURE__ */ ((ServiceType3) => {
|
|
|
504
523
|
ServiceType3["AWS_S3"] = "aws_s3";
|
|
505
524
|
ServiceType3["BUTTPLUG"] = "buttplug";
|
|
506
525
|
ServiceType3["SLACK"] = "slack";
|
|
526
|
+
ServiceType3["IRYS"] = "irys";
|
|
527
|
+
ServiceType3["TEE_LOG"] = "tee_log";
|
|
528
|
+
ServiceType3["GOPLUS_SECURITY"] = "goplus_security";
|
|
507
529
|
return ServiceType3;
|
|
508
530
|
})(ServiceType || {});
|
|
509
531
|
var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
@@ -512,6 +534,12 @@ var LoggingLevel = /* @__PURE__ */ ((LoggingLevel2) => {
|
|
|
512
534
|
LoggingLevel2["NONE"] = "none";
|
|
513
535
|
return LoggingLevel2;
|
|
514
536
|
})(LoggingLevel || {});
|
|
537
|
+
var VerifiableInferenceProvider = /* @__PURE__ */ ((VerifiableInferenceProvider2) => {
|
|
538
|
+
VerifiableInferenceProvider2["RECLAIM"] = "reclaim";
|
|
539
|
+
VerifiableInferenceProvider2["OPACITY"] = "opacity";
|
|
540
|
+
VerifiableInferenceProvider2["PRIMUS"] = "primus";
|
|
541
|
+
return VerifiableInferenceProvider2;
|
|
542
|
+
})(VerifiableInferenceProvider || {});
|
|
515
543
|
var TokenizerType = /* @__PURE__ */ ((TokenizerType2) => {
|
|
516
544
|
TokenizerType2["Auto"] = "auto";
|
|
517
545
|
TokenizerType2["TikToken"] = "tiktoken";
|
|
@@ -523,6 +551,11 @@ var TranscriptionProvider = /* @__PURE__ */ ((TranscriptionProvider2) => {
|
|
|
523
551
|
TranscriptionProvider2["Local"] = "local";
|
|
524
552
|
return TranscriptionProvider2;
|
|
525
553
|
})(TranscriptionProvider || {});
|
|
554
|
+
var ActionTimelineType = /* @__PURE__ */ ((ActionTimelineType2) => {
|
|
555
|
+
ActionTimelineType2["ForYou"] = "foryou";
|
|
556
|
+
ActionTimelineType2["Following"] = "following";
|
|
557
|
+
return ActionTimelineType2;
|
|
558
|
+
})(ActionTimelineType || {});
|
|
526
559
|
|
|
527
560
|
// src/defaultCharacter.ts
|
|
528
561
|
var defaultCharacter = {
|
|
@@ -1051,12 +1084,10 @@ var defaultCharacter = {
|
|
|
1051
1084
|
"unorthodox",
|
|
1052
1085
|
"meticulous",
|
|
1053
1086
|
"provocative"
|
|
1054
|
-
]
|
|
1087
|
+
],
|
|
1088
|
+
extends: []
|
|
1055
1089
|
};
|
|
1056
1090
|
|
|
1057
|
-
// src/embedding.ts
|
|
1058
|
-
import path3 from "node:path";
|
|
1059
|
-
|
|
1060
1091
|
// src/settings.ts
|
|
1061
1092
|
import { config } from "dotenv";
|
|
1062
1093
|
import fs from "fs";
|
|
@@ -1145,443 +1176,1038 @@ function parseNamespacedSettings(env) {
|
|
|
1145
1176
|
var models = {
|
|
1146
1177
|
["openai" /* OPENAI */]: {
|
|
1147
1178
|
endpoint: settings_default.OPENAI_API_URL || "https://api.openai.com/v1",
|
|
1148
|
-
settings: {
|
|
1149
|
-
stop: [],
|
|
1150
|
-
maxInputTokens: 128e3,
|
|
1151
|
-
maxOutputTokens: 8192,
|
|
1152
|
-
frequency_penalty: 0,
|
|
1153
|
-
presence_penalty: 0,
|
|
1154
|
-
temperature: 0.6
|
|
1155
|
-
},
|
|
1156
1179
|
model: {
|
|
1157
|
-
["small" /* SMALL */]:
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1180
|
+
["small" /* SMALL */]: {
|
|
1181
|
+
name: settings_default.SMALL_OPENAI_MODEL || "gpt-4o-mini",
|
|
1182
|
+
stop: [],
|
|
1183
|
+
maxInputTokens: 128e3,
|
|
1184
|
+
maxOutputTokens: 8192,
|
|
1185
|
+
frequency_penalty: 0,
|
|
1186
|
+
presence_penalty: 0,
|
|
1187
|
+
temperature: 0.6
|
|
1188
|
+
},
|
|
1189
|
+
["medium" /* MEDIUM */]: {
|
|
1190
|
+
name: settings_default.MEDIUM_OPENAI_MODEL || "gpt-4o",
|
|
1191
|
+
stop: [],
|
|
1192
|
+
maxInputTokens: 128e3,
|
|
1193
|
+
maxOutputTokens: 8192,
|
|
1194
|
+
frequency_penalty: 0,
|
|
1195
|
+
presence_penalty: 0,
|
|
1196
|
+
temperature: 0.6
|
|
1197
|
+
},
|
|
1198
|
+
["large" /* LARGE */]: {
|
|
1199
|
+
name: settings_default.LARGE_OPENAI_MODEL || "gpt-4o",
|
|
1200
|
+
stop: [],
|
|
1201
|
+
maxInputTokens: 128e3,
|
|
1202
|
+
maxOutputTokens: 8192,
|
|
1203
|
+
frequency_penalty: 0,
|
|
1204
|
+
presence_penalty: 0,
|
|
1205
|
+
temperature: 0.6
|
|
1206
|
+
},
|
|
1207
|
+
["embedding" /* EMBEDDING */]: {
|
|
1208
|
+
name: settings_default.EMBEDDING_OPENAI_MODEL || "text-embedding-3-small",
|
|
1209
|
+
dimensions: 1536
|
|
1210
|
+
},
|
|
1211
|
+
["image" /* IMAGE */]: {
|
|
1212
|
+
name: settings_default.IMAGE_OPENAI_MODEL || "dall-e-3"
|
|
1213
|
+
}
|
|
1162
1214
|
}
|
|
1163
1215
|
},
|
|
1164
1216
|
["eternalai" /* ETERNALAI */]: {
|
|
1165
1217
|
endpoint: settings_default.ETERNALAI_URL,
|
|
1166
|
-
settings: {
|
|
1167
|
-
stop: [],
|
|
1168
|
-
maxInputTokens: 128e3,
|
|
1169
|
-
maxOutputTokens: 8192,
|
|
1170
|
-
frequency_penalty: 0,
|
|
1171
|
-
presence_penalty: 0,
|
|
1172
|
-
temperature: 0.6
|
|
1173
|
-
},
|
|
1174
1218
|
model: {
|
|
1175
|
-
["small" /* SMALL */]:
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1219
|
+
["small" /* SMALL */]: {
|
|
1220
|
+
name: settings_default.ETERNALAI_MODEL || "neuralmagic/Meta-Llama-3.1-405B-Instruct-quantized.w4a16",
|
|
1221
|
+
stop: [],
|
|
1222
|
+
maxInputTokens: 128e3,
|
|
1223
|
+
maxOutputTokens: 8192,
|
|
1224
|
+
frequency_penalty: 0,
|
|
1225
|
+
presence_penalty: 0,
|
|
1226
|
+
temperature: 0.6
|
|
1227
|
+
},
|
|
1228
|
+
["medium" /* MEDIUM */]: {
|
|
1229
|
+
name: settings_default.ETERNALAI_MODEL || "neuralmagic/Meta-Llama-3.1-405B-Instruct-quantized.w4a16",
|
|
1230
|
+
stop: [],
|
|
1231
|
+
maxInputTokens: 128e3,
|
|
1232
|
+
maxOutputTokens: 8192,
|
|
1233
|
+
frequency_penalty: 0,
|
|
1234
|
+
presence_penalty: 0,
|
|
1235
|
+
temperature: 0.6
|
|
1236
|
+
},
|
|
1237
|
+
["large" /* LARGE */]: {
|
|
1238
|
+
name: settings_default.ETERNALAI_MODEL || "neuralmagic/Meta-Llama-3.1-405B-Instruct-quantized.w4a16",
|
|
1239
|
+
stop: [],
|
|
1240
|
+
maxInputTokens: 128e3,
|
|
1241
|
+
maxOutputTokens: 8192,
|
|
1242
|
+
frequency_penalty: 0,
|
|
1243
|
+
presence_penalty: 0,
|
|
1244
|
+
temperature: 0.6
|
|
1245
|
+
}
|
|
1180
1246
|
}
|
|
1181
1247
|
},
|
|
1182
1248
|
["anthropic" /* ANTHROPIC */]: {
|
|
1183
|
-
settings: {
|
|
1184
|
-
stop: [],
|
|
1185
|
-
maxInputTokens: 2e5,
|
|
1186
|
-
maxOutputTokens: 4096,
|
|
1187
|
-
frequency_penalty: 0.4,
|
|
1188
|
-
presence_penalty: 0.4,
|
|
1189
|
-
temperature: 0.7
|
|
1190
|
-
},
|
|
1191
1249
|
endpoint: "https://api.anthropic.com/v1",
|
|
1192
1250
|
model: {
|
|
1193
|
-
["small" /* SMALL */]:
|
|
1194
|
-
|
|
1195
|
-
|
|
1251
|
+
["small" /* SMALL */]: {
|
|
1252
|
+
name: settings_default.SMALL_ANTHROPIC_MODEL || "claude-3-haiku-20240307",
|
|
1253
|
+
stop: [],
|
|
1254
|
+
maxInputTokens: 2e5,
|
|
1255
|
+
maxOutputTokens: 4096,
|
|
1256
|
+
frequency_penalty: 0.4,
|
|
1257
|
+
presence_penalty: 0.4,
|
|
1258
|
+
temperature: 0.7
|
|
1259
|
+
},
|
|
1260
|
+
["medium" /* MEDIUM */]: {
|
|
1261
|
+
name: settings_default.MEDIUM_ANTHROPIC_MODEL || "claude-3-5-sonnet-20241022",
|
|
1262
|
+
stop: [],
|
|
1263
|
+
maxInputTokens: 2e5,
|
|
1264
|
+
maxOutputTokens: 4096,
|
|
1265
|
+
frequency_penalty: 0.4,
|
|
1266
|
+
presence_penalty: 0.4,
|
|
1267
|
+
temperature: 0.7
|
|
1268
|
+
},
|
|
1269
|
+
["large" /* LARGE */]: {
|
|
1270
|
+
name: settings_default.LARGE_ANTHROPIC_MODEL || "claude-3-5-sonnet-20241022",
|
|
1271
|
+
stop: [],
|
|
1272
|
+
maxInputTokens: 2e5,
|
|
1273
|
+
maxOutputTokens: 4096,
|
|
1274
|
+
frequency_penalty: 0.4,
|
|
1275
|
+
presence_penalty: 0.4,
|
|
1276
|
+
temperature: 0.7
|
|
1277
|
+
}
|
|
1196
1278
|
}
|
|
1197
1279
|
},
|
|
1198
1280
|
["claude_vertex" /* CLAUDE_VERTEX */]: {
|
|
1199
|
-
settings: {
|
|
1200
|
-
stop: [],
|
|
1201
|
-
maxInputTokens: 2e5,
|
|
1202
|
-
maxOutputTokens: 8192,
|
|
1203
|
-
frequency_penalty: 0.4,
|
|
1204
|
-
presence_penalty: 0.4,
|
|
1205
|
-
temperature: 0.7
|
|
1206
|
-
},
|
|
1207
1281
|
endpoint: "https://api.anthropic.com/v1",
|
|
1208
1282
|
// TODO: check
|
|
1209
1283
|
model: {
|
|
1210
|
-
["small" /* SMALL */]:
|
|
1211
|
-
|
|
1212
|
-
|
|
1284
|
+
["small" /* SMALL */]: {
|
|
1285
|
+
name: "claude-3-5-sonnet-20241022",
|
|
1286
|
+
stop: [],
|
|
1287
|
+
maxInputTokens: 2e5,
|
|
1288
|
+
maxOutputTokens: 8192,
|
|
1289
|
+
frequency_penalty: 0.4,
|
|
1290
|
+
presence_penalty: 0.4,
|
|
1291
|
+
temperature: 0.7
|
|
1292
|
+
},
|
|
1293
|
+
["medium" /* MEDIUM */]: {
|
|
1294
|
+
name: "claude-3-5-sonnet-20241022",
|
|
1295
|
+
stop: [],
|
|
1296
|
+
maxInputTokens: 2e5,
|
|
1297
|
+
maxOutputTokens: 8192,
|
|
1298
|
+
frequency_penalty: 0.4,
|
|
1299
|
+
presence_penalty: 0.4,
|
|
1300
|
+
temperature: 0.7
|
|
1301
|
+
},
|
|
1302
|
+
["large" /* LARGE */]: {
|
|
1303
|
+
name: "claude-3-opus-20240229",
|
|
1304
|
+
stop: [],
|
|
1305
|
+
maxInputTokens: 2e5,
|
|
1306
|
+
maxOutputTokens: 8192,
|
|
1307
|
+
frequency_penalty: 0.4,
|
|
1308
|
+
presence_penalty: 0.4,
|
|
1309
|
+
temperature: 0.7
|
|
1310
|
+
}
|
|
1213
1311
|
}
|
|
1214
1312
|
},
|
|
1215
1313
|
["grok" /* GROK */]: {
|
|
1216
|
-
settings: {
|
|
1217
|
-
stop: [],
|
|
1218
|
-
maxInputTokens: 128e3,
|
|
1219
|
-
maxOutputTokens: 8192,
|
|
1220
|
-
frequency_penalty: 0.4,
|
|
1221
|
-
presence_penalty: 0.4,
|
|
1222
|
-
temperature: 0.7
|
|
1223
|
-
},
|
|
1224
1314
|
endpoint: "https://api.x.ai/v1",
|
|
1225
1315
|
model: {
|
|
1226
|
-
["small" /* SMALL */]:
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1316
|
+
["small" /* SMALL */]: {
|
|
1317
|
+
name: settings_default.SMALL_GROK_MODEL || "grok-2-1212",
|
|
1318
|
+
stop: [],
|
|
1319
|
+
maxInputTokens: 128e3,
|
|
1320
|
+
maxOutputTokens: 8192,
|
|
1321
|
+
frequency_penalty: 0.4,
|
|
1322
|
+
presence_penalty: 0.4,
|
|
1323
|
+
temperature: 0.7
|
|
1324
|
+
},
|
|
1325
|
+
["medium" /* MEDIUM */]: {
|
|
1326
|
+
name: settings_default.MEDIUM_GROK_MODEL || "grok-2-1212",
|
|
1327
|
+
stop: [],
|
|
1328
|
+
maxInputTokens: 128e3,
|
|
1329
|
+
maxOutputTokens: 8192,
|
|
1330
|
+
frequency_penalty: 0.4,
|
|
1331
|
+
presence_penalty: 0.4,
|
|
1332
|
+
temperature: 0.7
|
|
1333
|
+
},
|
|
1334
|
+
["large" /* LARGE */]: {
|
|
1335
|
+
name: settings_default.LARGE_GROK_MODEL || "grok-2-1212",
|
|
1336
|
+
stop: [],
|
|
1337
|
+
maxInputTokens: 128e3,
|
|
1338
|
+
maxOutputTokens: 8192,
|
|
1339
|
+
frequency_penalty: 0.4,
|
|
1340
|
+
presence_penalty: 0.4,
|
|
1341
|
+
temperature: 0.7
|
|
1342
|
+
},
|
|
1343
|
+
["embedding" /* EMBEDDING */]: {
|
|
1344
|
+
name: settings_default.EMBEDDING_GROK_MODEL || "grok-2-1212"
|
|
1345
|
+
// not sure about this one
|
|
1346
|
+
}
|
|
1231
1347
|
}
|
|
1232
1348
|
},
|
|
1233
1349
|
["groq" /* GROQ */]: {
|
|
1234
1350
|
endpoint: "https://api.groq.com/openai/v1",
|
|
1235
|
-
settings: {
|
|
1236
|
-
stop: [],
|
|
1237
|
-
maxInputTokens: 128e3,
|
|
1238
|
-
maxOutputTokens: 8e3,
|
|
1239
|
-
frequency_penalty: 0.4,
|
|
1240
|
-
presence_penalty: 0.4,
|
|
1241
|
-
temperature: 0.7
|
|
1242
|
-
},
|
|
1243
1351
|
model: {
|
|
1244
|
-
["small" /* SMALL */]:
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1352
|
+
["small" /* SMALL */]: {
|
|
1353
|
+
name: settings_default.SMALL_GROQ_MODEL || "llama-3.1-8b-instant",
|
|
1354
|
+
stop: [],
|
|
1355
|
+
maxInputTokens: 128e3,
|
|
1356
|
+
maxOutputTokens: 8e3,
|
|
1357
|
+
frequency_penalty: 0.4,
|
|
1358
|
+
presence_penalty: 0.4,
|
|
1359
|
+
temperature: 0.7
|
|
1360
|
+
},
|
|
1361
|
+
["medium" /* MEDIUM */]: {
|
|
1362
|
+
name: settings_default.MEDIUM_GROQ_MODEL || "llama-3.3-70b-versatile",
|
|
1363
|
+
stop: [],
|
|
1364
|
+
maxInputTokens: 128e3,
|
|
1365
|
+
maxOutputTokens: 8e3,
|
|
1366
|
+
frequency_penalty: 0.4,
|
|
1367
|
+
presence_penalty: 0.4,
|
|
1368
|
+
temperature: 0.7
|
|
1369
|
+
},
|
|
1370
|
+
["large" /* LARGE */]: {
|
|
1371
|
+
name: settings_default.LARGE_GROQ_MODEL || "llama-3.2-90b-vision-preview",
|
|
1372
|
+
stop: [],
|
|
1373
|
+
maxInputTokens: 128e3,
|
|
1374
|
+
maxOutputTokens: 8e3,
|
|
1375
|
+
frequency_penalty: 0.4,
|
|
1376
|
+
presence_penalty: 0.4,
|
|
1377
|
+
temperature: 0.7
|
|
1378
|
+
},
|
|
1379
|
+
["embedding" /* EMBEDDING */]: {
|
|
1380
|
+
name: settings_default.EMBEDDING_GROQ_MODEL || "llama-3.1-8b-instant"
|
|
1381
|
+
}
|
|
1248
1382
|
}
|
|
1249
1383
|
},
|
|
1250
1384
|
["llama_cloud" /* LLAMACLOUD */]: {
|
|
1251
|
-
settings: {
|
|
1252
|
-
stop: [],
|
|
1253
|
-
maxInputTokens: 128e3,
|
|
1254
|
-
maxOutputTokens: 8192,
|
|
1255
|
-
repetition_penalty: 0.4,
|
|
1256
|
-
temperature: 0.7
|
|
1257
|
-
},
|
|
1258
|
-
imageSettings: {
|
|
1259
|
-
steps: 4
|
|
1260
|
-
},
|
|
1261
1385
|
endpoint: "https://api.llamacloud.com/v1",
|
|
1262
1386
|
model: {
|
|
1263
|
-
["small" /* SMALL */]:
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1387
|
+
["small" /* SMALL */]: {
|
|
1388
|
+
name: "meta-llama/Llama-3.2-3B-Instruct-Turbo",
|
|
1389
|
+
stop: [],
|
|
1390
|
+
maxInputTokens: 128e3,
|
|
1391
|
+
maxOutputTokens: 8192,
|
|
1392
|
+
repetition_penalty: 0.4,
|
|
1393
|
+
temperature: 0.7
|
|
1394
|
+
},
|
|
1395
|
+
["medium" /* MEDIUM */]: {
|
|
1396
|
+
name: "meta-llama-3.1-8b-instruct",
|
|
1397
|
+
stop: [],
|
|
1398
|
+
maxInputTokens: 128e3,
|
|
1399
|
+
maxOutputTokens: 8192,
|
|
1400
|
+
repetition_penalty: 0.4,
|
|
1401
|
+
temperature: 0.7
|
|
1402
|
+
},
|
|
1403
|
+
["large" /* LARGE */]: {
|
|
1404
|
+
name: "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
|
|
1405
|
+
stop: [],
|
|
1406
|
+
maxInputTokens: 128e3,
|
|
1407
|
+
maxOutputTokens: 8192,
|
|
1408
|
+
repetition_penalty: 0.4,
|
|
1409
|
+
temperature: 0.7
|
|
1410
|
+
},
|
|
1411
|
+
["embedding" /* EMBEDDING */]: {
|
|
1412
|
+
name: "togethercomputer/m2-bert-80M-32k-retrieval"
|
|
1413
|
+
},
|
|
1414
|
+
["image" /* IMAGE */]: {
|
|
1415
|
+
name: "black-forest-labs/FLUX.1-schnell",
|
|
1416
|
+
steps: 4
|
|
1417
|
+
}
|
|
1268
1418
|
}
|
|
1269
1419
|
},
|
|
1270
1420
|
["together" /* TOGETHER */]: {
|
|
1271
|
-
settings: {
|
|
1272
|
-
stop: [],
|
|
1273
|
-
maxInputTokens: 128e3,
|
|
1274
|
-
maxOutputTokens: 8192,
|
|
1275
|
-
repetition_penalty: 0.4,
|
|
1276
|
-
temperature: 0.7
|
|
1277
|
-
},
|
|
1278
|
-
imageSettings: {
|
|
1279
|
-
steps: 4
|
|
1280
|
-
},
|
|
1281
1421
|
endpoint: "https://api.together.ai/v1",
|
|
1282
1422
|
model: {
|
|
1283
|
-
["small" /* SMALL */]:
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1423
|
+
["small" /* SMALL */]: {
|
|
1424
|
+
name: "meta-llama/Llama-3.2-3B-Instruct-Turbo",
|
|
1425
|
+
stop: [],
|
|
1426
|
+
maxInputTokens: 128e3,
|
|
1427
|
+
maxOutputTokens: 8192,
|
|
1428
|
+
repetition_penalty: 0.4,
|
|
1429
|
+
temperature: 0.7
|
|
1430
|
+
},
|
|
1431
|
+
["medium" /* MEDIUM */]: {
|
|
1432
|
+
name: "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo-128K",
|
|
1433
|
+
stop: [],
|
|
1434
|
+
maxInputTokens: 128e3,
|
|
1435
|
+
maxOutputTokens: 8192,
|
|
1436
|
+
repetition_penalty: 0.4,
|
|
1437
|
+
temperature: 0.7
|
|
1438
|
+
},
|
|
1439
|
+
["large" /* LARGE */]: {
|
|
1440
|
+
name: "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
|
|
1441
|
+
stop: [],
|
|
1442
|
+
maxInputTokens: 128e3,
|
|
1443
|
+
maxOutputTokens: 8192,
|
|
1444
|
+
repetition_penalty: 0.4,
|
|
1445
|
+
temperature: 0.7
|
|
1446
|
+
},
|
|
1447
|
+
["embedding" /* EMBEDDING */]: {
|
|
1448
|
+
name: "togethercomputer/m2-bert-80M-32k-retrieval"
|
|
1449
|
+
},
|
|
1450
|
+
["image" /* IMAGE */]: {
|
|
1451
|
+
name: "black-forest-labs/FLUX.1-schnell",
|
|
1452
|
+
steps: 4
|
|
1453
|
+
}
|
|
1288
1454
|
}
|
|
1289
1455
|
},
|
|
1290
1456
|
["llama_local" /* LLAMALOCAL */]: {
|
|
1291
|
-
settings: {
|
|
1292
|
-
stop: ["<|eot_id|>", "<|eom_id|>"],
|
|
1293
|
-
maxInputTokens: 32768,
|
|
1294
|
-
maxOutputTokens: 8192,
|
|
1295
|
-
repetition_penalty: 0.4,
|
|
1296
|
-
temperature: 0.7
|
|
1297
|
-
},
|
|
1298
1457
|
model: {
|
|
1299
|
-
["small" /* SMALL */]:
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1458
|
+
["small" /* SMALL */]: {
|
|
1459
|
+
name: "NousResearch/Hermes-3-Llama-3.1-8B-GGUF/resolve/main/Hermes-3-Llama-3.1-8B.Q8_0.gguf?download=true",
|
|
1460
|
+
stop: ["<|eot_id|>", "<|eom_id|>"],
|
|
1461
|
+
maxInputTokens: 32768,
|
|
1462
|
+
maxOutputTokens: 8192,
|
|
1463
|
+
repetition_penalty: 0.4,
|
|
1464
|
+
temperature: 0.7
|
|
1465
|
+
},
|
|
1466
|
+
["medium" /* MEDIUM */]: {
|
|
1467
|
+
name: "NousResearch/Hermes-3-Llama-3.1-8B-GGUF/resolve/main/Hermes-3-Llama-3.1-8B.Q8_0.gguf?download=true",
|
|
1468
|
+
// TODO: ?download=true
|
|
1469
|
+
stop: ["<|eot_id|>", "<|eom_id|>"],
|
|
1470
|
+
maxInputTokens: 32768,
|
|
1471
|
+
maxOutputTokens: 8192,
|
|
1472
|
+
repetition_penalty: 0.4,
|
|
1473
|
+
temperature: 0.7
|
|
1474
|
+
},
|
|
1475
|
+
["large" /* LARGE */]: {
|
|
1476
|
+
name: "NousResearch/Hermes-3-Llama-3.1-8B-GGUF/resolve/main/Hermes-3-Llama-3.1-8B.Q8_0.gguf?download=true",
|
|
1477
|
+
// "RichardErkhov/NousResearch_-_Meta-Llama-3.1-70B-gguf", // TODO:
|
|
1478
|
+
stop: ["<|eot_id|>", "<|eom_id|>"],
|
|
1479
|
+
maxInputTokens: 32768,
|
|
1480
|
+
maxOutputTokens: 8192,
|
|
1481
|
+
repetition_penalty: 0.4,
|
|
1482
|
+
temperature: 0.7
|
|
1483
|
+
},
|
|
1484
|
+
["embedding" /* EMBEDDING */]: {
|
|
1485
|
+
name: "togethercomputer/m2-bert-80M-32k-retrieval"
|
|
1486
|
+
}
|
|
1305
1487
|
}
|
|
1306
1488
|
},
|
|
1307
1489
|
["google" /* GOOGLE */]: {
|
|
1308
|
-
|
|
1309
|
-
stop: [],
|
|
1310
|
-
maxInputTokens: 128e3,
|
|
1311
|
-
maxOutputTokens: 8192,
|
|
1312
|
-
frequency_penalty: 0.4,
|
|
1313
|
-
presence_penalty: 0.4,
|
|
1314
|
-
temperature: 0.7
|
|
1315
|
-
},
|
|
1490
|
+
endpoint: "https://generativelanguage.googleapis.com",
|
|
1316
1491
|
model: {
|
|
1317
|
-
["small" /* SMALL */]:
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1492
|
+
["small" /* SMALL */]: {
|
|
1493
|
+
name: settings_default.SMALL_GOOGLE_MODEL || settings_default.GOOGLE_MODEL || "gemini-2.0-flash-exp",
|
|
1494
|
+
stop: [],
|
|
1495
|
+
maxInputTokens: 128e3,
|
|
1496
|
+
maxOutputTokens: 8192,
|
|
1497
|
+
frequency_penalty: 0.4,
|
|
1498
|
+
presence_penalty: 0.4,
|
|
1499
|
+
temperature: 0.7
|
|
1500
|
+
},
|
|
1501
|
+
["medium" /* MEDIUM */]: {
|
|
1502
|
+
name: settings_default.MEDIUM_GOOGLE_MODEL || settings_default.GOOGLE_MODEL || "gemini-2.0-flash-exp",
|
|
1503
|
+
stop: [],
|
|
1504
|
+
maxInputTokens: 128e3,
|
|
1505
|
+
maxOutputTokens: 8192,
|
|
1506
|
+
frequency_penalty: 0.4,
|
|
1507
|
+
presence_penalty: 0.4,
|
|
1508
|
+
temperature: 0.7
|
|
1509
|
+
},
|
|
1510
|
+
["large" /* LARGE */]: {
|
|
1511
|
+
name: settings_default.LARGE_GOOGLE_MODEL || settings_default.GOOGLE_MODEL || "gemini-2.0-flash-exp",
|
|
1512
|
+
stop: [],
|
|
1513
|
+
maxInputTokens: 128e3,
|
|
1514
|
+
maxOutputTokens: 8192,
|
|
1515
|
+
frequency_penalty: 0.4,
|
|
1516
|
+
presence_penalty: 0.4,
|
|
1517
|
+
temperature: 0.7
|
|
1518
|
+
},
|
|
1519
|
+
["embedding" /* EMBEDDING */]: {
|
|
1520
|
+
name: settings_default.EMBEDDING_GOOGLE_MODEL || settings_default.GOOGLE_MODEL || "text-embedding-004"
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
},
|
|
1524
|
+
["mistral" /* MISTRAL */]: {
|
|
1525
|
+
model: {
|
|
1526
|
+
["small" /* SMALL */]: {
|
|
1527
|
+
name: settings_default.SMALL_MISTRAL_MODEL || settings_default.MISTRAL_MODEL || "mistral-small-latest",
|
|
1528
|
+
stop: [],
|
|
1529
|
+
maxInputTokens: 128e3,
|
|
1530
|
+
maxOutputTokens: 8192,
|
|
1531
|
+
frequency_penalty: 0.4,
|
|
1532
|
+
presence_penalty: 0.4,
|
|
1533
|
+
temperature: 0.7
|
|
1534
|
+
},
|
|
1535
|
+
["medium" /* MEDIUM */]: {
|
|
1536
|
+
name: settings_default.MEDIUM_MISTRAL_MODEL || settings_default.MISTRAL_MODEL || "mistral-large-latest",
|
|
1537
|
+
stop: [],
|
|
1538
|
+
maxInputTokens: 128e3,
|
|
1539
|
+
maxOutputTokens: 8192,
|
|
1540
|
+
frequency_penalty: 0.4,
|
|
1541
|
+
presence_penalty: 0.4,
|
|
1542
|
+
temperature: 0.7
|
|
1543
|
+
},
|
|
1544
|
+
["large" /* LARGE */]: {
|
|
1545
|
+
name: settings_default.LARGE_MISTRAL_MODEL || settings_default.MISTRAL_MODEL || "mistral-large-latest",
|
|
1546
|
+
stop: [],
|
|
1547
|
+
maxInputTokens: 128e3,
|
|
1548
|
+
maxOutputTokens: 8192,
|
|
1549
|
+
frequency_penalty: 0.4,
|
|
1550
|
+
presence_penalty: 0.4,
|
|
1551
|
+
temperature: 0.7
|
|
1552
|
+
}
|
|
1321
1553
|
}
|
|
1322
1554
|
},
|
|
1323
1555
|
["redpill" /* REDPILL */]: {
|
|
1324
1556
|
endpoint: "https://api.red-pill.ai/v1",
|
|
1325
|
-
settings: {
|
|
1326
|
-
stop: [],
|
|
1327
|
-
maxInputTokens: 128e3,
|
|
1328
|
-
maxOutputTokens: 8192,
|
|
1329
|
-
frequency_penalty: 0,
|
|
1330
|
-
presence_penalty: 0,
|
|
1331
|
-
temperature: 0.6
|
|
1332
|
-
},
|
|
1333
1557
|
// Available models: https://docs.red-pill.ai/get-started/supported-models
|
|
1334
1558
|
// To test other models, change the models below
|
|
1335
1559
|
model: {
|
|
1336
|
-
["small" /* SMALL */]:
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1560
|
+
["small" /* SMALL */]: {
|
|
1561
|
+
name: settings_default.SMALL_REDPILL_MODEL || settings_default.REDPILL_MODEL || "gpt-4o-mini",
|
|
1562
|
+
stop: [],
|
|
1563
|
+
maxInputTokens: 128e3,
|
|
1564
|
+
maxOutputTokens: 8192,
|
|
1565
|
+
frequency_penalty: 0,
|
|
1566
|
+
presence_penalty: 0,
|
|
1567
|
+
temperature: 0.6
|
|
1568
|
+
},
|
|
1569
|
+
["medium" /* MEDIUM */]: {
|
|
1570
|
+
name: settings_default.MEDIUM_REDPILL_MODEL || settings_default.REDPILL_MODEL || "gpt-4o",
|
|
1571
|
+
stop: [],
|
|
1572
|
+
maxInputTokens: 128e3,
|
|
1573
|
+
maxOutputTokens: 8192,
|
|
1574
|
+
frequency_penalty: 0,
|
|
1575
|
+
presence_penalty: 0,
|
|
1576
|
+
temperature: 0.6
|
|
1577
|
+
},
|
|
1578
|
+
["large" /* LARGE */]: {
|
|
1579
|
+
name: settings_default.LARGE_REDPILL_MODEL || settings_default.REDPILL_MODEL || "gpt-4o",
|
|
1580
|
+
stop: [],
|
|
1581
|
+
maxInputTokens: 128e3,
|
|
1582
|
+
maxOutputTokens: 8192,
|
|
1583
|
+
frequency_penalty: 0,
|
|
1584
|
+
presence_penalty: 0,
|
|
1585
|
+
temperature: 0.6
|
|
1586
|
+
},
|
|
1587
|
+
["embedding" /* EMBEDDING */]: {
|
|
1588
|
+
name: "text-embedding-3-small"
|
|
1589
|
+
}
|
|
1340
1590
|
}
|
|
1341
1591
|
},
|
|
1342
1592
|
["openrouter" /* OPENROUTER */]: {
|
|
1343
1593
|
endpoint: "https://openrouter.ai/api/v1",
|
|
1344
|
-
settings: {
|
|
1345
|
-
stop: [],
|
|
1346
|
-
maxInputTokens: 128e3,
|
|
1347
|
-
maxOutputTokens: 8192,
|
|
1348
|
-
frequency_penalty: 0.4,
|
|
1349
|
-
presence_penalty: 0.4,
|
|
1350
|
-
temperature: 0.7
|
|
1351
|
-
},
|
|
1352
1594
|
// Available models: https://openrouter.ai/models
|
|
1353
1595
|
// To test other models, change the models below
|
|
1354
1596
|
model: {
|
|
1355
|
-
["small" /* SMALL */]:
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1597
|
+
["small" /* SMALL */]: {
|
|
1598
|
+
name: settings_default.SMALL_OPENROUTER_MODEL || settings_default.OPENROUTER_MODEL || "nousresearch/hermes-3-llama-3.1-405b",
|
|
1599
|
+
stop: [],
|
|
1600
|
+
maxInputTokens: 128e3,
|
|
1601
|
+
maxOutputTokens: 8192,
|
|
1602
|
+
frequency_penalty: 0.4,
|
|
1603
|
+
presence_penalty: 0.4,
|
|
1604
|
+
temperature: 0.7
|
|
1605
|
+
},
|
|
1606
|
+
["medium" /* MEDIUM */]: {
|
|
1607
|
+
name: settings_default.MEDIUM_OPENROUTER_MODEL || settings_default.OPENROUTER_MODEL || "nousresearch/hermes-3-llama-3.1-405b",
|
|
1608
|
+
stop: [],
|
|
1609
|
+
maxInputTokens: 128e3,
|
|
1610
|
+
maxOutputTokens: 8192,
|
|
1611
|
+
frequency_penalty: 0.4,
|
|
1612
|
+
presence_penalty: 0.4,
|
|
1613
|
+
temperature: 0.7
|
|
1614
|
+
},
|
|
1615
|
+
["large" /* LARGE */]: {
|
|
1616
|
+
name: settings_default.LARGE_OPENROUTER_MODEL || settings_default.OPENROUTER_MODEL || "nousresearch/hermes-3-llama-3.1-405b",
|
|
1617
|
+
stop: [],
|
|
1618
|
+
maxInputTokens: 128e3,
|
|
1619
|
+
maxOutputTokens: 8192,
|
|
1620
|
+
frequency_penalty: 0.4,
|
|
1621
|
+
presence_penalty: 0.4,
|
|
1622
|
+
temperature: 0.7
|
|
1623
|
+
},
|
|
1624
|
+
["embedding" /* EMBEDDING */]: {
|
|
1625
|
+
name: "text-embedding-3-small"
|
|
1626
|
+
}
|
|
1359
1627
|
}
|
|
1360
1628
|
},
|
|
1361
1629
|
["ollama" /* OLLAMA */]: {
|
|
1362
|
-
settings: {
|
|
1363
|
-
stop: [],
|
|
1364
|
-
maxInputTokens: 128e3,
|
|
1365
|
-
maxOutputTokens: 8192,
|
|
1366
|
-
frequency_penalty: 0.4,
|
|
1367
|
-
presence_penalty: 0.4,
|
|
1368
|
-
temperature: 0.7
|
|
1369
|
-
},
|
|
1370
1630
|
endpoint: settings_default.OLLAMA_SERVER_URL || "http://localhost:11434",
|
|
1371
1631
|
model: {
|
|
1372
|
-
["small" /* SMALL */]:
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1632
|
+
["small" /* SMALL */]: {
|
|
1633
|
+
name: settings_default.SMALL_OLLAMA_MODEL || settings_default.OLLAMA_MODEL || "llama3.2",
|
|
1634
|
+
stop: [],
|
|
1635
|
+
maxInputTokens: 128e3,
|
|
1636
|
+
maxOutputTokens: 8192,
|
|
1637
|
+
frequency_penalty: 0.4,
|
|
1638
|
+
presence_penalty: 0.4,
|
|
1639
|
+
temperature: 0.7
|
|
1640
|
+
},
|
|
1641
|
+
["medium" /* MEDIUM */]: {
|
|
1642
|
+
name: settings_default.MEDIUM_OLLAMA_MODEL || settings_default.OLLAMA_MODEL || "hermes3",
|
|
1643
|
+
stop: [],
|
|
1644
|
+
maxInputTokens: 128e3,
|
|
1645
|
+
maxOutputTokens: 8192,
|
|
1646
|
+
frequency_penalty: 0.4,
|
|
1647
|
+
presence_penalty: 0.4,
|
|
1648
|
+
temperature: 0.7
|
|
1649
|
+
},
|
|
1650
|
+
["large" /* LARGE */]: {
|
|
1651
|
+
name: settings_default.LARGE_OLLAMA_MODEL || settings_default.OLLAMA_MODEL || "hermes3:70b",
|
|
1652
|
+
stop: [],
|
|
1653
|
+
maxInputTokens: 128e3,
|
|
1654
|
+
maxOutputTokens: 8192,
|
|
1655
|
+
frequency_penalty: 0.4,
|
|
1656
|
+
presence_penalty: 0.4,
|
|
1657
|
+
temperature: 0.7
|
|
1658
|
+
},
|
|
1659
|
+
["embedding" /* EMBEDDING */]: {
|
|
1660
|
+
name: settings_default.OLLAMA_EMBEDDING_MODEL || "mxbai-embed-large",
|
|
1661
|
+
dimensions: 1024
|
|
1662
|
+
}
|
|
1376
1663
|
}
|
|
1377
1664
|
},
|
|
1378
1665
|
["heurist" /* HEURIST */]: {
|
|
1379
|
-
settings: {
|
|
1380
|
-
stop: [],
|
|
1381
|
-
maxInputTokens: 128e3,
|
|
1382
|
-
maxOutputTokens: 8192,
|
|
1383
|
-
repetition_penalty: 0.4,
|
|
1384
|
-
temperature: 0.7
|
|
1385
|
-
},
|
|
1386
|
-
imageSettings: {
|
|
1387
|
-
steps: 20
|
|
1388
|
-
},
|
|
1389
1666
|
endpoint: "https://llm-gateway.heurist.xyz",
|
|
1390
1667
|
model: {
|
|
1391
|
-
["small" /* SMALL */]:
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1668
|
+
["small" /* SMALL */]: {
|
|
1669
|
+
name: settings_default.SMALL_HEURIST_MODEL || "meta-llama/llama-3-70b-instruct",
|
|
1670
|
+
stop: [],
|
|
1671
|
+
maxInputTokens: 128e3,
|
|
1672
|
+
maxOutputTokens: 8192,
|
|
1673
|
+
repetition_penalty: 0.4,
|
|
1674
|
+
temperature: 0.7
|
|
1675
|
+
},
|
|
1676
|
+
["medium" /* MEDIUM */]: {
|
|
1677
|
+
name: settings_default.MEDIUM_HEURIST_MODEL || "meta-llama/llama-3-70b-instruct",
|
|
1678
|
+
stop: [],
|
|
1679
|
+
maxInputTokens: 128e3,
|
|
1680
|
+
maxOutputTokens: 8192,
|
|
1681
|
+
repetition_penalty: 0.4,
|
|
1682
|
+
temperature: 0.7
|
|
1683
|
+
},
|
|
1684
|
+
["large" /* LARGE */]: {
|
|
1685
|
+
name: settings_default.LARGE_HEURIST_MODEL || "meta-llama/llama-3.3-70b-instruct",
|
|
1686
|
+
stop: [],
|
|
1687
|
+
maxInputTokens: 128e3,
|
|
1688
|
+
maxOutputTokens: 8192,
|
|
1689
|
+
repetition_penalty: 0.4,
|
|
1690
|
+
temperature: 0.7
|
|
1691
|
+
},
|
|
1692
|
+
["image" /* IMAGE */]: {
|
|
1693
|
+
name: settings_default.HEURIST_IMAGE_MODEL || "FLUX.1-dev",
|
|
1694
|
+
steps: 20
|
|
1695
|
+
},
|
|
1696
|
+
["embedding" /* EMBEDDING */]: {
|
|
1697
|
+
name: "BAAI/bge-large-en-v1.5",
|
|
1698
|
+
dimensions: 1024
|
|
1699
|
+
}
|
|
1397
1700
|
}
|
|
1398
1701
|
},
|
|
1399
1702
|
["galadriel" /* GALADRIEL */]: {
|
|
1400
|
-
endpoint: "https://api.galadriel.com/v1",
|
|
1401
|
-
settings: {
|
|
1402
|
-
stop: [],
|
|
1403
|
-
maxInputTokens: 128e3,
|
|
1404
|
-
maxOutputTokens: 8192,
|
|
1405
|
-
frequency_penalty: 0.5,
|
|
1406
|
-
presence_penalty: 0.5,
|
|
1407
|
-
temperature: 0.8
|
|
1408
|
-
},
|
|
1703
|
+
endpoint: "https://api.galadriel.com/v1/verified",
|
|
1409
1704
|
model: {
|
|
1410
|
-
["small" /* SMALL */]:
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1705
|
+
["small" /* SMALL */]: {
|
|
1706
|
+
name: settings_default.SMALL_GALADRIEL_MODEL || "gpt-4o-mini",
|
|
1707
|
+
stop: [],
|
|
1708
|
+
maxInputTokens: 128e3,
|
|
1709
|
+
maxOutputTokens: 8192,
|
|
1710
|
+
frequency_penalty: 0,
|
|
1711
|
+
presence_penalty: 0,
|
|
1712
|
+
temperature: 0.6
|
|
1713
|
+
},
|
|
1714
|
+
["medium" /* MEDIUM */]: {
|
|
1715
|
+
name: settings_default.MEDIUM_GALADRIEL_MODEL || "gpt-4o",
|
|
1716
|
+
stop: [],
|
|
1717
|
+
maxInputTokens: 128e3,
|
|
1718
|
+
maxOutputTokens: 8192,
|
|
1719
|
+
frequency_penalty: 0,
|
|
1720
|
+
presence_penalty: 0,
|
|
1721
|
+
temperature: 0.6
|
|
1722
|
+
},
|
|
1723
|
+
["large" /* LARGE */]: {
|
|
1724
|
+
name: settings_default.LARGE_GALADRIEL_MODEL || "gpt-4o",
|
|
1725
|
+
stop: [],
|
|
1726
|
+
maxInputTokens: 128e3,
|
|
1727
|
+
maxOutputTokens: 8192,
|
|
1728
|
+
frequency_penalty: 0,
|
|
1729
|
+
presence_penalty: 0,
|
|
1730
|
+
temperature: 0.6
|
|
1731
|
+
}
|
|
1415
1732
|
}
|
|
1416
1733
|
},
|
|
1417
1734
|
["falai" /* FAL */]: {
|
|
1418
|
-
settings: {
|
|
1419
|
-
stop: [],
|
|
1420
|
-
maxInputTokens: 128e3,
|
|
1421
|
-
maxOutputTokens: 8192,
|
|
1422
|
-
repetition_penalty: 0.4,
|
|
1423
|
-
temperature: 0.7
|
|
1424
|
-
},
|
|
1425
|
-
imageSettings: {
|
|
1426
|
-
steps: 28
|
|
1427
|
-
},
|
|
1428
1735
|
endpoint: "https://api.fal.ai/v1",
|
|
1429
1736
|
model: {
|
|
1430
|
-
["
|
|
1431
|
-
// FAL doesn't provide text models
|
|
1432
|
-
["medium" /* MEDIUM */]: "",
|
|
1433
|
-
["large" /* LARGE */]: "",
|
|
1434
|
-
["embedding" /* EMBEDDING */]: "",
|
|
1435
|
-
["image" /* IMAGE */]: "fal-ai/flux-lora"
|
|
1737
|
+
["image" /* IMAGE */]: { name: "fal-ai/flux-lora", steps: 28 }
|
|
1436
1738
|
}
|
|
1437
1739
|
},
|
|
1438
1740
|
["gaianet" /* GAIANET */]: {
|
|
1439
|
-
settings: {
|
|
1440
|
-
stop: [],
|
|
1441
|
-
maxInputTokens: 128e3,
|
|
1442
|
-
maxOutputTokens: 8192,
|
|
1443
|
-
repetition_penalty: 0.4,
|
|
1444
|
-
temperature: 0.7
|
|
1445
|
-
},
|
|
1446
1741
|
endpoint: settings_default.GAIANET_SERVER_URL,
|
|
1447
1742
|
model: {
|
|
1448
|
-
["small" /* SMALL */]:
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1743
|
+
["small" /* SMALL */]: {
|
|
1744
|
+
name: settings_default.GAIANET_MODEL || settings_default.SMALL_GAIANET_MODEL || "llama3b",
|
|
1745
|
+
stop: [],
|
|
1746
|
+
maxInputTokens: 128e3,
|
|
1747
|
+
maxOutputTokens: 8192,
|
|
1748
|
+
repetition_penalty: 0.4,
|
|
1749
|
+
temperature: 0.7
|
|
1750
|
+
},
|
|
1751
|
+
["medium" /* MEDIUM */]: {
|
|
1752
|
+
name: settings_default.GAIANET_MODEL || settings_default.MEDIUM_GAIANET_MODEL || "llama",
|
|
1753
|
+
stop: [],
|
|
1754
|
+
maxInputTokens: 128e3,
|
|
1755
|
+
maxOutputTokens: 8192,
|
|
1756
|
+
repetition_penalty: 0.4,
|
|
1757
|
+
temperature: 0.7
|
|
1758
|
+
},
|
|
1759
|
+
["large" /* LARGE */]: {
|
|
1760
|
+
name: settings_default.GAIANET_MODEL || settings_default.LARGE_GAIANET_MODEL || "qwen72b",
|
|
1761
|
+
stop: [],
|
|
1762
|
+
maxInputTokens: 128e3,
|
|
1763
|
+
maxOutputTokens: 8192,
|
|
1764
|
+
repetition_penalty: 0.4,
|
|
1765
|
+
temperature: 0.7
|
|
1766
|
+
},
|
|
1767
|
+
["embedding" /* EMBEDDING */]: {
|
|
1768
|
+
name: settings_default.GAIANET_EMBEDDING_MODEL || "nomic-embed",
|
|
1769
|
+
dimensions: 768
|
|
1770
|
+
}
|
|
1452
1771
|
}
|
|
1453
1772
|
},
|
|
1454
1773
|
["ali_bailian" /* ALI_BAILIAN */]: {
|
|
1455
1774
|
endpoint: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
1456
|
-
settings: {
|
|
1457
|
-
stop: [],
|
|
1458
|
-
maxInputTokens: 128e3,
|
|
1459
|
-
maxOutputTokens: 8192,
|
|
1460
|
-
frequency_penalty: 0.4,
|
|
1461
|
-
presence_penalty: 0.4,
|
|
1462
|
-
temperature: 0.6
|
|
1463
|
-
},
|
|
1464
1775
|
model: {
|
|
1465
|
-
["small" /* SMALL */]:
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1776
|
+
["small" /* SMALL */]: {
|
|
1777
|
+
name: "qwen-turbo",
|
|
1778
|
+
stop: [],
|
|
1779
|
+
maxInputTokens: 128e3,
|
|
1780
|
+
maxOutputTokens: 8192,
|
|
1781
|
+
frequency_penalty: 0.4,
|
|
1782
|
+
presence_penalty: 0.4,
|
|
1783
|
+
temperature: 0.6
|
|
1784
|
+
},
|
|
1785
|
+
["medium" /* MEDIUM */]: {
|
|
1786
|
+
name: "qwen-plus",
|
|
1787
|
+
stop: [],
|
|
1788
|
+
maxInputTokens: 128e3,
|
|
1789
|
+
maxOutputTokens: 8192,
|
|
1790
|
+
frequency_penalty: 0.4,
|
|
1791
|
+
presence_penalty: 0.4,
|
|
1792
|
+
temperature: 0.6
|
|
1793
|
+
},
|
|
1794
|
+
["large" /* LARGE */]: {
|
|
1795
|
+
name: "qwen-max",
|
|
1796
|
+
stop: [],
|
|
1797
|
+
maxInputTokens: 128e3,
|
|
1798
|
+
maxOutputTokens: 8192,
|
|
1799
|
+
frequency_penalty: 0.4,
|
|
1800
|
+
presence_penalty: 0.4,
|
|
1801
|
+
temperature: 0.6
|
|
1802
|
+
},
|
|
1803
|
+
["image" /* IMAGE */]: {
|
|
1804
|
+
name: "wanx-v1"
|
|
1805
|
+
}
|
|
1469
1806
|
}
|
|
1470
1807
|
},
|
|
1471
1808
|
["volengine" /* VOLENGINE */]: {
|
|
1472
1809
|
endpoint: settings_default.VOLENGINE_API_URL || "https://open.volcengineapi.com/api/v3/",
|
|
1473
|
-
settings: {
|
|
1474
|
-
stop: [],
|
|
1475
|
-
maxInputTokens: 128e3,
|
|
1476
|
-
maxOutputTokens: 8192,
|
|
1477
|
-
frequency_penalty: 0.4,
|
|
1478
|
-
presence_penalty: 0.4,
|
|
1479
|
-
temperature: 0.6
|
|
1480
|
-
},
|
|
1481
1810
|
model: {
|
|
1482
|
-
["small" /* SMALL */]:
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1811
|
+
["small" /* SMALL */]: {
|
|
1812
|
+
name: settings_default.SMALL_VOLENGINE_MODEL || settings_default.VOLENGINE_MODEL || "doubao-lite-128k",
|
|
1813
|
+
stop: [],
|
|
1814
|
+
maxInputTokens: 128e3,
|
|
1815
|
+
maxOutputTokens: 8192,
|
|
1816
|
+
frequency_penalty: 0.4,
|
|
1817
|
+
presence_penalty: 0.4,
|
|
1818
|
+
temperature: 0.6
|
|
1819
|
+
},
|
|
1820
|
+
["medium" /* MEDIUM */]: {
|
|
1821
|
+
name: settings_default.MEDIUM_VOLENGINE_MODEL || settings_default.VOLENGINE_MODEL || "doubao-pro-128k",
|
|
1822
|
+
stop: [],
|
|
1823
|
+
maxInputTokens: 128e3,
|
|
1824
|
+
maxOutputTokens: 8192,
|
|
1825
|
+
frequency_penalty: 0.4,
|
|
1826
|
+
presence_penalty: 0.4,
|
|
1827
|
+
temperature: 0.6
|
|
1828
|
+
},
|
|
1829
|
+
["large" /* LARGE */]: {
|
|
1830
|
+
name: settings_default.LARGE_VOLENGINE_MODEL || settings_default.VOLENGINE_MODEL || "doubao-pro-256k",
|
|
1831
|
+
stop: [],
|
|
1832
|
+
maxInputTokens: 128e3,
|
|
1833
|
+
maxOutputTokens: 8192,
|
|
1834
|
+
frequency_penalty: 0.4,
|
|
1835
|
+
presence_penalty: 0.4,
|
|
1836
|
+
temperature: 0.6
|
|
1837
|
+
},
|
|
1838
|
+
["embedding" /* EMBEDDING */]: {
|
|
1839
|
+
name: settings_default.VOLENGINE_EMBEDDING_MODEL || "doubao-embedding"
|
|
1840
|
+
}
|
|
1486
1841
|
}
|
|
1487
1842
|
},
|
|
1488
1843
|
["nanogpt" /* NANOGPT */]: {
|
|
1489
1844
|
endpoint: "https://nano-gpt.com/api/v1",
|
|
1490
|
-
settings: {
|
|
1491
|
-
stop: [],
|
|
1492
|
-
maxInputTokens: 128e3,
|
|
1493
|
-
maxOutputTokens: 8192,
|
|
1494
|
-
frequency_penalty: 0,
|
|
1495
|
-
presence_penalty: 0,
|
|
1496
|
-
temperature: 0.6
|
|
1497
|
-
},
|
|
1498
1845
|
model: {
|
|
1499
|
-
["small" /* SMALL */]:
|
|
1500
|
-
|
|
1501
|
-
|
|
1846
|
+
["small" /* SMALL */]: {
|
|
1847
|
+
name: settings_default.SMALL_NANOGPT_MODEL || "gpt-4o-mini",
|
|
1848
|
+
stop: [],
|
|
1849
|
+
maxInputTokens: 128e3,
|
|
1850
|
+
maxOutputTokens: 8192,
|
|
1851
|
+
frequency_penalty: 0,
|
|
1852
|
+
presence_penalty: 0,
|
|
1853
|
+
temperature: 0.6
|
|
1854
|
+
},
|
|
1855
|
+
["medium" /* MEDIUM */]: {
|
|
1856
|
+
name: settings_default.MEDIUM_NANOGPT_MODEL || "gpt-4o",
|
|
1857
|
+
stop: [],
|
|
1858
|
+
maxInputTokens: 128e3,
|
|
1859
|
+
maxOutputTokens: 8192,
|
|
1860
|
+
frequency_penalty: 0,
|
|
1861
|
+
presence_penalty: 0,
|
|
1862
|
+
temperature: 0.6
|
|
1863
|
+
},
|
|
1864
|
+
["large" /* LARGE */]: {
|
|
1865
|
+
name: settings_default.LARGE_NANOGPT_MODEL || "gpt-4o",
|
|
1866
|
+
stop: [],
|
|
1867
|
+
maxInputTokens: 128e3,
|
|
1868
|
+
maxOutputTokens: 8192,
|
|
1869
|
+
frequency_penalty: 0,
|
|
1870
|
+
presence_penalty: 0,
|
|
1871
|
+
temperature: 0.6
|
|
1872
|
+
}
|
|
1502
1873
|
}
|
|
1503
1874
|
},
|
|
1504
1875
|
["hyperbolic" /* HYPERBOLIC */]: {
|
|
1505
1876
|
endpoint: "https://api.hyperbolic.xyz/v1",
|
|
1506
|
-
settings: {
|
|
1507
|
-
stop: [],
|
|
1508
|
-
maxInputTokens: 128e3,
|
|
1509
|
-
maxOutputTokens: 8192,
|
|
1510
|
-
temperature: 0.6
|
|
1511
|
-
},
|
|
1512
1877
|
model: {
|
|
1513
|
-
["small" /* SMALL */]:
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1878
|
+
["small" /* SMALL */]: {
|
|
1879
|
+
name: settings_default.SMALL_HYPERBOLIC_MODEL || settings_default.HYPERBOLIC_MODEL || "meta-llama/Llama-3.2-3B-Instruct",
|
|
1880
|
+
stop: [],
|
|
1881
|
+
maxInputTokens: 128e3,
|
|
1882
|
+
maxOutputTokens: 8192,
|
|
1883
|
+
temperature: 0.6
|
|
1884
|
+
},
|
|
1885
|
+
["medium" /* MEDIUM */]: {
|
|
1886
|
+
name: settings_default.MEDIUM_HYPERBOLIC_MODEL || settings_default.HYPERBOLIC_MODEL || "meta-llama/Meta-Llama-3.1-70B-Instruct",
|
|
1887
|
+
stop: [],
|
|
1888
|
+
maxInputTokens: 128e3,
|
|
1889
|
+
maxOutputTokens: 8192,
|
|
1890
|
+
temperature: 0.6
|
|
1891
|
+
},
|
|
1892
|
+
["large" /* LARGE */]: {
|
|
1893
|
+
name: settings_default.LARGE_HYPERBOLIC_MODEL || settings_default.HYPERBOLIC_MODEL || "meta-llama/Meta-Llama-3.1-405-Instruct",
|
|
1894
|
+
stop: [],
|
|
1895
|
+
maxInputTokens: 128e3,
|
|
1896
|
+
maxOutputTokens: 8192,
|
|
1897
|
+
temperature: 0.6
|
|
1898
|
+
},
|
|
1899
|
+
["image" /* IMAGE */]: {
|
|
1900
|
+
name: settings_default.IMAGE_HYPERBOLIC_MODEL || "FLUX.1-dev"
|
|
1901
|
+
}
|
|
1517
1902
|
}
|
|
1518
1903
|
},
|
|
1519
1904
|
["venice" /* VENICE */]: {
|
|
1520
1905
|
endpoint: "https://api.venice.ai/api/v1",
|
|
1521
|
-
settings: {
|
|
1522
|
-
stop: [],
|
|
1523
|
-
maxInputTokens: 128e3,
|
|
1524
|
-
maxOutputTokens: 8192,
|
|
1525
|
-
temperature: 0.6
|
|
1526
|
-
},
|
|
1527
1906
|
model: {
|
|
1528
|
-
["small" /* SMALL */]:
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1907
|
+
["small" /* SMALL */]: {
|
|
1908
|
+
name: settings_default.SMALL_VENICE_MODEL || "llama-3.3-70b",
|
|
1909
|
+
stop: [],
|
|
1910
|
+
maxInputTokens: 128e3,
|
|
1911
|
+
maxOutputTokens: 8192,
|
|
1912
|
+
temperature: 0.6
|
|
1913
|
+
},
|
|
1914
|
+
["medium" /* MEDIUM */]: {
|
|
1915
|
+
name: settings_default.MEDIUM_VENICE_MODEL || "llama-3.3-70b",
|
|
1916
|
+
stop: [],
|
|
1917
|
+
maxInputTokens: 128e3,
|
|
1918
|
+
maxOutputTokens: 8192,
|
|
1919
|
+
temperature: 0.6
|
|
1920
|
+
},
|
|
1921
|
+
["large" /* LARGE */]: {
|
|
1922
|
+
name: settings_default.LARGE_VENICE_MODEL || "llama-3.1-405b",
|
|
1923
|
+
stop: [],
|
|
1924
|
+
maxInputTokens: 128e3,
|
|
1925
|
+
maxOutputTokens: 8192,
|
|
1926
|
+
temperature: 0.6
|
|
1927
|
+
},
|
|
1928
|
+
["image" /* IMAGE */]: {
|
|
1929
|
+
name: settings_default.IMAGE_VENICE_MODEL || "fluently-xl"
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
},
|
|
1933
|
+
["nineteen_ai" /* NINETEEN_AI */]: {
|
|
1934
|
+
endpoint: "https://api.nineteen.ai/v1",
|
|
1935
|
+
model: {
|
|
1936
|
+
["small" /* SMALL */]: {
|
|
1937
|
+
name: settings_default.SMALL_NINETEEN_AI_MODEL || "unsloth/Llama-3.2-3B-Instruct",
|
|
1938
|
+
stop: [],
|
|
1939
|
+
maxInputTokens: 128e3,
|
|
1940
|
+
maxOutputTokens: 8192,
|
|
1941
|
+
temperature: 0.6
|
|
1942
|
+
},
|
|
1943
|
+
["medium" /* MEDIUM */]: {
|
|
1944
|
+
name: settings_default.MEDIUM_NINETEEN_AI_MODEL || "unsloth/Meta-Llama-3.1-8B-Instruct",
|
|
1945
|
+
stop: [],
|
|
1946
|
+
maxInputTokens: 128e3,
|
|
1947
|
+
maxOutputTokens: 8192,
|
|
1948
|
+
temperature: 0.6
|
|
1949
|
+
},
|
|
1950
|
+
["large" /* LARGE */]: {
|
|
1951
|
+
name: settings_default.LARGE_NINETEEN_AI_MODEL || "hugging-quants/Meta-Llama-3.1-70B-Instruct-AWQ-INT4",
|
|
1952
|
+
stop: [],
|
|
1953
|
+
maxInputTokens: 128e3,
|
|
1954
|
+
maxOutputTokens: 8192,
|
|
1955
|
+
temperature: 0.6
|
|
1956
|
+
},
|
|
1957
|
+
["image" /* IMAGE */]: {
|
|
1958
|
+
name: settings_default.IMAGE_NINETEEN_AI_MODEL || "dataautogpt3/ProteusV0.4-Lightning"
|
|
1959
|
+
}
|
|
1532
1960
|
}
|
|
1533
1961
|
},
|
|
1534
1962
|
["akash_chat_api" /* AKASH_CHAT_API */]: {
|
|
1535
1963
|
endpoint: "https://chatapi.akash.network/api/v1",
|
|
1536
|
-
settings: {
|
|
1537
|
-
stop: [],
|
|
1538
|
-
maxInputTokens: 128e3,
|
|
1539
|
-
maxOutputTokens: 8192,
|
|
1540
|
-
temperature: 0.6
|
|
1541
|
-
},
|
|
1542
1964
|
model: {
|
|
1543
|
-
["small" /* SMALL */]:
|
|
1544
|
-
|
|
1545
|
-
|
|
1965
|
+
["small" /* SMALL */]: {
|
|
1966
|
+
name: settings_default.SMALL_AKASH_CHAT_API_MODEL || "Meta-Llama-3-2-3B-Instruct",
|
|
1967
|
+
stop: [],
|
|
1968
|
+
maxInputTokens: 128e3,
|
|
1969
|
+
maxOutputTokens: 8192,
|
|
1970
|
+
temperature: 0.6
|
|
1971
|
+
},
|
|
1972
|
+
["medium" /* MEDIUM */]: {
|
|
1973
|
+
name: settings_default.MEDIUM_AKASH_CHAT_API_MODEL || "Meta-Llama-3-3-70B-Instruct",
|
|
1974
|
+
stop: [],
|
|
1975
|
+
maxInputTokens: 128e3,
|
|
1976
|
+
maxOutputTokens: 8192,
|
|
1977
|
+
temperature: 0.6
|
|
1978
|
+
},
|
|
1979
|
+
["large" /* LARGE */]: {
|
|
1980
|
+
name: settings_default.LARGE_AKASH_CHAT_API_MODEL || "Meta-Llama-3-1-405B-Instruct-FP8",
|
|
1981
|
+
stop: [],
|
|
1982
|
+
maxInputTokens: 128e3,
|
|
1983
|
+
maxOutputTokens: 8192,
|
|
1984
|
+
temperature: 0.6
|
|
1985
|
+
}
|
|
1546
1986
|
}
|
|
1547
1987
|
},
|
|
1548
1988
|
["livepeer" /* LIVEPEER */]: {
|
|
1549
|
-
settings: {
|
|
1550
|
-
stop: [],
|
|
1551
|
-
maxInputTokens: 128e3,
|
|
1552
|
-
maxOutputTokens: 8192,
|
|
1553
|
-
repetition_penalty: 0.4,
|
|
1554
|
-
temperature: 0.7
|
|
1555
|
-
},
|
|
1556
1989
|
// livepeer endpoint is handled from the sdk
|
|
1557
1990
|
model: {
|
|
1558
|
-
["
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1991
|
+
["image" /* IMAGE */]: {
|
|
1992
|
+
name: settings_default.LIVEPEER_IMAGE_MODEL || "ByteDance/SDXL-Lightning"
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
},
|
|
1996
|
+
["infera" /* INFERA */]: {
|
|
1997
|
+
endpoint: "https://api.infera.org",
|
|
1998
|
+
model: {
|
|
1999
|
+
["small" /* SMALL */]: {
|
|
2000
|
+
name: settings_default.SMALL_INFERA_MODEL || "llama3.2:3b",
|
|
2001
|
+
stop: [],
|
|
2002
|
+
maxInputTokens: 128e3,
|
|
2003
|
+
maxOutputTokens: 8192,
|
|
2004
|
+
temperature: 0.6
|
|
2005
|
+
},
|
|
2006
|
+
["medium" /* MEDIUM */]: {
|
|
2007
|
+
name: settings_default.MEDIUM_INFERA_MODEL || "mistral-nemo:latest",
|
|
2008
|
+
stop: [],
|
|
2009
|
+
maxInputTokens: 128e3,
|
|
2010
|
+
maxOutputTokens: 8192,
|
|
2011
|
+
temperature: 0.6
|
|
2012
|
+
},
|
|
2013
|
+
["large" /* LARGE */]: {
|
|
2014
|
+
name: settings_default.LARGE_INFERA_MODEL || "mistral-small:latest",
|
|
2015
|
+
stop: [],
|
|
2016
|
+
maxInputTokens: 128e3,
|
|
2017
|
+
maxOutputTokens: 8192,
|
|
2018
|
+
temperature: 0.6
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
},
|
|
2022
|
+
["deepseek" /* DEEPSEEK */]: {
|
|
2023
|
+
endpoint: settings_default.DEEPSEEK_API_URL || "https://api.deepseek.com",
|
|
2024
|
+
model: {
|
|
2025
|
+
["small" /* SMALL */]: {
|
|
2026
|
+
name: settings_default.SMALL_DEEPSEEK_MODEL || "deepseek-chat",
|
|
2027
|
+
stop: [],
|
|
2028
|
+
maxInputTokens: 128e3,
|
|
2029
|
+
maxOutputTokens: 8192,
|
|
2030
|
+
frequency_penalty: 0,
|
|
2031
|
+
presence_penalty: 0,
|
|
2032
|
+
temperature: 0.7
|
|
2033
|
+
},
|
|
2034
|
+
["medium" /* MEDIUM */]: {
|
|
2035
|
+
name: settings_default.MEDIUM_DEEPSEEK_MODEL || "deepseek-chat",
|
|
2036
|
+
stop: [],
|
|
2037
|
+
maxInputTokens: 128e3,
|
|
2038
|
+
maxOutputTokens: 8192,
|
|
2039
|
+
frequency_penalty: 0,
|
|
2040
|
+
presence_penalty: 0,
|
|
2041
|
+
temperature: 0.7
|
|
2042
|
+
},
|
|
2043
|
+
["large" /* LARGE */]: {
|
|
2044
|
+
name: settings_default.LARGE_DEEPSEEK_MODEL || "deepseek-chat",
|
|
2045
|
+
stop: [],
|
|
2046
|
+
maxInputTokens: 128e3,
|
|
2047
|
+
maxOutputTokens: 8192,
|
|
2048
|
+
frequency_penalty: 0,
|
|
2049
|
+
presence_penalty: 0,
|
|
2050
|
+
temperature: 0.7
|
|
2051
|
+
}
|
|
1563
2052
|
}
|
|
1564
2053
|
}
|
|
1565
2054
|
};
|
|
1566
|
-
function
|
|
1567
|
-
return models[provider]
|
|
2055
|
+
function getModelSettings(provider, type) {
|
|
2056
|
+
return models[provider]?.model[type];
|
|
2057
|
+
}
|
|
2058
|
+
function getImageModelSettings(provider) {
|
|
2059
|
+
return models[provider]?.model["image" /* IMAGE */];
|
|
2060
|
+
}
|
|
2061
|
+
function getEmbeddingModelSettings(provider) {
|
|
2062
|
+
return models[provider]?.model["embedding" /* EMBEDDING */];
|
|
1568
2063
|
}
|
|
1569
2064
|
function getEndpoint(provider) {
|
|
1570
2065
|
return models[provider].endpoint;
|
|
1571
2066
|
}
|
|
1572
2067
|
|
|
2068
|
+
// src/localembeddingManager.ts
|
|
2069
|
+
import path3 from "node:path";
|
|
2070
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2071
|
+
import { FlagEmbedding, EmbeddingModel } from "fastembed";
|
|
2072
|
+
var LocalEmbeddingModelManager = class _LocalEmbeddingModelManager {
|
|
2073
|
+
static instance;
|
|
2074
|
+
model = null;
|
|
2075
|
+
initPromise = null;
|
|
2076
|
+
initializationLock = false;
|
|
2077
|
+
constructor() {
|
|
2078
|
+
}
|
|
2079
|
+
static getInstance() {
|
|
2080
|
+
if (!_LocalEmbeddingModelManager.instance) {
|
|
2081
|
+
_LocalEmbeddingModelManager.instance = new _LocalEmbeddingModelManager();
|
|
2082
|
+
}
|
|
2083
|
+
return _LocalEmbeddingModelManager.instance;
|
|
2084
|
+
}
|
|
2085
|
+
async getRootPath() {
|
|
2086
|
+
const __filename2 = fileURLToPath2(import.meta.url);
|
|
2087
|
+
const __dirname3 = path3.dirname(__filename2);
|
|
2088
|
+
const rootPath = path3.resolve(__dirname3, "..");
|
|
2089
|
+
return rootPath.includes("/eliza/") ? rootPath.split("/eliza/")[0] + "/eliza/" : path3.resolve(__dirname3, "..");
|
|
2090
|
+
}
|
|
2091
|
+
async initialize() {
|
|
2092
|
+
if (this.model) {
|
|
2093
|
+
return;
|
|
2094
|
+
}
|
|
2095
|
+
if (this.initPromise) {
|
|
2096
|
+
return this.initPromise;
|
|
2097
|
+
}
|
|
2098
|
+
if (this.initializationLock) {
|
|
2099
|
+
while (this.initializationLock) {
|
|
2100
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2101
|
+
}
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
this.initializationLock = true;
|
|
2105
|
+
try {
|
|
2106
|
+
this.initPromise = this.initializeModel();
|
|
2107
|
+
await this.initPromise;
|
|
2108
|
+
} finally {
|
|
2109
|
+
this.initializationLock = false;
|
|
2110
|
+
this.initPromise = null;
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
async initializeModel() {
|
|
2114
|
+
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
2115
|
+
if (!isNode) {
|
|
2116
|
+
throw new Error("Local embedding not supported in browser");
|
|
2117
|
+
}
|
|
2118
|
+
try {
|
|
2119
|
+
const fs3 = await import("fs");
|
|
2120
|
+
const cacheDir = await this.getRootPath() + "/cache/";
|
|
2121
|
+
if (!fs3.existsSync(cacheDir)) {
|
|
2122
|
+
fs3.mkdirSync(cacheDir, { recursive: true });
|
|
2123
|
+
}
|
|
2124
|
+
logger_default.debug("Initializing BGE embedding model...");
|
|
2125
|
+
this.model = await FlagEmbedding.init({
|
|
2126
|
+
cacheDir,
|
|
2127
|
+
model: EmbeddingModel.BGESmallENV15,
|
|
2128
|
+
maxLength: 512
|
|
2129
|
+
});
|
|
2130
|
+
logger_default.debug("BGE model initialized successfully");
|
|
2131
|
+
} catch (error) {
|
|
2132
|
+
logger_default.error("Failed to initialize BGE model:", error);
|
|
2133
|
+
throw error;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
async generateEmbedding(input) {
|
|
2137
|
+
if (!this.model) {
|
|
2138
|
+
await this.initialize();
|
|
2139
|
+
}
|
|
2140
|
+
if (!this.model) {
|
|
2141
|
+
throw new Error("Failed to initialize model");
|
|
2142
|
+
}
|
|
2143
|
+
try {
|
|
2144
|
+
const embedding = await this.model.queryEmbed(input);
|
|
2145
|
+
logger_default.debug("Raw embedding from BGE:", {
|
|
2146
|
+
type: typeof embedding,
|
|
2147
|
+
isArray: Array.isArray(embedding),
|
|
2148
|
+
dimensions: Array.isArray(embedding) ? embedding.length : "not an array",
|
|
2149
|
+
sample: Array.isArray(embedding) ? embedding.slice(0, 5) : embedding
|
|
2150
|
+
});
|
|
2151
|
+
return this.processEmbedding(embedding);
|
|
2152
|
+
} catch (error) {
|
|
2153
|
+
logger_default.error("Embedding generation failed:", error);
|
|
2154
|
+
throw error;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
processEmbedding(embedding) {
|
|
2158
|
+
let finalEmbedding;
|
|
2159
|
+
if (ArrayBuffer.isView(embedding) && embedding.constructor === Float32Array) {
|
|
2160
|
+
finalEmbedding = Array.from(embedding);
|
|
2161
|
+
} else if (Array.isArray(embedding) && ArrayBuffer.isView(embedding[0]) && embedding[0].constructor === Float32Array) {
|
|
2162
|
+
finalEmbedding = Array.from(embedding[0]);
|
|
2163
|
+
} else if (Array.isArray(embedding)) {
|
|
2164
|
+
finalEmbedding = embedding;
|
|
2165
|
+
} else {
|
|
2166
|
+
throw new Error(`Unexpected embedding format: ${typeof embedding}`);
|
|
2167
|
+
}
|
|
2168
|
+
finalEmbedding = finalEmbedding.map((n) => Number(n));
|
|
2169
|
+
if (!Array.isArray(finalEmbedding) || finalEmbedding[0] === void 0) {
|
|
2170
|
+
throw new Error(
|
|
2171
|
+
"Invalid embedding format: must be an array starting with a number"
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
if (finalEmbedding.length !== 384) {
|
|
2175
|
+
logger_default.warn(
|
|
2176
|
+
`Unexpected embedding dimension: ${finalEmbedding.length}`
|
|
2177
|
+
);
|
|
2178
|
+
}
|
|
2179
|
+
return finalEmbedding;
|
|
2180
|
+
}
|
|
2181
|
+
async reset() {
|
|
2182
|
+
if (this.model) {
|
|
2183
|
+
this.model = null;
|
|
2184
|
+
}
|
|
2185
|
+
this.initPromise = null;
|
|
2186
|
+
this.initializationLock = false;
|
|
2187
|
+
}
|
|
2188
|
+
// For testing purposes
|
|
2189
|
+
static resetInstance() {
|
|
2190
|
+
if (_LocalEmbeddingModelManager.instance) {
|
|
2191
|
+
_LocalEmbeddingModelManager.instance.reset();
|
|
2192
|
+
_LocalEmbeddingModelManager.instance = null;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
};
|
|
2196
|
+
var localembeddingManager_default = LocalEmbeddingModelManager;
|
|
2197
|
+
|
|
1573
2198
|
// src/embedding.ts
|
|
1574
2199
|
var EmbeddingProvider = {
|
|
1575
2200
|
OpenAI: "OpenAI",
|
|
1576
2201
|
Ollama: "Ollama",
|
|
1577
2202
|
GaiaNet: "GaiaNet",
|
|
2203
|
+
Heurist: "Heurist",
|
|
1578
2204
|
BGE: "BGE"
|
|
1579
2205
|
};
|
|
1580
2206
|
var getEmbeddingConfig = () => ({
|
|
1581
|
-
dimensions: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ?
|
|
2207
|
+
dimensions: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("openai" /* OPENAI */).dimensions : settings_default.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("ollama" /* OLLAMA */).dimensions : settings_default.USE_GAIANET_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("gaianet" /* GAIANET */).dimensions : settings_default.USE_HEURIST_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("heurist" /* HEURIST */).dimensions : 384,
|
|
1582
2208
|
// BGE
|
|
1583
|
-
model: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ? "
|
|
1584
|
-
provider: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ? "OpenAI" : settings_default.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true" ? "Ollama" : settings_default.USE_GAIANET_EMBEDDING?.toLowerCase() === "true" ? "GaiaNet" : "BGE"
|
|
2209
|
+
model: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("openai" /* OPENAI */).name : settings_default.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("ollama" /* OLLAMA */).name : settings_default.USE_GAIANET_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("gaianet" /* GAIANET */).name : settings_default.USE_HEURIST_EMBEDDING?.toLowerCase() === "true" ? getEmbeddingModelSettings("heurist" /* HEURIST */).name : "BGE-small-en-v1.5",
|
|
2210
|
+
provider: settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true" ? "OpenAI" : settings_default.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true" ? "Ollama" : settings_default.USE_GAIANET_EMBEDDING?.toLowerCase() === "true" ? "GaiaNet" : settings_default.USE_HEURIST_EMBEDDING?.toLowerCase() === "true" ? "Heurist" : "BGE"
|
|
1585
2211
|
});
|
|
1586
2212
|
async function getRemoteEmbedding(input, options) {
|
|
1587
2213
|
const baseEndpoint = options.endpoint.endsWith("/v1") ? options.endpoint : `${options.endpoint}${options.isOllama ? "/v1" : ""}`;
|
|
@@ -1618,17 +2244,27 @@ async function getRemoteEmbedding(input, options) {
|
|
|
1618
2244
|
}
|
|
1619
2245
|
function getEmbeddingType(runtime) {
|
|
1620
2246
|
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1621
|
-
const isLocal = isNode && runtime.character.modelProvider !== "openai" /* OPENAI */ && runtime.character.modelProvider !== "gaianet" /* GAIANET */ && !settings_default.USE_OPENAI_EMBEDDING;
|
|
2247
|
+
const isLocal = isNode && runtime.character.modelProvider !== "openai" /* OPENAI */ && runtime.character.modelProvider !== "gaianet" /* GAIANET */ && runtime.character.modelProvider !== "heurist" /* HEURIST */ && !settings_default.USE_OPENAI_EMBEDDING;
|
|
1622
2248
|
return isLocal ? "local" : "remote";
|
|
1623
2249
|
}
|
|
1624
2250
|
function getEmbeddingZeroVector() {
|
|
1625
2251
|
let embeddingDimension = 384;
|
|
1626
2252
|
if (settings_default.USE_OPENAI_EMBEDDING?.toLowerCase() === "true") {
|
|
1627
|
-
embeddingDimension =
|
|
2253
|
+
embeddingDimension = getEmbeddingModelSettings(
|
|
2254
|
+
"openai" /* OPENAI */
|
|
2255
|
+
).dimensions;
|
|
1628
2256
|
} else if (settings_default.USE_OLLAMA_EMBEDDING?.toLowerCase() === "true") {
|
|
1629
|
-
embeddingDimension =
|
|
2257
|
+
embeddingDimension = getEmbeddingModelSettings(
|
|
2258
|
+
"ollama" /* OLLAMA */
|
|
2259
|
+
).dimensions;
|
|
1630
2260
|
} else if (settings_default.USE_GAIANET_EMBEDDING?.toLowerCase() === "true") {
|
|
1631
|
-
embeddingDimension =
|
|
2261
|
+
embeddingDimension = getEmbeddingModelSettings(
|
|
2262
|
+
"gaianet" /* GAIANET */
|
|
2263
|
+
).dimensions;
|
|
2264
|
+
} else if (settings_default.USE_HEURIST_EMBEDDING?.toLowerCase() === "true") {
|
|
2265
|
+
embeddingDimension = getEmbeddingModelSettings(
|
|
2266
|
+
"heurist" /* HEURIST */
|
|
2267
|
+
).dimensions;
|
|
1632
2268
|
}
|
|
1633
2269
|
return Array(embeddingDimension).fill(0);
|
|
1634
2270
|
}
|
|
@@ -1665,7 +2301,7 @@ async function embed(runtime, input) {
|
|
|
1665
2301
|
if (config2.provider === EmbeddingProvider.Ollama) {
|
|
1666
2302
|
return await getRemoteEmbedding(input, {
|
|
1667
2303
|
model: config2.model,
|
|
1668
|
-
endpoint: runtime.character.modelEndpointOverride ||
|
|
2304
|
+
endpoint: runtime.character.modelEndpointOverride || getEndpoint("ollama" /* OLLAMA */),
|
|
1669
2305
|
isOllama: true,
|
|
1670
2306
|
dimensions: config2.dimensions
|
|
1671
2307
|
});
|
|
@@ -1673,11 +2309,19 @@ async function embed(runtime, input) {
|
|
|
1673
2309
|
if (config2.provider == EmbeddingProvider.GaiaNet) {
|
|
1674
2310
|
return await getRemoteEmbedding(input, {
|
|
1675
2311
|
model: config2.model,
|
|
1676
|
-
endpoint: runtime.character.modelEndpointOverride ||
|
|
2312
|
+
endpoint: runtime.character.modelEndpointOverride || getEndpoint("gaianet" /* GAIANET */) || settings_default.SMALL_GAIANET_SERVER_URL || settings_default.MEDIUM_GAIANET_SERVER_URL || settings_default.LARGE_GAIANET_SERVER_URL,
|
|
1677
2313
|
apiKey: settings_default.GAIANET_API_KEY || runtime.token,
|
|
1678
2314
|
dimensions: config2.dimensions
|
|
1679
2315
|
});
|
|
1680
2316
|
}
|
|
2317
|
+
if (config2.provider === EmbeddingProvider.Heurist) {
|
|
2318
|
+
return await getRemoteEmbedding(input, {
|
|
2319
|
+
model: config2.model,
|
|
2320
|
+
endpoint: getEndpoint("heurist" /* HEURIST */),
|
|
2321
|
+
apiKey: runtime.token,
|
|
2322
|
+
dimensions: config2.dimensions
|
|
2323
|
+
});
|
|
2324
|
+
}
|
|
1681
2325
|
if (isNode) {
|
|
1682
2326
|
try {
|
|
1683
2327
|
return await getLocalEmbedding(input);
|
|
@@ -1690,102 +2334,18 @@ async function embed(runtime, input) {
|
|
|
1690
2334
|
}
|
|
1691
2335
|
return await getRemoteEmbedding(input, {
|
|
1692
2336
|
model: config2.model,
|
|
1693
|
-
endpoint: runtime.character.modelEndpointOverride ||
|
|
2337
|
+
endpoint: runtime.character.modelEndpointOverride || getEndpoint(runtime.character.modelProvider),
|
|
1694
2338
|
apiKey: runtime.token,
|
|
1695
2339
|
dimensions: config2.dimensions
|
|
1696
2340
|
});
|
|
1697
2341
|
async function getLocalEmbedding(input2) {
|
|
1698
2342
|
logger_default.debug("DEBUG - Inside getLocalEmbedding function");
|
|
1699
|
-
const isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
1700
|
-
if (!isNode2) {
|
|
1701
|
-
logger_default.warn(
|
|
1702
|
-
"Local embedding not supported in browser, falling back to remote embedding"
|
|
1703
|
-
);
|
|
1704
|
-
throw new Error("Local embedding not supported in browser");
|
|
1705
|
-
}
|
|
1706
2343
|
try {
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
return rootPath.split("/eliza/")[0] + "/eliza/";
|
|
1713
|
-
}
|
|
1714
|
-
return path3.resolve(__dirname3, "..");
|
|
1715
|
-
};
|
|
1716
|
-
const moduleImports = await Promise.all([
|
|
1717
|
-
import("fs"),
|
|
1718
|
-
import("url"),
|
|
1719
|
-
(async () => {
|
|
1720
|
-
try {
|
|
1721
|
-
return await import("fastembed");
|
|
1722
|
-
} catch {
|
|
1723
|
-
logger_default.error("Failed to load fastembed.");
|
|
1724
|
-
throw new Error(
|
|
1725
|
-
"fastembed import failed, falling back to remote embedding"
|
|
1726
|
-
);
|
|
1727
|
-
}
|
|
1728
|
-
})()
|
|
1729
|
-
]);
|
|
1730
|
-
const [fs3, { fileURLToPath: fileURLToPath2 }, fastEmbed] = moduleImports;
|
|
1731
|
-
const { FlagEmbedding, EmbeddingModel } = fastEmbed;
|
|
1732
|
-
const cacheDir = getRootPath() + "/cache/";
|
|
1733
|
-
if (!fs3.existsSync(cacheDir)) {
|
|
1734
|
-
fs3.mkdirSync(cacheDir, { recursive: true });
|
|
1735
|
-
}
|
|
1736
|
-
logger_default.debug("Initializing BGE embedding model...");
|
|
1737
|
-
const embeddingModel = await FlagEmbedding.init({
|
|
1738
|
-
cacheDir,
|
|
1739
|
-
model: EmbeddingModel.BGESmallENV15,
|
|
1740
|
-
// BGE-small-en-v1.5 specific settings
|
|
1741
|
-
maxLength: 512
|
|
1742
|
-
// BGE's context window
|
|
1743
|
-
});
|
|
1744
|
-
logger_default.debug("Generating embedding for input:", {
|
|
1745
|
-
inputLength: input2.length,
|
|
1746
|
-
inputPreview: input2.slice(0, 100) + "..."
|
|
1747
|
-
});
|
|
1748
|
-
const embedding = await embeddingModel.queryEmbed(input2);
|
|
1749
|
-
logger_default.debug("Raw embedding from BGE:", {
|
|
1750
|
-
type: typeof embedding,
|
|
1751
|
-
isArray: Array.isArray(embedding),
|
|
1752
|
-
dimensions: Array.isArray(embedding) ? embedding.length : "not an array",
|
|
1753
|
-
sample: Array.isArray(embedding) ? embedding.slice(0, 5) : embedding
|
|
1754
|
-
});
|
|
1755
|
-
let finalEmbedding;
|
|
1756
|
-
if (ArrayBuffer.isView(embedding) && embedding.constructor === Float32Array) {
|
|
1757
|
-
finalEmbedding = Array.from(embedding);
|
|
1758
|
-
} else if (Array.isArray(embedding) && ArrayBuffer.isView(embedding[0]) && embedding[0].constructor === Float32Array) {
|
|
1759
|
-
finalEmbedding = Array.from(embedding[0]);
|
|
1760
|
-
} else if (Array.isArray(embedding)) {
|
|
1761
|
-
finalEmbedding = embedding;
|
|
1762
|
-
} else {
|
|
1763
|
-
throw new Error(
|
|
1764
|
-
`Unexpected embedding format: ${typeof embedding}`
|
|
1765
|
-
);
|
|
1766
|
-
}
|
|
1767
|
-
logger_default.debug("Processed embedding:", {
|
|
1768
|
-
length: finalEmbedding.length,
|
|
1769
|
-
sample: finalEmbedding.slice(0, 5),
|
|
1770
|
-
allNumbers: finalEmbedding.every((n) => typeof n === "number")
|
|
1771
|
-
});
|
|
1772
|
-
finalEmbedding = finalEmbedding.map((n) => Number(n));
|
|
1773
|
-
if (!Array.isArray(finalEmbedding) || finalEmbedding[0] === void 0) {
|
|
1774
|
-
throw new Error(
|
|
1775
|
-
"Invalid embedding format: must be an array starting with a number"
|
|
1776
|
-
);
|
|
1777
|
-
}
|
|
1778
|
-
if (finalEmbedding.length !== 384) {
|
|
1779
|
-
logger_default.warn(
|
|
1780
|
-
`Unexpected embedding dimension: ${finalEmbedding.length} (expected 384)`
|
|
1781
|
-
);
|
|
1782
|
-
}
|
|
1783
|
-
return finalEmbedding;
|
|
1784
|
-
} catch {
|
|
1785
|
-
logger_default.warn(
|
|
1786
|
-
"Local embedding not supported in browser, falling back to remote embedding"
|
|
1787
|
-
);
|
|
1788
|
-
throw new Error("Local embedding not supported in browser");
|
|
2344
|
+
const embeddingManager = localembeddingManager_default.getInstance();
|
|
2345
|
+
return await embeddingManager.generateEmbedding(input2);
|
|
2346
|
+
} catch (error) {
|
|
2347
|
+
logger_default.error("Local embedding failed:", error);
|
|
2348
|
+
throw error;
|
|
1789
2349
|
}
|
|
1790
2350
|
}
|
|
1791
2351
|
async function retrieveCachedEmbedding(runtime2, input2) {
|
|
@@ -1925,6 +2485,27 @@ var parseActionResponseFromText = (text) => {
|
|
|
1925
2485
|
}
|
|
1926
2486
|
return { actions };
|
|
1927
2487
|
};
|
|
2488
|
+
function truncateToCompleteSentence(text, maxLength) {
|
|
2489
|
+
if (text.length <= maxLength) {
|
|
2490
|
+
return text;
|
|
2491
|
+
}
|
|
2492
|
+
const lastPeriodIndex = text.lastIndexOf(".", maxLength - 1);
|
|
2493
|
+
if (lastPeriodIndex !== -1) {
|
|
2494
|
+
const truncatedAtPeriod = text.slice(0, lastPeriodIndex + 1).trim();
|
|
2495
|
+
if (truncatedAtPeriod.length > 0) {
|
|
2496
|
+
return truncatedAtPeriod;
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
const lastSpaceIndex = text.lastIndexOf(" ", maxLength - 1);
|
|
2500
|
+
if (lastSpaceIndex !== -1) {
|
|
2501
|
+
const truncatedAtSpace = text.slice(0, lastSpaceIndex).trim();
|
|
2502
|
+
if (truncatedAtSpace.length > 0) {
|
|
2503
|
+
return truncatedAtSpace + "...";
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
const hardTruncated = text.slice(0, maxLength - 3).trim();
|
|
2507
|
+
return hardTruncated + "...";
|
|
2508
|
+
}
|
|
1928
2509
|
|
|
1929
2510
|
// src/evaluators.ts
|
|
1930
2511
|
var evaluationTemplate = `TASK: Based on the conversation and conditions, determine which evaluation functions are appropriate to call.
|
|
@@ -2003,6 +2584,7 @@ function formatEvaluatorExampleDescriptions(evaluators) {
|
|
|
2003
2584
|
// src/generation.ts
|
|
2004
2585
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2005
2586
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2587
|
+
import { createMistral } from "@ai-sdk/mistral";
|
|
2006
2588
|
import { createGroq } from "@ai-sdk/groq";
|
|
2007
2589
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
2008
2590
|
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
|
|
@@ -29801,6 +30383,37 @@ async function truncateTiktoken(model, context, maxTokens) {
|
|
|
29801
30383
|
return context.slice(-maxTokens * 4);
|
|
29802
30384
|
}
|
|
29803
30385
|
}
|
|
30386
|
+
function getCloudflareGatewayBaseURL(runtime, provider) {
|
|
30387
|
+
const isCloudflareEnabled = runtime.getSetting("CLOUDFLARE_GW_ENABLED") === "true";
|
|
30388
|
+
const cloudflareAccountId = runtime.getSetting("CLOUDFLARE_AI_ACCOUNT_ID");
|
|
30389
|
+
const cloudflareGatewayId = runtime.getSetting("CLOUDFLARE_AI_GATEWAY_ID");
|
|
30390
|
+
elizaLogger.debug("Cloudflare Gateway Configuration:", {
|
|
30391
|
+
isEnabled: isCloudflareEnabled,
|
|
30392
|
+
hasAccountId: !!cloudflareAccountId,
|
|
30393
|
+
hasGatewayId: !!cloudflareGatewayId,
|
|
30394
|
+
provider
|
|
30395
|
+
});
|
|
30396
|
+
if (!isCloudflareEnabled) {
|
|
30397
|
+
elizaLogger.debug("Cloudflare Gateway is not enabled");
|
|
30398
|
+
return void 0;
|
|
30399
|
+
}
|
|
30400
|
+
if (!cloudflareAccountId) {
|
|
30401
|
+
elizaLogger.warn("Cloudflare Gateway is enabled but CLOUDFLARE_AI_ACCOUNT_ID is not set");
|
|
30402
|
+
return void 0;
|
|
30403
|
+
}
|
|
30404
|
+
if (!cloudflareGatewayId) {
|
|
30405
|
+
elizaLogger.warn("Cloudflare Gateway is enabled but CLOUDFLARE_AI_GATEWAY_ID is not set");
|
|
30406
|
+
return void 0;
|
|
30407
|
+
}
|
|
30408
|
+
const baseURL = `https://gateway.ai.cloudflare.com/v1/${cloudflareAccountId}/${cloudflareGatewayId}/${provider.toLowerCase()}`;
|
|
30409
|
+
elizaLogger.info("Using Cloudflare Gateway:", {
|
|
30410
|
+
provider,
|
|
30411
|
+
baseURL,
|
|
30412
|
+
accountId: cloudflareAccountId,
|
|
30413
|
+
gatewayId: cloudflareGatewayId
|
|
30414
|
+
});
|
|
30415
|
+
return baseURL;
|
|
30416
|
+
}
|
|
29804
30417
|
async function generateText({
|
|
29805
30418
|
runtime,
|
|
29806
30419
|
context,
|
|
@@ -29809,7 +30422,9 @@ async function generateText({
|
|
|
29809
30422
|
onStepFinish,
|
|
29810
30423
|
maxSteps = 1,
|
|
29811
30424
|
stop,
|
|
29812
|
-
customSystemPrompt
|
|
30425
|
+
customSystemPrompt,
|
|
30426
|
+
verifiableInference = process.env.VERIFIABLE_INFERENCE_ENABLED === "true",
|
|
30427
|
+
verifiableInferenceOptions
|
|
29813
30428
|
}) {
|
|
29814
30429
|
if (!context) {
|
|
29815
30430
|
console.error("generateText context is empty");
|
|
@@ -29818,11 +30433,45 @@ async function generateText({
|
|
|
29818
30433
|
elizaLogger.log("Generating text...");
|
|
29819
30434
|
elizaLogger.info("Generating text with options:", {
|
|
29820
30435
|
modelProvider: runtime.modelProvider,
|
|
29821
|
-
model: modelClass
|
|
30436
|
+
model: modelClass,
|
|
30437
|
+
verifiableInference
|
|
29822
30438
|
});
|
|
30439
|
+
elizaLogger.log("Using provider:", runtime.modelProvider);
|
|
30440
|
+
if (verifiableInference && runtime.verifiableInferenceAdapter) {
|
|
30441
|
+
elizaLogger.log(
|
|
30442
|
+
"Using verifiable inference adapter:",
|
|
30443
|
+
runtime.verifiableInferenceAdapter
|
|
30444
|
+
);
|
|
30445
|
+
try {
|
|
30446
|
+
const result = await runtime.verifiableInferenceAdapter.generateText(
|
|
30447
|
+
context,
|
|
30448
|
+
modelClass,
|
|
30449
|
+
verifiableInferenceOptions
|
|
30450
|
+
);
|
|
30451
|
+
elizaLogger.log("Verifiable inference result:", result);
|
|
30452
|
+
const isValid = await runtime.verifiableInferenceAdapter.verifyProof(result);
|
|
30453
|
+
if (!isValid) {
|
|
30454
|
+
throw new Error("Failed to verify inference proof");
|
|
30455
|
+
}
|
|
30456
|
+
return result.text;
|
|
30457
|
+
} catch (error) {
|
|
30458
|
+
elizaLogger.error("Error in verifiable inference:", error);
|
|
30459
|
+
throw error;
|
|
30460
|
+
}
|
|
30461
|
+
}
|
|
29823
30462
|
const provider = runtime.modelProvider;
|
|
29824
|
-
|
|
29825
|
-
|
|
30463
|
+
elizaLogger.debug("Provider settings:", {
|
|
30464
|
+
provider,
|
|
30465
|
+
hasRuntime: !!runtime,
|
|
30466
|
+
runtimeSettings: {
|
|
30467
|
+
CLOUDFLARE_GW_ENABLED: runtime.getSetting("CLOUDFLARE_GW_ENABLED"),
|
|
30468
|
+
CLOUDFLARE_AI_ACCOUNT_ID: runtime.getSetting("CLOUDFLARE_AI_ACCOUNT_ID"),
|
|
30469
|
+
CLOUDFLARE_AI_GATEWAY_ID: runtime.getSetting("CLOUDFLARE_AI_GATEWAY_ID")
|
|
30470
|
+
}
|
|
30471
|
+
});
|
|
30472
|
+
const endpoint = runtime.character.modelEndpointOverride || getEndpoint(provider);
|
|
30473
|
+
const modelSettings = getModelSettings(runtime.modelProvider, modelClass);
|
|
30474
|
+
let model = modelSettings.name;
|
|
29826
30475
|
switch (provider) {
|
|
29827
30476
|
// if runtime.getSetting("LLAMACLOUD_MODEL_LARGE") is true and modelProvider is LLAMACLOUD, then use the large model
|
|
29828
30477
|
case "llama_cloud" /* LLAMACLOUD */:
|
|
@@ -29876,12 +30525,12 @@ async function generateText({
|
|
|
29876
30525
|
}
|
|
29877
30526
|
elizaLogger.info("Selected model:", model);
|
|
29878
30527
|
const modelConfiguration = runtime.character?.settings?.modelConfig;
|
|
29879
|
-
const temperature = modelConfiguration?.temperature ||
|
|
29880
|
-
const frequency_penalty = modelConfiguration?.frequency_penalty ||
|
|
29881
|
-
const presence_penalty = modelConfiguration?.presence_penalty ||
|
|
29882
|
-
const max_context_length = modelConfiguration?.maxInputTokens ||
|
|
29883
|
-
const max_response_length = modelConfiguration?.max_response_length ||
|
|
29884
|
-
const experimental_telemetry = modelConfiguration?.experimental_telemetry ||
|
|
30528
|
+
const temperature = modelConfiguration?.temperature || modelSettings.temperature;
|
|
30529
|
+
const frequency_penalty = modelConfiguration?.frequency_penalty || modelSettings.frequency_penalty;
|
|
30530
|
+
const presence_penalty = modelConfiguration?.presence_penalty || modelSettings.presence_penalty;
|
|
30531
|
+
const max_context_length = modelConfiguration?.maxInputTokens || modelSettings.maxInputTokens;
|
|
30532
|
+
const max_response_length = modelConfiguration?.max_response_length || modelSettings.maxOutputTokens;
|
|
30533
|
+
const experimental_telemetry = modelConfiguration?.experimental_telemetry || modelSettings.experimental_telemetry;
|
|
29885
30534
|
const apiKey = runtime.token;
|
|
29886
30535
|
try {
|
|
29887
30536
|
elizaLogger.debug(
|
|
@@ -29889,7 +30538,7 @@ async function generateText({
|
|
|
29889
30538
|
);
|
|
29890
30539
|
context = await trimTokens(context, max_context_length, runtime);
|
|
29891
30540
|
let response;
|
|
29892
|
-
const _stop = stop ||
|
|
30541
|
+
const _stop = stop || modelSettings.stop;
|
|
29893
30542
|
elizaLogger.debug(
|
|
29894
30543
|
`Using provider: ${provider}, model: ${model}, temperature: ${temperature}, max response length: ${max_response_length}`
|
|
29895
30544
|
);
|
|
@@ -29902,11 +30551,13 @@ async function generateText({
|
|
|
29902
30551
|
case "nanogpt" /* NANOGPT */:
|
|
29903
30552
|
case "hyperbolic" /* HYPERBOLIC */:
|
|
29904
30553
|
case "together" /* TOGETHER */:
|
|
30554
|
+
case "nineteen_ai" /* NINETEEN_AI */:
|
|
29905
30555
|
case "akash_chat_api" /* AKASH_CHAT_API */: {
|
|
29906
|
-
elizaLogger.debug("Initializing OpenAI model
|
|
30556
|
+
elizaLogger.debug("Initializing OpenAI model with Cloudflare check");
|
|
30557
|
+
const baseURL2 = getCloudflareGatewayBaseURL(runtime, "openai") || endpoint;
|
|
29907
30558
|
const openai = createOpenAI({
|
|
29908
30559
|
apiKey,
|
|
29909
|
-
baseURL:
|
|
30560
|
+
baseURL: baseURL2,
|
|
29910
30561
|
fetch: runtime.fetch
|
|
29911
30562
|
});
|
|
29912
30563
|
const { text: openaiResponse } = await aiGenerateText({
|
|
@@ -29923,7 +30574,7 @@ async function generateText({
|
|
|
29923
30574
|
experimental_telemetry
|
|
29924
30575
|
});
|
|
29925
30576
|
response = openaiResponse;
|
|
29926
|
-
|
|
30577
|
+
console.log("Received response from OpenAI model.");
|
|
29927
30578
|
break;
|
|
29928
30579
|
}
|
|
29929
30580
|
case "eternalai" /* ETERNALAI */: {
|
|
@@ -29932,21 +30583,31 @@ async function generateText({
|
|
|
29932
30583
|
apiKey,
|
|
29933
30584
|
baseURL: endpoint,
|
|
29934
30585
|
fetch: async (url, options) => {
|
|
30586
|
+
const chain_id = runtime.getSetting("ETERNALAI_CHAIN_ID") || "45762";
|
|
30587
|
+
if (options?.body) {
|
|
30588
|
+
const body = JSON.parse(options.body);
|
|
30589
|
+
body.chain_id = chain_id;
|
|
30590
|
+
options.body = JSON.stringify(body);
|
|
30591
|
+
}
|
|
29935
30592
|
const fetching = await runtime.fetch(url, options);
|
|
29936
30593
|
if (parseBooleanFromText(
|
|
29937
|
-
runtime.getSetting("
|
|
30594
|
+
runtime.getSetting("ETERNALAI_LOG")
|
|
29938
30595
|
)) {
|
|
29939
30596
|
elizaLogger.info(
|
|
29940
30597
|
"Request data: ",
|
|
29941
30598
|
JSON.stringify(options, null, 2)
|
|
29942
30599
|
);
|
|
29943
30600
|
const clonedResponse = fetching.clone();
|
|
29944
|
-
|
|
29945
|
-
|
|
29946
|
-
|
|
29947
|
-
|
|
29948
|
-
|
|
29949
|
-
|
|
30601
|
+
try {
|
|
30602
|
+
clonedResponse.json().then((data) => {
|
|
30603
|
+
elizaLogger.info(
|
|
30604
|
+
"Response data: ",
|
|
30605
|
+
JSON.stringify(data, null, 2)
|
|
30606
|
+
);
|
|
30607
|
+
});
|
|
30608
|
+
} catch (e) {
|
|
30609
|
+
elizaLogger.debug(e);
|
|
30610
|
+
}
|
|
29950
30611
|
}
|
|
29951
30612
|
return fetching;
|
|
29952
30613
|
}
|
|
@@ -29986,12 +30647,26 @@ async function generateText({
|
|
|
29986
30647
|
elizaLogger.debug("Received response from Google model.");
|
|
29987
30648
|
break;
|
|
29988
30649
|
}
|
|
29989
|
-
case "
|
|
29990
|
-
|
|
29991
|
-
const
|
|
29992
|
-
|
|
29993
|
-
|
|
30650
|
+
case "mistral" /* MISTRAL */: {
|
|
30651
|
+
const mistral = createMistral();
|
|
30652
|
+
const { text: mistralResponse } = await aiGenerateText({
|
|
30653
|
+
model: mistral(model),
|
|
30654
|
+
prompt: context,
|
|
30655
|
+
system: runtime.character.system ?? settings_default.SYSTEM_PROMPT ?? void 0,
|
|
30656
|
+
temperature,
|
|
30657
|
+
maxTokens: max_response_length,
|
|
30658
|
+
frequencyPenalty: frequency_penalty,
|
|
30659
|
+
presencePenalty: presence_penalty
|
|
29994
30660
|
});
|
|
30661
|
+
response = mistralResponse;
|
|
30662
|
+
elizaLogger.debug("Received response from Mistral model.");
|
|
30663
|
+
break;
|
|
30664
|
+
}
|
|
30665
|
+
case "anthropic" /* ANTHROPIC */: {
|
|
30666
|
+
elizaLogger.debug("Initializing Anthropic model with Cloudflare check");
|
|
30667
|
+
const baseURL2 = getCloudflareGatewayBaseURL(runtime, "anthropic") || "https://api.anthropic.com/v1";
|
|
30668
|
+
elizaLogger.debug("Anthropic baseURL result:", { baseURL: baseURL2 });
|
|
30669
|
+
const anthropic = createAnthropic({ apiKey, baseURL: baseURL2, fetch: runtime.fetch });
|
|
29995
30670
|
const { text: anthropicResponse } = await aiGenerateText({
|
|
29996
30671
|
model: anthropic.languageModel(model),
|
|
29997
30672
|
prompt: context,
|
|
@@ -30061,7 +30736,10 @@ async function generateText({
|
|
|
30061
30736
|
break;
|
|
30062
30737
|
}
|
|
30063
30738
|
case "groq" /* GROQ */: {
|
|
30064
|
-
|
|
30739
|
+
elizaLogger.debug("Initializing Groq model with Cloudflare check");
|
|
30740
|
+
const baseURL2 = getCloudflareGatewayBaseURL(runtime, "groq");
|
|
30741
|
+
elizaLogger.debug("Groq baseURL result:", { baseURL: baseURL2 });
|
|
30742
|
+
const groq = createGroq({ apiKey, fetch: runtime.fetch, baseURL: baseURL2 });
|
|
30065
30743
|
const { text: groqResponse } = await aiGenerateText({
|
|
30066
30744
|
model: groq.languageModel(model),
|
|
30067
30745
|
prompt: context,
|
|
@@ -30076,6 +30754,7 @@ async function generateText({
|
|
|
30076
30754
|
experimental_telemetry
|
|
30077
30755
|
});
|
|
30078
30756
|
response = groqResponse;
|
|
30757
|
+
elizaLogger.debug("Received response from Groq model.");
|
|
30079
30758
|
break;
|
|
30080
30759
|
}
|
|
30081
30760
|
case "llama_local" /* LLAMALOCAL */: {
|
|
@@ -30101,7 +30780,7 @@ async function generateText({
|
|
|
30101
30780
|
}
|
|
30102
30781
|
case "redpill" /* REDPILL */: {
|
|
30103
30782
|
elizaLogger.debug("Initializing RedPill model.");
|
|
30104
|
-
const serverUrl =
|
|
30783
|
+
const serverUrl = getEndpoint(provider);
|
|
30105
30784
|
const openai = createOpenAI({
|
|
30106
30785
|
apiKey,
|
|
30107
30786
|
baseURL: serverUrl,
|
|
@@ -30126,7 +30805,7 @@ async function generateText({
|
|
|
30126
30805
|
}
|
|
30127
30806
|
case "openrouter" /* OPENROUTER */: {
|
|
30128
30807
|
elizaLogger.debug("Initializing OpenRouter model.");
|
|
30129
|
-
const serverUrl =
|
|
30808
|
+
const serverUrl = getEndpoint(provider);
|
|
30130
30809
|
const openrouter = createOpenAI({
|
|
30131
30810
|
apiKey,
|
|
30132
30811
|
baseURL: serverUrl,
|
|
@@ -30153,7 +30832,7 @@ async function generateText({
|
|
|
30153
30832
|
{
|
|
30154
30833
|
elizaLogger.debug("Initializing Ollama model.");
|
|
30155
30834
|
const ollamaProvider = createOllama({
|
|
30156
|
-
baseURL:
|
|
30835
|
+
baseURL: getEndpoint(provider) + "/api",
|
|
30157
30836
|
fetch: runtime.fetch
|
|
30158
30837
|
});
|
|
30159
30838
|
const ollama = ollamaProvider(model);
|
|
@@ -30200,7 +30879,7 @@ async function generateText({
|
|
|
30200
30879
|
}
|
|
30201
30880
|
case "gaianet" /* GAIANET */: {
|
|
30202
30881
|
elizaLogger.debug("Initializing GAIANET model.");
|
|
30203
|
-
var baseURL =
|
|
30882
|
+
var baseURL = getEndpoint(provider);
|
|
30204
30883
|
if (!baseURL) {
|
|
30205
30884
|
switch (modelClass) {
|
|
30206
30885
|
case "small" /* SMALL */:
|
|
@@ -30239,7 +30918,15 @@ async function generateText({
|
|
|
30239
30918
|
}
|
|
30240
30919
|
case "galadriel" /* GALADRIEL */: {
|
|
30241
30920
|
elizaLogger.debug("Initializing Galadriel model.");
|
|
30921
|
+
const headers = {};
|
|
30922
|
+
const fineTuneApiKey = runtime.getSetting(
|
|
30923
|
+
"GALADRIEL_FINE_TUNE_API_KEY"
|
|
30924
|
+
);
|
|
30925
|
+
if (fineTuneApiKey) {
|
|
30926
|
+
headers["Fine-Tune-Authentication"] = fineTuneApiKey;
|
|
30927
|
+
}
|
|
30242
30928
|
const galadriel = createOpenAI({
|
|
30929
|
+
headers,
|
|
30243
30930
|
apiKey,
|
|
30244
30931
|
baseURL: endpoint,
|
|
30245
30932
|
fetch: runtime.fetch
|
|
@@ -30261,6 +30948,30 @@ async function generateText({
|
|
|
30261
30948
|
elizaLogger.debug("Received response from Galadriel model.");
|
|
30262
30949
|
break;
|
|
30263
30950
|
}
|
|
30951
|
+
case "infera" /* INFERA */: {
|
|
30952
|
+
elizaLogger.debug("Initializing Infera model.");
|
|
30953
|
+
const apiKey2 = settings_default.INFERA_API_KEY || runtime.token;
|
|
30954
|
+
const infera = createOpenAI({
|
|
30955
|
+
apiKey: apiKey2,
|
|
30956
|
+
baseURL: endpoint,
|
|
30957
|
+
headers: {
|
|
30958
|
+
api_key: apiKey2,
|
|
30959
|
+
"Content-Type": "application/json"
|
|
30960
|
+
}
|
|
30961
|
+
});
|
|
30962
|
+
const { text: inferaResponse } = await aiGenerateText({
|
|
30963
|
+
model: infera.languageModel(model),
|
|
30964
|
+
prompt: context,
|
|
30965
|
+
system: runtime.character.system ?? settings_default.SYSTEM_PROMPT ?? void 0,
|
|
30966
|
+
temperature,
|
|
30967
|
+
maxTokens: max_response_length,
|
|
30968
|
+
frequencyPenalty: frequency_penalty,
|
|
30969
|
+
presencePenalty: presence_penalty
|
|
30970
|
+
});
|
|
30971
|
+
response = inferaResponse;
|
|
30972
|
+
elizaLogger.debug("Received response from Infera model.");
|
|
30973
|
+
break;
|
|
30974
|
+
}
|
|
30264
30975
|
case "venice" /* VENICE */: {
|
|
30265
30976
|
elizaLogger.debug("Initializing Venice model.");
|
|
30266
30977
|
const venice = createOpenAI({
|
|
@@ -30277,8 +30988,33 @@ async function generateText({
|
|
|
30277
30988
|
maxSteps,
|
|
30278
30989
|
maxTokens: max_response_length
|
|
30279
30990
|
});
|
|
30280
|
-
response = veniceResponse;
|
|
30281
|
-
elizaLogger.debug("Received response from Venice model.");
|
|
30991
|
+
response = veniceResponse;
|
|
30992
|
+
elizaLogger.debug("Received response from Venice model.");
|
|
30993
|
+
break;
|
|
30994
|
+
}
|
|
30995
|
+
case "deepseek" /* DEEPSEEK */: {
|
|
30996
|
+
elizaLogger.debug("Initializing Deepseek model.");
|
|
30997
|
+
const serverUrl = models[provider].endpoint;
|
|
30998
|
+
const deepseek = createOpenAI({
|
|
30999
|
+
apiKey,
|
|
31000
|
+
baseURL: serverUrl,
|
|
31001
|
+
fetch: runtime.fetch
|
|
31002
|
+
});
|
|
31003
|
+
const { text: deepseekResponse } = await aiGenerateText({
|
|
31004
|
+
model: deepseek.languageModel(model),
|
|
31005
|
+
prompt: context,
|
|
31006
|
+
temperature,
|
|
31007
|
+
system: runtime.character.system ?? settings_default.SYSTEM_PROMPT ?? void 0,
|
|
31008
|
+
tools,
|
|
31009
|
+
onStepFinish,
|
|
31010
|
+
maxSteps,
|
|
31011
|
+
maxTokens: max_response_length,
|
|
31012
|
+
frequencyPenalty: frequency_penalty,
|
|
31013
|
+
presencePenalty: presence_penalty,
|
|
31014
|
+
experimental_telemetry
|
|
31015
|
+
});
|
|
31016
|
+
response = deepseekResponse;
|
|
31017
|
+
elizaLogger.debug("Received response from Deepseek model.");
|
|
30282
31018
|
break;
|
|
30283
31019
|
}
|
|
30284
31020
|
default: {
|
|
@@ -30344,11 +31080,9 @@ async function generateTrueOrFalse({
|
|
|
30344
31080
|
modelClass
|
|
30345
31081
|
}) {
|
|
30346
31082
|
let retryDelay = 1e3;
|
|
31083
|
+
const modelSettings = getModelSettings(runtime.modelProvider, modelClass);
|
|
30347
31084
|
const stop = Array.from(
|
|
30348
|
-
/* @__PURE__ */ new Set([
|
|
30349
|
-
...models[runtime.modelProvider].settings.stop || [],
|
|
30350
|
-
["\n"]
|
|
30351
|
-
])
|
|
31085
|
+
/* @__PURE__ */ new Set([...modelSettings.stop || [], ["\n"]])
|
|
30352
31086
|
);
|
|
30353
31087
|
while (true) {
|
|
30354
31088
|
try {
|
|
@@ -30458,9 +31192,10 @@ async function generateMessageResponse({
|
|
|
30458
31192
|
context,
|
|
30459
31193
|
modelClass
|
|
30460
31194
|
}) {
|
|
30461
|
-
const
|
|
30462
|
-
const max_context_length =
|
|
31195
|
+
const modelSettings = getModelSettings(runtime.modelProvider, modelClass);
|
|
31196
|
+
const max_context_length = modelSettings.maxInputTokens;
|
|
30463
31197
|
context = await trimTokens(context, max_context_length, runtime);
|
|
31198
|
+
elizaLogger.debug("Context:", context);
|
|
30464
31199
|
let retryLength = 1e3;
|
|
30465
31200
|
while (true) {
|
|
30466
31201
|
try {
|
|
@@ -30485,8 +31220,8 @@ async function generateMessageResponse({
|
|
|
30485
31220
|
}
|
|
30486
31221
|
}
|
|
30487
31222
|
var generateImage = async (data, runtime) => {
|
|
30488
|
-
const
|
|
30489
|
-
const
|
|
31223
|
+
const modelSettings = getImageModelSettings(runtime.imageModelProvider);
|
|
31224
|
+
const model = modelSettings.name;
|
|
30490
31225
|
elizaLogger.info("Generating image with options:", {
|
|
30491
31226
|
imageModelProvider: model
|
|
30492
31227
|
});
|
|
@@ -30505,7 +31240,7 @@ var generateImage = async (data, runtime) => {
|
|
|
30505
31240
|
case "livepeer" /* LIVEPEER */:
|
|
30506
31241
|
return runtime.getSetting("LIVEPEER_GATEWAY_URL");
|
|
30507
31242
|
default:
|
|
30508
|
-
return runtime.getSetting("HEURIST_API_KEY") ?? runtime.getSetting("TOGETHER_API_KEY") ?? runtime.getSetting("FAL_API_KEY") ?? runtime.getSetting("OPENAI_API_KEY") ?? runtime.getSetting("VENICE_API_KEY") ?? runtime.getSetting("LIVEPEER_GATEWAY_URL");
|
|
31243
|
+
return runtime.getSetting("HEURIST_API_KEY") ?? runtime.getSetting("NINETEEN_AI_API_KEY") ?? runtime.getSetting("TOGETHER_API_KEY") ?? runtime.getSetting("FAL_API_KEY") ?? runtime.getSetting("OPENAI_API_KEY") ?? runtime.getSetting("VENICE_API_KEY") ?? runtime.getSetting("LIVEPEER_GATEWAY_URL");
|
|
30509
31244
|
}
|
|
30510
31245
|
})();
|
|
30511
31246
|
try {
|
|
@@ -30531,7 +31266,7 @@ var generateImage = async (data, runtime) => {
|
|
|
30531
31266
|
seed: data.seed || -1
|
|
30532
31267
|
}
|
|
30533
31268
|
},
|
|
30534
|
-
model_id:
|
|
31269
|
+
model_id: model,
|
|
30535
31270
|
deadline: 60,
|
|
30536
31271
|
priority: 1
|
|
30537
31272
|
})
|
|
@@ -30548,7 +31283,7 @@ var generateImage = async (data, runtime) => {
|
|
|
30548
31283
|
runtime.imageModelProvider === "llama_cloud" /* LLAMACLOUD */) {
|
|
30549
31284
|
const together = new Together({ apiKey });
|
|
30550
31285
|
const response = await together.images.create({
|
|
30551
|
-
model
|
|
31286
|
+
model,
|
|
30552
31287
|
prompt: data.prompt,
|
|
30553
31288
|
width: data.width,
|
|
30554
31289
|
height: data.height,
|
|
@@ -30635,7 +31370,7 @@ var generateImage = async (data, runtime) => {
|
|
|
30635
31370
|
"Content-Type": "application/json"
|
|
30636
31371
|
},
|
|
30637
31372
|
body: JSON.stringify({
|
|
30638
|
-
model
|
|
31373
|
+
model,
|
|
30639
31374
|
prompt: data.prompt,
|
|
30640
31375
|
negative_prompt: data.negativePrompt,
|
|
30641
31376
|
width: data.width,
|
|
@@ -30660,6 +31395,39 @@ var generateImage = async (data, runtime) => {
|
|
|
30660
31395
|
return `data:image/png;base64,${base64String}`;
|
|
30661
31396
|
});
|
|
30662
31397
|
return { success: true, data: base64s };
|
|
31398
|
+
} else if (runtime.imageModelProvider === "nineteen_ai" /* NINETEEN_AI */) {
|
|
31399
|
+
const response = await fetch(
|
|
31400
|
+
"https://api.nineteen.ai/v1/text-to-image",
|
|
31401
|
+
{
|
|
31402
|
+
method: "POST",
|
|
31403
|
+
headers: {
|
|
31404
|
+
Authorization: `Bearer ${apiKey}`,
|
|
31405
|
+
"Content-Type": "application/json"
|
|
31406
|
+
},
|
|
31407
|
+
body: JSON.stringify({
|
|
31408
|
+
model,
|
|
31409
|
+
prompt: data.prompt,
|
|
31410
|
+
negative_prompt: data.negativePrompt,
|
|
31411
|
+
width: data.width,
|
|
31412
|
+
height: data.height,
|
|
31413
|
+
steps: data.numIterations,
|
|
31414
|
+
cfg_scale: data.guidanceScale || 3
|
|
31415
|
+
})
|
|
31416
|
+
}
|
|
31417
|
+
);
|
|
31418
|
+
const result = await response.json();
|
|
31419
|
+
if (!result.images || !Array.isArray(result.images)) {
|
|
31420
|
+
throw new Error("Invalid response format from Nineteen AI");
|
|
31421
|
+
}
|
|
31422
|
+
const base64s = result.images.map((base64String) => {
|
|
31423
|
+
if (!base64String) {
|
|
31424
|
+
throw new Error(
|
|
31425
|
+
"Empty base64 string in Nineteen AI response"
|
|
31426
|
+
);
|
|
31427
|
+
}
|
|
31428
|
+
return `data:image/png;base64,${base64String}`;
|
|
31429
|
+
});
|
|
31430
|
+
return { success: true, data: base64s };
|
|
30663
31431
|
} else if (runtime.imageModelProvider === "livepeer" /* LIVEPEER */) {
|
|
30664
31432
|
if (!apiKey) {
|
|
30665
31433
|
throw new Error("Livepeer Gateway is not defined");
|
|
@@ -30677,7 +31445,7 @@ var generateImage = async (data, runtime) => {
|
|
|
30677
31445
|
"Content-Type": "application/json"
|
|
30678
31446
|
},
|
|
30679
31447
|
body: JSON.stringify({
|
|
30680
|
-
model_id:
|
|
31448
|
+
model_id: model,
|
|
30681
31449
|
prompt: data.prompt,
|
|
30682
31450
|
width: data.width || 1024,
|
|
30683
31451
|
height: data.height || 1024
|
|
@@ -30791,7 +31559,10 @@ var generateObject = async ({
|
|
|
30791
31559
|
schemaName,
|
|
30792
31560
|
schemaDescription,
|
|
30793
31561
|
stop,
|
|
30794
|
-
mode = "json"
|
|
31562
|
+
mode = "json",
|
|
31563
|
+
verifiableInference = false,
|
|
31564
|
+
verifiableInferenceAdapter,
|
|
31565
|
+
verifiableInferenceOptions
|
|
30795
31566
|
}) => {
|
|
30796
31567
|
if (!context) {
|
|
30797
31568
|
const errorMessage = "generateObject context is empty";
|
|
@@ -30799,13 +31570,14 @@ var generateObject = async ({
|
|
|
30799
31570
|
throw new Error(errorMessage);
|
|
30800
31571
|
}
|
|
30801
31572
|
const provider = runtime.modelProvider;
|
|
30802
|
-
const
|
|
30803
|
-
const
|
|
30804
|
-
const
|
|
30805
|
-
const
|
|
30806
|
-
const
|
|
30807
|
-
const
|
|
30808
|
-
const
|
|
31573
|
+
const modelSettings = getModelSettings(runtime.modelProvider, modelClass);
|
|
31574
|
+
const model = modelSettings.name;
|
|
31575
|
+
const temperature = modelSettings.temperature;
|
|
31576
|
+
const frequency_penalty = modelSettings.frequency_penalty;
|
|
31577
|
+
const presence_penalty = modelSettings.presence_penalty;
|
|
31578
|
+
const max_context_length = modelSettings.maxInputTokens;
|
|
31579
|
+
const max_response_length = modelSettings.maxOutputTokens;
|
|
31580
|
+
const experimental_telemetry = modelSettings.experimental_telemetry;
|
|
30809
31581
|
const apiKey = runtime.token;
|
|
30810
31582
|
try {
|
|
30811
31583
|
context = await trimTokens(context, max_context_length, runtime);
|
|
@@ -30815,7 +31587,7 @@ var generateObject = async ({
|
|
|
30815
31587
|
maxTokens: max_response_length,
|
|
30816
31588
|
frequencyPenalty: frequency_penalty,
|
|
30817
31589
|
presencePenalty: presence_penalty,
|
|
30818
|
-
stop: stop ||
|
|
31590
|
+
stop: stop || modelSettings.stop,
|
|
30819
31591
|
experimental_telemetry
|
|
30820
31592
|
};
|
|
30821
31593
|
const response = await handleProvider({
|
|
@@ -30829,7 +31601,10 @@ var generateObject = async ({
|
|
|
30829
31601
|
modelOptions,
|
|
30830
31602
|
runtime,
|
|
30831
31603
|
context,
|
|
30832
|
-
modelClass
|
|
31604
|
+
modelClass,
|
|
31605
|
+
verifiableInference,
|
|
31606
|
+
verifiableInferenceAdapter,
|
|
31607
|
+
verifiableInferenceOptions
|
|
30833
31608
|
});
|
|
30834
31609
|
return response;
|
|
30835
31610
|
} catch (error) {
|
|
@@ -30838,7 +31613,15 @@ var generateObject = async ({
|
|
|
30838
31613
|
}
|
|
30839
31614
|
};
|
|
30840
31615
|
async function handleProvider(options) {
|
|
30841
|
-
const {
|
|
31616
|
+
const {
|
|
31617
|
+
provider,
|
|
31618
|
+
runtime,
|
|
31619
|
+
context,
|
|
31620
|
+
modelClass
|
|
31621
|
+
//verifiableInference,
|
|
31622
|
+
//verifiableInferenceAdapter,
|
|
31623
|
+
//verifiableInferenceOptions,
|
|
31624
|
+
} = options;
|
|
30842
31625
|
switch (provider) {
|
|
30843
31626
|
case "openai" /* OPENAI */:
|
|
30844
31627
|
case "eternalai" /* ETERNALAI */:
|
|
@@ -30864,12 +31647,16 @@ async function handleProvider(options) {
|
|
|
30864
31647
|
});
|
|
30865
31648
|
case "google" /* GOOGLE */:
|
|
30866
31649
|
return await handleGoogle(options);
|
|
31650
|
+
case "mistral" /* MISTRAL */:
|
|
31651
|
+
return await handleMistral(options);
|
|
30867
31652
|
case "redpill" /* REDPILL */:
|
|
30868
31653
|
return await handleRedPill(options);
|
|
30869
31654
|
case "openrouter" /* OPENROUTER */:
|
|
30870
31655
|
return await handleOpenRouter(options);
|
|
30871
31656
|
case "ollama" /* OLLAMA */:
|
|
30872
31657
|
return await handleOllama(options);
|
|
31658
|
+
case "deepseek" /* DEEPSEEK */:
|
|
31659
|
+
return await handleDeepSeek(options);
|
|
30873
31660
|
default: {
|
|
30874
31661
|
const errorMessage = `Unsupported provider: ${provider}`;
|
|
30875
31662
|
elizaLogger.error(errorMessage);
|
|
@@ -30883,10 +31670,12 @@ async function handleOpenAI({
|
|
|
30883
31670
|
schema,
|
|
30884
31671
|
schemaName,
|
|
30885
31672
|
schemaDescription,
|
|
30886
|
-
mode,
|
|
30887
|
-
modelOptions
|
|
31673
|
+
mode = "json",
|
|
31674
|
+
modelOptions,
|
|
31675
|
+
provider: _provider,
|
|
31676
|
+
runtime
|
|
30888
31677
|
}) {
|
|
30889
|
-
const baseURL = models.openai.endpoint
|
|
31678
|
+
const baseURL = getCloudflareGatewayBaseURL(runtime, "openai") || models.openai.endpoint;
|
|
30890
31679
|
const openai = createOpenAI({ apiKey, baseURL });
|
|
30891
31680
|
return await aiGenerateObject({
|
|
30892
31681
|
model: openai.languageModel(model),
|
|
@@ -30903,10 +31692,14 @@ async function handleAnthropic({
|
|
|
30903
31692
|
schema,
|
|
30904
31693
|
schemaName,
|
|
30905
31694
|
schemaDescription,
|
|
30906
|
-
mode,
|
|
30907
|
-
modelOptions
|
|
31695
|
+
mode = "json",
|
|
31696
|
+
modelOptions,
|
|
31697
|
+
runtime
|
|
30908
31698
|
}) {
|
|
30909
|
-
|
|
31699
|
+
elizaLogger.debug("Handling Anthropic request with Cloudflare check");
|
|
31700
|
+
const baseURL = getCloudflareGatewayBaseURL(runtime, "anthropic");
|
|
31701
|
+
elizaLogger.debug("Anthropic handleAnthropic baseURL:", { baseURL });
|
|
31702
|
+
const anthropic = createAnthropic({ apiKey, baseURL });
|
|
30910
31703
|
return await aiGenerateObject({
|
|
30911
31704
|
model: anthropic.languageModel(model),
|
|
30912
31705
|
schema,
|
|
@@ -30922,7 +31715,7 @@ async function handleGrok({
|
|
|
30922
31715
|
schema,
|
|
30923
31716
|
schemaName,
|
|
30924
31717
|
schemaDescription,
|
|
30925
|
-
mode,
|
|
31718
|
+
mode = "json",
|
|
30926
31719
|
modelOptions
|
|
30927
31720
|
}) {
|
|
30928
31721
|
const grok = createOpenAI({ apiKey, baseURL: models.grok.endpoint });
|
|
@@ -30941,10 +31734,14 @@ async function handleGroq({
|
|
|
30941
31734
|
schema,
|
|
30942
31735
|
schemaName,
|
|
30943
31736
|
schemaDescription,
|
|
30944
|
-
mode,
|
|
30945
|
-
modelOptions
|
|
31737
|
+
mode = "json",
|
|
31738
|
+
modelOptions,
|
|
31739
|
+
runtime
|
|
30946
31740
|
}) {
|
|
30947
|
-
|
|
31741
|
+
elizaLogger.debug("Handling Groq request with Cloudflare check");
|
|
31742
|
+
const baseURL = getCloudflareGatewayBaseURL(runtime, "groq");
|
|
31743
|
+
elizaLogger.debug("Groq handleGroq baseURL:", { baseURL });
|
|
31744
|
+
const groq = createGroq({ apiKey, baseURL });
|
|
30948
31745
|
return await aiGenerateObject({
|
|
30949
31746
|
model: groq.languageModel(model),
|
|
30950
31747
|
schema,
|
|
@@ -30960,7 +31757,7 @@ async function handleGoogle({
|
|
|
30960
31757
|
schema,
|
|
30961
31758
|
schemaName,
|
|
30962
31759
|
schemaDescription,
|
|
30963
|
-
mode,
|
|
31760
|
+
mode = "json",
|
|
30964
31761
|
modelOptions
|
|
30965
31762
|
}) {
|
|
30966
31763
|
const google = createGoogleGenerativeAI();
|
|
@@ -30973,13 +31770,31 @@ async function handleGoogle({
|
|
|
30973
31770
|
...modelOptions
|
|
30974
31771
|
});
|
|
30975
31772
|
}
|
|
31773
|
+
async function handleMistral({
|
|
31774
|
+
model,
|
|
31775
|
+
schema,
|
|
31776
|
+
schemaName,
|
|
31777
|
+
schemaDescription,
|
|
31778
|
+
mode,
|
|
31779
|
+
modelOptions
|
|
31780
|
+
}) {
|
|
31781
|
+
const mistral = createMistral();
|
|
31782
|
+
return await aiGenerateObject({
|
|
31783
|
+
model: mistral(model),
|
|
31784
|
+
schema,
|
|
31785
|
+
schemaName,
|
|
31786
|
+
schemaDescription,
|
|
31787
|
+
mode,
|
|
31788
|
+
...modelOptions
|
|
31789
|
+
});
|
|
31790
|
+
}
|
|
30976
31791
|
async function handleRedPill({
|
|
30977
31792
|
model,
|
|
30978
31793
|
apiKey,
|
|
30979
31794
|
schema,
|
|
30980
31795
|
schemaName,
|
|
30981
31796
|
schemaDescription,
|
|
30982
|
-
mode,
|
|
31797
|
+
mode = "json",
|
|
30983
31798
|
modelOptions
|
|
30984
31799
|
}) {
|
|
30985
31800
|
const redPill = createOpenAI({ apiKey, baseURL: models.redpill.endpoint });
|
|
@@ -30998,7 +31813,7 @@ async function handleOpenRouter({
|
|
|
30998
31813
|
schema,
|
|
30999
31814
|
schemaName,
|
|
31000
31815
|
schemaDescription,
|
|
31001
|
-
mode,
|
|
31816
|
+
mode = "json",
|
|
31002
31817
|
modelOptions
|
|
31003
31818
|
}) {
|
|
31004
31819
|
const openRouter = createOpenAI({
|
|
@@ -31019,12 +31834,12 @@ async function handleOllama({
|
|
|
31019
31834
|
schema,
|
|
31020
31835
|
schemaName,
|
|
31021
31836
|
schemaDescription,
|
|
31022
|
-
mode,
|
|
31837
|
+
mode = "json",
|
|
31023
31838
|
modelOptions,
|
|
31024
31839
|
provider
|
|
31025
31840
|
}) {
|
|
31026
31841
|
const ollamaProvider = createOllama({
|
|
31027
|
-
baseURL:
|
|
31842
|
+
baseURL: getEndpoint(provider) + "/api"
|
|
31028
31843
|
});
|
|
31029
31844
|
const ollama = ollamaProvider(model);
|
|
31030
31845
|
return await aiGenerateObject({
|
|
@@ -31036,6 +31851,25 @@ async function handleOllama({
|
|
|
31036
31851
|
...modelOptions
|
|
31037
31852
|
});
|
|
31038
31853
|
}
|
|
31854
|
+
async function handleDeepSeek({
|
|
31855
|
+
model,
|
|
31856
|
+
apiKey,
|
|
31857
|
+
schema,
|
|
31858
|
+
schemaName,
|
|
31859
|
+
schemaDescription,
|
|
31860
|
+
mode,
|
|
31861
|
+
modelOptions
|
|
31862
|
+
}) {
|
|
31863
|
+
const openai = createOpenAI({ apiKey, baseURL: models.deepseek.endpoint });
|
|
31864
|
+
return await aiGenerateObject({
|
|
31865
|
+
model: openai.languageModel(model),
|
|
31866
|
+
schema,
|
|
31867
|
+
schemaName,
|
|
31868
|
+
schemaDescription,
|
|
31869
|
+
mode,
|
|
31870
|
+
...modelOptions
|
|
31871
|
+
});
|
|
31872
|
+
}
|
|
31039
31873
|
async function generateTweetActions({
|
|
31040
31874
|
runtime,
|
|
31041
31875
|
context,
|
|
@@ -31255,7 +32089,8 @@ var MemoryManager = class {
|
|
|
31255
32089
|
return await this.runtime.databaseAdapter.getMemoriesByRoomIds({
|
|
31256
32090
|
tableName: this.tableName,
|
|
31257
32091
|
agentId: this.runtime.agentId,
|
|
31258
|
-
roomIds: params.roomIds
|
|
32092
|
+
roomIds: params.roomIds,
|
|
32093
|
+
limit: params.limit
|
|
31259
32094
|
});
|
|
31260
32095
|
}
|
|
31261
32096
|
async getMemoryById(id) {
|
|
@@ -31462,11 +32297,19 @@ async function formatRelationships({
|
|
|
31462
32297
|
}
|
|
31463
32298
|
|
|
31464
32299
|
// src/runtime.ts
|
|
32300
|
+
import { readFile } from "fs/promises";
|
|
32301
|
+
import { join } from "path";
|
|
31465
32302
|
import { names as names4, uniqueNamesGenerator as uniqueNamesGenerator4 } from "unique-names-generator";
|
|
31466
32303
|
import { v4 as uuidv4 } from "uuid";
|
|
31467
32304
|
|
|
31468
32305
|
// src/uuid.ts
|
|
31469
32306
|
import { sha1 } from "js-sha1";
|
|
32307
|
+
import { z } from "zod";
|
|
32308
|
+
var uuidSchema = z.string().uuid();
|
|
32309
|
+
function validateUuid(value) {
|
|
32310
|
+
const result = uuidSchema.safeParse(value);
|
|
32311
|
+
return result.success ? result.data : null;
|
|
32312
|
+
}
|
|
31470
32313
|
function stringToUuid(target) {
|
|
31471
32314
|
if (typeof target === "number") {
|
|
31472
32315
|
target = target.toString();
|
|
@@ -31593,6 +32436,345 @@ var knowledge_default = {
|
|
|
31593
32436
|
preprocess
|
|
31594
32437
|
};
|
|
31595
32438
|
|
|
32439
|
+
// src/ragknowledge.ts
|
|
32440
|
+
var RAGKnowledgeManager = class {
|
|
32441
|
+
/**
|
|
32442
|
+
* The AgentRuntime instance associated with this manager.
|
|
32443
|
+
*/
|
|
32444
|
+
runtime;
|
|
32445
|
+
/**
|
|
32446
|
+
* The name of the database table this manager operates on.
|
|
32447
|
+
*/
|
|
32448
|
+
tableName;
|
|
32449
|
+
/**
|
|
32450
|
+
* Constructs a new KnowledgeManager instance.
|
|
32451
|
+
* @param opts Options for the manager.
|
|
32452
|
+
* @param opts.tableName The name of the table this manager will operate on.
|
|
32453
|
+
* @param opts.runtime The AgentRuntime instance associated with this manager.
|
|
32454
|
+
*/
|
|
32455
|
+
constructor(opts) {
|
|
32456
|
+
this.runtime = opts.runtime;
|
|
32457
|
+
this.tableName = opts.tableName;
|
|
32458
|
+
}
|
|
32459
|
+
defaultRAGMatchThreshold = 0.85;
|
|
32460
|
+
defaultRAGMatchCount = 5;
|
|
32461
|
+
/**
|
|
32462
|
+
* Common English stop words to filter out from query analysis
|
|
32463
|
+
*/
|
|
32464
|
+
stopWords = /* @__PURE__ */ new Set([
|
|
32465
|
+
"a",
|
|
32466
|
+
"an",
|
|
32467
|
+
"and",
|
|
32468
|
+
"are",
|
|
32469
|
+
"as",
|
|
32470
|
+
"at",
|
|
32471
|
+
"be",
|
|
32472
|
+
"by",
|
|
32473
|
+
"does",
|
|
32474
|
+
"for",
|
|
32475
|
+
"from",
|
|
32476
|
+
"had",
|
|
32477
|
+
"has",
|
|
32478
|
+
"have",
|
|
32479
|
+
"he",
|
|
32480
|
+
"her",
|
|
32481
|
+
"his",
|
|
32482
|
+
"how",
|
|
32483
|
+
"hey",
|
|
32484
|
+
"i",
|
|
32485
|
+
"in",
|
|
32486
|
+
"is",
|
|
32487
|
+
"it",
|
|
32488
|
+
"its",
|
|
32489
|
+
"of",
|
|
32490
|
+
"on",
|
|
32491
|
+
"or",
|
|
32492
|
+
"that",
|
|
32493
|
+
"the",
|
|
32494
|
+
"this",
|
|
32495
|
+
"to",
|
|
32496
|
+
"was",
|
|
32497
|
+
"what",
|
|
32498
|
+
"when",
|
|
32499
|
+
"where",
|
|
32500
|
+
"which",
|
|
32501
|
+
"who",
|
|
32502
|
+
"will",
|
|
32503
|
+
"with",
|
|
32504
|
+
"would",
|
|
32505
|
+
"there",
|
|
32506
|
+
"their",
|
|
32507
|
+
"they",
|
|
32508
|
+
"your",
|
|
32509
|
+
"you"
|
|
32510
|
+
]);
|
|
32511
|
+
/**
|
|
32512
|
+
* Filters out stop words and returns meaningful terms
|
|
32513
|
+
*/
|
|
32514
|
+
getQueryTerms(query) {
|
|
32515
|
+
return query.toLowerCase().split(" ").filter((term) => term.length > 3).filter((term) => !this.stopWords.has(term));
|
|
32516
|
+
}
|
|
32517
|
+
/**
|
|
32518
|
+
* Preprocesses text content for better RAG performance.
|
|
32519
|
+
* @param content The text content to preprocess.
|
|
32520
|
+
* @returns The preprocessed text.
|
|
32521
|
+
*/
|
|
32522
|
+
preprocess(content) {
|
|
32523
|
+
if (!content || typeof content !== "string") {
|
|
32524
|
+
logger_default.warn("Invalid input for preprocessing");
|
|
32525
|
+
return "";
|
|
32526
|
+
}
|
|
32527
|
+
return content.replace(/```[\s\S]*?```/g, "").replace(/`.*?`/g, "").replace(/#{1,6}\s*(.*)/g, "$1").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\(.*?\)/g, "$1").replace(/(https?:\/\/)?(www\.)?([^\s]+\.[^\s]+)/g, "$3").replace(/<@[!&]?\d+>/g, "").replace(/<[^>]*>/g, "").replace(/^\s*[-*_]{3,}\s*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*/g, "").replace(/\s+/g, " ").replace(/\n{3,}/g, "\n\n").replace(/[^a-zA-Z0-9\s\-_./:?=&]/g, "").trim().toLowerCase();
|
|
32528
|
+
}
|
|
32529
|
+
hasProximityMatch(text, terms) {
|
|
32530
|
+
const words = text.toLowerCase().split(" ");
|
|
32531
|
+
const positions = terms.map((term) => words.findIndex((w) => w.includes(term))).filter((pos) => pos !== -1);
|
|
32532
|
+
if (positions.length < 2) return false;
|
|
32533
|
+
for (let i = 0; i < positions.length - 1; i++) {
|
|
32534
|
+
if (Math.abs(positions[i] - positions[i + 1]) <= 5) {
|
|
32535
|
+
return true;
|
|
32536
|
+
}
|
|
32537
|
+
}
|
|
32538
|
+
return false;
|
|
32539
|
+
}
|
|
32540
|
+
async getKnowledge(params) {
|
|
32541
|
+
const agentId = params.agentId || this.runtime.agentId;
|
|
32542
|
+
if (params.id) {
|
|
32543
|
+
const directResults = await this.runtime.databaseAdapter.getKnowledge({
|
|
32544
|
+
id: params.id,
|
|
32545
|
+
agentId
|
|
32546
|
+
});
|
|
32547
|
+
if (directResults.length > 0) {
|
|
32548
|
+
return directResults;
|
|
32549
|
+
}
|
|
32550
|
+
}
|
|
32551
|
+
if (params.query) {
|
|
32552
|
+
try {
|
|
32553
|
+
const processedQuery = this.preprocess(params.query);
|
|
32554
|
+
let searchText = processedQuery;
|
|
32555
|
+
if (params.conversationContext) {
|
|
32556
|
+
const relevantContext = this.preprocess(
|
|
32557
|
+
params.conversationContext
|
|
32558
|
+
);
|
|
32559
|
+
searchText = `${relevantContext} ${processedQuery}`;
|
|
32560
|
+
}
|
|
32561
|
+
const embeddingArray = await embed(this.runtime, searchText);
|
|
32562
|
+
const embedding = new Float32Array(embeddingArray);
|
|
32563
|
+
const results = await this.runtime.databaseAdapter.searchKnowledge({
|
|
32564
|
+
agentId: this.runtime.agentId,
|
|
32565
|
+
embedding,
|
|
32566
|
+
match_threshold: this.defaultRAGMatchThreshold,
|
|
32567
|
+
match_count: (params.limit || this.defaultRAGMatchCount) * 2,
|
|
32568
|
+
searchText: processedQuery
|
|
32569
|
+
});
|
|
32570
|
+
const rerankedResults = results.map((result) => {
|
|
32571
|
+
let score = result.similarity;
|
|
32572
|
+
const queryTerms = this.getQueryTerms(processedQuery);
|
|
32573
|
+
const matchingTerms = queryTerms.filter(
|
|
32574
|
+
(term) => result.content.text.toLowerCase().includes(term)
|
|
32575
|
+
);
|
|
32576
|
+
if (matchingTerms.length > 0) {
|
|
32577
|
+
score *= 1 + matchingTerms.length / queryTerms.length * 2;
|
|
32578
|
+
if (this.hasProximityMatch(
|
|
32579
|
+
result.content.text,
|
|
32580
|
+
matchingTerms
|
|
32581
|
+
)) {
|
|
32582
|
+
score *= 1.5;
|
|
32583
|
+
}
|
|
32584
|
+
} else {
|
|
32585
|
+
if (!params.conversationContext) {
|
|
32586
|
+
score *= 0.3;
|
|
32587
|
+
}
|
|
32588
|
+
}
|
|
32589
|
+
return {
|
|
32590
|
+
...result,
|
|
32591
|
+
score,
|
|
32592
|
+
matchedTerms: matchingTerms
|
|
32593
|
+
// Add for debugging
|
|
32594
|
+
};
|
|
32595
|
+
}).sort((a, b) => b.score - a.score);
|
|
32596
|
+
return rerankedResults.filter(
|
|
32597
|
+
(result) => result.score >= this.defaultRAGMatchThreshold
|
|
32598
|
+
).slice(0, params.limit || this.defaultRAGMatchCount);
|
|
32599
|
+
} catch (error) {
|
|
32600
|
+
console.log(`[RAG Search Error] ${error}`);
|
|
32601
|
+
return [];
|
|
32602
|
+
}
|
|
32603
|
+
}
|
|
32604
|
+
return [];
|
|
32605
|
+
}
|
|
32606
|
+
async createKnowledge(item) {
|
|
32607
|
+
if (!item.content.text) {
|
|
32608
|
+
logger_default.warn("Empty content in knowledge item");
|
|
32609
|
+
return;
|
|
32610
|
+
}
|
|
32611
|
+
try {
|
|
32612
|
+
const processedContent = this.preprocess(item.content.text);
|
|
32613
|
+
const mainEmbeddingArray = await embed(
|
|
32614
|
+
this.runtime,
|
|
32615
|
+
processedContent
|
|
32616
|
+
);
|
|
32617
|
+
const mainEmbedding = new Float32Array(mainEmbeddingArray);
|
|
32618
|
+
await this.runtime.databaseAdapter.createKnowledge({
|
|
32619
|
+
id: item.id,
|
|
32620
|
+
agentId: this.runtime.agentId,
|
|
32621
|
+
content: {
|
|
32622
|
+
text: item.content.text,
|
|
32623
|
+
metadata: {
|
|
32624
|
+
...item.content.metadata,
|
|
32625
|
+
isMain: true
|
|
32626
|
+
}
|
|
32627
|
+
},
|
|
32628
|
+
embedding: mainEmbedding,
|
|
32629
|
+
createdAt: Date.now()
|
|
32630
|
+
});
|
|
32631
|
+
const chunks = await splitChunks(processedContent, 512, 20);
|
|
32632
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
32633
|
+
const chunkEmbeddingArray = await embed(this.runtime, chunk);
|
|
32634
|
+
const chunkEmbedding = new Float32Array(chunkEmbeddingArray);
|
|
32635
|
+
const chunkId = `${item.id}-chunk-${index}`;
|
|
32636
|
+
await this.runtime.databaseAdapter.createKnowledge({
|
|
32637
|
+
id: chunkId,
|
|
32638
|
+
agentId: this.runtime.agentId,
|
|
32639
|
+
content: {
|
|
32640
|
+
text: chunk,
|
|
32641
|
+
metadata: {
|
|
32642
|
+
...item.content.metadata,
|
|
32643
|
+
isChunk: true,
|
|
32644
|
+
originalId: item.id,
|
|
32645
|
+
chunkIndex: index
|
|
32646
|
+
}
|
|
32647
|
+
},
|
|
32648
|
+
embedding: chunkEmbedding,
|
|
32649
|
+
createdAt: Date.now()
|
|
32650
|
+
});
|
|
32651
|
+
}
|
|
32652
|
+
} catch (error) {
|
|
32653
|
+
logger_default.error(`Error processing knowledge ${item.id}:`, error);
|
|
32654
|
+
throw error;
|
|
32655
|
+
}
|
|
32656
|
+
}
|
|
32657
|
+
async searchKnowledge(params) {
|
|
32658
|
+
const {
|
|
32659
|
+
match_threshold = this.defaultRAGMatchThreshold,
|
|
32660
|
+
match_count = this.defaultRAGMatchCount,
|
|
32661
|
+
embedding,
|
|
32662
|
+
searchText
|
|
32663
|
+
} = params;
|
|
32664
|
+
const float32Embedding = Array.isArray(embedding) ? new Float32Array(embedding) : embedding;
|
|
32665
|
+
return await this.runtime.databaseAdapter.searchKnowledge({
|
|
32666
|
+
agentId: params.agentId || this.runtime.agentId,
|
|
32667
|
+
embedding: float32Embedding,
|
|
32668
|
+
match_threshold,
|
|
32669
|
+
match_count,
|
|
32670
|
+
searchText
|
|
32671
|
+
});
|
|
32672
|
+
}
|
|
32673
|
+
async removeKnowledge(id) {
|
|
32674
|
+
await this.runtime.databaseAdapter.removeKnowledge(id);
|
|
32675
|
+
}
|
|
32676
|
+
async clearKnowledge(shared) {
|
|
32677
|
+
await this.runtime.databaseAdapter.clearKnowledge(
|
|
32678
|
+
this.runtime.agentId,
|
|
32679
|
+
shared ? shared : false
|
|
32680
|
+
);
|
|
32681
|
+
}
|
|
32682
|
+
async processFile(file) {
|
|
32683
|
+
const timeMarker = (label) => {
|
|
32684
|
+
const time = (Date.now() - startTime) / 1e3;
|
|
32685
|
+
logger_default.info(`[Timing] ${label}: ${time.toFixed(2)}s`);
|
|
32686
|
+
};
|
|
32687
|
+
const startTime = Date.now();
|
|
32688
|
+
const content = file.content;
|
|
32689
|
+
try {
|
|
32690
|
+
const fileSizeKB = new TextEncoder().encode(content).length / 1024;
|
|
32691
|
+
logger_default.info(
|
|
32692
|
+
`[File Progress] Starting ${file.path} (${fileSizeKB.toFixed(2)} KB)`
|
|
32693
|
+
);
|
|
32694
|
+
const processedContent = this.preprocess(content);
|
|
32695
|
+
timeMarker("Preprocessing");
|
|
32696
|
+
const mainEmbeddingArray = await embed(
|
|
32697
|
+
this.runtime,
|
|
32698
|
+
processedContent
|
|
32699
|
+
);
|
|
32700
|
+
const mainEmbedding = new Float32Array(mainEmbeddingArray);
|
|
32701
|
+
timeMarker("Main embedding");
|
|
32702
|
+
await this.runtime.databaseAdapter.createKnowledge({
|
|
32703
|
+
id: stringToUuid(file.path),
|
|
32704
|
+
agentId: this.runtime.agentId,
|
|
32705
|
+
content: {
|
|
32706
|
+
text: content,
|
|
32707
|
+
metadata: {
|
|
32708
|
+
source: file.path,
|
|
32709
|
+
type: file.type,
|
|
32710
|
+
isShared: file.isShared || false
|
|
32711
|
+
}
|
|
32712
|
+
},
|
|
32713
|
+
embedding: mainEmbedding,
|
|
32714
|
+
createdAt: Date.now()
|
|
32715
|
+
});
|
|
32716
|
+
timeMarker("Main document storage");
|
|
32717
|
+
const chunks = await splitChunks(processedContent, 512, 20);
|
|
32718
|
+
const totalChunks = chunks.length;
|
|
32719
|
+
logger_default.info(`Generated ${totalChunks} chunks`);
|
|
32720
|
+
timeMarker("Chunk generation");
|
|
32721
|
+
const BATCH_SIZE = 10;
|
|
32722
|
+
let processedChunks = 0;
|
|
32723
|
+
for (let i = 0; i < chunks.length; i += BATCH_SIZE) {
|
|
32724
|
+
const batchStart = Date.now();
|
|
32725
|
+
const batch = chunks.slice(
|
|
32726
|
+
i,
|
|
32727
|
+
Math.min(i + BATCH_SIZE, chunks.length)
|
|
32728
|
+
);
|
|
32729
|
+
const embeddings = await Promise.all(
|
|
32730
|
+
batch.map((chunk) => embed(this.runtime, chunk))
|
|
32731
|
+
);
|
|
32732
|
+
await Promise.all(
|
|
32733
|
+
embeddings.map(async (embeddingArray, index) => {
|
|
32734
|
+
const chunkId = `${stringToUuid(file.path)}-chunk-${i + index}`;
|
|
32735
|
+
const chunkEmbedding = new Float32Array(embeddingArray);
|
|
32736
|
+
await this.runtime.databaseAdapter.createKnowledge({
|
|
32737
|
+
id: chunkId,
|
|
32738
|
+
agentId: this.runtime.agentId,
|
|
32739
|
+
content: {
|
|
32740
|
+
text: batch[index],
|
|
32741
|
+
metadata: {
|
|
32742
|
+
source: file.path,
|
|
32743
|
+
type: file.type,
|
|
32744
|
+
isShared: file.isShared || false,
|
|
32745
|
+
isChunk: true,
|
|
32746
|
+
originalId: stringToUuid(file.path),
|
|
32747
|
+
chunkIndex: i + index
|
|
32748
|
+
}
|
|
32749
|
+
},
|
|
32750
|
+
embedding: chunkEmbedding,
|
|
32751
|
+
createdAt: Date.now()
|
|
32752
|
+
});
|
|
32753
|
+
})
|
|
32754
|
+
);
|
|
32755
|
+
processedChunks += batch.length;
|
|
32756
|
+
const batchTime = (Date.now() - batchStart) / 1e3;
|
|
32757
|
+
logger_default.info(
|
|
32758
|
+
`[Batch Progress] Processed ${processedChunks}/${totalChunks} chunks (${batchTime.toFixed(2)}s for batch)`
|
|
32759
|
+
);
|
|
32760
|
+
}
|
|
32761
|
+
const totalTime = (Date.now() - startTime) / 1e3;
|
|
32762
|
+
logger_default.info(
|
|
32763
|
+
`[Complete] Processed ${file.path} in ${totalTime.toFixed(2)}s`
|
|
32764
|
+
);
|
|
32765
|
+
} catch (error) {
|
|
32766
|
+
if (file.isShared && error?.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
32767
|
+
logger_default.info(
|
|
32768
|
+
`Shared knowledge ${file.path} already exists in database, skipping creation`
|
|
32769
|
+
);
|
|
32770
|
+
return;
|
|
32771
|
+
}
|
|
32772
|
+
logger_default.error(`Error processing file ${file.path}:`, error);
|
|
32773
|
+
throw error;
|
|
32774
|
+
}
|
|
32775
|
+
}
|
|
32776
|
+
};
|
|
32777
|
+
|
|
31596
32778
|
// src/runtime.ts
|
|
31597
32779
|
var AgentRuntime = class {
|
|
31598
32780
|
/**
|
|
@@ -31638,8 +32820,8 @@ var AgentRuntime = class {
|
|
|
31638
32820
|
*/
|
|
31639
32821
|
imageModelProvider;
|
|
31640
32822
|
/**
|
|
31641
|
-
|
|
31642
|
-
|
|
32823
|
+
* The model to use for describing images.
|
|
32824
|
+
*/
|
|
31643
32825
|
imageVisionModelProvider;
|
|
31644
32826
|
/**
|
|
31645
32827
|
* Fetch function to use
|
|
@@ -31670,10 +32852,12 @@ var AgentRuntime = class {
|
|
|
31670
32852
|
* Searchable document fragments
|
|
31671
32853
|
*/
|
|
31672
32854
|
knowledgeManager;
|
|
32855
|
+
ragKnowledgeManager;
|
|
31673
32856
|
services = /* @__PURE__ */ new Map();
|
|
31674
32857
|
memoryManagers = /* @__PURE__ */ new Map();
|
|
31675
32858
|
cacheManager;
|
|
31676
32859
|
clients;
|
|
32860
|
+
verifiableInferenceAdapter;
|
|
31677
32861
|
registerMemoryManager(manager) {
|
|
31678
32862
|
if (!manager.tableName) {
|
|
31679
32863
|
throw new Error("Memory manager must have a tableName");
|
|
@@ -31747,7 +32931,7 @@ var AgentRuntime = class {
|
|
|
31747
32931
|
).then(() => {
|
|
31748
32932
|
this.ensureParticipantExists(this.agentId, this.agentId);
|
|
31749
32933
|
});
|
|
31750
|
-
elizaLogger.success(
|
|
32934
|
+
elizaLogger.success(`Agent ID: ${this.agentId}`);
|
|
31751
32935
|
this.fetch = opts.fetch ?? this.fetch;
|
|
31752
32936
|
this.cacheManager = opts.cacheManager;
|
|
31753
32937
|
this.messageManager = new MemoryManager({
|
|
@@ -31770,6 +32954,10 @@ var AgentRuntime = class {
|
|
|
31770
32954
|
runtime: this,
|
|
31771
32955
|
tableName: "fragments"
|
|
31772
32956
|
});
|
|
32957
|
+
this.ragKnowledgeManager = new RAGKnowledgeManager({
|
|
32958
|
+
runtime: this,
|
|
32959
|
+
tableName: "knowledge"
|
|
32960
|
+
});
|
|
31773
32961
|
(opts.managers ?? []).forEach((manager) => {
|
|
31774
32962
|
this.registerMemoryManager(manager);
|
|
31775
32963
|
});
|
|
@@ -31836,6 +33024,7 @@ var AgentRuntime = class {
|
|
|
31836
33024
|
(opts.evaluators ?? []).forEach((evaluator) => {
|
|
31837
33025
|
this.registerEvaluator(evaluator);
|
|
31838
33026
|
});
|
|
33027
|
+
this.verifiableInferenceAdapter = opts.verifiableInferenceAdapter;
|
|
31839
33028
|
}
|
|
31840
33029
|
async initialize() {
|
|
31841
33030
|
for (const [serviceType, service] of this.services.entries()) {
|
|
@@ -31860,14 +33049,28 @@ var AgentRuntime = class {
|
|
|
31860
33049
|
);
|
|
31861
33050
|
}
|
|
31862
33051
|
if (this.character && this.character.knowledge && this.character.knowledge.length > 0) {
|
|
31863
|
-
|
|
33052
|
+
if (this.character.settings.ragKnowledge) {
|
|
33053
|
+
await this.processCharacterRAGKnowledge(
|
|
33054
|
+
this.character.knowledge
|
|
33055
|
+
);
|
|
33056
|
+
} else {
|
|
33057
|
+
const stringKnowledge = this.character.knowledge.filter(
|
|
33058
|
+
(item) => typeof item === "string"
|
|
33059
|
+
);
|
|
33060
|
+
await this.processCharacterKnowledge(stringKnowledge);
|
|
33061
|
+
}
|
|
31864
33062
|
}
|
|
31865
33063
|
}
|
|
31866
33064
|
async stop() {
|
|
31867
33065
|
elizaLogger.debug("runtime::stop - character", this.character);
|
|
31868
33066
|
for (const cStr in this.clients) {
|
|
31869
33067
|
const c = this.clients[cStr];
|
|
31870
|
-
elizaLogger.log(
|
|
33068
|
+
elizaLogger.log(
|
|
33069
|
+
"runtime::stop - requesting",
|
|
33070
|
+
cStr,
|
|
33071
|
+
"client stop for",
|
|
33072
|
+
this.character.name
|
|
33073
|
+
);
|
|
31871
33074
|
c.stop();
|
|
31872
33075
|
}
|
|
31873
33076
|
}
|
|
@@ -31898,6 +33101,131 @@ var AgentRuntime = class {
|
|
|
31898
33101
|
});
|
|
31899
33102
|
}
|
|
31900
33103
|
}
|
|
33104
|
+
/**
|
|
33105
|
+
* Processes character knowledge by creating document memories and fragment memories.
|
|
33106
|
+
* This function takes an array of knowledge items, creates a document knowledge for each item if it doesn't exist,
|
|
33107
|
+
* then chunks the content into fragments, embeds each fragment, and creates fragment knowledge.
|
|
33108
|
+
* An array of knowledge items or objects containing id, path, and content.
|
|
33109
|
+
*/
|
|
33110
|
+
async processCharacterRAGKnowledge(items) {
|
|
33111
|
+
let hasError = false;
|
|
33112
|
+
for (const item of items) {
|
|
33113
|
+
if (!item) continue;
|
|
33114
|
+
try {
|
|
33115
|
+
let isShared = false;
|
|
33116
|
+
let contentItem = item;
|
|
33117
|
+
if (typeof item === "object" && "path" in item) {
|
|
33118
|
+
isShared = item.shared === true;
|
|
33119
|
+
contentItem = item.path;
|
|
33120
|
+
} else {
|
|
33121
|
+
contentItem = item;
|
|
33122
|
+
}
|
|
33123
|
+
const knowledgeId = stringToUuid(contentItem);
|
|
33124
|
+
const fileExtension = contentItem.split(".").pop()?.toLowerCase();
|
|
33125
|
+
if (fileExtension && ["md", "txt", "pdf"].includes(fileExtension)) {
|
|
33126
|
+
try {
|
|
33127
|
+
const rootPath = join(process.cwd(), "..");
|
|
33128
|
+
const filePath = join(
|
|
33129
|
+
rootPath,
|
|
33130
|
+
"characters",
|
|
33131
|
+
"knowledge",
|
|
33132
|
+
contentItem
|
|
33133
|
+
);
|
|
33134
|
+
elizaLogger.info(
|
|
33135
|
+
"Attempting to read file from:",
|
|
33136
|
+
filePath
|
|
33137
|
+
);
|
|
33138
|
+
const existingKnowledge = await this.ragKnowledgeManager.getKnowledge({
|
|
33139
|
+
id: knowledgeId,
|
|
33140
|
+
agentId: this.agentId
|
|
33141
|
+
});
|
|
33142
|
+
const content = await readFile(
|
|
33143
|
+
filePath,
|
|
33144
|
+
"utf8"
|
|
33145
|
+
);
|
|
33146
|
+
if (!content) {
|
|
33147
|
+
hasError = true;
|
|
33148
|
+
continue;
|
|
33149
|
+
}
|
|
33150
|
+
if (existingKnowledge.length > 0) {
|
|
33151
|
+
const existingContent = existingKnowledge[0].content.text;
|
|
33152
|
+
if (existingContent === content) {
|
|
33153
|
+
elizaLogger.info(
|
|
33154
|
+
`File ${contentItem} unchanged, skipping`
|
|
33155
|
+
);
|
|
33156
|
+
continue;
|
|
33157
|
+
} else {
|
|
33158
|
+
await this.ragKnowledgeManager.removeKnowledge(
|
|
33159
|
+
knowledgeId
|
|
33160
|
+
);
|
|
33161
|
+
await this.ragKnowledgeManager.removeKnowledge(
|
|
33162
|
+
`${knowledgeId}-chunk-*`
|
|
33163
|
+
);
|
|
33164
|
+
}
|
|
33165
|
+
}
|
|
33166
|
+
elizaLogger.info(
|
|
33167
|
+
`Successfully read ${fileExtension.toUpperCase()} file content for`,
|
|
33168
|
+
this.character.name,
|
|
33169
|
+
"-",
|
|
33170
|
+
contentItem
|
|
33171
|
+
);
|
|
33172
|
+
await this.ragKnowledgeManager.processFile({
|
|
33173
|
+
path: contentItem,
|
|
33174
|
+
content,
|
|
33175
|
+
type: fileExtension,
|
|
33176
|
+
isShared
|
|
33177
|
+
});
|
|
33178
|
+
} catch (error) {
|
|
33179
|
+
hasError = true;
|
|
33180
|
+
elizaLogger.error(
|
|
33181
|
+
`Failed to read knowledge file ${contentItem}. Error details:`,
|
|
33182
|
+
error?.message || error || "Unknown error"
|
|
33183
|
+
);
|
|
33184
|
+
continue;
|
|
33185
|
+
}
|
|
33186
|
+
} else {
|
|
33187
|
+
elizaLogger.info(
|
|
33188
|
+
"Processing direct knowledge for",
|
|
33189
|
+
this.character.name,
|
|
33190
|
+
"-",
|
|
33191
|
+
contentItem.slice(0, 100)
|
|
33192
|
+
);
|
|
33193
|
+
const existingKnowledge = await this.ragKnowledgeManager.getKnowledge({
|
|
33194
|
+
id: knowledgeId,
|
|
33195
|
+
agentId: this.agentId
|
|
33196
|
+
});
|
|
33197
|
+
if (existingKnowledge.length > 0) {
|
|
33198
|
+
elizaLogger.info(
|
|
33199
|
+
`Direct knowledge ${knowledgeId} already exists, skipping`
|
|
33200
|
+
);
|
|
33201
|
+
continue;
|
|
33202
|
+
}
|
|
33203
|
+
await this.ragKnowledgeManager.createKnowledge({
|
|
33204
|
+
id: knowledgeId,
|
|
33205
|
+
agentId: this.agentId,
|
|
33206
|
+
content: {
|
|
33207
|
+
text: contentItem,
|
|
33208
|
+
metadata: {
|
|
33209
|
+
type: "direct"
|
|
33210
|
+
}
|
|
33211
|
+
}
|
|
33212
|
+
});
|
|
33213
|
+
}
|
|
33214
|
+
} catch (error) {
|
|
33215
|
+
hasError = true;
|
|
33216
|
+
elizaLogger.error(
|
|
33217
|
+
`Error processing knowledge item ${item}:`,
|
|
33218
|
+
error?.message || error || "Unknown error"
|
|
33219
|
+
);
|
|
33220
|
+
continue;
|
|
33221
|
+
}
|
|
33222
|
+
}
|
|
33223
|
+
if (hasError) {
|
|
33224
|
+
elizaLogger.warn(
|
|
33225
|
+
"Some knowledge items failed to process, but continuing with available knowledge"
|
|
33226
|
+
);
|
|
33227
|
+
}
|
|
33228
|
+
}
|
|
31901
33229
|
getSetting(key) {
|
|
31902
33230
|
if (this.character.settings?.secrets?.[key]) {
|
|
31903
33231
|
return this.character.settings.secrets[key];
|
|
@@ -32021,8 +33349,10 @@ var AgentRuntime = class {
|
|
|
32021
33349
|
}
|
|
32022
33350
|
);
|
|
32023
33351
|
const resolvedEvaluators = await Promise.all(evaluatorPromises);
|
|
32024
|
-
const evaluatorsData = resolvedEvaluators.filter(
|
|
32025
|
-
|
|
33352
|
+
const evaluatorsData = resolvedEvaluators.filter(
|
|
33353
|
+
(evaluator) => evaluator !== null
|
|
33354
|
+
);
|
|
33355
|
+
if (!evaluatorsData || evaluatorsData.length === 0) {
|
|
32026
33356
|
return [];
|
|
32027
33357
|
}
|
|
32028
33358
|
const context = composeContext({
|
|
@@ -32036,13 +33366,14 @@ var AgentRuntime = class {
|
|
|
32036
33366
|
const result = await generateText({
|
|
32037
33367
|
runtime: this,
|
|
32038
33368
|
context,
|
|
32039
|
-
modelClass: "small" /* SMALL
|
|
33369
|
+
modelClass: "small" /* SMALL */,
|
|
33370
|
+
verifiableInferenceAdapter: this.verifiableInferenceAdapter
|
|
32040
33371
|
});
|
|
32041
33372
|
const evaluators = parseJsonArrayFromText(
|
|
32042
33373
|
result
|
|
32043
33374
|
);
|
|
32044
33375
|
for (const evaluator of this.evaluators) {
|
|
32045
|
-
if (!evaluators
|
|
33376
|
+
if (!evaluators?.includes(evaluator.name)) continue;
|
|
32046
33377
|
if (evaluator.handler)
|
|
32047
33378
|
await evaluator.handler(this, message, state, {}, callback);
|
|
32048
33379
|
}
|
|
@@ -32172,7 +33503,7 @@ var AgentRuntime = class {
|
|
|
32172
33503
|
(msg) => msg.content.attachments && msg.content.attachments.length > 0
|
|
32173
33504
|
);
|
|
32174
33505
|
if (lastMessageWithAttachment) {
|
|
32175
|
-
const lastMessageTime = lastMessageWithAttachment.
|
|
33506
|
+
const lastMessageTime = lastMessageWithAttachment?.createdAt ?? Date.now();
|
|
32176
33507
|
const oneHourBeforeLastMessage = lastMessageTime - 60 * 60 * 1e3;
|
|
32177
33508
|
allAttachments = recentMessagesData.reverse().map((msg) => {
|
|
32178
33509
|
const msgTime = msg.createdAt ?? Date.now();
|
|
@@ -32230,13 +33561,11 @@ Text: ${attachment.text}
|
|
|
32230
33561
|
userA,
|
|
32231
33562
|
userB
|
|
32232
33563
|
]);
|
|
32233
|
-
|
|
33564
|
+
return this.messageManager.getMemoriesByRoomIds({
|
|
32234
33565
|
// filter out the current room id from rooms
|
|
32235
|
-
roomIds: rooms.filter((room) => room !== roomId)
|
|
33566
|
+
roomIds: rooms.filter((room) => room !== roomId),
|
|
33567
|
+
limit: 20
|
|
32236
33568
|
});
|
|
32237
|
-
existingMemories.sort((a, b) => b.createdAt - a.createdAt);
|
|
32238
|
-
const recentInteractionsData = existingMemories.slice(0, 20);
|
|
32239
|
-
return recentInteractionsData;
|
|
32240
33569
|
};
|
|
32241
33570
|
const recentInteractions = userId !== this.agentId ? await getRecentInteractions(userId, this.agentId) : [];
|
|
32242
33571
|
const getRecentMessageInteractions = async (recentInteractionsData) => {
|
|
@@ -32274,8 +33603,20 @@ Text: ${attachment.text}
|
|
|
32274
33603
|
if (Array.isArray(bio)) {
|
|
32275
33604
|
bio = bio.sort(() => 0.5 - Math.random()).slice(0, 3).join(" ");
|
|
32276
33605
|
}
|
|
32277
|
-
|
|
32278
|
-
|
|
33606
|
+
let knowledgeData = [];
|
|
33607
|
+
let formattedKnowledge = "";
|
|
33608
|
+
if (this.character.settings?.ragKnowledge) {
|
|
33609
|
+
const recentContext = recentMessagesData.slice(-3).map((msg) => msg.content.text).join(" ");
|
|
33610
|
+
knowledgeData = await this.ragKnowledgeManager.getKnowledge({
|
|
33611
|
+
query: message.content.text,
|
|
33612
|
+
conversationContext: recentContext,
|
|
33613
|
+
limit: 5
|
|
33614
|
+
});
|
|
33615
|
+
formattedKnowledge = formatKnowledge(knowledgeData);
|
|
33616
|
+
} else {
|
|
33617
|
+
knowledgeData = await knowledge_default.get(this, message);
|
|
33618
|
+
formattedKnowledge = formatKnowledge(knowledgeData);
|
|
33619
|
+
}
|
|
32279
33620
|
const initialState = {
|
|
32280
33621
|
agentId: this.agentId,
|
|
32281
33622
|
agentName,
|
|
@@ -32285,7 +33626,8 @@ Text: ${attachment.text}
|
|
|
32285
33626
|
Math.random() * this.character.adjectives.length
|
|
32286
33627
|
)] : "",
|
|
32287
33628
|
knowledge: formattedKnowledge,
|
|
32288
|
-
knowledgeData
|
|
33629
|
+
knowledgeData,
|
|
33630
|
+
ragKnowledgeData: knowledgeData,
|
|
32289
33631
|
// Recent interactions between the sender and receiver, formatted as messages
|
|
32290
33632
|
recentMessageInteractions: formattedMessageInteractions,
|
|
32291
33633
|
// Recent interactions between the sender and receiver, formatted as posts
|
|
@@ -32434,10 +33776,10 @@ Text: ${attachment.text}
|
|
|
32434
33776
|
(msg) => msg.content.attachments && msg.content.attachments.length > 0
|
|
32435
33777
|
);
|
|
32436
33778
|
if (lastMessageWithAttachment) {
|
|
32437
|
-
const lastMessageTime = lastMessageWithAttachment.
|
|
33779
|
+
const lastMessageTime = lastMessageWithAttachment?.createdAt ?? Date.now();
|
|
32438
33780
|
const oneHourBeforeLastMessage = lastMessageTime - 60 * 60 * 1e3;
|
|
32439
33781
|
allAttachments = recentMessagesData.filter((msg) => {
|
|
32440
|
-
const msgTime = msg.createdAt;
|
|
33782
|
+
const msgTime = msg.createdAt ?? Date.now();
|
|
32441
33783
|
return msgTime >= oneHourBeforeLastMessage;
|
|
32442
33784
|
}).flatMap((msg) => msg.content.attachments || []);
|
|
32443
33785
|
}
|
|
@@ -32461,28 +33803,34 @@ Text: ${attachment.text}
|
|
|
32461
33803
|
attachments: formattedAttachments
|
|
32462
33804
|
};
|
|
32463
33805
|
}
|
|
33806
|
+
getVerifiableInferenceAdapter() {
|
|
33807
|
+
return this.verifiableInferenceAdapter;
|
|
33808
|
+
}
|
|
33809
|
+
setVerifiableInferenceAdapter(adapter) {
|
|
33810
|
+
this.verifiableInferenceAdapter = adapter;
|
|
33811
|
+
}
|
|
32464
33812
|
};
|
|
32465
33813
|
var formatKnowledge = (knowledge) => {
|
|
32466
33814
|
return knowledge.map((knowledge2) => `- ${knowledge2.content.text}`).join("\n");
|
|
32467
33815
|
};
|
|
32468
33816
|
|
|
32469
33817
|
// src/environment.ts
|
|
32470
|
-
import { z } from "zod";
|
|
32471
|
-
var envSchema =
|
|
33818
|
+
import { z as z2 } from "zod";
|
|
33819
|
+
var envSchema = z2.object({
|
|
32472
33820
|
// API Keys with specific formats
|
|
32473
|
-
OPENAI_API_KEY:
|
|
32474
|
-
REDPILL_API_KEY:
|
|
32475
|
-
GROK_API_KEY:
|
|
32476
|
-
GROQ_API_KEY:
|
|
32477
|
-
OPENROUTER_API_KEY:
|
|
32478
|
-
GOOGLE_GENERATIVE_AI_API_KEY:
|
|
32479
|
-
ELEVENLABS_XI_API_KEY:
|
|
33821
|
+
OPENAI_API_KEY: z2.string().startsWith("sk-", "OpenAI API key must start with 'sk-'"),
|
|
33822
|
+
REDPILL_API_KEY: z2.string().min(1, "REDPILL API key is required"),
|
|
33823
|
+
GROK_API_KEY: z2.string().min(1, "GROK API key is required"),
|
|
33824
|
+
GROQ_API_KEY: z2.string().startsWith("gsk_", "GROQ API key must start with 'gsk_'"),
|
|
33825
|
+
OPENROUTER_API_KEY: z2.string().min(1, "OpenRouter API key is required"),
|
|
33826
|
+
GOOGLE_GENERATIVE_AI_API_KEY: z2.string().min(1, "Gemini API key is required"),
|
|
33827
|
+
ELEVENLABS_XI_API_KEY: z2.string().min(1, "ElevenLabs API key is required")
|
|
32480
33828
|
});
|
|
32481
33829
|
function validateEnv() {
|
|
32482
33830
|
try {
|
|
32483
33831
|
return envSchema.parse(process.env);
|
|
32484
33832
|
} catch (error) {
|
|
32485
|
-
if (error instanceof
|
|
33833
|
+
if (error instanceof z2.ZodError) {
|
|
32486
33834
|
const errorMessages = error.errors.map((err) => `${err.path}: ${err.message}`).join("\n");
|
|
32487
33835
|
throw new Error(`Environment validation failed:
|
|
32488
33836
|
${errorMessages}`);
|
|
@@ -32490,89 +33838,109 @@ ${errorMessages}`);
|
|
|
32490
33838
|
throw error;
|
|
32491
33839
|
}
|
|
32492
33840
|
}
|
|
32493
|
-
var MessageExampleSchema =
|
|
32494
|
-
user:
|
|
32495
|
-
content:
|
|
32496
|
-
text:
|
|
32497
|
-
action:
|
|
32498
|
-
source:
|
|
32499
|
-
url:
|
|
32500
|
-
inReplyTo:
|
|
32501
|
-
attachments:
|
|
32502
|
-
}).and(
|
|
33841
|
+
var MessageExampleSchema = z2.object({
|
|
33842
|
+
user: z2.string(),
|
|
33843
|
+
content: z2.object({
|
|
33844
|
+
text: z2.string(),
|
|
33845
|
+
action: z2.string().optional(),
|
|
33846
|
+
source: z2.string().optional(),
|
|
33847
|
+
url: z2.string().optional(),
|
|
33848
|
+
inReplyTo: z2.string().uuid().optional(),
|
|
33849
|
+
attachments: z2.array(z2.any()).optional()
|
|
33850
|
+
}).and(z2.record(z2.string(), z2.unknown()))
|
|
32503
33851
|
// For additional properties
|
|
32504
33852
|
});
|
|
32505
|
-
var PluginSchema =
|
|
32506
|
-
name:
|
|
32507
|
-
description:
|
|
32508
|
-
actions:
|
|
32509
|
-
providers:
|
|
32510
|
-
evaluators:
|
|
32511
|
-
services:
|
|
32512
|
-
clients:
|
|
33853
|
+
var PluginSchema = z2.object({
|
|
33854
|
+
name: z2.string(),
|
|
33855
|
+
description: z2.string(),
|
|
33856
|
+
actions: z2.array(z2.any()).optional(),
|
|
33857
|
+
providers: z2.array(z2.any()).optional(),
|
|
33858
|
+
evaluators: z2.array(z2.any()).optional(),
|
|
33859
|
+
services: z2.array(z2.any()).optional(),
|
|
33860
|
+
clients: z2.array(z2.any()).optional()
|
|
32513
33861
|
});
|
|
32514
|
-
var CharacterSchema =
|
|
32515
|
-
id:
|
|
32516
|
-
name:
|
|
32517
|
-
system:
|
|
32518
|
-
modelProvider:
|
|
32519
|
-
modelEndpointOverride:
|
|
32520
|
-
templates:
|
|
32521
|
-
bio:
|
|
32522
|
-
lore:
|
|
32523
|
-
messageExamples:
|
|
32524
|
-
postExamples:
|
|
32525
|
-
topics:
|
|
32526
|
-
adjectives:
|
|
32527
|
-
knowledge:
|
|
32528
|
-
|
|
32529
|
-
|
|
32530
|
-
|
|
32531
|
-
|
|
32532
|
-
|
|
32533
|
-
|
|
32534
|
-
|
|
32535
|
-
|
|
32536
|
-
|
|
32537
|
-
|
|
33862
|
+
var CharacterSchema = z2.object({
|
|
33863
|
+
id: z2.string().uuid().optional(),
|
|
33864
|
+
name: z2.string(),
|
|
33865
|
+
system: z2.string().optional(),
|
|
33866
|
+
modelProvider: z2.nativeEnum(ModelProviderName),
|
|
33867
|
+
modelEndpointOverride: z2.string().optional(),
|
|
33868
|
+
templates: z2.record(z2.string()).optional(),
|
|
33869
|
+
bio: z2.union([z2.string(), z2.array(z2.string())]),
|
|
33870
|
+
lore: z2.array(z2.string()),
|
|
33871
|
+
messageExamples: z2.array(z2.array(MessageExampleSchema)),
|
|
33872
|
+
postExamples: z2.array(z2.string()),
|
|
33873
|
+
topics: z2.array(z2.string()),
|
|
33874
|
+
adjectives: z2.array(z2.string()),
|
|
33875
|
+
knowledge: z2.array(
|
|
33876
|
+
z2.union([
|
|
33877
|
+
z2.string(),
|
|
33878
|
+
z2.object({
|
|
33879
|
+
path: z2.string(),
|
|
33880
|
+
shared: z2.boolean().optional()
|
|
33881
|
+
})
|
|
33882
|
+
])
|
|
33883
|
+
).optional(),
|
|
33884
|
+
clients: z2.array(z2.nativeEnum(Clients)),
|
|
33885
|
+
plugins: z2.union([z2.array(z2.string()), z2.array(PluginSchema)]),
|
|
33886
|
+
settings: z2.object({
|
|
33887
|
+
secrets: z2.record(z2.string()).optional(),
|
|
33888
|
+
voice: z2.object({
|
|
33889
|
+
model: z2.string().optional(),
|
|
33890
|
+
url: z2.string().optional()
|
|
32538
33891
|
}).optional(),
|
|
32539
|
-
model:
|
|
32540
|
-
embeddingModel:
|
|
33892
|
+
model: z2.string().optional(),
|
|
33893
|
+
embeddingModel: z2.string().optional()
|
|
32541
33894
|
}).optional(),
|
|
32542
|
-
clientConfig:
|
|
32543
|
-
discord:
|
|
32544
|
-
shouldIgnoreBotMessages:
|
|
32545
|
-
shouldIgnoreDirectMessages:
|
|
33895
|
+
clientConfig: z2.object({
|
|
33896
|
+
discord: z2.object({
|
|
33897
|
+
shouldIgnoreBotMessages: z2.boolean().optional(),
|
|
33898
|
+
shouldIgnoreDirectMessages: z2.boolean().optional()
|
|
32546
33899
|
}).optional(),
|
|
32547
|
-
telegram:
|
|
32548
|
-
shouldIgnoreBotMessages:
|
|
32549
|
-
shouldIgnoreDirectMessages:
|
|
33900
|
+
telegram: z2.object({
|
|
33901
|
+
shouldIgnoreBotMessages: z2.boolean().optional(),
|
|
33902
|
+
shouldIgnoreDirectMessages: z2.boolean().optional()
|
|
32550
33903
|
}).optional()
|
|
32551
33904
|
}).optional(),
|
|
32552
|
-
style:
|
|
32553
|
-
all:
|
|
32554
|
-
chat:
|
|
32555
|
-
post:
|
|
33905
|
+
style: z2.object({
|
|
33906
|
+
all: z2.array(z2.string()),
|
|
33907
|
+
chat: z2.array(z2.string()),
|
|
33908
|
+
post: z2.array(z2.string())
|
|
32556
33909
|
}),
|
|
32557
|
-
twitterProfile:
|
|
32558
|
-
username:
|
|
32559
|
-
screenName:
|
|
32560
|
-
bio:
|
|
32561
|
-
nicknames:
|
|
33910
|
+
twitterProfile: z2.object({
|
|
33911
|
+
username: z2.string(),
|
|
33912
|
+
screenName: z2.string(),
|
|
33913
|
+
bio: z2.string(),
|
|
33914
|
+
nicknames: z2.array(z2.string()).optional()
|
|
33915
|
+
}).optional(),
|
|
33916
|
+
nft: z2.object({
|
|
33917
|
+
prompt: z2.string().optional()
|
|
32562
33918
|
}).optional(),
|
|
32563
|
-
|
|
32564
|
-
prompt: z.string().optional()
|
|
32565
|
-
}).optional()
|
|
33919
|
+
extends: z2.array(z2.string()).optional()
|
|
32566
33920
|
});
|
|
32567
33921
|
function validateCharacterConfig(json) {
|
|
32568
33922
|
try {
|
|
32569
33923
|
return CharacterSchema.parse(json);
|
|
32570
33924
|
} catch (error) {
|
|
32571
|
-
if (error instanceof
|
|
32572
|
-
const
|
|
33925
|
+
if (error instanceof z2.ZodError) {
|
|
33926
|
+
const groupedErrors = error.errors.reduce(
|
|
33927
|
+
(acc, err) => {
|
|
33928
|
+
const path5 = err.path.join(".");
|
|
33929
|
+
if (!acc[path5]) {
|
|
33930
|
+
acc[path5] = [];
|
|
33931
|
+
}
|
|
33932
|
+
acc[path5].push(err.message);
|
|
33933
|
+
return acc;
|
|
33934
|
+
},
|
|
33935
|
+
{}
|
|
33936
|
+
);
|
|
33937
|
+
Object.entries(groupedErrors).forEach(([field, messages]) => {
|
|
33938
|
+
logger_default.error(
|
|
33939
|
+
`Validation errors in ${field}: ${messages.join(" - ")}`
|
|
33940
|
+
);
|
|
33941
|
+
});
|
|
32573
33942
|
throw new Error(
|
|
32574
|
-
|
|
32575
|
-
${errorMessages}`
|
|
33943
|
+
"Character configuration validation failed. Check logs for details."
|
|
32576
33944
|
);
|
|
32577
33945
|
}
|
|
32578
33946
|
throw error;
|
|
@@ -32668,6 +34036,7 @@ var CacheManager = class {
|
|
|
32668
34036
|
}
|
|
32669
34037
|
};
|
|
32670
34038
|
export {
|
|
34039
|
+
ActionTimelineType,
|
|
32671
34040
|
AgentRuntime,
|
|
32672
34041
|
CacheManager,
|
|
32673
34042
|
CacheStore,
|
|
@@ -32678,15 +34047,19 @@ export {
|
|
|
32678
34047
|
EmbeddingProvider,
|
|
32679
34048
|
FsCacheAdapter,
|
|
32680
34049
|
GoalStatus,
|
|
34050
|
+
IrysDataType,
|
|
34051
|
+
IrysMessageType,
|
|
32681
34052
|
LoggingLevel,
|
|
32682
34053
|
MemoryCacheAdapter,
|
|
32683
34054
|
MemoryManager,
|
|
32684
34055
|
ModelClass,
|
|
32685
34056
|
ModelProviderName,
|
|
34057
|
+
RAGKnowledgeManager,
|
|
32686
34058
|
Service,
|
|
32687
34059
|
ServiceType,
|
|
32688
34060
|
TokenizerType,
|
|
32689
34061
|
TranscriptionProvider,
|
|
34062
|
+
VerifiableInferenceProvider,
|
|
32690
34063
|
addHeader,
|
|
32691
34064
|
booleanFooter,
|
|
32692
34065
|
composeActionExamples,
|
|
@@ -32727,12 +34100,14 @@ export {
|
|
|
32727
34100
|
generateWebSearch,
|
|
32728
34101
|
getActorDetails,
|
|
32729
34102
|
getEmbeddingConfig,
|
|
34103
|
+
getEmbeddingModelSettings,
|
|
32730
34104
|
getEmbeddingType,
|
|
32731
34105
|
getEmbeddingZeroVector,
|
|
32732
34106
|
getEndpoint,
|
|
32733
34107
|
getEnvVariable,
|
|
32734
34108
|
getGoals,
|
|
32735
|
-
|
|
34109
|
+
getImageModelSettings,
|
|
34110
|
+
getModelSettings,
|
|
32736
34111
|
getProviders,
|
|
32737
34112
|
getRelationship,
|
|
32738
34113
|
getRelationships,
|
|
@@ -32754,9 +34129,12 @@ export {
|
|
|
32754
34129
|
stringArrayFooter,
|
|
32755
34130
|
stringToUuid,
|
|
32756
34131
|
trimTokens,
|
|
34132
|
+
truncateToCompleteSentence,
|
|
32757
34133
|
updateGoal,
|
|
34134
|
+
uuidSchema,
|
|
32758
34135
|
validateCharacterConfig,
|
|
32759
|
-
validateEnv
|
|
34136
|
+
validateEnv,
|
|
34137
|
+
validateUuid
|
|
32760
34138
|
};
|
|
32761
34139
|
/*! Bundled license information:
|
|
32762
34140
|
|