typia 10.0.2 → 11.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.
Files changed (86) hide show
  1. package/README.md +14 -10
  2. package/lib/factories/internal/metadata/emplace_metadata_object.js +11 -1
  3. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  4. package/lib/factories/internal/metadata/emplace_metadata_object.mjs +11 -0
  5. package/lib/index.mjs +2 -2
  6. package/lib/internal/_createStandardSchema.d.mts +1 -1
  7. package/lib/internal/_createStandardSchema.d.ts +1 -1
  8. package/lib/internal/_createStandardSchema.js.map +1 -1
  9. package/lib/internal/_llmApplicationFinalize.d.mts +2 -2
  10. package/lib/internal/_llmApplicationFinalize.d.ts +2 -2
  11. package/lib/internal/_llmApplicationFinalize.js +9 -10
  12. package/lib/internal/_llmApplicationFinalize.js.map +1 -1
  13. package/lib/internal/_llmApplicationFinalize.mjs +12 -13
  14. package/lib/llm.d.mts +20 -199
  15. package/lib/llm.d.ts +20 -199
  16. package/lib/llm.js.map +1 -1
  17. package/lib/misc.d.mts +3 -3
  18. package/lib/misc.d.ts +3 -3
  19. package/lib/misc.js.map +1 -1
  20. package/lib/module.d.mts +2 -2
  21. package/lib/module.d.ts +2 -2
  22. package/lib/programmers/internal/json_schema_object.js +1 -0
  23. package/lib/programmers/internal/json_schema_object.js.map +1 -1
  24. package/lib/programmers/internal/json_schema_object.mjs +1 -0
  25. package/lib/programmers/llm/LlmApplicationProgrammer.d.mts +8 -8
  26. package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +8 -8
  27. package/lib/programmers/llm/LlmApplicationProgrammer.js +58 -64
  28. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  29. package/lib/programmers/llm/LlmApplicationProgrammer.mjs +63 -68
  30. package/lib/programmers/llm/{LlmModelPredicator.d.mts → LlmMetadataFactory.d.mts} +2 -8
  31. package/lib/programmers/llm/{LlmModelPredicator.d.ts → LlmMetadataFactory.d.ts} +2 -8
  32. package/lib/programmers/llm/{LlmModelPredicator.js → LlmMetadataFactory.js} +6 -37
  33. package/lib/programmers/llm/LlmMetadataFactory.js.map +1 -0
  34. package/lib/programmers/llm/{LlmModelPredicator.mjs → LlmMetadataFactory.mjs} +6 -34
  35. package/lib/programmers/llm/LlmMetadataFactory.mjs.map +1 -0
  36. package/lib/programmers/llm/LlmParametersProgrammer.d.mts +8 -8
  37. package/lib/programmers/llm/LlmParametersProgrammer.d.ts +8 -8
  38. package/lib/programmers/llm/LlmParametersProgrammer.js +10 -10
  39. package/lib/programmers/llm/LlmParametersProgrammer.js.map +1 -1
  40. package/lib/programmers/llm/LlmParametersProgrammer.mjs +10 -13
  41. package/lib/programmers/llm/LlmSchemaProgrammer.d.mts +10 -12
  42. package/lib/programmers/llm/LlmSchemaProgrammer.d.ts +10 -12
  43. package/lib/programmers/llm/LlmSchemaProgrammer.js +21 -33
  44. package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
  45. package/lib/programmers/llm/LlmSchemaProgrammer.mjs +21 -37
  46. package/lib/schemas/metadata/IMetadataProperty.d.mts +1 -0
  47. package/lib/schemas/metadata/IMetadataProperty.d.ts +1 -0
  48. package/lib/schemas/metadata/MetadataProperty.d.mts +1 -0
  49. package/lib/schemas/metadata/MetadataProperty.d.ts +1 -0
  50. package/lib/schemas/metadata/MetadataProperty.js +3 -0
  51. package/lib/schemas/metadata/MetadataProperty.js.map +1 -1
  52. package/lib/schemas/metadata/MetadataProperty.mjs +4 -0
  53. package/lib/transformers/features/llm/LlmApplicationTransformer.d.mts +0 -2
  54. package/lib/transformers/features/llm/LlmApplicationTransformer.d.ts +0 -2
  55. package/lib/transformers/features/llm/LlmApplicationTransformer.js +9 -20
  56. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  57. package/lib/transformers/features/llm/LlmApplicationTransformer.mjs +9 -20
  58. package/lib/transformers/features/llm/LlmControllerTransformer.js +1 -8
  59. package/lib/transformers/features/llm/LlmControllerTransformer.js.map +1 -1
  60. package/lib/transformers/features/llm/LlmControllerTransformer.mjs +1 -8
  61. package/lib/transformers/features/llm/LlmParametersTransformer.js +6 -15
  62. package/lib/transformers/features/llm/LlmParametersTransformer.js.map +1 -1
  63. package/lib/transformers/features/llm/LlmParametersTransformer.mjs +6 -15
  64. package/lib/transformers/features/llm/LlmSchemaTransformer.js +11 -26
  65. package/lib/transformers/features/llm/LlmSchemaTransformer.js.map +1 -1
  66. package/lib/transformers/features/llm/LlmSchemaTransformer.mjs +11 -26
  67. package/package.json +4 -3
  68. package/src/factories/internal/metadata/emplace_metadata_object.ts +16 -0
  69. package/src/internal/_createStandardSchema.ts +2 -2
  70. package/src/internal/_llmApplicationFinalize.ts +18 -25
  71. package/src/llm.ts +28 -221
  72. package/src/misc.ts +9 -9
  73. package/src/module.ts +2 -2
  74. package/src/programmers/internal/json_schema_object.ts +1 -0
  75. package/src/programmers/llm/LlmApplicationProgrammer.ts +139 -151
  76. package/src/programmers/llm/{LlmModelPredicator.ts → LlmMetadataFactory.ts} +4 -42
  77. package/src/programmers/llm/LlmParametersProgrammer.ts +34 -41
  78. package/src/programmers/llm/LlmSchemaProgrammer.ts +59 -98
  79. package/src/schemas/metadata/IMetadataProperty.ts +1 -0
  80. package/src/schemas/metadata/MetadataProperty.ts +4 -0
  81. package/src/transformers/features/llm/LlmApplicationTransformer.ts +14 -29
  82. package/src/transformers/features/llm/LlmControllerTransformer.ts +1 -12
  83. package/src/transformers/features/llm/LlmParametersTransformer.ts +10 -21
  84. package/src/transformers/features/llm/LlmSchemaTransformer.ts +29 -65
  85. package/lib/programmers/llm/LlmModelPredicator.js.map +0 -1
  86. package/lib/programmers/llm/LlmModelPredicator.mjs.map +0 -1
@@ -1,10 +1,4 @@
1
- import {
2
- IChatGptSchema,
3
- ILlmSchema,
4
- ILlmSchemaV3,
5
- IOpenApiSchemaError,
6
- IResult,
7
- } from "@samchon/openapi";
1
+ import { ILlmSchema, IOpenApiSchemaError, IResult } from "@samchon/openapi";
8
2
  import { LlmSchemaComposer } from "@samchon/openapi/lib/composers/LlmSchemaComposer";
9
3
 
10
4
  import { IJsonSchemaCollection } from "../../schemas/json/IJsonSchemaCollection";
@@ -21,34 +15,29 @@ import { json_schema_string } from "../internal/json_schema_string";
21
15
  import { JsonSchemasProgrammer } from "../json/JsonSchemasProgrammer";
22
16
 
23
17
  export namespace LlmSchemaProgrammer {
24
- export interface IOutput<Model extends ILlmSchema.Model> {
25
- model: Model;
26
- schema: ILlmSchema.ModelSchema[Model];
27
- $defs: Record<string, ILlmSchema.ModelSchema[Model]>;
18
+ export interface IOutput {
19
+ schema: ILlmSchema;
20
+ $defs: Record<string, ILlmSchema>;
28
21
  }
29
22
 
30
- export const write = <Model extends ILlmSchema.Model>(props: {
31
- model: Model;
23
+ export const write = (props: {
32
24
  metadata: Metadata;
33
- config?: Partial<ILlmSchema.ModelConfig[Model]>;
34
- }): IOutput<Model> => {
25
+ config?: Partial<ILlmSchema.IConfig>;
26
+ }): IOutput => {
35
27
  const collection: IJsonSchemaCollection<"3.1"> =
36
28
  JsonSchemasProgrammer.write({
37
29
  version: "3.1",
38
30
  metadatas: [props.metadata],
39
31
  });
40
32
 
41
- const $defs: Record<string, ILlmSchema.ModelSchema[Model]> = {};
42
- const result: IResult<ILlmSchema.ModelSchema[Model], IOpenApiSchemaError> =
43
- LlmSchemaComposer.schema(props.model)({
44
- config: {
45
- ...LlmSchemaComposer.defaultConfig(props.model),
46
- ...props.config,
47
- } as any,
33
+ const $defs: Record<string, ILlmSchema> = {};
34
+ const result: IResult<ILlmSchema, IOpenApiSchemaError> =
35
+ LlmSchemaComposer.schema({
36
+ config: LlmSchemaComposer.getConfig(props.config),
48
37
  components: collection.components,
49
38
  schema: collection.schemas[0]!,
50
- $defs: $defs as any,
51
- }) as IResult<ILlmSchema.ModelSchema[Model], IOpenApiSchemaError>;
39
+ $defs,
40
+ });
52
41
  if (result.success === false)
53
42
  throw new TransformerError({
54
43
  code: "typia.llm.schema",
@@ -59,92 +48,64 @@ export namespace LlmSchemaProgrammer {
59
48
  .join("\n"),
60
49
  });
61
50
  return {
62
- model: props.model,
63
51
  $defs,
64
52
  schema: result.value,
65
53
  };
66
54
  };
67
55
 
68
- export const validate =
69
- <Model extends ILlmSchema.Model>(props: {
70
- model: ILlmSchema.Model;
71
- config?: Partial<ILlmSchema.ModelConfig[Model]>;
72
- }) =>
73
- (metadata: Metadata): string[] => {
74
- const output: string[] = [];
56
+ export const validate = (props: {
57
+ config?: Partial<ILlmSchema.IConfig>;
58
+ metadata: Metadata;
59
+ }): string[] => {
60
+ const output: string[] = [];
75
61
 
76
- // no additionalProperties in ChatGPT strict mode or Gemini
77
- if (
78
- props.model === "chatgpt" &&
79
- (props.config as Partial<IChatGptSchema.IConfig> | undefined)
80
- ?.strict === true &&
81
- metadata.objects.some((o) =>
82
- o.type.properties.some(
83
- (p) => p.key.isSoleLiteral() === false && p.value.size() !== 0,
84
- ),
85
- )
62
+ // no additionalProperties in OpenAI strict mode
63
+ const config: ILlmSchema.IConfig = LlmSchemaComposer.getConfig(
64
+ props.config,
65
+ );
66
+ if (
67
+ config.strict === true &&
68
+ props.metadata.objects.some((o) =>
69
+ o.type.properties.some(
70
+ (p) => p.key.isSoleLiteral() === false && p.value.size() !== 0,
71
+ ),
86
72
  )
87
- output.push(
88
- `LLM schema of "${props.model}"${props.model === "chatgpt" ? " (strict mode)" : ""} does not support dynamic property in object.`,
89
- );
73
+ )
74
+ output.push(`Strict mode does not allow dynamic property in object.`);
90
75
 
91
- // ChatGPT strict mode even does not support the optional property
92
- if (
93
- props.model === "chatgpt" &&
94
- (props.config as Partial<IChatGptSchema.IConfig> | undefined)
95
- ?.strict === true &&
96
- metadata.objects.some((o) =>
97
- o.type.properties.some((p) => p.value.isRequired() === false),
98
- )
76
+ // OpenAI strict mode even does not support the optional property
77
+ if (
78
+ config.strict === true &&
79
+ props.metadata.objects.some((o) =>
80
+ o.type.properties.some((p) => p.value.isRequired() === false),
99
81
  )
100
- output.push(
101
- `LLM schema of "chatgpt" (strict mode) does not support optional property in object.`,
102
- );
103
-
104
- // no recursive rule of Gemini and V3
105
- if (
106
- props.model === "3.0" &&
107
- ((props.config as ILlmSchemaV3.IConfig | undefined)?.recursive ===
108
- false ||
109
- (props.config as ILlmSchemaV3.IConfig | undefined)?.recursive === 0)
110
- ) {
111
- if (metadata.objects.some((o) => o.type.recursive))
112
- output.push(
113
- `LLM schema of "${props.model}" does not support recursive object.`,
114
- );
115
- if (metadata.arrays.some((a) => a.type.recursive))
116
- output.push(
117
- `LLM schema of "${props.model}" does not support recursive array.`,
118
- );
119
- }
82
+ )
83
+ output.push(`Strict mode does not support optional property in object.`);
120
84
 
121
- // just JSON rule
122
- if (
123
- metadata.atomics.some((a) => a.type === "bigint") ||
124
- metadata.constants.some((c) => c.type === "bigint")
125
- )
126
- output.push("LLM schema does not support bigint type.");
85
+ // just JSON rule
86
+ if (
87
+ props.metadata.atomics.some((a) => a.type === "bigint") ||
88
+ props.metadata.constants.some((c) => c.type === "bigint")
89
+ )
90
+ output.push("LLM schema does not support bigint type.");
91
+ if (props.metadata.tuples.length !== 0)
92
+ output.push("LLM schema does not support tuple type.");
93
+ if (props.metadata.arrays.some((a) => a.type.value.isRequired() === false))
94
+ output.push("LLM schema does not support undefined type in array.");
95
+ if (props.metadata.maps.length)
96
+ output.push("LLM schema does not support Map type.");
97
+ if (props.metadata.sets.length)
98
+ output.push("LLM schema does not support Set type.");
99
+ for (const native of props.metadata.natives)
127
100
  if (
128
- metadata.tuples.some((t) =>
129
- t.type.elements.some((e) => e.isRequired() === false),
130
- ) ||
131
- metadata.arrays.some((a) => a.type.value.isRequired() === false)
101
+ AtomicPredicator.native(native.name) === false &&
102
+ native.name !== "Date" &&
103
+ native.name !== "Blob" &&
104
+ native.name !== "File"
132
105
  )
133
- output.push("LLM schema does not support undefined type in array.");
134
- if (metadata.maps.length)
135
- output.push("LLM schema does not support Map type.");
136
- if (metadata.sets.length)
137
- output.push("LLM schema does not support Set type.");
138
- for (const native of metadata.natives)
139
- if (
140
- AtomicPredicator.native(native.name) === false &&
141
- native.name !== "Date" &&
142
- native.name !== "Blob" &&
143
- native.name !== "File"
144
- )
145
- output.push(`LLM schema does not support ${native.name} type.`);
146
- return output;
147
- };
106
+ output.push(`LLM schema does not support ${native.name} type.`);
107
+ return output;
108
+ };
148
109
  }
149
110
 
150
111
  const size = (metadata: Metadata): number =>
@@ -6,4 +6,5 @@ export interface IMetadataProperty {
6
6
  value: IMetadata;
7
7
  description: string | null;
8
8
  jsDocTags: IJsDocTagInfo[];
9
+ mutability?: "readonly" | null | undefined;
9
10
  }
@@ -11,6 +11,7 @@ export class MetadataProperty {
11
11
  public readonly value: Metadata;
12
12
  public readonly description: string | null;
13
13
  public readonly jsDocTags: IJsDocTagInfo[];
14
+ public readonly mutability?: "readonly" | null | undefined;
14
15
 
15
16
  public of_protobuf_?: IProtobufProperty;
16
17
 
@@ -23,6 +24,7 @@ export class MetadataProperty {
23
24
  this.value = props.value;
24
25
  this.description = props.description;
25
26
  this.jsDocTags = props.jsDocTags;
27
+ this.mutability = props.mutability;
26
28
  }
27
29
 
28
30
  /** @internal */
@@ -39,6 +41,7 @@ export class MetadataProperty {
39
41
  value: Metadata.from(property.value, dict),
40
42
  description: property.description,
41
43
  jsDocTags: property.jsDocTags.slice(),
44
+ mutability: property.mutability,
42
45
  });
43
46
  }
44
47
 
@@ -48,6 +51,7 @@ export class MetadataProperty {
48
51
  value: this.value.toJSON(),
49
52
  description: this.description,
50
53
  jsDocTags: this.jsDocTags,
54
+ mutability: this.mutability,
51
55
  };
52
56
  }
53
57
  }
@@ -10,7 +10,7 @@ import { StatementFactory } from "../../../factories/StatementFactory";
10
10
  import { Metadata } from "../../../schemas/metadata/Metadata";
11
11
 
12
12
  import { LlmApplicationProgrammer } from "../../../programmers/llm/LlmApplicationProgrammer";
13
- import { LlmModelPredicator } from "../../../programmers/llm/LlmModelPredicator";
13
+ import { LlmMetadataFactory } from "../../../programmers/llm/LlmMetadataFactory";
14
14
 
15
15
  import { ValidationPipe } from "../../../typings/ValidationPipe";
16
16
 
@@ -28,14 +28,10 @@ export namespace LlmApplicationTransformer {
28
28
  props.context.importer.type({
29
29
  file: "@samchon/openapi",
30
30
  name: "ILlmApplication",
31
- arguments: [
32
- ts.factory.createLiteralTypeNode(
33
- ts.factory.createStringLiteral(dec.application.model),
34
- ),
35
- ],
31
+ arguments: [dec.node],
36
32
  }),
37
33
  );
38
- if (!props.expression.arguments?.[0]) return literal;
34
+ if (props.expression.arguments?.[0] === undefined) return literal;
39
35
  return ExpressionFactory.selfCall(
40
36
  ts.factory.createBlock(
41
37
  [
@@ -49,7 +45,6 @@ export namespace LlmApplicationTransformer {
49
45
  value: ts.factory.createIdentifier("application"),
50
46
  argument: props.expression.arguments[0]!,
51
47
  equals: dec.config?.equals,
52
- model: dec.application.model,
53
48
  }),
54
49
  ),
55
50
  ts.factory.createReturnStatement(
@@ -66,7 +61,7 @@ export namespace LlmApplicationTransformer {
66
61
  method: string,
67
62
  props: ITransformProps,
68
63
  ): {
69
- application: ILlmApplication<ILlmSchema.Model>;
64
+ application: ILlmApplication;
70
65
  type: ts.Type;
71
66
  node: ts.TypeNode;
72
67
  config:
@@ -87,22 +82,16 @@ export namespace LlmApplicationTransformer {
87
82
  if (ts.isTypeNode(top) === false) return null;
88
83
 
89
84
  // GET TYPE
90
- const model: ILlmSchema.Model = LlmModelPredicator.getModel({
91
- checker: props.context.checker,
92
- method,
93
- node: props.expression.typeArguments[1],
94
- });
95
85
  const config:
96
86
  | Partial<
97
87
  ILlmSchema.IConfig & {
98
88
  equals: boolean;
99
89
  }
100
90
  >
101
- | undefined = LlmModelPredicator.getConfig({
91
+ | undefined = LlmMetadataFactory.getConfig({
102
92
  context: props.context,
103
93
  method,
104
- model,
105
- node: props.expression.typeArguments[2],
94
+ node: props.expression.typeArguments[1],
106
95
  });
107
96
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
108
97
 
@@ -119,10 +108,12 @@ export namespace LlmApplicationTransformer {
119
108
  functional: true,
120
109
  validate:
121
110
  validate === true
122
- ? LlmApplicationProgrammer.validate({
123
- model,
124
- config,
125
- })
111
+ ? (metadata, explore) =>
112
+ LlmApplicationProgrammer.validate({
113
+ config,
114
+ metadata,
115
+ explore,
116
+ })
126
117
  : undefined,
127
118
  },
128
119
  collection: new MetadataCollection({
@@ -142,7 +133,6 @@ export namespace LlmApplicationTransformer {
142
133
  // GENERATE LLM APPLICATION
143
134
  return {
144
135
  application: LlmApplicationProgrammer.write({
145
- model,
146
136
  context: props.context,
147
137
  modulo: props.modulo,
148
138
  metadata: analyze(false),
@@ -160,7 +150,6 @@ export namespace LlmApplicationTransformer {
160
150
  value: ts.Expression;
161
151
  argument: ts.Expression;
162
152
  equals?: boolean;
163
- model: ILlmSchema.Model;
164
153
  }) => {
165
154
  const satisfiesTypeNode: ts.TypeNode = ts.factory.createTypeReferenceNode(
166
155
  ts.factory.createIdentifier("Partial"),
@@ -175,13 +164,9 @@ export namespace LlmApplicationTransformer {
175
164
  undefined,
176
165
  ts.factory.createQualifiedName(
177
166
  ts.factory.createIdentifier("ILlmApplication"),
178
- ts.factory.createIdentifier("IOptions"),
167
+ ts.factory.createIdentifier("IConfig"),
179
168
  ),
180
- [
181
- ts.factory.createLiteralTypeNode(
182
- ts.factory.createStringLiteral(props.model),
183
- ),
184
- ],
169
+ undefined,
185
170
  false,
186
171
  ),
187
172
  ts.factory.createUnionTypeNode([
@@ -28,11 +28,6 @@ export namespace LlmControllerTransformer {
28
28
  props.context.importer.type({
29
29
  file: "@samchon/openapi",
30
30
  name: "ILlmApplication",
31
- arguments: [
32
- ts.factory.createLiteralTypeNode(
33
- ts.factory.createStringLiteral(dec.application.model),
34
- ),
35
- ],
36
31
  }),
37
32
  );
38
33
  const value: ts.Expression = ts.factory.createObjectLiteralExpression(
@@ -68,7 +63,6 @@ export namespace LlmControllerTransformer {
68
63
  value: ts.factory.createIdentifier("application"),
69
64
  argument: props.expression.arguments[2]!,
70
65
  equals: dec.config?.equals,
71
- model: dec.application.model,
72
66
  }),
73
67
  ),
74
68
  ]
@@ -80,12 +74,7 @@ export namespace LlmControllerTransformer {
80
74
  props.context.importer.type({
81
75
  file: "@samchon/openapi",
82
76
  name: "ILlmController",
83
- arguments: [
84
- ts.factory.createLiteralTypeNode(
85
- ts.factory.createStringLiteral(dec.application.model),
86
- ),
87
- dec.node,
88
- ],
77
+ arguments: [dec.node],
89
78
  }),
90
79
  );
91
80
  };
@@ -1,5 +1,4 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { ILlmFunction } from "@samchon/openapi/lib/structures/ILlmFunction";
3
2
  import ts from "typescript";
4
3
 
5
4
  import { LiteralFactory } from "../../../factories/LiteralFactory";
@@ -8,7 +7,7 @@ import { MetadataFactory } from "../../../factories/MetadataFactory";
8
7
 
9
8
  import { Metadata } from "../../../schemas/metadata/Metadata";
10
9
 
11
- import { LlmModelPredicator } from "../../../programmers/llm/LlmModelPredicator";
10
+ import { LlmMetadataFactory } from "../../../programmers/llm/LlmMetadataFactory";
12
11
  import { LlmParametersProgrammer } from "../../../programmers/llm/LlmParametersProgrammer";
13
12
 
14
13
  import { ValidationPipe } from "../../../typings/ValidationPipe";
@@ -31,16 +30,10 @@ export namespace LlmParametersTransformer {
31
30
  if (ts.isTypeNode(top) === false) return props.expression;
32
31
 
33
32
  // GET TYPE
34
- const model: ILlmSchema.Model = LlmModelPredicator.getModel({
35
- checker: props.context.checker,
36
- method: "parameters",
37
- node: props.expression.typeArguments[1],
38
- });
39
- const config: Partial<ILlmSchema.IConfig> = LlmModelPredicator.getConfig({
33
+ const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
40
34
  context: props.context,
41
35
  method: "parameters",
42
- model,
43
- node: props.expression.typeArguments[2],
36
+ node: props.expression.typeArguments[1],
44
37
  }) as Partial<ILlmSchema.IConfig>;
45
38
 
46
39
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
@@ -57,10 +50,12 @@ export namespace LlmParametersTransformer {
57
50
  constant: true,
58
51
  validate:
59
52
  validate === true
60
- ? LlmParametersProgrammer.validate({
61
- model,
62
- config,
63
- })
53
+ ? (metadata, explore) =>
54
+ LlmParametersProgrammer.validate({
55
+ config,
56
+ metadata,
57
+ explore,
58
+ })
64
59
  : undefined,
65
60
  },
66
61
  collection: new MetadataCollection({
@@ -78,8 +73,7 @@ export namespace LlmParametersTransformer {
78
73
  analyze(true);
79
74
 
80
75
  // GENERATE LLM SCHEMA
81
- const out: ILlmFunction<any>["parameters"] = LlmParametersProgrammer.write({
82
- model,
76
+ const out: ILlmSchema.IParameters = LlmParametersProgrammer.write({
83
77
  metadata: analyze(false),
84
78
  config,
85
79
  });
@@ -91,11 +85,6 @@ export namespace LlmParametersTransformer {
91
85
  ts.factory.createIdentifier("ILlmSchema"),
92
86
  ts.factory.createIdentifier("IParameters"),
93
87
  ),
94
- arguments: [
95
- ts.factory.createLiteralTypeNode(
96
- ts.factory.createStringLiteral(model),
97
- ),
98
- ],
99
88
  }),
100
89
  );
101
90
  };
@@ -8,7 +8,7 @@ import { MetadataFactory } from "../../../factories/MetadataFactory";
8
8
 
9
9
  import { Metadata } from "../../../schemas/metadata/Metadata";
10
10
 
11
- import { LlmModelPredicator } from "../../../programmers/llm/LlmModelPredicator";
11
+ import { LlmMetadataFactory } from "../../../programmers/llm/LlmMetadataFactory";
12
12
  import { LlmSchemaProgrammer } from "../../../programmers/llm/LlmSchemaProgrammer";
13
13
 
14
14
  import { ValidationPipe } from "../../../typings/ValidationPipe";
@@ -31,16 +31,10 @@ export namespace LlmSchemaTransformer {
31
31
  if (ts.isTypeNode(top) === false) return props.expression;
32
32
 
33
33
  // GET TYPE
34
- const model: ILlmSchema.Model = LlmModelPredicator.getModel({
35
- checker: props.context.checker,
36
- method: "schema",
37
- node: props.expression.typeArguments[1],
38
- });
39
- const config: Partial<ILlmSchema.IConfig> = LlmModelPredicator.getConfig({
34
+ const config: Partial<ILlmSchema.IConfig> = LlmMetadataFactory.getConfig({
40
35
  context: props.context,
41
36
  method: "schema",
42
- model,
43
- node: props.expression.typeArguments[2],
37
+ node: props.expression.typeArguments[1],
44
38
  }) as Partial<ILlmSchema.IConfig>;
45
39
 
46
40
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
@@ -57,10 +51,11 @@ export namespace LlmSchemaTransformer {
57
51
  escape: true,
58
52
  validate:
59
53
  validate === true
60
- ? LlmSchemaProgrammer.validate({
61
- model,
62
- config,
63
- })
54
+ ? (metadata: Metadata) =>
55
+ LlmSchemaProgrammer.validate({
56
+ config,
57
+ metadata,
58
+ })
64
59
  : undefined,
65
60
  },
66
61
  collection: new MetadataCollection({
@@ -78,17 +73,13 @@ export namespace LlmSchemaTransformer {
78
73
  analyze(true);
79
74
 
80
75
  // GENERATE LLM SCHEMA
81
- const out: LlmSchemaProgrammer.IOutput<any> = LlmSchemaProgrammer.write({
82
- model,
76
+ const out: LlmSchemaProgrammer.IOutput = LlmSchemaProgrammer.write({
83
77
  metadata: analyze(false),
84
78
  config,
85
79
  });
86
80
  const schemaTypeNode = props.context.importer.type({
87
81
  file: "@samchon/openapi",
88
82
  name: "ILlmSchema",
89
- arguments: [
90
- ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(model)),
91
- ],
92
83
  });
93
84
  const literal = ts.factory.createAsExpression(
94
85
  LiteralFactory.write(out.schema),
@@ -101,24 +92,10 @@ export namespace LlmSchemaTransformer {
101
92
  undefined,
102
93
  [
103
94
  IdentifierFactory.parameter(
104
- "props",
105
- ts.factory.createTypeLiteralNode([
106
- ts.factory.createPropertySignature(
107
- undefined,
108
- ts.factory.createIdentifier("$defs"),
109
- ts.factory.createToken(ts.SyntaxKind.QuestionToken),
110
- ts.factory.createUnionTypeNode([
111
- ts.factory.createTypeReferenceNode("Record", [
112
- ts.factory.createKeywordTypeNode(
113
- ts.SyntaxKind.StringKeyword,
114
- ),
115
- schemaTypeNode,
116
- ]),
117
- ts.factory.createKeywordTypeNode(
118
- ts.SyntaxKind.UndefinedKeyword,
119
- ),
120
- ]),
121
- ),
95
+ "$defs",
96
+ ts.factory.createTypeReferenceNode("Record", [
97
+ ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
98
+ schemaTypeNode,
122
99
  ]),
123
100
  undefined,
124
101
  ),
@@ -127,35 +104,22 @@ export namespace LlmSchemaTransformer {
127
104
  undefined,
128
105
  ts.factory.createBlock(
129
106
  [
130
- ts.factory.createIfStatement(
131
- ts.factory.createStrictInequality(
132
- ts.factory.createIdentifier("undefined"),
133
- IdentifierFactory.access(
134
- ts.factory.createIdentifier("props"),
135
- "$defs",
136
- true,
137
- ),
138
- ),
139
- ts.factory.createExpressionStatement(
140
- ts.factory.createCallExpression(
141
- ts.factory.createIdentifier("Object.assign"),
142
- undefined,
143
- [
144
- IdentifierFactory.access(
145
- ts.factory.createIdentifier("props"),
146
- "$defs",
147
- ),
148
- ts.factory.createAsExpression(
149
- LiteralFactory.write(out.$defs),
150
- ts.factory.createTypeReferenceNode("Record", [
151
- ts.factory.createKeywordTypeNode(
152
- ts.SyntaxKind.StringKeyword,
153
- ),
154
- schemaTypeNode,
155
- ]),
156
- ),
157
- ],
158
- ),
107
+ ts.factory.createExpressionStatement(
108
+ ts.factory.createCallExpression(
109
+ ts.factory.createIdentifier("Object.assign"),
110
+ undefined,
111
+ [
112
+ ts.factory.createIdentifier("$defs"),
113
+ ts.factory.createAsExpression(
114
+ LiteralFactory.write(out.$defs),
115
+ ts.factory.createTypeReferenceNode("Record", [
116
+ ts.factory.createKeywordTypeNode(
117
+ ts.SyntaxKind.StringKeyword,
118
+ ),
119
+ schemaTypeNode,
120
+ ]),
121
+ ),
122
+ ],
159
123
  ),
160
124
  ),
161
125
  ts.factory.createReturnStatement(literal),
@@ -1 +0,0 @@
1
- {"version":3,"file":"LlmModelPredicator.js","sourceRoot":"","sources":["../../../src/programmers/llm/LlmModelPredicator.ts"],"names":[],"mappings":";;;;;;AAC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