@copilotkit/shared 1.0.0-beta.1 → 1.0.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/.turbo/turbo-build.log +47 -61
- package/CHANGELOG.md +31 -0
- package/dist/{chunk-3VA36BKL.mjs → chunk-2WEXXBTK.mjs} +1 -4
- package/dist/chunk-2WEXXBTK.mjs.map +1 -0
- package/dist/{chunk-2VLE6D3W.mjs → chunk-3AJ2GKWG.mjs} +2 -2
- package/dist/chunk-3AJ2GKWG.mjs.map +1 -0
- package/dist/chunk-DE5K76I2.mjs +1 -0
- package/dist/chunk-YJLRG5U3.mjs +1 -0
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/index.mjs +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +6 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -14
- package/dist/telemetry/index.js +0 -3
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/index.mjs +1 -1
- package/dist/telemetry/telemetry-client.js +0 -3
- package/dist/telemetry/telemetry-client.js.map +1 -1
- package/dist/telemetry/telemetry-client.mjs +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +1 -2
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.js +5 -168
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +2 -10
- package/package.json +3 -3
- package/src/constants/index.ts +1 -1
- package/src/telemetry/telemetry-client.ts +0 -5
- package/src/types/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/dist/chunk-2VLE6D3W.mjs.map +0 -1
- package/dist/chunk-3VA36BKL.mjs.map +0 -1
- package/dist/chunk-BANDZXMP.mjs +0 -1
- package/dist/chunk-CYDWEPFL.mjs +0 -1
- package/dist/chunk-S4HGLK2E.mjs +0 -163
- package/dist/chunk-S4HGLK2E.mjs.map +0 -1
- package/dist/chunk-YBHX4Y25.mjs +0 -1
- package/dist/chunk-YBHX4Y25.mjs.map +0 -1
- package/dist/types/annotated-function.d.ts +0 -24
- package/dist/types/annotated-function.js +0 -19
- package/dist/types/annotated-function.js.map +0 -1
- package/dist/types/annotated-function.mjs +0 -2
- package/dist/types/annotated-function.mjs.map +0 -1
- package/dist/utils/annotated-function.d.ts +0 -9
- package/dist/utils/annotated-function.js +0 -189
- package/dist/utils/annotated-function.js.map +0 -1
- package/dist/utils/annotated-function.mjs +0 -11
- package/dist/utils/annotated-function.mjs.map +0 -1
- package/src/types/annotated-function.ts +0 -27
- package/src/utils/annotated-function.ts +0 -179
- /package/dist/{chunk-BANDZXMP.mjs.map → chunk-DE5K76I2.mjs.map} +0 -0
- /package/dist/{chunk-CYDWEPFL.mjs.map → chunk-YJLRG5U3.mjs.map} +0 -0
package/dist/chunk-S4HGLK2E.mjs
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
// src/utils/annotated-function.ts
|
|
2
|
-
function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
3
|
-
let parameters = {};
|
|
4
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
5
|
-
let { name, required, ...forwardedArgs } = arg;
|
|
6
|
-
parameters[arg.name] = forwardedArgs;
|
|
7
|
-
}
|
|
8
|
-
let requiredParameterNames = [];
|
|
9
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
10
|
-
if (arg.required) {
|
|
11
|
-
requiredParameterNames.push(arg.name);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
let chatCompletionFunction = {
|
|
15
|
-
type: "function",
|
|
16
|
-
function: {
|
|
17
|
-
name: annotatedFunction.name,
|
|
18
|
-
description: annotatedFunction.description,
|
|
19
|
-
parameters: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: parameters,
|
|
22
|
-
required: requiredParameterNames
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
return chatCompletionFunction;
|
|
27
|
-
}
|
|
28
|
-
function convertAttribute(attribute) {
|
|
29
|
-
var _a, _b, _c;
|
|
30
|
-
switch (attribute.type) {
|
|
31
|
-
case "string":
|
|
32
|
-
return {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: attribute.description,
|
|
35
|
-
...attribute.enum && { enum: attribute.enum }
|
|
36
|
-
};
|
|
37
|
-
case "number":
|
|
38
|
-
case "boolean":
|
|
39
|
-
return {
|
|
40
|
-
type: attribute.type,
|
|
41
|
-
description: attribute.description
|
|
42
|
-
};
|
|
43
|
-
case "object":
|
|
44
|
-
case "object[]":
|
|
45
|
-
const properties = (_a = attribute.attributes) == null ? void 0 : _a.reduce(
|
|
46
|
-
(acc, attr) => {
|
|
47
|
-
acc[attr.name] = convertAttribute(attr);
|
|
48
|
-
return acc;
|
|
49
|
-
},
|
|
50
|
-
{}
|
|
51
|
-
);
|
|
52
|
-
const required = (_b = attribute.attributes) == null ? void 0 : _b.filter((attr) => attr.required !== false).map((attr) => attr.name);
|
|
53
|
-
if (attribute.type === "object[]") {
|
|
54
|
-
return {
|
|
55
|
-
type: "array",
|
|
56
|
-
items: {
|
|
57
|
-
type: "object",
|
|
58
|
-
...properties && { properties },
|
|
59
|
-
...required && required.length > 0 && { required }
|
|
60
|
-
},
|
|
61
|
-
description: attribute.description
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
type: "object",
|
|
66
|
-
description: attribute.description,
|
|
67
|
-
...properties && { properties },
|
|
68
|
-
...required && required.length > 0 && { required }
|
|
69
|
-
};
|
|
70
|
-
default:
|
|
71
|
-
if ((_c = attribute.type) == null ? void 0 : _c.endsWith("[]")) {
|
|
72
|
-
const itemType = attribute.type.slice(0, -2);
|
|
73
|
-
return {
|
|
74
|
-
type: "array",
|
|
75
|
-
items: { type: itemType },
|
|
76
|
-
description: attribute.description
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
type: "string",
|
|
81
|
-
description: attribute.description
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function actionToChatCompletionFunction(action) {
|
|
86
|
-
let parameters = {};
|
|
87
|
-
for (let parameter of action.parameters || []) {
|
|
88
|
-
parameters[parameter.name] = convertAttribute(parameter);
|
|
89
|
-
}
|
|
90
|
-
let requiredParameterNames = [];
|
|
91
|
-
for (let arg of action.parameters || []) {
|
|
92
|
-
if (arg.required !== false) {
|
|
93
|
-
requiredParameterNames.push(arg.name);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
let chatCompletionFunction = {
|
|
97
|
-
type: "function",
|
|
98
|
-
function: {
|
|
99
|
-
name: action.name,
|
|
100
|
-
...action.description && { description: action.description },
|
|
101
|
-
parameters: {
|
|
102
|
-
type: "object",
|
|
103
|
-
properties: parameters,
|
|
104
|
-
required: requiredParameterNames
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
return chatCompletionFunction;
|
|
109
|
-
}
|
|
110
|
-
function annotatedFunctionToAction(annotatedFunction) {
|
|
111
|
-
const parameters = annotatedFunction.argumentAnnotations.map((annotation) => {
|
|
112
|
-
switch (annotation.type) {
|
|
113
|
-
case "string":
|
|
114
|
-
case "number":
|
|
115
|
-
case "boolean":
|
|
116
|
-
case "object":
|
|
117
|
-
return {
|
|
118
|
-
name: annotation.name,
|
|
119
|
-
description: annotation.description,
|
|
120
|
-
type: annotation.type,
|
|
121
|
-
required: annotation.required
|
|
122
|
-
};
|
|
123
|
-
case "array":
|
|
124
|
-
let type;
|
|
125
|
-
if (annotation.items.type === "string") {
|
|
126
|
-
type = "string[]";
|
|
127
|
-
} else if (annotation.items.type === "number") {
|
|
128
|
-
type = "number[]";
|
|
129
|
-
} else if (annotation.items.type === "boolean") {
|
|
130
|
-
type = "boolean[]";
|
|
131
|
-
} else if (annotation.items.type === "object") {
|
|
132
|
-
type = "object[]";
|
|
133
|
-
} else {
|
|
134
|
-
type = "string[]";
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
name: annotation.name,
|
|
138
|
-
description: annotation.description,
|
|
139
|
-
type,
|
|
140
|
-
required: annotation.required
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
name: annotatedFunction.name,
|
|
146
|
-
description: annotatedFunction.description,
|
|
147
|
-
parameters,
|
|
148
|
-
handler: (args) => {
|
|
149
|
-
const paramsInCorrectOrder = [];
|
|
150
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
151
|
-
paramsInCorrectOrder.push(args[arg.name]);
|
|
152
|
-
}
|
|
153
|
-
return annotatedFunction.implementation(...paramsInCorrectOrder);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export {
|
|
159
|
-
annotatedFunctionToChatCompletionFunction,
|
|
160
|
-
actionToChatCompletionFunction,
|
|
161
|
-
annotatedFunctionToAction
|
|
162
|
-
};
|
|
163
|
-
//# sourceMappingURL=chunk-S4HGLK2E.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/annotated-function.ts"],"sourcesContent":["import { Action, AnnotatedFunction, ToolDefinition, Parameter } from \"../types\";\n\nexport function annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>,\n): ToolDefinition {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ToolDefinition = {\n type: \"function\",\n function: {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n },\n };\n\n return chatCompletionFunction;\n}\n\nfunction convertAttribute(attribute: Parameter): any {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function actionToChatCompletionFunction(action: Action<any>): ToolDefinition {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of action.parameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of action.parameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ToolDefinition = {\n type: \"function\",\n function: {\n name: action.name,\n ...(action.description && { description: action.description }),\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n },\n };\n\n return chatCompletionFunction;\n}\n\nexport function annotatedFunctionToAction(\n annotatedFunction: AnnotatedFunction<any[]>,\n): Action<any> {\n const parameters: Parameter[] = annotatedFunction.argumentAnnotations.map((annotation) => {\n switch (annotation.type) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"object\":\n return {\n name: annotation.name,\n description: annotation.description,\n type: annotation.type,\n required: annotation.required,\n };\n case \"array\":\n let type;\n if (annotation.items.type === \"string\") {\n type = \"string[]\";\n } else if (annotation.items.type === \"number\") {\n type = \"number[]\";\n } else if (annotation.items.type === \"boolean\") {\n type = \"boolean[]\";\n } else if (annotation.items.type === \"object\") {\n type = \"object[]\";\n } else {\n type = \"string[]\";\n }\n return {\n name: annotation.name,\n description: annotation.description,\n type: type as any,\n required: annotation.required,\n };\n }\n });\n\n return {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: parameters,\n handler: (args) => {\n const paramsInCorrectOrder: any[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(args[arg.name]);\n }\n return annotatedFunction.implementation(...paramsInCorrectOrder);\n },\n };\n}\n"],"mappings":";AAEO,SAAS,0CACd,mBACgB;AAEhB,MAAI,aAAqC,CAAC;AAC1C,WAAS,OAAO,kBAAkB,qBAAqB;AAErD,QAAI,EAAE,MAAM,UAAU,GAAG,cAAc,IAAI;AAC3C,eAAW,IAAI,IAAI,IAAI;AAAA,EACzB;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,kBAAkB,qBAAqB;AACrD,QAAI,IAAI,UAAU;AAChB,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,MAAI,yBAAyC;AAAA,IAC3C,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,WAA2B;AAr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,UAAU,WAAW;AAAA,QACvB;AAAA,IACJ;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,MAAM,kBAAkB;AAAA,IACxB,aAAa,kBAAkB;AAAA,IAC/B;AAAA,IACA,SAAS,CAAC,SAAS;AACjB,YAAM,uBAA8B,CAAC;AACrC,eAAS,OAAO,kBAAkB,qBAAqB;AACrD,6BAAqB,KAAK,KAAK,IAAI,IAAI,CAAC;AAAA,MAC1C;AACA,aAAO,kBAAkB,eAAe,GAAG,oBAAoB;AAAA,IACjE;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-YBHX4Y25.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-YBHX4Y25.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
interface AnnotatedFunctionSimpleArgument {
|
|
2
|
-
name: string;
|
|
3
|
-
type: "string" | "number" | "boolean" | "object";
|
|
4
|
-
description: string;
|
|
5
|
-
required: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface AnnotatedFunctionArrayArgument {
|
|
8
|
-
name: string;
|
|
9
|
-
type: "array";
|
|
10
|
-
items: {
|
|
11
|
-
type: string;
|
|
12
|
-
};
|
|
13
|
-
description: string;
|
|
14
|
-
required: boolean;
|
|
15
|
-
}
|
|
16
|
-
type AnnotatedFunctionArgument = AnnotatedFunctionSimpleArgument | AnnotatedFunctionArrayArgument;
|
|
17
|
-
interface AnnotatedFunction<Inputs extends any[]> {
|
|
18
|
-
name: string;
|
|
19
|
-
description: string;
|
|
20
|
-
argumentAnnotations: AnnotatedFunctionArgument[];
|
|
21
|
-
implementation: (...args: Inputs) => Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export { AnnotatedFunction, AnnotatedFunctionArgument, AnnotatedFunctionArrayArgument, AnnotatedFunctionSimpleArgument };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/types/annotated-function.ts
|
|
17
|
-
var annotated_function_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(annotated_function_exports);
|
|
19
|
-
//# sourceMappingURL=annotated-function.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/annotated-function.ts"],"sourcesContent":["export interface AnnotatedFunctionSimpleArgument {\n name: string;\n type: \"string\" | \"number\" | \"boolean\" | \"object\"; // Add or change types according to your needs.\n description: string;\n required: boolean;\n}\n\nexport interface AnnotatedFunctionArrayArgument {\n name: string;\n type: \"array\";\n items: {\n type: string;\n };\n description: string;\n required: boolean;\n}\n\nexport type AnnotatedFunctionArgument =\n | AnnotatedFunctionSimpleArgument\n | AnnotatedFunctionArrayArgument;\n\nexport interface AnnotatedFunction<Inputs extends any[]> {\n name: string;\n description: string;\n argumentAnnotations: AnnotatedFunctionArgument[];\n implementation: (...args: Inputs) => Promise<any>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ToolDefinition } from '../types/openai-assistant.js';
|
|
2
|
-
import { AnnotatedFunction } from '../types/annotated-function.js';
|
|
3
|
-
import { Action } from '../types/action.js';
|
|
4
|
-
|
|
5
|
-
declare function annotatedFunctionToChatCompletionFunction(annotatedFunction: AnnotatedFunction<any[]>): ToolDefinition;
|
|
6
|
-
declare function actionToChatCompletionFunction(action: Action<any>): ToolDefinition;
|
|
7
|
-
declare function annotatedFunctionToAction(annotatedFunction: AnnotatedFunction<any[]>): Action<any>;
|
|
8
|
-
|
|
9
|
-
export { actionToChatCompletionFunction, annotatedFunctionToAction, annotatedFunctionToChatCompletionFunction };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/utils/annotated-function.ts
|
|
21
|
-
var annotated_function_exports = {};
|
|
22
|
-
__export(annotated_function_exports, {
|
|
23
|
-
actionToChatCompletionFunction: () => actionToChatCompletionFunction,
|
|
24
|
-
annotatedFunctionToAction: () => annotatedFunctionToAction,
|
|
25
|
-
annotatedFunctionToChatCompletionFunction: () => annotatedFunctionToChatCompletionFunction
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(annotated_function_exports);
|
|
28
|
-
function annotatedFunctionToChatCompletionFunction(annotatedFunction) {
|
|
29
|
-
let parameters = {};
|
|
30
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
31
|
-
let { name, required, ...forwardedArgs } = arg;
|
|
32
|
-
parameters[arg.name] = forwardedArgs;
|
|
33
|
-
}
|
|
34
|
-
let requiredParameterNames = [];
|
|
35
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
36
|
-
if (arg.required) {
|
|
37
|
-
requiredParameterNames.push(arg.name);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
let chatCompletionFunction = {
|
|
41
|
-
type: "function",
|
|
42
|
-
function: {
|
|
43
|
-
name: annotatedFunction.name,
|
|
44
|
-
description: annotatedFunction.description,
|
|
45
|
-
parameters: {
|
|
46
|
-
type: "object",
|
|
47
|
-
properties: parameters,
|
|
48
|
-
required: requiredParameterNames
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
return chatCompletionFunction;
|
|
53
|
-
}
|
|
54
|
-
function convertAttribute(attribute) {
|
|
55
|
-
var _a, _b, _c;
|
|
56
|
-
switch (attribute.type) {
|
|
57
|
-
case "string":
|
|
58
|
-
return {
|
|
59
|
-
type: "string",
|
|
60
|
-
description: attribute.description,
|
|
61
|
-
...attribute.enum && { enum: attribute.enum }
|
|
62
|
-
};
|
|
63
|
-
case "number":
|
|
64
|
-
case "boolean":
|
|
65
|
-
return {
|
|
66
|
-
type: attribute.type,
|
|
67
|
-
description: attribute.description
|
|
68
|
-
};
|
|
69
|
-
case "object":
|
|
70
|
-
case "object[]":
|
|
71
|
-
const properties = (_a = attribute.attributes) == null ? void 0 : _a.reduce(
|
|
72
|
-
(acc, attr) => {
|
|
73
|
-
acc[attr.name] = convertAttribute(attr);
|
|
74
|
-
return acc;
|
|
75
|
-
},
|
|
76
|
-
{}
|
|
77
|
-
);
|
|
78
|
-
const required = (_b = attribute.attributes) == null ? void 0 : _b.filter((attr) => attr.required !== false).map((attr) => attr.name);
|
|
79
|
-
if (attribute.type === "object[]") {
|
|
80
|
-
return {
|
|
81
|
-
type: "array",
|
|
82
|
-
items: {
|
|
83
|
-
type: "object",
|
|
84
|
-
...properties && { properties },
|
|
85
|
-
...required && required.length > 0 && { required }
|
|
86
|
-
},
|
|
87
|
-
description: attribute.description
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
type: "object",
|
|
92
|
-
description: attribute.description,
|
|
93
|
-
...properties && { properties },
|
|
94
|
-
...required && required.length > 0 && { required }
|
|
95
|
-
};
|
|
96
|
-
default:
|
|
97
|
-
if ((_c = attribute.type) == null ? void 0 : _c.endsWith("[]")) {
|
|
98
|
-
const itemType = attribute.type.slice(0, -2);
|
|
99
|
-
return {
|
|
100
|
-
type: "array",
|
|
101
|
-
items: { type: itemType },
|
|
102
|
-
description: attribute.description
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
type: "string",
|
|
107
|
-
description: attribute.description
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function actionToChatCompletionFunction(action) {
|
|
112
|
-
let parameters = {};
|
|
113
|
-
for (let parameter of action.parameters || []) {
|
|
114
|
-
parameters[parameter.name] = convertAttribute(parameter);
|
|
115
|
-
}
|
|
116
|
-
let requiredParameterNames = [];
|
|
117
|
-
for (let arg of action.parameters || []) {
|
|
118
|
-
if (arg.required !== false) {
|
|
119
|
-
requiredParameterNames.push(arg.name);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
let chatCompletionFunction = {
|
|
123
|
-
type: "function",
|
|
124
|
-
function: {
|
|
125
|
-
name: action.name,
|
|
126
|
-
...action.description && { description: action.description },
|
|
127
|
-
parameters: {
|
|
128
|
-
type: "object",
|
|
129
|
-
properties: parameters,
|
|
130
|
-
required: requiredParameterNames
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
return chatCompletionFunction;
|
|
135
|
-
}
|
|
136
|
-
function annotatedFunctionToAction(annotatedFunction) {
|
|
137
|
-
const parameters = annotatedFunction.argumentAnnotations.map((annotation) => {
|
|
138
|
-
switch (annotation.type) {
|
|
139
|
-
case "string":
|
|
140
|
-
case "number":
|
|
141
|
-
case "boolean":
|
|
142
|
-
case "object":
|
|
143
|
-
return {
|
|
144
|
-
name: annotation.name,
|
|
145
|
-
description: annotation.description,
|
|
146
|
-
type: annotation.type,
|
|
147
|
-
required: annotation.required
|
|
148
|
-
};
|
|
149
|
-
case "array":
|
|
150
|
-
let type;
|
|
151
|
-
if (annotation.items.type === "string") {
|
|
152
|
-
type = "string[]";
|
|
153
|
-
} else if (annotation.items.type === "number") {
|
|
154
|
-
type = "number[]";
|
|
155
|
-
} else if (annotation.items.type === "boolean") {
|
|
156
|
-
type = "boolean[]";
|
|
157
|
-
} else if (annotation.items.type === "object") {
|
|
158
|
-
type = "object[]";
|
|
159
|
-
} else {
|
|
160
|
-
type = "string[]";
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
name: annotation.name,
|
|
164
|
-
description: annotation.description,
|
|
165
|
-
type,
|
|
166
|
-
required: annotation.required
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
return {
|
|
171
|
-
name: annotatedFunction.name,
|
|
172
|
-
description: annotatedFunction.description,
|
|
173
|
-
parameters,
|
|
174
|
-
handler: (args) => {
|
|
175
|
-
const paramsInCorrectOrder = [];
|
|
176
|
-
for (let arg of annotatedFunction.argumentAnnotations) {
|
|
177
|
-
paramsInCorrectOrder.push(args[arg.name]);
|
|
178
|
-
}
|
|
179
|
-
return annotatedFunction.implementation(...paramsInCorrectOrder);
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
-
0 && (module.exports = {
|
|
185
|
-
actionToChatCompletionFunction,
|
|
186
|
-
annotatedFunctionToAction,
|
|
187
|
-
annotatedFunctionToChatCompletionFunction
|
|
188
|
-
});
|
|
189
|
-
//# sourceMappingURL=annotated-function.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/annotated-function.ts"],"sourcesContent":["import { Action, AnnotatedFunction, ToolDefinition, Parameter } from \"../types\";\n\nexport function annotatedFunctionToChatCompletionFunction(\n annotatedFunction: AnnotatedFunction<any[]>,\n): ToolDefinition {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let arg of annotatedFunction.argumentAnnotations) {\n // isolate the args we should forward inline\n let { name, required, ...forwardedArgs } = arg;\n parameters[arg.name] = forwardedArgs;\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n if (arg.required) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ToolDefinition = {\n type: \"function\",\n function: {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n },\n };\n\n return chatCompletionFunction;\n}\n\nfunction convertAttribute(attribute: Parameter): any {\n switch (attribute.type) {\n case \"string\":\n return {\n type: \"string\",\n description: attribute.description,\n ...(attribute.enum && { enum: attribute.enum }),\n };\n case \"number\":\n case \"boolean\":\n return {\n type: attribute.type,\n description: attribute.description,\n };\n case \"object\":\n case \"object[]\":\n const properties = attribute.attributes?.reduce(\n (acc, attr) => {\n acc[attr.name] = convertAttribute(attr);\n return acc;\n },\n {} as Record<string, any>,\n );\n const required = attribute.attributes\n ?.filter((attr) => attr.required !== false)\n .map((attr) => attr.name);\n if (attribute.type === \"object[]\") {\n return {\n type: \"array\",\n items: {\n type: \"object\",\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n },\n description: attribute.description,\n };\n }\n return {\n type: \"object\",\n description: attribute.description,\n ...(properties && { properties }),\n ...(required && required.length > 0 && { required }),\n };\n default:\n // Handle arrays of primitive types and undefined attribute.type\n if (attribute.type?.endsWith(\"[]\")) {\n const itemType = attribute.type.slice(0, -2);\n return {\n type: \"array\",\n items: { type: itemType },\n description: attribute.description,\n };\n }\n // Fallback for undefined type or any other unexpected type\n return {\n type: \"string\",\n description: attribute.description,\n };\n }\n}\n\nexport function actionToChatCompletionFunction(action: Action<any>): ToolDefinition {\n // Create the parameters object based on the argumentAnnotations\n let parameters: { [key: string]: any } = {};\n for (let parameter of action.parameters || []) {\n parameters[parameter.name] = convertAttribute(parameter);\n }\n\n let requiredParameterNames: string[] = [];\n for (let arg of action.parameters || []) {\n if (arg.required !== false) {\n requiredParameterNames.push(arg.name);\n }\n }\n\n // Create the ChatCompletionFunctions object\n let chatCompletionFunction: ToolDefinition = {\n type: \"function\",\n function: {\n name: action.name,\n ...(action.description && { description: action.description }),\n parameters: {\n type: \"object\",\n properties: parameters,\n required: requiredParameterNames,\n },\n },\n };\n\n return chatCompletionFunction;\n}\n\nexport function annotatedFunctionToAction(\n annotatedFunction: AnnotatedFunction<any[]>,\n): Action<any> {\n const parameters: Parameter[] = annotatedFunction.argumentAnnotations.map((annotation) => {\n switch (annotation.type) {\n case \"string\":\n case \"number\":\n case \"boolean\":\n case \"object\":\n return {\n name: annotation.name,\n description: annotation.description,\n type: annotation.type,\n required: annotation.required,\n };\n case \"array\":\n let type;\n if (annotation.items.type === \"string\") {\n type = \"string[]\";\n } else if (annotation.items.type === \"number\") {\n type = \"number[]\";\n } else if (annotation.items.type === \"boolean\") {\n type = \"boolean[]\";\n } else if (annotation.items.type === \"object\") {\n type = \"object[]\";\n } else {\n type = \"string[]\";\n }\n return {\n name: annotation.name,\n description: annotation.description,\n type: type as any,\n required: annotation.required,\n };\n }\n });\n\n return {\n name: annotatedFunction.name,\n description: annotatedFunction.description,\n parameters: parameters,\n handler: (args) => {\n const paramsInCorrectOrder: any[] = [];\n for (let arg of annotatedFunction.argumentAnnotations) {\n paramsInCorrectOrder.push(args[arg.name]);\n }\n return annotatedFunction.implementation(...paramsInCorrectOrder);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,0CACd,mBACgB;AAEhB,MAAI,aAAqC,CAAC;AAC1C,WAAS,OAAO,kBAAkB,qBAAqB;AAErD,QAAI,EAAE,MAAM,UAAU,GAAG,cAAc,IAAI;AAC3C,eAAW,IAAI,IAAI,IAAI;AAAA,EACzB;AAEA,MAAI,yBAAmC,CAAC;AACxC,WAAS,OAAO,kBAAkB,qBAAqB;AACrD,QAAI,IAAI,UAAU;AAChB,6BAAuB,KAAK,IAAI,IAAI;AAAA,IACtC;AAAA,EACF;AAGA,MAAI,yBAAyC;AAAA,IAC3C,MAAM;AAAA,IACN,UAAU;AAAA,MACR,MAAM,kBAAkB;AAAA,MACxB,aAAa,kBAAkB;AAAA,MAC/B,YAAY;AAAA,QACV,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,iBAAiB,WAA2B;AArCrD;AAsCE,UAAQ,UAAU,MAAM;AAAA,IACtB,KAAK;AACH,aAAO;AAAA,QACL,MAAM;AAAA,QACN,aAAa,UAAU;AAAA,QACvB,GAAI,UAAU,QAAQ,EAAE,MAAM,UAAU,KAAK;AAAA,MAC/C;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,QACL,MAAM,UAAU;AAAA,QAChB,aAAa,UAAU;AAAA,MACzB;AAAA,IACF,KAAK;AAAA,IACL,KAAK;AACH,YAAM,cAAa,eAAU,eAAV,mBAA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;AACF;","names":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
actionToChatCompletionFunction,
|
|
3
|
-
annotatedFunctionToAction,
|
|
4
|
-
annotatedFunctionToChatCompletionFunction
|
|
5
|
-
} from "../chunk-S4HGLK2E.mjs";
|
|
6
|
-
export {
|
|
7
|
-
actionToChatCompletionFunction,
|
|
8
|
-
annotatedFunctionToAction,
|
|
9
|
-
annotatedFunctionToChatCompletionFunction
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=annotated-function.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface AnnotatedFunctionSimpleArgument {
|
|
2
|
-
name: string;
|
|
3
|
-
type: "string" | "number" | "boolean" | "object"; // Add or change types according to your needs.
|
|
4
|
-
description: string;
|
|
5
|
-
required: boolean;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface AnnotatedFunctionArrayArgument {
|
|
9
|
-
name: string;
|
|
10
|
-
type: "array";
|
|
11
|
-
items: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
description: string;
|
|
15
|
-
required: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type AnnotatedFunctionArgument =
|
|
19
|
-
| AnnotatedFunctionSimpleArgument
|
|
20
|
-
| AnnotatedFunctionArrayArgument;
|
|
21
|
-
|
|
22
|
-
export interface AnnotatedFunction<Inputs extends any[]> {
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
argumentAnnotations: AnnotatedFunctionArgument[];
|
|
26
|
-
implementation: (...args: Inputs) => Promise<any>;
|
|
27
|
-
}
|