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,9 @@
1
1
  import {
2
- ChatGptTypeChecker,
3
- IChatGptSchema,
4
2
  ILlmApplication,
5
3
  ILlmSchema,
6
4
  IOpenApiSchemaError,
7
5
  IResult,
6
+ LlmTypeChecker,
8
7
  OpenApi,
9
8
  } from "@samchon/openapi";
10
9
  import { LlmSchemaComposer } from "@samchon/openapi/lib/composers/LlmSchemaComposer";
@@ -28,90 +27,89 @@ import { JsonApplicationProgrammer } from "../json/JsonApplicationProgrammer";
28
27
  import { LlmSchemaProgrammer } from "./LlmSchemaProgrammer";
29
28
 
30
29
  export namespace LlmApplicationProgrammer {
31
- export const validate = <Model extends ILlmSchema.Model>(props: {
32
- model: Model;
33
- config?: Partial<ILlmSchema.ModelConfig[Model]>;
34
- }) => {
35
- let top: Metadata | undefined;
36
- return (
37
- metadata: Metadata,
38
- explore: MetadataFactory.IExplore,
39
- ): string[] => {
40
- top ??= metadata;
41
- if (explore.top === false)
42
- if (
43
- explore.object === top?.objects[0]?.type &&
44
- typeof explore.property === "string" &&
45
- metadata.size() === 1 &&
46
- metadata.nullable === false &&
47
- metadata.isRequired() === true &&
48
- metadata.functions.length === 1
49
- )
50
- return validateFunction(explore.property, metadata.functions[0]!);
51
- else return LlmSchemaProgrammer.validate(props)(metadata);
52
-
53
- const output: string[] = [];
54
- const validity: boolean =
55
- metadata.size() === 1 &&
56
- metadata.objects.length === 1 &&
57
- metadata.isRequired() === true &&
58
- metadata.nullable === false;
59
- if (validity === false)
60
- output.push(
61
- "LLM application's generic argument must be a class/interface type.",
30
+ export const validate = (props: {
31
+ config?: Partial<ILlmSchema.IConfig>;
32
+ metadata: Metadata;
33
+ explore: MetadataFactory.IExplore;
34
+ }): string[] => {
35
+ const top: Metadata = props.metadata;
36
+ if (props.explore.top === false)
37
+ if (
38
+ props.explore.object === top?.objects[0]?.type &&
39
+ typeof props.explore.property === "string" &&
40
+ props.metadata.size() === 1 &&
41
+ props.metadata.nullable === false &&
42
+ props.metadata.isRequired() === true &&
43
+ props.metadata.functions.length === 1
44
+ )
45
+ return validateFunction(
46
+ props.explore.property,
47
+ props.metadata.functions[0]!,
62
48
  );
49
+ else return LlmSchemaProgrammer.validate(props);
63
50
 
64
- const object: MetadataObjectType | undefined = metadata.objects[0]?.type;
65
- if (object !== undefined) {
66
- if (object.properties.some((p) => p.key.isSoleLiteral() === false))
67
- output.push(
68
- "LLM application does not allow dynamic keys on class/interface type.",
69
- );
70
- let least: boolean = false;
71
- for (const p of object.properties) {
72
- const name: string = JSON.stringify(p.key.getSoleLiteral()!);
73
- const value: Metadata = p.value;
74
- if (value.functions.length) {
75
- least ||= true;
76
- if (validity === false) {
77
- if (value.functions.length !== 1 || value.size() !== 1)
78
- output.push(
79
- `LLM application's function (${name}) type does not allow union type.`,
80
- );
81
- if (value.isRequired() === false)
82
- output.push(
83
- `LLM application's function (${name}) type must be required.`,
84
- );
85
- if (value.nullable === true)
86
- output.push(
87
- `LLM application's function (${name}) type must not be nullable.`,
88
- );
89
- }
51
+ const output: string[] = [];
52
+ const validity: boolean =
53
+ props.metadata.size() === 1 &&
54
+ props.metadata.objects.length === 1 &&
55
+ props.metadata.isRequired() === true &&
56
+ props.metadata.nullable === false;
57
+ if (validity === false)
58
+ output.push(
59
+ "LLM application's generic argument must be a class/interface type.",
60
+ );
90
61
 
91
- const description: string | undefined = concatDescription(
92
- JsonApplicationProgrammer.writeDescription({
93
- description:
94
- p.description ??
95
- p.jsDocTags.find((tag) => tag.name === "description")
96
- ?.text?.[0]?.text ??
97
- null,
98
- jsDocTags: p.jsDocTags,
99
- kind: "summary",
100
- }),
101
- );
102
- if (description !== undefined && description.length > 1_024)
62
+ const object: MetadataObjectType | undefined =
63
+ props.metadata.objects[0]?.type;
64
+ if (object !== undefined) {
65
+ if (object.properties.some((p) => p.key.isSoleLiteral() === false))
66
+ output.push(
67
+ "LLM application does not allow dynamic keys on class/interface type.",
68
+ );
69
+ let least: boolean = false;
70
+ for (const p of object.properties) {
71
+ const name: string = JSON.stringify(p.key.getSoleLiteral()!);
72
+ const value: Metadata = p.value;
73
+ if (value.functions.length) {
74
+ least ||= true;
75
+ if (validity === false) {
76
+ if (value.functions.length !== 1 || value.size() !== 1)
77
+ output.push(
78
+ `LLM application's function (${name}) type does not allow union type.`,
79
+ );
80
+ if (value.isRequired() === false)
81
+ output.push(
82
+ `LLM application's function (${name}) type must be required.`,
83
+ );
84
+ if (value.nullable === true)
103
85
  output.push(
104
- `LLM application's function (${name}) description must not exceed 1,024 characters.`,
86
+ `LLM application's function (${name}) type must not be nullable.`,
105
87
  );
106
88
  }
107
- }
108
- if (least === false)
109
- output.push(
110
- "LLM application's target type must have at least a function type.",
89
+
90
+ const description: string | undefined = concatDescription(
91
+ JsonApplicationProgrammer.writeDescription({
92
+ description:
93
+ p.description ??
94
+ p.jsDocTags.find((tag) => tag.name === "description")?.text?.[0]
95
+ ?.text ??
96
+ null,
97
+ jsDocTags: p.jsDocTags,
98
+ kind: "summary",
99
+ }),
111
100
  );
101
+ if (description !== undefined && description.length > 1_024)
102
+ output.push(
103
+ `LLM application's function (${name}) description must not exceed 1,024 characters.`,
104
+ );
105
+ }
112
106
  }
113
- return output;
114
- };
107
+ if (least === false)
108
+ output.push(
109
+ "LLM application's target type must have at least a function type.",
110
+ );
111
+ }
112
+ return output;
115
113
  };
116
114
 
117
115
  const validateFunction = (name: string, func: MetadataFunction): string[] => {
@@ -155,18 +153,17 @@ export namespace LlmApplicationProgrammer {
155
153
  return output;
156
154
  };
157
155
 
158
- export const write = <Model extends ILlmSchema.Model>(props: {
159
- model: Model;
156
+ export const write = (props: {
160
157
  context: ITypiaContext;
161
158
  modulo: ts.LeftHandSideExpression;
162
159
  metadata: Metadata;
163
160
  config?: Partial<
164
- ILlmSchema.ModelConfig[Model] & {
161
+ ILlmSchema.IConfig & {
165
162
  equals: boolean;
166
163
  }
167
164
  >;
168
165
  name?: string;
169
- }): ILlmApplication<Model> => {
166
+ }): ILlmApplication => {
170
167
  const metadata: Metadata = Metadata.unalias(props.metadata);
171
168
  const functionParameters: Record<string, MetadataParameter> =
172
169
  Object.fromEntries(
@@ -198,10 +195,9 @@ export namespace LlmApplicationProgrammer {
198
195
  filter: (p) =>
199
196
  p.jsDocTags.some((tag) => tag.name === "human") === false,
200
197
  });
201
- const functions: Array<ILlmFunction<Model> | null> =
202
- application.functions.map((func) =>
198
+ const functions: Array<ILlmFunction | null> = application.functions.map(
199
+ (func) =>
203
200
  writeFunction({
204
- model: props.model,
205
201
  context: props.context,
206
202
  modulo: props.modulo,
207
203
  className: props.name,
@@ -211,25 +207,23 @@ export namespace LlmApplicationProgrammer {
211
207
  errors: errorMessages,
212
208
  parameter: functionParameters[func.name] ?? null,
213
209
  }),
214
- );
210
+ );
215
211
  if (functions.some((func) => func === null))
216
212
  throw new Error(
217
213
  "Failed to write LLM application:\n\n" +
218
214
  errorMessages.map((str) => ` - ${str}`).join("\n"),
219
215
  );
220
216
  return {
221
- model: props.model,
222
- options: {
223
- ...LlmSchemaComposer.defaultConfig(props.model),
224
- ...props.config,
217
+ config: {
218
+ ...LlmSchemaComposer.getConfig(props.config),
225
219
  separate: null,
220
+ validate: null,
226
221
  },
227
- functions: functions as ILlmFunction<Model>[],
222
+ functions: functions.filter((f) => f !== null),
228
223
  };
229
224
  };
230
225
 
231
- const writeFunction = <Model extends ILlmSchema.Model>(props: {
232
- model: Model;
226
+ const writeFunction = (props: {
233
227
  context: ITypiaContext;
234
228
  modulo: ts.LeftHandSideExpression;
235
229
  components: OpenApi.IComponents;
@@ -239,37 +233,34 @@ export namespace LlmApplicationProgrammer {
239
233
  className?: string;
240
234
  config:
241
235
  | Partial<
242
- ILlmSchema.ModelConfig[Model] & {
236
+ ILlmSchema.IConfig & {
243
237
  equals: boolean;
244
238
  }
245
239
  >
246
240
  | undefined;
247
- }): ILlmFunction<Model> | null => {
248
- const parameters: ILlmSchema.ModelParameters[Model] | null =
249
- writeParameters({
250
- ...props,
251
- accessor: `$input.${props.function.name}.parameters`,
252
- });
241
+ }): ILlmFunction | null => {
242
+ const config: ILlmSchema.IConfig = LlmSchemaComposer.getConfig(
243
+ props.config,
244
+ );
245
+ const parameters: ILlmSchema.IParameters | null = writeParameters({
246
+ ...props,
247
+ config,
248
+ accessor: `$input.${props.function.name}.parameters`,
249
+ });
253
250
  if (parameters === null) return null;
254
- const output: ILlmSchema.ModelSchema[Model] | null | undefined =
255
- writeOutput({
256
- model: props.model,
257
- parameters,
258
- components: props.components,
259
- schema: props.function.output?.schema ?? null,
260
- errors: props.errors,
261
- accessor: `$input.${props.function.name}.output`,
262
- });
251
+ const output: ILlmSchema | null | undefined = writeOutput({
252
+ parameters,
253
+ config,
254
+ components: props.components,
255
+ schema: props.function.output?.schema ?? null,
256
+ errors: props.errors,
257
+ accessor: `$input.${props.function.name}.output`,
258
+ });
263
259
  if (output === null) return null;
264
260
 
265
- const isReference = (
266
- schema: unknown,
267
- ): schema is IChatGptSchema.IReference =>
268
- ChatGptTypeChecker.isReference(schema as any);
269
261
  if (
270
262
  output &&
271
- props.model !== "chatgpt" &&
272
- isReference(output) === false &&
263
+ LlmTypeChecker.isReference(output) === false &&
273
264
  output.description === undefined &&
274
265
  !!props.function.output?.description?.length
275
266
  )
@@ -277,9 +268,7 @@ export namespace LlmApplicationProgrammer {
277
268
  return {
278
269
  name: props.function.name,
279
270
  parameters,
280
- output: (output ?? undefined) as
281
- | ILlmSchema.ModelSchema[Model]
282
- | undefined,
271
+ output: output ?? undefined,
283
272
  description: (() => {
284
273
  if (
285
274
  !props.function.summary?.length ||
@@ -306,35 +295,34 @@ export namespace LlmApplicationProgrammer {
306
295
  };
307
296
  };
308
297
 
309
- const writeParameters = <Model extends ILlmSchema.Model>(props: {
310
- model: Model;
298
+ const writeParameters = (props: {
311
299
  components: OpenApi.IComponents;
312
300
  function: IJsonSchemaApplication.IFunction<OpenApi.IJsonSchema>;
313
301
  errors: string[];
314
302
  accessor: string;
315
- }): ILlmSchema.ModelParameters[Model] | null => {
316
- const schema = props.function.parameters[0]?.schema ?? {
317
- type: "object",
318
- properties: {},
319
- additionalProperties: false,
320
- required: [],
321
- };
322
- const result: IResult<
323
- ILlmSchema.ModelParameters[Model],
324
- IOpenApiSchemaError
325
- > = LlmSchemaComposer.parameters(props.model)({
326
- config: LlmSchemaComposer.defaultConfig(props.model) as any,
327
- components: props.components,
328
- schema: {
329
- ...(schema as
330
- | OpenApi.IJsonSchema.IObject
331
- | OpenApi.IJsonSchema.IReference),
332
- title: schema.title ?? props.function.parameters[0]?.title,
333
- description:
334
- schema.description ?? props.function.parameters[0]?.description,
335
- },
336
- accessor: props.accessor,
337
- }) as IResult<ILlmSchema.ModelParameters[Model], IOpenApiSchemaError>;
303
+ config: ILlmSchema.IConfig;
304
+ }): ILlmSchema.IParameters | null => {
305
+ const schema: OpenApi.IJsonSchema.IObject | OpenApi.IJsonSchema.IReference =
306
+ (props.function.parameters[0]?.schema as
307
+ | OpenApi.IJsonSchema.IObject
308
+ | OpenApi.IJsonSchema.IReference) ?? {
309
+ type: "object",
310
+ properties: {},
311
+ additionalProperties: false,
312
+ required: [],
313
+ };
314
+ const result: IResult<ILlmSchema.IParameters, IOpenApiSchemaError> =
315
+ LlmSchemaComposer.parameters({
316
+ config: props.config,
317
+ components: props.components,
318
+ schema: {
319
+ ...schema,
320
+ title: schema.title ?? props.function.parameters[0]?.title,
321
+ description:
322
+ schema.description ?? props.function.parameters[0]?.description,
323
+ },
324
+ accessor: props.accessor,
325
+ });
338
326
  if (result.success === false) {
339
327
  props.errors.push(
340
328
  ...result.error.reasons.map((r) => ` - ${r.accessor}: ${r.message}`),
@@ -344,23 +332,23 @@ export namespace LlmApplicationProgrammer {
344
332
  return result.value;
345
333
  };
346
334
 
347
- const writeOutput = <Model extends ILlmSchema.Model>(props: {
348
- model: Model;
349
- parameters: ILlmSchema.ModelParameters[Model];
335
+ const writeOutput = (props: {
336
+ parameters: ILlmSchema.IParameters;
350
337
  components: OpenApi.IComponents;
338
+ config: ILlmSchema.IConfig;
351
339
  schema: OpenApi.IJsonSchema | null;
352
340
  errors: string[];
353
341
  accessor: string;
354
- }): ILlmSchema.ModelSchema[Model] | null | undefined => {
342
+ }): ILlmSchema | null | undefined => {
355
343
  if (props.schema === null) return undefined;
356
- const result: IResult<ILlmSchema.ModelSchema[Model], IOpenApiSchemaError> =
357
- LlmSchemaComposer.schema(props.model)({
358
- config: LlmSchemaComposer.defaultConfig(props.model) as any,
344
+ const result: IResult<ILlmSchema, IOpenApiSchemaError> =
345
+ LlmSchemaComposer.schema({
346
+ config: props.config,
359
347
  components: props.components,
360
348
  schema: props.schema,
361
349
  $defs: (props.parameters as any).$defs,
362
350
  accessor: props.accessor,
363
- }) as IResult<ILlmSchema.ModelSchema[Model], IOpenApiSchemaError>;
351
+ });
364
352
  if (result.success === false) {
365
353
  props.errors.push(
366
354
  ...result.error.reasons.map((r) => ` - ${r.accessor}: ${r.message}`),
@@ -1,5 +1,4 @@
1
1
  import { ILlmSchema } from "@samchon/openapi";
2
- import { LlmSchemaComposer } from "@samchon/openapi/lib/composers/LlmSchemaComposer";
3
2
  import ts from "typescript";
4
3
 
5
4
  import { MetadataCollection } from "../../factories/MetadataCollection";
@@ -13,20 +12,20 @@ import { TransformerError } from "../../transformers/TransformerError";
13
12
 
14
13
  import { ValidationPipe } from "../../typings/ValidationPipe";
15
14
 
16
- export namespace LlmModelPredicator {
15
+ export namespace LlmMetadataFactory {
17
16
  export const getConfig = (props: {
18
17
  context: ITypiaContext;
19
18
  method: string;
20
- model: ILlmSchema.Model;
21
19
  node: ts.TypeNode | undefined;
22
20
  }):
23
21
  | Partial<
24
- ILlmSchema.ModelConfig[ILlmSchema.Model] & {
22
+ ILlmSchema.IConfig & {
25
23
  equals: boolean;
26
24
  }
27
25
  >
28
26
  | undefined => {
29
27
  if (props.node === undefined) return undefined;
28
+
30
29
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(props.node);
31
30
  const collection: MetadataCollection = new MetadataCollection();
32
31
  const result: ValidationPipe<Metadata, MetadataFactory.IError> =
@@ -79,7 +78,7 @@ export namespace LlmModelPredicator {
79
78
  code: `typia.llm.${props.method}`,
80
79
  message: `Invalid generic argument "Config". It must be a literal object type. Do not allow variable type.`,
81
80
  });
82
- const config: Partial<ILlmSchema.ModelConfig[ILlmSchema.Model]> = {};
81
+ const config: Partial<ILlmSchema.IConfig> = {};
83
82
  for (const prop of obj.type.properties) {
84
83
  const key: string = prop.key.getSoleLiteral()!;
85
84
  const value: boolean | bigint | number | string =
@@ -93,41 +92,4 @@ export namespace LlmModelPredicator {
93
92
  }
94
93
  return config;
95
94
  };
96
-
97
- export const getModel = (props: {
98
- checker: ts.TypeChecker;
99
- method: string;
100
- node: ts.TypeNode | undefined;
101
- }): ILlmSchema.Model => {
102
- if (props.node === undefined)
103
- throw new TransformerError({
104
- code: `typia.llm.${props.method}`,
105
- message: `generic argument "Model" must be specified.`,
106
- });
107
-
108
- // CHECK LITERAL TYPE
109
- const type: ts.Type = props.checker.getTypeFromTypeNode(props.node);
110
- if (
111
- !type.isLiteral() &&
112
- (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
113
- )
114
- throw new TransformerError({
115
- code: `typia.llm.${props.method}`,
116
- message: `generic argument "Model" must be constant.`,
117
- });
118
-
119
- // GET VALUE AND VALIDATE IT
120
- const value = type.isLiteral()
121
- ? type.value
122
- : props.checker.typeToString(type);
123
- if (
124
- typeof value !== "string" ||
125
- LlmSchemaComposer.defaultConfig(value as "3.0") === undefined
126
- )
127
- throw new TransformerError({
128
- code: "typia.llm.schema",
129
- message: `invalid value on generic argument "Model".`,
130
- });
131
- return value as ILlmSchema.Model;
132
- };
133
95
  }
@@ -18,11 +18,10 @@ import { JsonSchemasProgrammer } from "../json/JsonSchemasProgrammer";
18
18
  import { LlmSchemaProgrammer } from "./LlmSchemaProgrammer";
19
19
 
20
20
  export namespace LlmParametersProgrammer {
21
- export const write = <Model extends ILlmSchema.Model>(props: {
22
- model: Model;
21
+ export const write = (props: {
23
22
  metadata: Metadata;
24
- config?: Partial<ILlmSchema.ModelConfig[Model]>;
25
- }): ILlmSchema.ModelParameters[Model] => {
23
+ config?: Partial<ILlmSchema.IConfig>;
24
+ }): ILlmSchema.IParameters => {
26
25
  const collection: IJsonSchemaCollection<"3.1"> =
27
26
  JsonSchemasProgrammer.write({
28
27
  version: "3.1",
@@ -39,17 +38,12 @@ export namespace LlmParametersProgrammer {
39
38
  throw new Error("Unreachable code. Failed to find the object schema.");
40
39
  })();
41
40
 
42
- const result: IResult<
43
- ILlmSchema.ModelParameters[Model],
44
- IOpenApiSchemaError
45
- > = LlmSchemaComposer.parameters(props.model)({
46
- config: {
47
- ...LlmSchemaComposer.defaultConfig(props.model),
48
- ...props.config,
49
- } as any,
50
- components: collection.components,
51
- schema,
52
- }) as IResult<ILlmSchema.ModelParameters[Model], IOpenApiSchemaError>;
41
+ const result: IResult<ILlmSchema.IParameters, IOpenApiSchemaError> =
42
+ LlmSchemaComposer.parameters({
43
+ config: LlmSchemaComposer.getConfig(props.config),
44
+ components: collection.components,
45
+ schema,
46
+ });
53
47
  if (result.success === false)
54
48
  throw new TransformerError({
55
49
  code: "typia.llm.parameters",
@@ -62,32 +56,31 @@ export namespace LlmParametersProgrammer {
62
56
  return result.value;
63
57
  };
64
58
 
65
- export const validate =
66
- <Model extends ILlmSchema.Model>(props: {
67
- model: Model;
68
- config?: Partial<ILlmSchema.ModelConfig[Model]>;
69
- }) =>
70
- (metadata: Metadata, explore: MetadataFactory.IExplore): string[] => {
71
- const output: string[] = [];
72
- if (explore.top === true) {
73
- if (metadata.objects.length === 0)
74
- output.push("LLM parameters must be an object type.");
75
- else if (metadata.objects.length !== 1 || metadata.size() > 1)
76
- output.push("LLM parameters must be a single object type.");
77
- else {
78
- if (
79
- metadata.objects[0]!.type.properties.some(
80
- (p) => p.key.isSoleLiteral() === false,
81
- )
59
+ export const validate = (props: {
60
+ config?: Partial<ILlmSchema.IConfig>;
61
+ metadata: Metadata;
62
+ explore: MetadataFactory.IExplore;
63
+ }): string[] => {
64
+ const output: string[] = [];
65
+ if (props.explore.top === true) {
66
+ if (props.metadata.objects.length === 0)
67
+ output.push("LLM parameters must be an object type.");
68
+ else if (props.metadata.objects.length !== 1 || props.metadata.size() > 1)
69
+ output.push("LLM parameters must be a single object type.");
70
+ else {
71
+ if (
72
+ props.metadata.objects[0]!.type.properties.some(
73
+ (p) => p.key.isSoleLiteral() === false,
82
74
  )
83
- output.push("LLM parameters must not have dynamic keys.");
84
- if (metadata.nullable)
85
- output.push("LLM parameters must be a non-nullable object type.");
86
- if (metadata.isRequired() === false)
87
- output.push("LLM parameters must be a non-undefined object type.");
88
- }
75
+ )
76
+ output.push("LLM parameters must not have dynamic keys.");
77
+ if (props.metadata.nullable)
78
+ output.push("LLM parameters must be a non-nullable object type.");
79
+ if (props.metadata.isRequired() === false)
80
+ output.push("LLM parameters must be a non-undefined object type.");
89
81
  }
90
- output.push(...LlmSchemaProgrammer.validate(props)(metadata));
91
- return output;
92
- };
82
+ }
83
+ output.push(...LlmSchemaProgrammer.validate(props));
84
+ return output;
85
+ };
93
86
  }