@ax-llm/ax 11.0.17 → 11.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +10 -15
- package/index.cjs.map +1 -1
- package/index.js +10 -15
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -4435,8 +4435,6 @@ var validateValue = (field, value) => {
|
|
|
4435
4435
|
switch (expectedType) {
|
|
4436
4436
|
case "code":
|
|
4437
4437
|
return typeof val === "string";
|
|
4438
|
-
case "json":
|
|
4439
|
-
return typeof val === "object";
|
|
4440
4438
|
case "string":
|
|
4441
4439
|
return typeof val === "string";
|
|
4442
4440
|
case "number":
|
|
@@ -4570,7 +4568,9 @@ function mergeDeltas(base, delta) {
|
|
|
4570
4568
|
for (const key of Object.keys(delta)) {
|
|
4571
4569
|
const baseValue = base[key];
|
|
4572
4570
|
const deltaValue = delta[key];
|
|
4573
|
-
if (
|
|
4571
|
+
if (baseValue === void 0 && Array.isArray(deltaValue)) {
|
|
4572
|
+
base[key] = [...deltaValue];
|
|
4573
|
+
} else if (Array.isArray(baseValue) && Array.isArray(deltaValue)) {
|
|
4574
4574
|
base[key] = [...baseValue ?? [], ...deltaValue];
|
|
4575
4575
|
} else if ((baseValue === void 0 || typeof baseValue === "string") && typeof deltaValue === "string") {
|
|
4576
4576
|
base[key] = (baseValue ?? "") + deltaValue;
|
|
@@ -5430,18 +5430,12 @@ function processStreamingDelta(content, xstate) {
|
|
|
5430
5430
|
const { name: fieldName, type: fieldType } = xstate.currField ?? {};
|
|
5431
5431
|
const { isArray: fieldIsArray, name: fieldTypeName } = fieldType ?? {};
|
|
5432
5432
|
if (!xstate.streamedIndex) {
|
|
5433
|
-
xstate.streamedIndex = {};
|
|
5433
|
+
xstate.streamedIndex = { [fieldName]: 0 };
|
|
5434
5434
|
}
|
|
5435
5435
|
if (fieldIsArray) {
|
|
5436
|
-
if (xstate.streamedIndex[fieldName] === void 0) {
|
|
5437
|
-
xstate.streamedIndex[fieldName] = 0;
|
|
5438
|
-
}
|
|
5439
5436
|
return null;
|
|
5440
5437
|
}
|
|
5441
5438
|
if (fieldTypeName !== "string" && fieldTypeName !== "code") {
|
|
5442
|
-
if (xstate.streamedIndex[fieldName] === void 0) {
|
|
5443
|
-
xstate.streamedIndex[fieldName] = 0;
|
|
5444
|
-
}
|
|
5445
5439
|
return null;
|
|
5446
5440
|
}
|
|
5447
5441
|
const pos = xstate.streamedIndex[fieldName] ?? 0;
|
|
@@ -5480,14 +5474,15 @@ function* streamValues(sig, values, xstate, delta) {
|
|
|
5480
5474
|
for (const key of Object.keys(values)) {
|
|
5481
5475
|
const value = values[key];
|
|
5482
5476
|
if (Array.isArray(value)) {
|
|
5483
|
-
|
|
5484
|
-
throw new Error("Streamed index is not set for array field " + key);
|
|
5485
|
-
}
|
|
5486
|
-
const s = xstate.streamedIndex[key];
|
|
5477
|
+
const s = xstate.streamedIndex?.[key] ?? 0;
|
|
5487
5478
|
const v = value.slice(s);
|
|
5488
5479
|
if (v && v.length > 0) {
|
|
5489
5480
|
yield { [key]: v };
|
|
5490
|
-
xstate.streamedIndex
|
|
5481
|
+
if (xstate.streamedIndex) {
|
|
5482
|
+
xstate.streamedIndex[key] = s + 1;
|
|
5483
|
+
} else {
|
|
5484
|
+
xstate.streamedIndex = { [key]: s + 1 };
|
|
5485
|
+
}
|
|
5491
5486
|
}
|
|
5492
5487
|
} else {
|
|
5493
5488
|
yield { [key]: value };
|