@agtlantis/core 0.4.1 → 0.5.0
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/{base-provider-C3mFLNiN.d.cts → base-provider-2TTw5HAa.d.cts} +20 -2
- package/dist/{base-provider-C3mFLNiN.d.ts → base-provider-2TTw5HAa.d.ts} +20 -2
- package/dist/index.cjs +92 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -28
- package/dist/index.d.ts +32 -28
- package/dist/index.js +92 -194
- package/dist/index.js.map +1 -1
- package/dist/testing/index.cjs +31 -8
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +5 -1
- package/dist/testing/index.d.ts +5 -1
- package/dist/testing/index.js +31 -4
- package/dist/testing/index.js.map +1 -1
- package/package.json +2 -4
package/dist/testing/index.cjs
CHANGED
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var test = require('ai/test');
|
|
4
4
|
var ai = require('ai');
|
|
5
|
-
var merge = require('lodash/merge');
|
|
6
|
-
|
|
7
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
-
|
|
9
|
-
var merge__default = /*#__PURE__*/_interopDefault(merge);
|
|
10
5
|
|
|
11
6
|
// src/session/usage-extractors.ts
|
|
12
7
|
function mergeUsages(usages) {
|
|
@@ -718,6 +713,23 @@ var BaseProvider = class {
|
|
|
718
713
|
}
|
|
719
714
|
};
|
|
720
715
|
|
|
716
|
+
// src/utils/deep-merge.ts
|
|
717
|
+
function isPlainObject(value) {
|
|
718
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
719
|
+
}
|
|
720
|
+
function deepMerge(...sources) {
|
|
721
|
+
const result = {};
|
|
722
|
+
for (const source of sources) {
|
|
723
|
+
if (!source) continue;
|
|
724
|
+
for (const key of Object.keys(source)) {
|
|
725
|
+
const existing = result[key];
|
|
726
|
+
const incoming = source[key];
|
|
727
|
+
result[key] = isPlainObject(existing) && isPlainObject(incoming) ? deepMerge(existing, incoming) : incoming;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return result;
|
|
731
|
+
}
|
|
732
|
+
|
|
721
733
|
// src/pricing/defaults.ts
|
|
722
734
|
var OPENAI_PRICING = {
|
|
723
735
|
"gpt-4o": { inputPricePerMillion: 2.5, outputPricePerMillion: 10 },
|
|
@@ -926,6 +938,7 @@ var SimpleSession = class {
|
|
|
926
938
|
providerPricing;
|
|
927
939
|
defaultProviderOptions;
|
|
928
940
|
defaultTools;
|
|
941
|
+
defaultGenerationOptions;
|
|
929
942
|
_fileManager;
|
|
930
943
|
logger;
|
|
931
944
|
sessionStartTime;
|
|
@@ -940,6 +953,7 @@ var SimpleSession = class {
|
|
|
940
953
|
this.providerPricing = options.providerPricing;
|
|
941
954
|
this.defaultProviderOptions = options.defaultProviderOptions;
|
|
942
955
|
this.defaultTools = options.defaultTools;
|
|
956
|
+
this.defaultGenerationOptions = options.defaultGenerationOptions;
|
|
943
957
|
this._fileManager = options.fileManager;
|
|
944
958
|
this.logger = options.logger ?? noopLogger;
|
|
945
959
|
this.sessionStartTime = options.startTime ?? Date.now();
|
|
@@ -976,7 +990,7 @@ var SimpleSession = class {
|
|
|
976
990
|
const { model: requestedModel, providerOptions, tools, ...restParams } = params;
|
|
977
991
|
const languageModel = this.getModel(requestedModel);
|
|
978
992
|
const modelId = this.extractModelId(languageModel);
|
|
979
|
-
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ?
|
|
993
|
+
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
|
|
980
994
|
const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
|
|
981
995
|
this.logger.onLLMCallStart?.({
|
|
982
996
|
type: "llm_call_start",
|
|
@@ -987,6 +1001,7 @@ var SimpleSession = class {
|
|
|
987
1001
|
});
|
|
988
1002
|
try {
|
|
989
1003
|
const result = await ai.generateText({
|
|
1004
|
+
...this.defaultGenerationOptions,
|
|
990
1005
|
...restParams,
|
|
991
1006
|
tools: mergedTools,
|
|
992
1007
|
providerOptions: mergedProviderOptions,
|
|
@@ -1037,7 +1052,7 @@ var SimpleSession = class {
|
|
|
1037
1052
|
const { model: requestedModel, providerOptions, tools, ...restParams } = params;
|
|
1038
1053
|
const languageModel = this.getModel(requestedModel);
|
|
1039
1054
|
const modelId = this.extractModelId(languageModel);
|
|
1040
|
-
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ?
|
|
1055
|
+
const mergedProviderOptions = this.defaultProviderOptions || providerOptions ? deepMerge(this.defaultProviderOptions ?? {}, providerOptions ?? {}) : void 0;
|
|
1041
1056
|
const mergedTools = this.defaultTools || tools ? { ...this.defaultTools, ...tools } : void 0;
|
|
1042
1057
|
this.logger.onLLMCallStart?.({
|
|
1043
1058
|
type: "llm_call_start",
|
|
@@ -1047,6 +1062,7 @@ var SimpleSession = class {
|
|
|
1047
1062
|
request: { params: restParams }
|
|
1048
1063
|
});
|
|
1049
1064
|
const result = ai.streamText({
|
|
1065
|
+
...this.defaultGenerationOptions,
|
|
1050
1066
|
...restParams,
|
|
1051
1067
|
tools: mergedTools,
|
|
1052
1068
|
providerOptions: mergedProviderOptions,
|
|
@@ -1214,7 +1230,8 @@ var StreamingSession = class extends SimpleSession {
|
|
|
1214
1230
|
startTime: options.startTime,
|
|
1215
1231
|
signal: options.signal,
|
|
1216
1232
|
defaultProviderOptions: options.defaultProviderOptions,
|
|
1217
|
-
defaultTools: options.defaultTools
|
|
1233
|
+
defaultTools: options.defaultTools,
|
|
1234
|
+
defaultGenerationOptions: options.defaultGenerationOptions
|
|
1218
1235
|
});
|
|
1219
1236
|
this.lastEventTime = this._startTime;
|
|
1220
1237
|
this._logger.onExecutionStart?.({
|
|
@@ -1494,6 +1511,12 @@ var MockProvider = class _MockProvider extends BaseProvider {
|
|
|
1494
1511
|
withDefaultOptions(_options) {
|
|
1495
1512
|
return this;
|
|
1496
1513
|
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Mock implementation - returns same provider since mocks don't use generation options.
|
|
1516
|
+
*/
|
|
1517
|
+
withDefaultGenerationOptions(_options) {
|
|
1518
|
+
return this;
|
|
1519
|
+
}
|
|
1497
1520
|
createSimpleSession(signal) {
|
|
1498
1521
|
return new SimpleSession({ ...this.buildSessionConfig(), signal });
|
|
1499
1522
|
}
|