typia 6.10.0-dev.20240909 → 6.10.0-dev.20240910-2
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/lib/executable/TypiaSetupWizard.js +48 -25
- package/lib/executable/TypiaSetupWizard.js.map +1 -1
- package/lib/executable/setup/PackageManager.js +12 -12
- package/lib/executable/setup/PackageManager.js.map +1 -1
- package/lib/factories/MetadataFactory.d.ts +2 -0
- package/lib/factories/MetadataFactory.js +89 -40
- package/lib/factories/MetadataFactory.js.map +1 -1
- package/lib/factories/internal/metadata/emplace_metadata_object.js +9 -3
- package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_comment_tags.js +3 -1
- package/lib/factories/internal/metadata/iterate_metadata_comment_tags.js.map +1 -1
- package/lib/factories/internal/metadata/iterate_metadata_function.js +2 -2
- package/lib/factories/internal/metadata/iterate_metadata_function.js.map +1 -1
- package/lib/llm.d.ts +8 -8
- package/lib/programmers/llm/LlmApplicationProgrammer.js +4 -1
- package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
- package/lib/transformers/TransformerError.js +6 -1
- package/lib/transformers/TransformerError.js.map +1 -1
- package/package.json +2 -1
- package/src/executable/TypiaGenerateWizard.ts +83 -83
- package/src/executable/TypiaPatchWizard.ts +42 -42
- package/src/executable/TypiaSetupWizard.ts +160 -151
- package/src/executable/setup/ArgumentParser.ts +43 -43
- package/src/executable/setup/CommandExecutor.ts +8 -8
- package/src/executable/setup/FileRetriever.ts +22 -22
- package/src/executable/setup/PackageManager.ts +86 -86
- package/src/executable/setup/PluginConfigurator.ts +69 -69
- package/src/executable/typia.ts +55 -55
- package/src/factories/MetadataFactory.ts +43 -2
- package/src/factories/internal/metadata/emplace_metadata_object.ts +9 -3
- package/src/factories/internal/metadata/iterate_metadata_comment_tags.ts +3 -1
- package/src/factories/internal/metadata/iterate_metadata_function.ts +2 -0
- package/src/llm.ts +8 -8
- package/src/programmers/llm/LlmApplicationProgrammer.ts +6 -1
- package/src/transformers/TransformerError.ts +6 -1
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import comments from "comment-json";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
5
|
-
|
|
6
|
-
export namespace PluginConfigurator {
|
|
7
|
-
export async function configure(
|
|
8
|
-
args: TypiaSetupWizard.IArguments,
|
|
9
|
-
): Promise<void> {
|
|
10
|
-
// GET COMPILER-OPTIONS
|
|
11
|
-
const config: comments.CommentObject = comments.parse(
|
|
12
|
-
await fs.promises.readFile(args.project!, "utf8"),
|
|
13
|
-
) as comments.CommentObject;
|
|
14
|
-
const compilerOptions = config.compilerOptions as
|
|
15
|
-
| comments.CommentObject
|
|
16
|
-
| undefined;
|
|
17
|
-
if (compilerOptions === undefined)
|
|
18
|
-
throw new ReferenceError(
|
|
19
|
-
`${args.project} file does not have "compilerOptions" property.`,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// PREPARE PLUGINS
|
|
23
|
-
const plugins: comments.CommentArray<comments.CommentObject> = (() => {
|
|
24
|
-
const plugins = compilerOptions.plugins as
|
|
25
|
-
| comments.CommentArray<comments.CommentObject>
|
|
26
|
-
| undefined;
|
|
27
|
-
if (plugins === undefined) return (compilerOptions.plugins = [] as any);
|
|
28
|
-
else if (!Array.isArray(plugins))
|
|
29
|
-
throw new TypeError(
|
|
30
|
-
`"plugins" property of ${args.project} must be array type.`,
|
|
31
|
-
);
|
|
32
|
-
return plugins;
|
|
33
|
-
})();
|
|
34
|
-
|
|
35
|
-
const strict: boolean | undefined = compilerOptions.strict as
|
|
36
|
-
| boolean
|
|
37
|
-
| undefined;
|
|
38
|
-
const strictNullChecks: boolean | undefined =
|
|
39
|
-
compilerOptions.strictNullChecks as boolean | undefined;
|
|
40
|
-
const oldbie: comments.CommentObject | undefined = plugins.find(
|
|
41
|
-
(p) =>
|
|
42
|
-
typeof p === "object" &&
|
|
43
|
-
p !== null &&
|
|
44
|
-
p.transform === "typia/lib/transform",
|
|
45
|
-
);
|
|
46
|
-
if (
|
|
47
|
-
strictNullChecks !== false &&
|
|
48
|
-
(strict === true || strictNullChecks === true) &&
|
|
49
|
-
oldbie !== undefined
|
|
50
|
-
)
|
|
51
|
-
return;
|
|
52
|
-
|
|
53
|
-
// DO CONFIGURE
|
|
54
|
-
compilerOptions.strictNullChecks = true;
|
|
55
|
-
if (strict === undefined && strictNullChecks === undefined)
|
|
56
|
-
compilerOptions.strict = true;
|
|
57
|
-
if (oldbie === undefined)
|
|
58
|
-
plugins.push(
|
|
59
|
-
comments.parse(`
|
|
60
|
-
{
|
|
61
|
-
"transform": "typia/lib/transform"
|
|
62
|
-
}`) as comments.CommentObject,
|
|
63
|
-
);
|
|
64
|
-
await fs.promises.writeFile(
|
|
65
|
-
args.project!,
|
|
66
|
-
comments.stringify(config, null, 2),
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
import comments from "comment-json";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
import { TypiaSetupWizard } from "../TypiaSetupWizard";
|
|
5
|
+
|
|
6
|
+
export namespace PluginConfigurator {
|
|
7
|
+
export async function configure(
|
|
8
|
+
args: TypiaSetupWizard.IArguments,
|
|
9
|
+
): Promise<void> {
|
|
10
|
+
// GET COMPILER-OPTIONS
|
|
11
|
+
const config: comments.CommentObject = comments.parse(
|
|
12
|
+
await fs.promises.readFile(args.project!, "utf8"),
|
|
13
|
+
) as comments.CommentObject;
|
|
14
|
+
const compilerOptions = config.compilerOptions as
|
|
15
|
+
| comments.CommentObject
|
|
16
|
+
| undefined;
|
|
17
|
+
if (compilerOptions === undefined)
|
|
18
|
+
throw new ReferenceError(
|
|
19
|
+
`${args.project} file does not have "compilerOptions" property.`,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// PREPARE PLUGINS
|
|
23
|
+
const plugins: comments.CommentArray<comments.CommentObject> = (() => {
|
|
24
|
+
const plugins = compilerOptions.plugins as
|
|
25
|
+
| comments.CommentArray<comments.CommentObject>
|
|
26
|
+
| undefined;
|
|
27
|
+
if (plugins === undefined) return (compilerOptions.plugins = [] as any);
|
|
28
|
+
else if (!Array.isArray(plugins))
|
|
29
|
+
throw new TypeError(
|
|
30
|
+
`"plugins" property of ${args.project} must be array type.`,
|
|
31
|
+
);
|
|
32
|
+
return plugins;
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
const strict: boolean | undefined = compilerOptions.strict as
|
|
36
|
+
| boolean
|
|
37
|
+
| undefined;
|
|
38
|
+
const strictNullChecks: boolean | undefined =
|
|
39
|
+
compilerOptions.strictNullChecks as boolean | undefined;
|
|
40
|
+
const oldbie: comments.CommentObject | undefined = plugins.find(
|
|
41
|
+
(p) =>
|
|
42
|
+
typeof p === "object" &&
|
|
43
|
+
p !== null &&
|
|
44
|
+
p.transform === "typia/lib/transform",
|
|
45
|
+
);
|
|
46
|
+
if (
|
|
47
|
+
strictNullChecks !== false &&
|
|
48
|
+
(strict === true || strictNullChecks === true) &&
|
|
49
|
+
oldbie !== undefined
|
|
50
|
+
)
|
|
51
|
+
return;
|
|
52
|
+
|
|
53
|
+
// DO CONFIGURE
|
|
54
|
+
compilerOptions.strictNullChecks = true;
|
|
55
|
+
if (strict === undefined && strictNullChecks === undefined)
|
|
56
|
+
compilerOptions.strict = true;
|
|
57
|
+
if (oldbie === undefined)
|
|
58
|
+
plugins.push(
|
|
59
|
+
comments.parse(`
|
|
60
|
+
{
|
|
61
|
+
"transform": "typia/lib/transform"
|
|
62
|
+
}`) as comments.CommentObject,
|
|
63
|
+
);
|
|
64
|
+
await fs.promises.writeFile(
|
|
65
|
+
args.project!,
|
|
66
|
+
comments.stringify(config, null, 2),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/executable/typia.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
-
|
|
4
|
-
npx typia setup \\
|
|
5
|
-
--manager (npm|pnpm|yarn) \\
|
|
6
|
-
--project {tsconfig.json file path}
|
|
7
|
-
|
|
8
|
-
- npx typia setup
|
|
9
|
-
- npx typia setup --manager pnpm
|
|
10
|
-
- npx typia setup --project tsconfig.test.json
|
|
11
|
-
|
|
12
|
-
npx typia generate
|
|
13
|
-
--input {directory} \\
|
|
14
|
-
--output {directory}
|
|
15
|
-
|
|
16
|
-
--npx typia generate --input src/templates --output src/functinoal
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
const halt = (desc: string): never => {
|
|
20
|
-
console.error(desc);
|
|
21
|
-
process.exit(-1);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const main = async (): Promise<void> => {
|
|
25
|
-
try {
|
|
26
|
-
await import("comment-json");
|
|
27
|
-
await import("inquirer");
|
|
28
|
-
await import("commander");
|
|
29
|
-
} catch {
|
|
30
|
-
halt(`typia has not been installed. Run "npm i typia" before.`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const type: string | undefined = process.argv[2];
|
|
34
|
-
if (type === "setup") {
|
|
35
|
-
const { TypiaSetupWizard } = await import("./TypiaSetupWizard");
|
|
36
|
-
await TypiaSetupWizard.setup();
|
|
37
|
-
} else if (type === "patch") {
|
|
38
|
-
const { TypiaPatchWizard } = await import("./TypiaPatchWizard");
|
|
39
|
-
await TypiaPatchWizard.main();
|
|
40
|
-
} else if (type === "generate") {
|
|
41
|
-
try {
|
|
42
|
-
await import("typescript");
|
|
43
|
-
} catch {
|
|
44
|
-
halt(
|
|
45
|
-
`typescript has not been installed. Run "npm i -D typescript" before.`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
|
|
49
|
-
await TypiaGenerateWizard.generate();
|
|
50
|
-
} else halt(USAGE);
|
|
51
|
-
};
|
|
52
|
-
main().catch((exp) => {
|
|
53
|
-
console.error(exp);
|
|
54
|
-
process.exit(-1);
|
|
55
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const USAGE = `Wrong command has been detected. Use like below:
|
|
3
|
+
|
|
4
|
+
npx typia setup \\
|
|
5
|
+
--manager (npm|pnpm|yarn) \\
|
|
6
|
+
--project {tsconfig.json file path}
|
|
7
|
+
|
|
8
|
+
- npx typia setup
|
|
9
|
+
- npx typia setup --manager pnpm
|
|
10
|
+
- npx typia setup --project tsconfig.test.json
|
|
11
|
+
|
|
12
|
+
npx typia generate
|
|
13
|
+
--input {directory} \\
|
|
14
|
+
--output {directory}
|
|
15
|
+
|
|
16
|
+
--npx typia generate --input src/templates --output src/functinoal
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const halt = (desc: string): never => {
|
|
20
|
+
console.error(desc);
|
|
21
|
+
process.exit(-1);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const main = async (): Promise<void> => {
|
|
25
|
+
try {
|
|
26
|
+
await import("comment-json");
|
|
27
|
+
await import("inquirer");
|
|
28
|
+
await import("commander");
|
|
29
|
+
} catch {
|
|
30
|
+
halt(`typia has not been installed. Run "npm i typia" before.`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const type: string | undefined = process.argv[2];
|
|
34
|
+
if (type === "setup") {
|
|
35
|
+
const { TypiaSetupWizard } = await import("./TypiaSetupWizard");
|
|
36
|
+
await TypiaSetupWizard.setup();
|
|
37
|
+
} else if (type === "patch") {
|
|
38
|
+
const { TypiaPatchWizard } = await import("./TypiaPatchWizard");
|
|
39
|
+
await TypiaPatchWizard.main();
|
|
40
|
+
} else if (type === "generate") {
|
|
41
|
+
try {
|
|
42
|
+
await import("typescript");
|
|
43
|
+
} catch {
|
|
44
|
+
halt(
|
|
45
|
+
`typescript has not been installed. Run "npm i -D typescript" before.`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
const { TypiaGenerateWizard } = await import("./TypiaGenerateWizard");
|
|
49
|
+
await TypiaGenerateWizard.generate();
|
|
50
|
+
} else halt(USAGE);
|
|
51
|
+
};
|
|
52
|
+
main().catch((exp) => {
|
|
53
|
+
console.error(exp);
|
|
54
|
+
process.exit(-1);
|
|
55
|
+
});
|
|
@@ -4,6 +4,7 @@ import { Metadata } from "../schemas/metadata/Metadata";
|
|
|
4
4
|
import { MetadataAlias } from "../schemas/metadata/MetadataAlias";
|
|
5
5
|
import { MetadataArrayType } from "../schemas/metadata/MetadataArrayType";
|
|
6
6
|
import { MetadataConstant } from "../schemas/metadata/MetadataConstant";
|
|
7
|
+
import { MetadataFunction } from "../schemas/metadata/MetadataFunction";
|
|
7
8
|
import { MetadataObject } from "../schemas/metadata/MetadataObject";
|
|
8
9
|
import { MetadataTupleType } from "../schemas/metadata/MetadataTupleType";
|
|
9
10
|
import { explore_metadata } from "./internal/metadata/explore_metadata";
|
|
@@ -32,6 +33,8 @@ export namespace MetadataFactory {
|
|
|
32
33
|
object: MetadataObject | null;
|
|
33
34
|
property: string | object | null;
|
|
34
35
|
nested: null | MetadataAlias | MetadataArrayType | MetadataTupleType;
|
|
36
|
+
parameter: string | null;
|
|
37
|
+
output: boolean;
|
|
35
38
|
escaped: boolean;
|
|
36
39
|
aliased: boolean;
|
|
37
40
|
}
|
|
@@ -54,9 +57,11 @@ export namespace MetadataFactory {
|
|
|
54
57
|
top: true,
|
|
55
58
|
object: null,
|
|
56
59
|
property: null,
|
|
60
|
+
parameter: null,
|
|
57
61
|
nested: null,
|
|
58
|
-
escaped: false,
|
|
59
62
|
aliased: false,
|
|
63
|
+
escaped: false,
|
|
64
|
+
output: false,
|
|
60
65
|
});
|
|
61
66
|
iterate_metadata_collection(errors)(collection);
|
|
62
67
|
iterate_metadata_sort(collection)(meta);
|
|
@@ -105,14 +110,17 @@ export namespace MetadataFactory {
|
|
|
105
110
|
arrays: new Set(),
|
|
106
111
|
tuples: new Set(),
|
|
107
112
|
aliases: new Set(),
|
|
113
|
+
functions: new Set(),
|
|
108
114
|
};
|
|
109
115
|
validateMeta(context)(options)(visitor)(meta, {
|
|
110
116
|
object: null,
|
|
111
117
|
property: null,
|
|
118
|
+
parameter: null,
|
|
112
119
|
nested: null,
|
|
113
120
|
top: true,
|
|
114
121
|
aliased: false,
|
|
115
122
|
escaped: false,
|
|
123
|
+
output: false,
|
|
116
124
|
});
|
|
117
125
|
return visitor.errors;
|
|
118
126
|
};
|
|
@@ -157,6 +165,8 @@ export namespace MetadataFactory {
|
|
|
157
165
|
validateTuple(context)(options)(visitor)(tuple.type, explore);
|
|
158
166
|
for (const obj of meta.objects)
|
|
159
167
|
validateObject(context)(options)(visitor)(obj);
|
|
168
|
+
for (const func of meta.functions)
|
|
169
|
+
validateFunction(context)(options)(visitor)(func, explore);
|
|
160
170
|
for (const set of meta.sets)
|
|
161
171
|
validateMeta(context)(options)(visitor)(set, explore);
|
|
162
172
|
for (const map of meta.maps) {
|
|
@@ -230,9 +240,11 @@ export namespace MetadataFactory {
|
|
|
230
240
|
object,
|
|
231
241
|
top: false,
|
|
232
242
|
property: null,
|
|
243
|
+
parameter: null,
|
|
233
244
|
nested: null,
|
|
234
|
-
escaped: false,
|
|
235
245
|
aliased: false,
|
|
246
|
+
escaped: false,
|
|
247
|
+
output: false,
|
|
236
248
|
};
|
|
237
249
|
const errors: string[] = options.validate(
|
|
238
250
|
Metadata.create({
|
|
@@ -255,10 +267,38 @@ export namespace MetadataFactory {
|
|
|
255
267
|
property: property.key.isSoleLiteral()
|
|
256
268
|
? property.key.getSoleLiteral()!
|
|
257
269
|
: {},
|
|
270
|
+
parameter: null,
|
|
258
271
|
nested: null,
|
|
259
272
|
top: false,
|
|
260
273
|
aliased: false,
|
|
261
274
|
escaped: false,
|
|
275
|
+
output: false,
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const validateFunction =
|
|
280
|
+
(context?: ts.TransformationContext) =>
|
|
281
|
+
(options: IOptions) =>
|
|
282
|
+
(visitor: IValidationVisitor) =>
|
|
283
|
+
(func: MetadataFunction, explore: IExplore) => {
|
|
284
|
+
if (visitor.functions.has(func)) return;
|
|
285
|
+
visitor.functions.add(func);
|
|
286
|
+
|
|
287
|
+
for (const param of func.parameters)
|
|
288
|
+
validateMeta(context)(options)(visitor)(param.type, {
|
|
289
|
+
...explore,
|
|
290
|
+
parameter: param.name,
|
|
291
|
+
nested: null,
|
|
292
|
+
top: false,
|
|
293
|
+
output: false,
|
|
294
|
+
});
|
|
295
|
+
if (func.output)
|
|
296
|
+
validateMeta(context)(options)(visitor)(func.output, {
|
|
297
|
+
...explore,
|
|
298
|
+
parameter: null,
|
|
299
|
+
nested: null,
|
|
300
|
+
top: false,
|
|
301
|
+
output: true,
|
|
262
302
|
});
|
|
263
303
|
};
|
|
264
304
|
|
|
@@ -269,5 +309,6 @@ export namespace MetadataFactory {
|
|
|
269
309
|
arrays: Set<MetadataArrayType>;
|
|
270
310
|
tuples: Set<MetadataTupleType>;
|
|
271
311
|
aliases: Set<MetadataAlias>;
|
|
312
|
+
functions: Set<MetadataFunction>;
|
|
272
313
|
}
|
|
273
314
|
}
|
|
@@ -101,9 +101,11 @@ export const emplace_metadata_object =
|
|
|
101
101
|
top: false,
|
|
102
102
|
object: obj,
|
|
103
103
|
property: prop.name,
|
|
104
|
+
parameter: null,
|
|
104
105
|
nested: null,
|
|
105
|
-
escaped: false,
|
|
106
106
|
aliased: false,
|
|
107
|
+
escaped: false,
|
|
108
|
+
output: false,
|
|
107
109
|
});
|
|
108
110
|
Writable(value).optional = (prop.flags & ts.SymbolFlags.Optional) !== 0;
|
|
109
111
|
insert(key)(value)(prop);
|
|
@@ -119,9 +121,11 @@ export const emplace_metadata_object =
|
|
|
119
121
|
top: false,
|
|
120
122
|
object: obj,
|
|
121
123
|
property,
|
|
124
|
+
parameter: null,
|
|
122
125
|
nested: null,
|
|
123
|
-
escaped: false,
|
|
124
126
|
aliased: false,
|
|
127
|
+
escaped: false,
|
|
128
|
+
output: false,
|
|
125
129
|
});
|
|
126
130
|
const key: Metadata = analyzer(index.keyType)(null);
|
|
127
131
|
const value: Metadata = analyzer(index.type)({});
|
|
@@ -145,9 +149,11 @@ export const emplace_metadata_object =
|
|
|
145
149
|
top: false,
|
|
146
150
|
object: obj,
|
|
147
151
|
property: "[key]",
|
|
152
|
+
parameter: null,
|
|
148
153
|
nested: null,
|
|
149
|
-
escaped: false,
|
|
150
154
|
aliased: false,
|
|
155
|
+
escaped: false,
|
|
156
|
+
output: false,
|
|
151
157
|
},
|
|
152
158
|
messages: [],
|
|
153
159
|
});
|
|
@@ -17,9 +17,11 @@ export const iterate_metadata_comment_tags =
|
|
|
17
17
|
property: property.key.isSoleLiteral()
|
|
18
18
|
? property.key.getSoleLiteral()!
|
|
19
19
|
: {},
|
|
20
|
+
parameter: null,
|
|
20
21
|
nested: null,
|
|
21
|
-
escaped: false,
|
|
22
22
|
aliased: false,
|
|
23
|
+
escaped: false,
|
|
24
|
+
output: false,
|
|
23
25
|
},
|
|
24
26
|
);
|
|
25
27
|
}
|
|
@@ -57,6 +57,7 @@ export const iterate_metadata_function =
|
|
|
57
57
|
{
|
|
58
58
|
...explore,
|
|
59
59
|
top: false,
|
|
60
|
+
parameter: p.name,
|
|
60
61
|
},
|
|
61
62
|
),
|
|
62
63
|
description: CommentFactory.description(p) ?? null,
|
|
@@ -75,6 +76,7 @@ export const iterate_metadata_function =
|
|
|
75
76
|
{
|
|
76
77
|
...explore,
|
|
77
78
|
top: false,
|
|
79
|
+
output: true,
|
|
78
80
|
},
|
|
79
81
|
),
|
|
80
82
|
}),
|
package/src/llm.ts
CHANGED
|
@@ -5,11 +5,11 @@ import * as Namespace from "./functional/Namespace";
|
|
|
5
5
|
/**
|
|
6
6
|
* > You must configure the generic argument `App`.
|
|
7
7
|
*
|
|
8
|
-
* TypeScript functions to LLM function
|
|
8
|
+
* TypeScript functions to LLM function calling application.
|
|
9
9
|
*
|
|
10
|
-
* Creates an application of LLM (Large Language Model) function calling
|
|
11
|
-
* a TypeScript class or interface type containig the target functions to be
|
|
12
|
-
* the LLM function calling feature.
|
|
10
|
+
* Creates an application of LLM (Large Language Model) function calling application
|
|
11
|
+
* from a TypeScript class or interface type containig the target functions to be
|
|
12
|
+
* called by the LLM function calling feature.
|
|
13
13
|
*
|
|
14
14
|
* If you put the returned {@link ILlmApplication.functions} objects to the LLM provider
|
|
15
15
|
* like [OpenAI (ChatGPT)](https://openai.com/), the LLM will automatically select the
|
|
@@ -43,11 +43,11 @@ import * as Namespace from "./functional/Namespace";
|
|
|
43
43
|
function application(options?: ILlmApplication.IOptions): never;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* TypeScript functions to LLM function
|
|
46
|
+
* TypeScript functions to LLM function calling application.
|
|
47
47
|
*
|
|
48
|
-
* Creates an application of LLM (Large Language Model) function calling
|
|
49
|
-
* a TypeScript class or interface type containig the target functions to be
|
|
50
|
-
* the LLM function calling feature.
|
|
48
|
+
* Creates an application of LLM (Large Language Model) function calling application
|
|
49
|
+
* from a TypeScript class or interface type containig the target functions to be
|
|
50
|
+
* called by the LLM function calling feature.
|
|
51
51
|
*
|
|
52
52
|
* If you put the returned {@link ILlmApplication.functions} objects to the LLM provider
|
|
53
53
|
* like [OpenAI (ChatGPT)](https://openai.com/), the LLM will automatically select the
|
|
@@ -64,9 +64,11 @@ export namespace LlmApplicationProgrammer {
|
|
|
64
64
|
top: true,
|
|
65
65
|
object: null,
|
|
66
66
|
property: null,
|
|
67
|
+
parameter: null,
|
|
67
68
|
nested: null,
|
|
68
|
-
escaped: false,
|
|
69
69
|
aliased: false,
|
|
70
|
+
escaped: false,
|
|
71
|
+
output: false,
|
|
70
72
|
});
|
|
71
73
|
if (errors.length)
|
|
72
74
|
throw new Error("Failed to write LLM application: " + errors.join("\n"));
|
|
@@ -80,6 +82,9 @@ export namespace LlmApplicationProgrammer {
|
|
|
80
82
|
p.value.size() === 1 &&
|
|
81
83
|
p.key.isSoleLiteral(),
|
|
82
84
|
)
|
|
85
|
+
.filter(
|
|
86
|
+
(p) => p.jsDocTags.find((tag) => tag.name === "hidden") === undefined,
|
|
87
|
+
)
|
|
83
88
|
.map((p) =>
|
|
84
89
|
writeFunction({
|
|
85
90
|
name: p.key.getSoleLiteral()!,
|
|
@@ -32,10 +32,15 @@ export namespace TransformerError {
|
|
|
32
32
|
e.explore.object === null
|
|
33
33
|
? ""
|
|
34
34
|
: join(e.explore.object)(e.explore.property);
|
|
35
|
+
const middle: string = e.explore.parameter
|
|
36
|
+
? `(parameter: ${JSON.stringify(e.explore.parameter)})`
|
|
37
|
+
: e.explore.output
|
|
38
|
+
? "(return type)"
|
|
39
|
+
: "";
|
|
35
40
|
const type: string = `${subject.length ? `${subject}: ` : ""}${
|
|
36
41
|
e.name
|
|
37
42
|
}`;
|
|
38
|
-
return `- ${type}\n${e.messages
|
|
43
|
+
return `- ${type}${middle}\n${e.messages
|
|
39
44
|
.map((msg) => ` - ${msg}`)
|
|
40
45
|
.join("\n")}`;
|
|
41
46
|
})
|