@ax-llm/ax 11.0.64 → 11.0.65
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 +145 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +40 -1
- package/index.d.ts +40 -1
- package/index.js +143 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -124,6 +124,7 @@ __export(index_exports, {
|
|
|
124
124
|
AxSpanKindValues: () => AxSpanKindValues,
|
|
125
125
|
AxStringUtil: () => AxStringUtil,
|
|
126
126
|
AxTestPrompt: () => AxTestPrompt,
|
|
127
|
+
ax: () => ax,
|
|
127
128
|
axAIAnthropicDefaultConfig: () => axAIAnthropicDefaultConfig,
|
|
128
129
|
axAIAnthropicVertexDefaultConfig: () => axAIAnthropicVertexDefaultConfig,
|
|
129
130
|
axAIAzureOpenAIBestConfig: () => axAIAzureOpenAIBestConfig,
|
|
@@ -158,6 +159,7 @@ __export(index_exports, {
|
|
|
158
159
|
axAITogetherDefaultConfig: () => axAITogetherDefaultConfig,
|
|
159
160
|
axBaseAIDefaultConfig: () => axBaseAIDefaultConfig,
|
|
160
161
|
axBaseAIDefaultCreativeConfig: () => axBaseAIDefaultCreativeConfig,
|
|
162
|
+
axField: () => axField,
|
|
161
163
|
axModelInfoAnthropic: () => axModelInfoAnthropic,
|
|
162
164
|
axModelInfoCohere: () => axModelInfoCohere,
|
|
163
165
|
axModelInfoDeepSeek: () => axModelInfoDeepSeek,
|
|
@@ -11931,6 +11933,147 @@ var AxTestPrompt = class {
|
|
|
11931
11933
|
}
|
|
11932
11934
|
};
|
|
11933
11935
|
|
|
11936
|
+
// dsp/template.ts
|
|
11937
|
+
function ax(strings, ...values) {
|
|
11938
|
+
let result = "";
|
|
11939
|
+
for (let i = 0; i < strings.length; i++) {
|
|
11940
|
+
result += strings[i] ?? "";
|
|
11941
|
+
if (i < values.length) {
|
|
11942
|
+
const val = values[i];
|
|
11943
|
+
if (isAxFieldType(val)) {
|
|
11944
|
+
const fieldNameMatch = result.match(/(\w+)\s*:\s*$/);
|
|
11945
|
+
if (fieldNameMatch && (val.isOptional || val.isInternal)) {
|
|
11946
|
+
const fieldName = fieldNameMatch[1];
|
|
11947
|
+
let modifiedFieldName = fieldName;
|
|
11948
|
+
if (val.isOptional) modifiedFieldName += "?";
|
|
11949
|
+
if (val.isInternal) modifiedFieldName += "!";
|
|
11950
|
+
result = result.replace(/(\w+)(\s*:\s*)$/, `${modifiedFieldName}$2`);
|
|
11951
|
+
}
|
|
11952
|
+
const { isOptional: _o, isInternal: _i, ...typeNoFlags } = val;
|
|
11953
|
+
result += convertFieldTypeToString(typeNoFlags);
|
|
11954
|
+
} else if (isAxFieldDescriptor(val)) {
|
|
11955
|
+
result += convertFieldDescriptorToString(val);
|
|
11956
|
+
} else if (typeof val === "string" || val instanceof AxSignature) {
|
|
11957
|
+
result += convertValueToSignatureString(val);
|
|
11958
|
+
} else {
|
|
11959
|
+
throw new Error("Unsupported template interpolation value");
|
|
11960
|
+
}
|
|
11961
|
+
}
|
|
11962
|
+
}
|
|
11963
|
+
return new AxSignature(result);
|
|
11964
|
+
}
|
|
11965
|
+
function convertValueToSignatureString(value) {
|
|
11966
|
+
if (typeof value === "string") {
|
|
11967
|
+
return value;
|
|
11968
|
+
}
|
|
11969
|
+
if (isAxFieldType(value)) {
|
|
11970
|
+
return convertFieldTypeToString(value);
|
|
11971
|
+
}
|
|
11972
|
+
if (isAxFieldDescriptor(value)) {
|
|
11973
|
+
return convertFieldDescriptorToString(value);
|
|
11974
|
+
}
|
|
11975
|
+
if (value instanceof AxSignature) {
|
|
11976
|
+
const sigString = value.toString();
|
|
11977
|
+
const arrowIndex = sigString.indexOf(" -> ");
|
|
11978
|
+
if (arrowIndex !== -1) {
|
|
11979
|
+
return sigString.substring(arrowIndex + 4);
|
|
11980
|
+
}
|
|
11981
|
+
return sigString;
|
|
11982
|
+
}
|
|
11983
|
+
throw new Error(`Unsupported template value type: ${typeof value}`);
|
|
11984
|
+
}
|
|
11985
|
+
function convertFieldTypeToString(fieldType) {
|
|
11986
|
+
let result = fieldType.type;
|
|
11987
|
+
if (fieldType.isArray) {
|
|
11988
|
+
result += "[]";
|
|
11989
|
+
}
|
|
11990
|
+
if (fieldType.options && fieldType.options.length > 0 && fieldType.type === "class") {
|
|
11991
|
+
result += ` "${fieldType.options.join(", ")}"`;
|
|
11992
|
+
}
|
|
11993
|
+
if (fieldType.description) {
|
|
11994
|
+
result += ` "${fieldType.description}"`;
|
|
11995
|
+
}
|
|
11996
|
+
return result;
|
|
11997
|
+
}
|
|
11998
|
+
function convertFieldDescriptorToString(descriptor) {
|
|
11999
|
+
let result = descriptor.name;
|
|
12000
|
+
if (descriptor.isOptional) {
|
|
12001
|
+
result += "?";
|
|
12002
|
+
}
|
|
12003
|
+
if (descriptor.isInternal) {
|
|
12004
|
+
result += "!";
|
|
12005
|
+
}
|
|
12006
|
+
if (descriptor.type) {
|
|
12007
|
+
result += ":" + convertFieldTypeToString(descriptor.type);
|
|
12008
|
+
}
|
|
12009
|
+
if (descriptor.description && !descriptor.type?.description) {
|
|
12010
|
+
result += ` "${descriptor.description}"`;
|
|
12011
|
+
}
|
|
12012
|
+
return result;
|
|
12013
|
+
}
|
|
12014
|
+
function isAxFieldType(value) {
|
|
12015
|
+
return value !== null && typeof value === "object" && value !== void 0 && "type" in value && typeof value.type === "string";
|
|
12016
|
+
}
|
|
12017
|
+
function isAxFieldDescriptor(value) {
|
|
12018
|
+
return value !== null && typeof value === "object" && value !== void 0 && "name" in value && typeof value.name === "string";
|
|
12019
|
+
}
|
|
12020
|
+
var axField = {
|
|
12021
|
+
string: (desc) => ({
|
|
12022
|
+
type: "string",
|
|
12023
|
+
description: desc
|
|
12024
|
+
}),
|
|
12025
|
+
number: (desc) => ({
|
|
12026
|
+
type: "number",
|
|
12027
|
+
description: desc
|
|
12028
|
+
}),
|
|
12029
|
+
boolean: (desc) => ({
|
|
12030
|
+
type: "boolean",
|
|
12031
|
+
description: desc
|
|
12032
|
+
}),
|
|
12033
|
+
date: (desc) => ({
|
|
12034
|
+
type: "date",
|
|
12035
|
+
description: desc
|
|
12036
|
+
}),
|
|
12037
|
+
datetime: (desc) => ({
|
|
12038
|
+
type: "datetime",
|
|
12039
|
+
description: desc
|
|
12040
|
+
}),
|
|
12041
|
+
json: (desc) => ({
|
|
12042
|
+
type: "json",
|
|
12043
|
+
description: desc
|
|
12044
|
+
}),
|
|
12045
|
+
image: (desc) => ({
|
|
12046
|
+
type: "image",
|
|
12047
|
+
description: desc
|
|
12048
|
+
}),
|
|
12049
|
+
audio: (desc) => ({
|
|
12050
|
+
type: "audio",
|
|
12051
|
+
description: desc
|
|
12052
|
+
}),
|
|
12053
|
+
class: (options, desc) => ({
|
|
12054
|
+
type: "class",
|
|
12055
|
+
options,
|
|
12056
|
+
description: desc
|
|
12057
|
+
}),
|
|
12058
|
+
code: (language, desc) => ({
|
|
12059
|
+
type: "code",
|
|
12060
|
+
options: [language],
|
|
12061
|
+
description: desc
|
|
12062
|
+
}),
|
|
12063
|
+
array: (baseType) => ({
|
|
12064
|
+
...baseType,
|
|
12065
|
+
isArray: true
|
|
12066
|
+
}),
|
|
12067
|
+
optional: (baseType) => ({
|
|
12068
|
+
...baseType,
|
|
12069
|
+
isOptional: true
|
|
12070
|
+
}),
|
|
12071
|
+
internal: (baseType) => ({
|
|
12072
|
+
...baseType,
|
|
12073
|
+
isInternal: true
|
|
12074
|
+
})
|
|
12075
|
+
};
|
|
12076
|
+
|
|
11934
12077
|
// prompts/cot.ts
|
|
11935
12078
|
var AxChainOfThought = class extends AxGen {
|
|
11936
12079
|
constructor(signature, options) {
|
|
@@ -13899,6 +14042,7 @@ var AxRAG = class extends AxChainOfThought {
|
|
|
13899
14042
|
AxSpanKindValues,
|
|
13900
14043
|
AxStringUtil,
|
|
13901
14044
|
AxTestPrompt,
|
|
14045
|
+
ax,
|
|
13902
14046
|
axAIAnthropicDefaultConfig,
|
|
13903
14047
|
axAIAnthropicVertexDefaultConfig,
|
|
13904
14048
|
axAIAzureOpenAIBestConfig,
|
|
@@ -13933,6 +14077,7 @@ var AxRAG = class extends AxChainOfThought {
|
|
|
13933
14077
|
axAITogetherDefaultConfig,
|
|
13934
14078
|
axBaseAIDefaultConfig,
|
|
13935
14079
|
axBaseAIDefaultCreativeConfig,
|
|
14080
|
+
axField,
|
|
13936
14081
|
axModelInfoAnthropic,
|
|
13937
14082
|
axModelInfoCohere,
|
|
13938
14083
|
axModelInfoDeepSeek,
|