@ax-llm/ax 11.0.55 → 11.0.57
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 +191 -34
- package/index.cjs.map +1 -1
- package/index.d.cts +3 -0
- package/index.d.ts +3 -0
- package/index.js +191 -34
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1591,6 +1591,8 @@ var GoogleVertexAuth = class {
|
|
|
1591
1591
|
|
|
1592
1592
|
// ai/anthropic/types.ts
|
|
1593
1593
|
var AxAIAnthropicModel = /* @__PURE__ */ ((AxAIAnthropicModel2) => {
|
|
1594
|
+
AxAIAnthropicModel2["Claude4Opus"] = "claude-opus-4-20250514";
|
|
1595
|
+
AxAIAnthropicModel2["Claude4Sonnet"] = "claude-sonnet-4-20250514";
|
|
1594
1596
|
AxAIAnthropicModel2["Claude37Sonnet"] = "claude-3-7-sonnet-latest";
|
|
1595
1597
|
AxAIAnthropicModel2["Claude35Sonnet"] = "claude-3-5-sonnet-latest";
|
|
1596
1598
|
AxAIAnthropicModel2["Claude35Haiku"] = "claude-3-5-haiku-latest";
|
|
@@ -1613,50 +1615,80 @@ var AxAIAnthropicVertexModel = /* @__PURE__ */ ((AxAIAnthropicVertexModel2) => {
|
|
|
1613
1615
|
|
|
1614
1616
|
// ai/anthropic/info.ts
|
|
1615
1617
|
var axModelInfoAnthropic = [
|
|
1616
|
-
//
|
|
1618
|
+
// 4
|
|
1619
|
+
{
|
|
1620
|
+
name: "claude-opus-4-20250514" /* Claude4Opus */,
|
|
1621
|
+
currency: "usd",
|
|
1622
|
+
promptTokenCostPer1M: 15,
|
|
1623
|
+
completionTokenCostPer1M: 75,
|
|
1624
|
+
maxTokens: 32e3
|
|
1625
|
+
},
|
|
1626
|
+
{
|
|
1627
|
+
name: "claude-sonnet-4-20250514" /* Claude4Sonnet */,
|
|
1628
|
+
currency: "usd",
|
|
1629
|
+
promptTokenCostPer1M: 3,
|
|
1630
|
+
completionTokenCostPer1M: 15,
|
|
1631
|
+
maxTokens: 64e3
|
|
1632
|
+
},
|
|
1633
|
+
// 3.7
|
|
1634
|
+
{
|
|
1635
|
+
name: "claude-3-7-sonnet-latest" /* Claude37Sonnet */,
|
|
1636
|
+
currency: "usd",
|
|
1637
|
+
promptTokenCostPer1M: 3,
|
|
1638
|
+
completionTokenCostPer1M: 15,
|
|
1639
|
+
maxTokens: 64e3
|
|
1640
|
+
},
|
|
1641
|
+
// 3.5
|
|
1617
1642
|
{
|
|
1618
1643
|
name: "claude-3-5-sonnet-latest" /* Claude35Sonnet */,
|
|
1619
1644
|
currency: "usd",
|
|
1620
1645
|
promptTokenCostPer1M: 3,
|
|
1621
|
-
completionTokenCostPer1M: 15
|
|
1646
|
+
completionTokenCostPer1M: 15,
|
|
1647
|
+
maxTokens: 8192
|
|
1622
1648
|
},
|
|
1623
1649
|
{
|
|
1624
1650
|
name: "claude-3-5-haiku-latest" /* Claude35Haiku */,
|
|
1625
1651
|
currency: "usd",
|
|
1626
1652
|
promptTokenCostPer1M: 0.8,
|
|
1627
|
-
completionTokenCostPer1M: 4
|
|
1653
|
+
completionTokenCostPer1M: 4,
|
|
1654
|
+
maxTokens: 8192
|
|
1628
1655
|
},
|
|
1629
1656
|
// 3
|
|
1630
1657
|
{
|
|
1631
1658
|
name: "claude-3-opus-latest" /* Claude3Opus */,
|
|
1632
1659
|
currency: "usd",
|
|
1633
1660
|
promptTokenCostPer1M: 15,
|
|
1634
|
-
completionTokenCostPer1M: 75
|
|
1661
|
+
completionTokenCostPer1M: 75,
|
|
1662
|
+
maxTokens: 4096
|
|
1635
1663
|
},
|
|
1636
1664
|
{
|
|
1637
1665
|
name: "claude-3-sonnet-20240229" /* Claude3Sonnet */,
|
|
1638
1666
|
currency: "usd",
|
|
1639
1667
|
promptTokenCostPer1M: 3,
|
|
1640
|
-
completionTokenCostPer1M: 15
|
|
1668
|
+
completionTokenCostPer1M: 15,
|
|
1669
|
+
maxTokens: 4096
|
|
1641
1670
|
},
|
|
1642
1671
|
{
|
|
1643
1672
|
name: "claude-3-haiku-20240307" /* Claude3Haiku */,
|
|
1644
1673
|
currency: "usd",
|
|
1645
1674
|
promptTokenCostPer1M: 0.25,
|
|
1646
|
-
completionTokenCostPer1M: 1.25
|
|
1675
|
+
completionTokenCostPer1M: 1.25,
|
|
1676
|
+
maxTokens: 4096
|
|
1647
1677
|
},
|
|
1648
|
-
//
|
|
1678
|
+
// 2.1
|
|
1649
1679
|
{
|
|
1650
1680
|
name: "claude-2.1" /* Claude21 */,
|
|
1651
1681
|
currency: "usd",
|
|
1652
1682
|
promptTokenCostPer1M: 8,
|
|
1653
|
-
completionTokenCostPer1M: 25
|
|
1683
|
+
completionTokenCostPer1M: 25,
|
|
1684
|
+
maxTokens: 4096
|
|
1654
1685
|
},
|
|
1655
1686
|
{
|
|
1656
1687
|
name: "claude-instant-1.2" /* ClaudeInstant12 */,
|
|
1657
1688
|
currency: "usd",
|
|
1658
1689
|
promptTokenCostPer1M: 0.8,
|
|
1659
|
-
completionTokenCostPer1M: 2.24
|
|
1690
|
+
completionTokenCostPer1M: 2.24,
|
|
1691
|
+
maxTokens: 4096
|
|
1660
1692
|
}
|
|
1661
1693
|
];
|
|
1662
1694
|
|
|
@@ -1681,7 +1713,7 @@ var AxAIAnthropicImpl = class {
|
|
|
1681
1713
|
getModelConfig() {
|
|
1682
1714
|
const { config } = this;
|
|
1683
1715
|
return {
|
|
1684
|
-
maxTokens: config.maxTokens,
|
|
1716
|
+
maxTokens: config.maxTokens ?? 4096,
|
|
1685
1717
|
temperature: config.temperature,
|
|
1686
1718
|
topP: config.topP,
|
|
1687
1719
|
topK: config.topK,
|
|
@@ -1744,13 +1776,18 @@ var AxAIAnthropicImpl = class {
|
|
|
1744
1776
|
input_schema: v.parameters
|
|
1745
1777
|
})
|
|
1746
1778
|
);
|
|
1779
|
+
const maxTokens = req.modelConfig?.maxTokens ?? this.config.maxTokens;
|
|
1780
|
+
const stopSequences = req.modelConfig?.stopSequences ?? this.config.stopSequences;
|
|
1781
|
+
const temperature = req.modelConfig?.temperature ?? this.config.temperature;
|
|
1782
|
+
const topP = req.modelConfig?.topP ?? this.config.topP;
|
|
1783
|
+
const topK = req.modelConfig?.topK ?? this.config.topK;
|
|
1747
1784
|
const reqValue = {
|
|
1748
1785
|
...this.isVertex ? { anthropic_version: "vertex-2023-10-16" } : { model },
|
|
1749
|
-
max_tokens:
|
|
1750
|
-
stop_sequences:
|
|
1751
|
-
temperature
|
|
1752
|
-
top_p:
|
|
1753
|
-
top_k:
|
|
1786
|
+
...maxTokens ? { max_tokens: maxTokens } : {},
|
|
1787
|
+
...stopSequences && stopSequences.length > 0 ? { stop_sequences: stopSequences } : {},
|
|
1788
|
+
...temperature ? { temperature } : {},
|
|
1789
|
+
...topP ? { top_p: topP } : {},
|
|
1790
|
+
...topK ? { top_k: topK } : {},
|
|
1754
1791
|
...toolsChoice,
|
|
1755
1792
|
...tools && tools.length > 0 ? { tools } : {},
|
|
1756
1793
|
...stream ? { stream: true } : {},
|
|
@@ -6892,6 +6929,9 @@ function getFieldProcessingMessage(field, resultText) {
|
|
|
6892
6929
|
var validateJSONSchema = (schema) => {
|
|
6893
6930
|
const errors = [];
|
|
6894
6931
|
const validateSchemaObject = (schema2, path = "") => {
|
|
6932
|
+
if (!schema2 || typeof schema2 !== "object") {
|
|
6933
|
+
return;
|
|
6934
|
+
}
|
|
6895
6935
|
const validTypes = [
|
|
6896
6936
|
"array",
|
|
6897
6937
|
"integer",
|
|
@@ -6901,38 +6941,155 @@ var validateJSONSchema = (schema) => {
|
|
|
6901
6941
|
"null",
|
|
6902
6942
|
"object"
|
|
6903
6943
|
];
|
|
6944
|
+
if (schema2.anyOf && Array.isArray(schema2.anyOf)) {
|
|
6945
|
+
if (schema2.anyOf.length === 0) {
|
|
6946
|
+
errors.push({
|
|
6947
|
+
path: path || "root",
|
|
6948
|
+
issue: "anyOf array is empty",
|
|
6949
|
+
fix: "Add at least one schema to the anyOf array",
|
|
6950
|
+
example: 'anyOf: [{ type: "string" }, { type: "null" }]'
|
|
6951
|
+
});
|
|
6952
|
+
}
|
|
6953
|
+
schema2.anyOf.forEach((subSchema, index) => {
|
|
6954
|
+
validateSchemaObject(subSchema, `${path}anyOf[${index}].`);
|
|
6955
|
+
});
|
|
6956
|
+
return;
|
|
6957
|
+
}
|
|
6958
|
+
if (schema2.oneOf && Array.isArray(schema2.oneOf)) {
|
|
6959
|
+
if (schema2.oneOf.length === 0) {
|
|
6960
|
+
errors.push({
|
|
6961
|
+
path: path || "root",
|
|
6962
|
+
issue: "oneOf array is empty",
|
|
6963
|
+
fix: "Add at least one schema to the oneOf array",
|
|
6964
|
+
example: 'oneOf: [{ type: "string" }, { type: "number" }]'
|
|
6965
|
+
});
|
|
6966
|
+
}
|
|
6967
|
+
schema2.oneOf.forEach((subSchema, index) => {
|
|
6968
|
+
validateSchemaObject(subSchema, `${path}oneOf[${index}].`);
|
|
6969
|
+
});
|
|
6970
|
+
return;
|
|
6971
|
+
}
|
|
6972
|
+
if (schema2.allOf && Array.isArray(schema2.allOf)) {
|
|
6973
|
+
if (schema2.allOf.length === 0) {
|
|
6974
|
+
errors.push({
|
|
6975
|
+
path: path || "root",
|
|
6976
|
+
issue: "allOf array is empty",
|
|
6977
|
+
fix: "Add at least one schema to the allOf array",
|
|
6978
|
+
example: 'allOf: [{ type: "object" }, { properties: { name: { type: "string" } } }]'
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
schema2.allOf.forEach((subSchema, index) => {
|
|
6982
|
+
validateSchemaObject(subSchema, `${path}allOf[${index}].`);
|
|
6983
|
+
});
|
|
6984
|
+
return;
|
|
6985
|
+
}
|
|
6986
|
+
if (!schema2.type) {
|
|
6987
|
+
return;
|
|
6988
|
+
}
|
|
6904
6989
|
if (!validTypes.includes(schema2.type)) {
|
|
6905
|
-
errors.push(
|
|
6990
|
+
errors.push({
|
|
6991
|
+
path: path || "root",
|
|
6992
|
+
issue: `Invalid type '${schema2.type}'`,
|
|
6993
|
+
fix: `Change type to one of: ${validTypes.join(", ")}`,
|
|
6994
|
+
example: `{ type: "string" } or { type: "object" }`
|
|
6995
|
+
});
|
|
6906
6996
|
return;
|
|
6907
6997
|
}
|
|
6908
|
-
if (schema2.type === "object"
|
|
6909
|
-
if (
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6998
|
+
if (schema2.type === "object") {
|
|
6999
|
+
if (schema2.properties) {
|
|
7000
|
+
if (typeof schema2.properties !== "object" || Array.isArray(schema2.properties)) {
|
|
7001
|
+
errors.push({
|
|
7002
|
+
path: path || "root",
|
|
7003
|
+
issue: "properties must be an object, not an array or primitive",
|
|
7004
|
+
fix: "Change properties to be an object with property names as keys",
|
|
7005
|
+
example: 'properties: { name: { type: "string" }, age: { type: "number" } }'
|
|
7006
|
+
});
|
|
7007
|
+
} else {
|
|
7008
|
+
for (const key in schema2.properties) {
|
|
7009
|
+
const value = schema2.properties[key];
|
|
7010
|
+
if (value === void 0 || value === null) {
|
|
7011
|
+
continue;
|
|
7012
|
+
}
|
|
7013
|
+
if (typeof value !== "object") {
|
|
7014
|
+
errors.push({
|
|
7015
|
+
path: `${path}${key}`,
|
|
7016
|
+
issue: `Property schema must be an object, got ${typeof value}`,
|
|
7017
|
+
fix: "Define the property as a proper schema object",
|
|
7018
|
+
example: `${key}: { type: "string", description: "..." }`
|
|
7019
|
+
});
|
|
7020
|
+
continue;
|
|
7021
|
+
}
|
|
7022
|
+
validateSchemaObject(value, `${path}${key}.`);
|
|
6917
7023
|
}
|
|
6918
|
-
validateSchemaObject(value, `${path}${key}.`);
|
|
6919
7024
|
}
|
|
6920
7025
|
}
|
|
6921
|
-
if (schema2.required
|
|
6922
|
-
|
|
7026
|
+
if (schema2.required) {
|
|
7027
|
+
if (!Array.isArray(schema2.required)) {
|
|
7028
|
+
errors.push({
|
|
7029
|
+
path: path || "root",
|
|
7030
|
+
issue: `'required' must be an array, got ${typeof schema2.required}`,
|
|
7031
|
+
fix: "Change required to be an array of property names",
|
|
7032
|
+
example: 'required: ["name", "email"] instead of required: "name,email"'
|
|
7033
|
+
});
|
|
7034
|
+
} else if (schema2.required.length === 0) {
|
|
7035
|
+
} else {
|
|
7036
|
+
if (schema2.properties) {
|
|
7037
|
+
for (const requiredProp of schema2.required) {
|
|
7038
|
+
if (typeof requiredProp !== "string") {
|
|
7039
|
+
errors.push({
|
|
7040
|
+
path: `${path}required`,
|
|
7041
|
+
issue: `Required property names must be strings, got ${typeof requiredProp}`,
|
|
7042
|
+
fix: "Ensure all items in required array are strings",
|
|
7043
|
+
example: 'required: ["name", "email"] not required: [123, "email"]'
|
|
7044
|
+
});
|
|
7045
|
+
} else if (!(requiredProp in schema2.properties)) {
|
|
7046
|
+
errors.push({
|
|
7047
|
+
path: `${path}required`,
|
|
7048
|
+
issue: `Required property '${requiredProp}' is not defined in properties`,
|
|
7049
|
+
fix: `Either add '${requiredProp}' to properties or remove it from required`,
|
|
7050
|
+
example: `properties: { ${requiredProp}: { type: "string" } }`
|
|
7051
|
+
});
|
|
7052
|
+
}
|
|
7053
|
+
}
|
|
7054
|
+
}
|
|
7055
|
+
}
|
|
6923
7056
|
}
|
|
6924
7057
|
}
|
|
6925
|
-
if (schema2.type === "array"
|
|
6926
|
-
if (
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
7058
|
+
if (schema2.type === "array") {
|
|
7059
|
+
if (schema2.items) {
|
|
7060
|
+
if (typeof schema2.items !== "object") {
|
|
7061
|
+
errors.push({
|
|
7062
|
+
path: `${path}items`,
|
|
7063
|
+
issue: `Array items schema must be an object, got ${typeof schema2.items}`,
|
|
7064
|
+
fix: "Define items as a proper schema object",
|
|
7065
|
+
example: 'items: { type: "string" } or items: { type: "object", properties: {...} }'
|
|
7066
|
+
});
|
|
7067
|
+
} else {
|
|
7068
|
+
validateSchemaObject(schema2.items, `${path}items.`);
|
|
7069
|
+
}
|
|
6930
7070
|
}
|
|
6931
7071
|
}
|
|
6932
7072
|
};
|
|
6933
7073
|
validateSchemaObject(schema);
|
|
6934
7074
|
if (errors.length > 0) {
|
|
6935
|
-
|
|
7075
|
+
const errorMessage = [
|
|
7076
|
+
"JSON Schema validation failed:",
|
|
7077
|
+
"",
|
|
7078
|
+
...errors.map((error, index) => {
|
|
7079
|
+
const parts = [
|
|
7080
|
+
`${index + 1}. Path: ${error.path}`,
|
|
7081
|
+
` Issue: ${error.issue}`,
|
|
7082
|
+
` Fix: ${error.fix}`
|
|
7083
|
+
];
|
|
7084
|
+
if (error.example) {
|
|
7085
|
+
parts.push(` Example: ${error.example}`);
|
|
7086
|
+
}
|
|
7087
|
+
return parts.join("\n");
|
|
7088
|
+
}),
|
|
7089
|
+
"",
|
|
7090
|
+
"Please fix these issues and try again."
|
|
7091
|
+
].join("\n");
|
|
7092
|
+
throw new Error(errorMessage);
|
|
6936
7093
|
}
|
|
6937
7094
|
};
|
|
6938
7095
|
|