typia 7.0.2-dev.20241205 → 7.1.0-dev.20241209

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.
Files changed (43) hide show
  1. package/lib/factories/LiteralFactory.js +4 -0
  2. package/lib/factories/LiteralFactory.js.map +1 -1
  3. package/lib/factories/internal/metadata/iterate_metadata_function.js +1 -0
  4. package/lib/factories/internal/metadata/iterate_metadata_function.js.map +1 -1
  5. package/lib/index.mjs +18 -1
  6. package/lib/index.mjs.map +1 -1
  7. package/lib/llm.d.ts +121 -2
  8. package/lib/llm.js +7 -0
  9. package/lib/llm.js.map +1 -1
  10. package/lib/module.d.ts +2 -0
  11. package/lib/module.js +2 -0
  12. package/lib/module.js.map +1 -1
  13. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.d.ts +15 -0
  14. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js +37 -0
  15. package/lib/programmers/llm/LlmApplicationOfValidateProgrammer.js.map +1 -0
  16. package/lib/schemas/llm/ILlmApplicationOfValidate.d.ts +52 -0
  17. package/lib/schemas/llm/ILlmApplicationOfValidate.js +7 -0
  18. package/lib/schemas/llm/ILlmApplicationOfValidate.js.map +1 -0
  19. package/lib/schemas/llm/ILlmFunctionOfValidate.d.ts +36 -0
  20. package/lib/schemas/llm/ILlmFunctionOfValidate.js +7 -0
  21. package/lib/schemas/llm/ILlmFunctionOfValidate.js.map +1 -0
  22. package/lib/schemas/metadata/MetadataParameter.d.ts +2 -0
  23. package/lib/schemas/metadata/MetadataParameter.js +1 -0
  24. package/lib/schemas/metadata/MetadataParameter.js.map +1 -1
  25. package/lib/transformers/CallExpressionTransformer.js +2 -0
  26. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  27. package/lib/transformers/features/llm/LlmApplicationOfValidateTransformer.d.ts +5 -0
  28. package/lib/transformers/features/llm/LlmApplicationOfValidateTransformer.js +94 -0
  29. package/lib/transformers/features/llm/LlmApplicationOfValidateTransformer.js.map +1 -0
  30. package/lib/transformers/features/llm/LlmApplicationTransformer.js +3 -3
  31. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/factories/LiteralFactory.ts +2 -0
  34. package/src/factories/internal/metadata/iterate_metadata_function.ts +1 -0
  35. package/src/llm.ts +141 -2
  36. package/src/module.ts +2 -0
  37. package/src/programmers/llm/LlmApplicationOfValidateProgrammer.ts +81 -0
  38. package/src/schemas/llm/ILlmApplicationOfValidate.ts +55 -0
  39. package/src/schemas/llm/ILlmFunctionOfValidate.ts +39 -0
  40. package/src/schemas/metadata/MetadataParameter.ts +4 -0
  41. package/src/transformers/CallExpressionTransformer.ts +2 -0
  42. package/src/transformers/features/llm/LlmApplicationOfValidateTransformer.ts +115 -0
  43. package/src/transformers/features/llm/LlmApplicationTransformer.ts +3 -3
@@ -0,0 +1,115 @@
1
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
2
+ import ts from "typescript";
3
+
4
+ import { ExpressionFactory } from "../../../factories/ExpressionFactory";
5
+ import { LiteralFactory } from "../../../factories/LiteralFactory";
6
+ import { MetadataCollection } from "../../../factories/MetadataCollection";
7
+ import { MetadataFactory } from "../../../factories/MetadataFactory";
8
+ import { StatementFactory } from "../../../factories/StatementFactory";
9
+
10
+ import { Metadata } from "../../../schemas/metadata/Metadata";
11
+
12
+ import { LlmApplicationOfValidateProgrammer } from "../../../programmers/llm/LlmApplicationOfValidateProgrammer";
13
+ import { LlmModelPredicator } from "../../../programmers/llm/LlmModelPredicator";
14
+
15
+ import { ValidationPipe } from "../../../typings/ValidationPipe";
16
+
17
+ import { ITransformProps } from "../../ITransformProps";
18
+ import { TransformerError } from "../../TransformerError";
19
+
20
+ export namespace LlmApplicationOfValidateTransformer {
21
+ export const transform = (props: ITransformProps): ts.Expression => {
22
+ // GET GENERIC ARGUMENT
23
+ if (!props.expression.typeArguments?.length)
24
+ throw new TransformerError({
25
+ code: "typia.llm.schema",
26
+ message: "no generic argument.",
27
+ });
28
+
29
+ const top: ts.Node = props.expression.typeArguments[0]!;
30
+ if (ts.isTypeNode(top) === false) return props.expression;
31
+
32
+ // GET TYPE
33
+ const model: ILlmSchema.Model = LlmModelPredicator.getModel({
34
+ checker: props.context.checker,
35
+ method: "application",
36
+ node: props.expression.typeArguments[1],
37
+ });
38
+ const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
39
+ const collection: MetadataCollection = new MetadataCollection({
40
+ replace: MetadataCollection.replace,
41
+ });
42
+ const result: ValidationPipe<Metadata, MetadataFactory.IError> =
43
+ MetadataFactory.analyze({
44
+ checker: props.context.checker,
45
+ transformer: props.context.transformer,
46
+ options: {
47
+ escape: true,
48
+ constant: true,
49
+ absorb: false,
50
+ functional: true,
51
+ validate: LlmApplicationOfValidateProgrammer.validate(model),
52
+ },
53
+ collection,
54
+ type,
55
+ });
56
+ if (result.success === false)
57
+ throw TransformerError.from({
58
+ code: "typia.llm.application",
59
+ errors: result.errors,
60
+ });
61
+
62
+ // GENERATE LLM APPLICATION
63
+ const schema: ILlmApplication<ILlmSchema.Model> =
64
+ LlmApplicationOfValidateProgrammer.write({
65
+ model,
66
+ context: props.context,
67
+ modulo: props.modulo,
68
+ metadata: result.data,
69
+ config: LlmModelPredicator.getConfig({
70
+ context: props.context,
71
+ method: "application",
72
+ model,
73
+ node: props.expression.typeArguments[2],
74
+ }),
75
+ });
76
+ const literal: ts.Expression = ts.factory.createAsExpression(
77
+ LiteralFactory.write(schema),
78
+ props.context.importer.type({
79
+ file: "typia",
80
+ name: "ILlmApplicationOfValidate",
81
+ arguments: [
82
+ ts.factory.createLiteralTypeNode(
83
+ ts.factory.createStringLiteral(model),
84
+ ),
85
+ ],
86
+ }),
87
+ );
88
+ if (!props.expression.arguments?.[0]) return literal;
89
+
90
+ return ExpressionFactory.selfCall(
91
+ ts.factory.createBlock(
92
+ [
93
+ StatementFactory.constant({
94
+ name: "app",
95
+ value: literal,
96
+ }),
97
+ ts.factory.createExpressionStatement(
98
+ ts.factory.createCallExpression(
99
+ props.context.importer.internal("llmApplicationFinalize"),
100
+ undefined,
101
+ [
102
+ ts.factory.createIdentifier("app"),
103
+ ...(props.expression.arguments?.[0]
104
+ ? [props.expression.arguments[0]]
105
+ : []),
106
+ ],
107
+ ),
108
+ ),
109
+ ts.factory.createReturnStatement(ts.factory.createIdentifier("app")),
110
+ ],
111
+ true,
112
+ ),
113
+ );
114
+ };
115
+ }
@@ -22,7 +22,7 @@ export namespace LlmApplicationTransformer {
22
22
  // GET GENERIC ARGUMENT
23
23
  if (!props.expression.typeArguments?.length)
24
24
  throw new TransformerError({
25
- code: "typia.llm.schema",
25
+ code: "typia.llm.application",
26
26
  message: "no generic argument.",
27
27
  });
28
28
 
@@ -32,7 +32,7 @@ export namespace LlmApplicationTransformer {
32
32
  // GET TYPE
33
33
  const model: ILlmSchema.Model = LlmModelPredicator.getModel({
34
34
  checker: props.context.checker,
35
- method: "application",
35
+ method: "applicationOfValidate",
36
36
  node: props.expression.typeArguments[1],
37
37
  });
38
38
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
@@ -55,7 +55,7 @@ export namespace LlmApplicationTransformer {
55
55
  });
56
56
  if (result.success === false)
57
57
  throw TransformerError.from({
58
- code: "typia.llm.application",
58
+ code: "typia.llm.applicationOfValidate",
59
59
  errors: result.errors,
60
60
  });
61
61