typia 7.0.0-dev.20241127-3 → 7.0.0-dev.20241127-5

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 (33) hide show
  1. package/lib/factories/internal/metadata/iterate_metadata_intersection.js +11 -8
  2. package/lib/factories/internal/metadata/iterate_metadata_intersection.js.map +1 -1
  3. package/lib/index.mjs.map +1 -1
  4. package/lib/llm.d.ts +9 -3
  5. package/lib/llm.js.map +1 -1
  6. package/lib/programmers/llm/LlmApplicationProgrammer.d.ts +1 -0
  7. package/lib/programmers/llm/LlmApplicationProgrammer.js +1 -1
  8. package/lib/programmers/llm/LlmApplicationProgrammer.js.map +1 -1
  9. package/lib/programmers/llm/LlmModelPredicator.d.ts +16 -0
  10. package/lib/programmers/llm/LlmModelPredicator.js +99 -0
  11. package/lib/programmers/llm/LlmModelPredicator.js.map +1 -0
  12. package/lib/programmers/llm/LlmParametersProgrammer.d.ts +1 -0
  13. package/lib/programmers/llm/LlmParametersProgrammer.js +1 -1
  14. package/lib/programmers/llm/LlmParametersProgrammer.js.map +1 -1
  15. package/lib/programmers/llm/LlmSchemaProgrammer.d.ts +1 -0
  16. package/lib/programmers/llm/LlmSchemaProgrammer.js +1 -1
  17. package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -1
  18. package/lib/transformers/features/llm/LlmApplicationTransformer.js +12 -32
  19. package/lib/transformers/features/llm/LlmApplicationTransformer.js.map +1 -1
  20. package/lib/transformers/features/llm/LlmParametersTransformer.js +12 -32
  21. package/lib/transformers/features/llm/LlmParametersTransformer.js.map +1 -1
  22. package/lib/transformers/features/llm/LlmSchemaTransformer.js +12 -32
  23. package/lib/transformers/features/llm/LlmSchemaTransformer.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/factories/internal/metadata/iterate_metadata_intersection.ts +13 -7
  26. package/src/llm.ts +17 -2
  27. package/src/programmers/llm/LlmApplicationProgrammer.ts +6 -4
  28. package/src/programmers/llm/LlmModelPredicator.ts +127 -0
  29. package/src/programmers/llm/LlmParametersProgrammer.ts +5 -1
  30. package/src/programmers/llm/LlmSchemaProgrammer.ts +5 -1
  31. package/src/transformers/features/llm/LlmApplicationTransformer.ts +12 -46
  32. package/src/transformers/features/llm/LlmParametersTransformer.ts +12 -46
  33. package/src/transformers/features/llm/LlmSchemaTransformer.ts +12 -46
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LlmParametersTransformer = void 0;
7
- const LlmSchemaConverter_1 = require("@samchon/openapi/lib/converters/LlmSchemaConverter");
8
7
  const typescript_1 = __importDefault(require("typescript"));
9
8
  const LiteralFactory_1 = require("../../../factories/LiteralFactory");
10
9
  const MetadataCollection_1 = require("../../../factories/MetadataCollection");
11
10
  const MetadataFactory_1 = require("../../../factories/MetadataFactory");
11
+ const LlmModelPredicator_1 = require("../../../programmers/llm/LlmModelPredicator");
12
12
  const LlmParametersProgrammer_1 = require("../../../programmers/llm/LlmParametersProgrammer");
13
13
  const LlmSchemaProgrammer_1 = require("../../../programmers/llm/LlmSchemaProgrammer");
14
14
  const TransformerError_1 = require("../../TransformerError");
@@ -25,16 +25,12 @@ var LlmParametersTransformer;
25
25
  const top = props.expression.typeArguments[0];
26
26
  if (typescript_1.default.isTypeNode(top) === false)
27
27
  return props.expression;
28
- // GET MODEL
29
- const model = getTemplateArgument({
30
- checker: props.context.checker,
31
- name: "Model",
32
- is: (value) => LlmSchemaConverter_1.LlmSchemaConverter.defaultConfig(value) !==
33
- undefined,
34
- cast: (value) => value,
35
- default: () => "3.1",
36
- })(props.expression.typeArguments[1]);
37
28
  // GET TYPE
29
+ const model = LlmModelPredicator_1.LlmModelPredicator.getModel({
30
+ checker: props.context.checker,
31
+ method: "parameters",
32
+ node: props.expression.typeArguments[1],
33
+ });
38
34
  const type = props.context.checker.getTypeFromTypeNode(top);
39
35
  const collection = new MetadataCollection_1.MetadataCollection({
40
36
  replace: MetadataCollection_1.MetadataCollection.replace,
@@ -60,6 +56,12 @@ var LlmParametersTransformer;
60
56
  const out = LlmParametersProgrammer_1.LlmParametersProgrammer.write({
61
57
  model,
62
58
  metadata: result.data,
59
+ config: LlmModelPredicator_1.LlmModelPredicator.getConfig({
60
+ context: props.context,
61
+ method: "parameters",
62
+ model,
63
+ node: props.expression.typeArguments[2],
64
+ }),
63
65
  });
64
66
  return typescript_1.default.factory.createAsExpression(LiteralFactory_1.LiteralFactory.write(out), typescript_1.default.factory.createTypeReferenceNode(props.context.importer.instance({
65
67
  name: "ILlmSchema",
@@ -70,27 +72,5 @@ var LlmParametersTransformer;
70
72
  typescript_1.default.factory.createLiteralTypeNode(typescript_1.default.factory.createStringLiteral(model)),
71
73
  ]));
72
74
  };
73
- const getTemplateArgument = (props) => (node) => {
74
- if (!node)
75
- return props.default();
76
- // CHECK LITERAL TYPE
77
- const type = props.checker.getTypeFromTypeNode(node);
78
- if (!type.isLiteral() &&
79
- (type.getFlags() & typescript_1.default.TypeFlags.BooleanLiteral) === 0)
80
- throw new TransformerError_1.TransformerError({
81
- code: "typia.llm.parameters",
82
- message: `generic argument "${props.name}" must be constant.`,
83
- });
84
- // GET VALUE AND VALIDATE IT
85
- const value = type.isLiteral()
86
- ? type.value
87
- : props.checker.typeToString(type);
88
- if (typeof value !== "string" || props.is(value) === false)
89
- throw new TransformerError_1.TransformerError({
90
- code: "typia.llm.parameters",
91
- message: `invalid value on generic argument "${props.name}".`,
92
- });
93
- return props.cast(value);
94
- };
95
75
  })(LlmParametersTransformer || (exports.LlmParametersTransformer = LlmParametersTransformer = {}));
96
76
  //# sourceMappingURL=LlmParametersTransformer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LlmParametersTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmParametersTransformer.ts"],"names":[],"mappings":";;;;;;AACA,2FAAwF;AAExF,4DAA4B;AAE5B,sEAAmE;AACnE,8EAA2E;AAC3E,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BAAmB,CAAC,IAAI,CAAC,CAAC;QAC9D,IACE,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,oBAAE,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC;YAErD,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,qBAAqB,KAAK,CAAC,IAAI,qBAAqB;aAC9D,CAAC,CAAC;QAEL,4BAA4B;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK;YACxD,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,sBAAsB;gBAC5B,OAAO,EAAE,sCAAsC,KAAK,CAAC,IAAI,IAAI;aAC9D,CAAC,CAAC;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC,EAzGgB,wBAAwB,wCAAxB,wBAAwB,QAyGxC"}
1
+ {"version":3,"file":"LlmParametersTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmParametersTransformer.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAE5B,sEAAmE;AACnE,8EAA2E;AAC3E,wEAAqE;AAIrE,oFAAiF;AACjF,8FAA2F;AAC3F,sFAAmF;AAKnF,6DAA0D;AAE1D,IAAiB,wBAAwB,CAuExC;AAvED,WAAiB,wBAAwB;IAC1B,kCAAS,GAAG,CACvB,KAAsC,EACvB,EAAE;;QACjB,uBAAuB;QACvB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,aAAa,0CAAE,M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B;QACtB,MAAM,GAAG,GAAoC,iDAAuB,CAAC,KAAK,CAAC;YACzE,KAAK;YACL,QAAQ,EAAE,MAAM,CAAC,IAAI;YACrB,MAAM,EAAE,uCAAkB,CAAC,SAAS,CAAC;gBACnC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM,EAAE,YAAY;gBACpB,KAAK;gBACL,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;aACxC,CAAC;SACH,CAAC,CAAC;QACH,OAAO,oBAAE,CAAC,OAAO,CAAC,kBAAkB,CAClC,+BAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EACzB,oBAAE,CAAC,OAAO,CAAC,uBAAuB,CAChC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC9B,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,cAAc;SACtB,CAAC,CAAC,IAAI,GAAG,cAAc,EACxB;YACE,oBAAE,CAAC,OAAO,CAAC,qBAAqB,CAC9B,oBAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CACtC;SACF,CACF,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAvEgB,wBAAwB,wCAAxB,wBAAwB,QAuExC"}
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LlmSchemaTransformer = void 0;
7
- const LlmSchemaConverter_1 = require("@samchon/openapi/lib/converters/LlmSchemaConverter");
8
7
  const typescript_1 = __importDefault(require("typescript"));
9
8
  const IdentifierFactory_1 = require("../../../factories/IdentifierFactory");
10
9
  const LiteralFactory_1 = require("../../../factories/LiteralFactory");
11
10
  const MetadataCollection_1 = require("../../../factories/MetadataCollection");
12
11
  const MetadataFactory_1 = require("../../../factories/MetadataFactory");
12
+ const LlmModelPredicator_1 = require("../../../programmers/llm/LlmModelPredicator");
13
13
  const LlmSchemaProgrammer_1 = require("../../../programmers/llm/LlmSchemaProgrammer");
14
14
  const TransformerError_1 = require("../../TransformerError");
15
15
  var LlmSchemaTransformer;
@@ -25,16 +25,12 @@ var LlmSchemaTransformer;
25
25
  const top = props.expression.typeArguments[0];
26
26
  if (typescript_1.default.isTypeNode(top) === false)
27
27
  return props.expression;
28
- // GET MODEL
29
- const model = getTemplateArgument({
30
- checker: props.context.checker,
31
- name: "Model",
32
- is: (value) => LlmSchemaConverter_1.LlmSchemaConverter.defaultConfig(value) !==
33
- undefined,
34
- cast: (value) => value,
35
- default: () => "3.1",
36
- })(props.expression.typeArguments[1]);
37
28
  // GET TYPE
29
+ const model = LlmModelPredicator_1.LlmModelPredicator.getModel({
30
+ checker: props.context.checker,
31
+ method: "schema",
32
+ node: props.expression.typeArguments[1],
33
+ });
38
34
  const type = props.context.checker.getTypeFromTypeNode(top);
39
35
  const collection = new MetadataCollection_1.MetadataCollection({
40
36
  replace: MetadataCollection_1.MetadataCollection.replace,
@@ -60,6 +56,12 @@ var LlmSchemaTransformer;
60
56
  const out = LlmSchemaProgrammer_1.LlmSchemaProgrammer.write({
61
57
  model,
62
58
  metadata: result.data,
59
+ config: LlmModelPredicator_1.LlmModelPredicator.getConfig({
60
+ context: props.context,
61
+ method: "schema",
62
+ model,
63
+ node: props.expression.typeArguments[2],
64
+ }),
63
65
  });
64
66
  const schemaTypeNode = typescript_1.default.factory.createTypeReferenceNode(props.context.importer.instance({
65
67
  name: "ILlmSchema",
@@ -86,27 +88,5 @@ var LlmSchemaTransformer;
86
88
  typescript_1.default.factory.createReturnStatement(literal),
87
89
  ], true)), undefined, [props.expression.arguments[0]]);
88
90
  };
89
- const getTemplateArgument = (props) => (node) => {
90
- if (!node)
91
- return props.default();
92
- // CHECK LITERAL TYPE
93
- const type = props.checker.getTypeFromTypeNode(node);
94
- if (!type.isLiteral() &&
95
- (type.getFlags() & typescript_1.default.TypeFlags.BooleanLiteral) === 0)
96
- throw new TransformerError_1.TransformerError({
97
- code: "typia.llm.schema",
98
- message: `generic argument "${props.name}" must be constant.`,
99
- });
100
- // GET VALUE AND VALIDATE IT
101
- const value = type.isLiteral()
102
- ? type.value
103
- : props.checker.typeToString(type);
104
- if (typeof value !== "string" || props.is(value) === false)
105
- throw new TransformerError_1.TransformerError({
106
- code: "typia.llm.schema",
107
- message: `invalid value on generic argument "${props.name}".`,
108
- });
109
- return props.cast(value);
110
- };
111
91
  })(LlmSchemaTransformer || (exports.LlmSchemaTransformer = LlmSchemaTransformer = {}));
112
92
  //# sourceMappingURL=LlmSchemaTransformer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LlmSchemaTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmSchemaTransformer.ts"],"names":[],"mappings":";;;;;;AACA,2FAAwF;AACxF,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,8EAA2E;AAC3E,wEAAqE;AAIrE,sFAAmF;AAKnF,6DAA0D;AAE1D,IAAiB,oBAAoB,CAmJpC;AAnJD,WAAiB,oBAAoB;IACtB,8BAAS,GAAG,CACvB,KAAsC,EACvB,EAAE;;QACjB,uBAAuB;QACvB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,aAAa,0CAAE,MAAM,CAAA;YACzC,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,sBAAsB;aAChC,CAAC,CAAC;QAEL,MAAM,GAAG,GAAY,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC;QACxD,IAAI,oBAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC;QAE1D,YAAY;QACZ,MAAM,KAAK,GAAqB,mBAAmB,CAAmB;YACpE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO;YAC9B,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AE,sCAAsC,KAAK,CAAC,IAAI,IAAI;aAC9D,CAAC,CAAC;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC,EAnJgB,oBAAoB,oCAApB,oBAAoB,QAmJpC"}
1
+ {"version":3,"file":"LlmSchemaTransformer.js","sourceRoot":"","sources":["../../../../src/transformers/features/llm/LlmSchemaTransformer.ts"],"names":[],"mappings":";;;;;;AACA,4DAA4B;AAE5B,4EAAyE;AACzE,sEAAmE;AACnE,8EAA2E;AAC3E,wEAAqE;AAIrE,oFAAiF;AACjF,sFAAmF;AAKnF,6DAA0D;AAE1D,IAAiB,oBAAoB,CAiHpC;AAjHD,WAAiB,oBAAoB;IACtB,8BAAS,GAAG,CACvB,KAAsC,EACvB,EAAE;;QACjB,uBAAuB;QACvB,IAAI,CAAC,CAAA,MAAA,KAAK,CAAC,UAAU,CAAC,aAAa,0CAAE,MAAM,CAAA;YACzC,MAAM,IAAI,mCAAgB,CAAC;gBACzB,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,sBAAsB;aAChC,CAAC,CAAC;QAEL,MAAM,GAAG,GAAY,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC;QACxD,IAAI,oBAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC,UAAU,CAAC;QAE1D,WAAW;QACX,MAAM,KAAK,GAAqB,uCAAkB,CAAC,QAAQ,CAAC;YAC1D,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO;YAC9B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;SACxC,CAAC,CAAC;QACH,MAAM,IAAI,GAAY,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACrE,MAAM,UAAU,GAAuB,IAAI,uC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OAAO,CAAC;SAC1C,EACD,IAAI,CACL,CACF,EACD,SAAS,EACT,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC,CACjC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,EAjHgB,oBAAoB,oCAApB,oBAAoB,QAiHpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typia",
3
- "version": "7.0.0-dev.20241127-3",
3
+ "version": "7.0.0-dev.20241127-5",
4
4
  "description": "Superfast runtime validators with only one line",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -37,11 +37,18 @@ export const iterate_metadata_intersection = (
37
37
  intersected: false,
38
38
  }),
39
39
  );
40
+
41
+ // ERROR OR ANY TYPE CASE
42
+ const escape = () => {
43
+ Object.assign(props.collection, commit);
44
+ return false;
45
+ };
40
46
  if (fakeErrors.length) {
41
47
  props.errors.push(...fakeErrors);
42
48
  return true;
43
- } else if (children.length === 0) return false;
44
- else if (children.some((m) => m.size() === 0)) return false;
49
+ } else if (children.length === 0) return escape();
50
+ else if (children.some((m) => m.any === true || m.size() === 0))
51
+ return escape();
45
52
 
46
53
  // PREPARE MEATDATAS AND TAGS
47
54
  const indexes: number[] = [];
@@ -78,15 +85,14 @@ export const iterate_metadata_intersection = (
78
85
  messages: ["type tag cannot be standalone"],
79
86
  });
80
87
  return true;
81
- } else return false;
88
+ } else return escape();
82
89
  // ONLY OBJECTS CASE
83
90
  else if (
84
91
  metadatas.every((m) => m.objects.length === 1) &&
85
92
  tagObjects.length === 0
86
- ) {
87
- Object.assign(props.collection, commit);
88
- return false;
89
- } else if (metadatas.length !== 1) {
93
+ )
94
+ return escape();
95
+ else if (metadatas.length !== 1) {
90
96
  const indexes: number[] = metadatas
91
97
  .map((m, i) =>
92
98
  m.size() === 1 &&
package/src/llm.ts CHANGED
@@ -34,6 +34,7 @@ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
34
34
  *
35
35
  * @template App Target class or interface type collecting the functions to call
36
36
  * @template Model LLM schema model
37
+ * @template Config Configuration of LLM schema composition
37
38
  * @param options Options for the LLM application construction
38
39
  * @returns Application of LLM function calling schemas
39
40
  * @reference https://platform.openai.com/docs/guides/function-calling
@@ -75,12 +76,17 @@ export function application(
75
76
  *
76
77
  * @template App Target class or interface type collecting the functions to call
77
78
  * @template Model LLM schema model
79
+ * @template Config Configuration of LLM schema composition
78
80
  * @param options Options for the LLM application construction
79
81
  * @returns Application of LLM function calling schemas
80
82
  * @reference https://platform.openai.com/docs/guides/function-calling
81
83
  * @author Jeongho Nam - https://github.com/samchon
82
84
  */
83
- export function application<App extends object, Model extends ILlmSchema.Model>(
85
+ export function application<
86
+ App extends object,
87
+ Model extends ILlmSchema.Model,
88
+ Config extends Partial<ILlmSchema.ModelConfig[Model]> = {},
89
+ >(
84
90
  options?: Partial<Pick<ILlmApplication.IOptions<Model>, "separate">>,
85
91
  ): ILlmApplication<Model>;
86
92
 
@@ -113,6 +119,7 @@ export function application(): never {
113
119
  *
114
120
  * @template Parameters Target parameters type
115
121
  * @template Model LLM schema model
122
+ * @template Config Configuration of LLM schema composition
116
123
  * @returns LLM parameters schema
117
124
  * @reference https://platform.openai.com/docs/guides/function-calling
118
125
  * @reference https://platform.openai.com/docs/guides/structured-outputs
@@ -139,6 +146,7 @@ export function parameters(): never;
139
146
  *
140
147
  * @template Parameters Target parameters type
141
148
  * @template Model LLM schema model
149
+ * @template Config Configuration of LLM schema composition
142
150
  * @returns LLM parameters schema
143
151
  * @reference https://platform.openai.com/docs/guides/function-calling
144
152
  * @reference https://platform.openai.com/docs/guides/structured-outputs
@@ -146,6 +154,7 @@ export function parameters(): never;
146
154
  export function parameters<
147
155
  Parameters extends object,
148
156
  Model extends ILlmSchema.Model,
157
+ Config extends Partial<ILlmSchema.ModelConfig[Model]> = {},
149
158
  >(): ILlmSchema.ModelParameters[Model];
150
159
 
151
160
  /**
@@ -188,6 +197,7 @@ export function parameters(): never {
188
197
  *
189
198
  * @template T Target type
190
199
  * @template Model LLM schema model
200
+ * @template Config Configuration of LLM schema composition
191
201
  * @returns LLM schema
192
202
  * @reference https://platform.openai.com/docs/guides/function-calling
193
203
  * @reference https://platform.openai.com/docs/guides/structured-outputs
@@ -226,12 +236,17 @@ export function schema(): never;
226
236
  *
227
237
  * @template T Target type
228
238
  * @template Model LLM schema model
239
+ * @template Config Configuration of LLM schema composition
229
240
  * @param $defs Definitions of named schemas if the model is `chatgpt`
230
241
  * @returns LLM schema
231
242
  * @reference https://platform.openai.com/docs/guides/function-calling
232
243
  * @author Jeongho Nam - https://github.com/samchon
233
244
  */
234
- export function schema<T, Model extends ILlmSchema.Model>(
245
+ export function schema<
246
+ T,
247
+ Model extends ILlmSchema.Model,
248
+ Config extends Partial<ILlmSchema.ModelConfig[Model]> = {},
249
+ >(
235
250
  ...$defs: Extract<
236
251
  ILlmSchema.ModelSchema[Model],
237
252
  { $ref: string }
@@ -89,6 +89,7 @@ export namespace LlmApplicationProgrammer {
89
89
  export const write = <Model extends ILlmSchema.Model>(props: {
90
90
  model: Model;
91
91
  metadata: Metadata;
92
+ config?: Partial<ILlmSchema.ModelConfig[Model]>;
92
93
  }): ILlmApplication<Model> => {
93
94
  const errors: string[] = validate(props.model)(props.metadata, {
94
95
  top: true,
@@ -110,6 +111,11 @@ export namespace LlmApplicationProgrammer {
110
111
  });
111
112
  return {
112
113
  model: props.model,
114
+ options: {
115
+ ...LlmSchemaConverter.defaultConfig(props.model),
116
+ ...props.config,
117
+ separate: null,
118
+ },
113
119
  functions: application.functions.map((func) =>
114
120
  writeFunction({
115
121
  model: props.model,
@@ -117,10 +123,6 @@ export namespace LlmApplicationProgrammer {
117
123
  function: func,
118
124
  }),
119
125
  ),
120
- options: {
121
- ...LlmSchemaConverter.defaultConfig(props.model),
122
- separate: null,
123
- },
124
126
  };
125
127
  };
126
128
 
@@ -0,0 +1,127 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+ import { LlmSchemaConverter } from "@samchon/openapi/lib/converters/LlmSchemaConverter";
3
+ import ts from "typescript";
4
+
5
+ import { MetadataCollection } from "../../factories/MetadataCollection";
6
+ import { MetadataFactory } from "../../factories/MetadataFactory";
7
+
8
+ import { Metadata } from "../../schemas/metadata/Metadata";
9
+ import { MetadataObject } from "../../schemas/metadata/MetadataObject";
10
+
11
+ import { ITypiaContext } from "../../transformers/ITypiaContext";
12
+ import { TransformerError } from "../../transformers/TransformerError";
13
+
14
+ import { ValidationPipe } from "../../typings/ValidationPipe";
15
+
16
+ export namespace LlmModelPredicator {
17
+ export const getConfig = (props: {
18
+ context: ITypiaContext;
19
+ method: string;
20
+ model: ILlmSchema.Model;
21
+ node: ts.TypeNode | undefined;
22
+ }): Partial<ILlmSchema.ModelConfig[ILlmSchema.Model]> | undefined => {
23
+ if (props.node === undefined) return undefined;
24
+ const type: ts.Type = props.context.checker.getTypeFromTypeNode(props.node);
25
+ const collection: MetadataCollection = new MetadataCollection();
26
+ const result: ValidationPipe<Metadata, MetadataFactory.IError> =
27
+ MetadataFactory.analyze({
28
+ checker: props.context.checker,
29
+ transformer: props.context.transformer,
30
+ options: {
31
+ escape: false,
32
+ constant: true,
33
+ absorb: false,
34
+ functional: false,
35
+ },
36
+ collection,
37
+ type,
38
+ });
39
+ if (result.success === false)
40
+ throw new TransformerError({
41
+ code: `typia.llm.${props.method}`,
42
+ message: `Failed to analyze generic argument "Config".`,
43
+ });
44
+
45
+ const meta: Metadata = result.data;
46
+ if (
47
+ meta.size() !== 1 ||
48
+ meta.objects.length !== 1 ||
49
+ meta.nullable === true ||
50
+ meta.isRequired() === false
51
+ )
52
+ throw new TransformerError({
53
+ code: `typia.llm.${props.method}`,
54
+ message: `Invalid generic argument "Config". It must be a literal object type.`,
55
+ });
56
+
57
+ const obj: MetadataObject = meta.objects[0]!;
58
+ if (obj.type.properties.some((p) => p.key.isSoleLiteral() === false))
59
+ throw new TransformerError({
60
+ code: `typia.llm.${props.method}`,
61
+ message: `Invalid generic argument "Config". It must be a literal object type. Do not allow dynamic properties.`,
62
+ });
63
+ else if (
64
+ obj.type.properties.some(
65
+ (p) =>
66
+ p.value.size() !== 1 ||
67
+ p.value.constants.length !== 1 ||
68
+ p.value.nullable === true ||
69
+ p.value.isRequired() === false,
70
+ )
71
+ )
72
+ throw new TransformerError({
73
+ code: `typia.llm.${props.method}`,
74
+ message: `Invalid generic argument "Config". It must be a literal object type. Do not allow variable type.`,
75
+ });
76
+ const config: Partial<ILlmSchema.ModelConfig[ILlmSchema.Model]> = {};
77
+ for (const prop of obj.type.properties) {
78
+ const key: string = prop.key.getSoleLiteral()!;
79
+ const value: boolean | bigint | number | string =
80
+ prop.value.constants[0]!.values[0]!.value;
81
+ if (typeof value === "bigint")
82
+ throw new TransformerError({
83
+ code: `typia.llm.${props.method}`,
84
+ message: `Invalid generic argument "Config". It must be a literal object type. Do not allow bigint.`,
85
+ });
86
+ (config as any)[key] = value;
87
+ }
88
+ return config;
89
+ };
90
+
91
+ export const getModel = (props: {
92
+ checker: ts.TypeChecker;
93
+ method: string;
94
+ node: ts.TypeNode | undefined;
95
+ }): ILlmSchema.Model => {
96
+ if (props.node === undefined)
97
+ throw new TransformerError({
98
+ code: `typia.llm.${props.method}`,
99
+ message: `generic argument "Model" must be specified.`,
100
+ });
101
+
102
+ // CHECK LITERAL TYPE
103
+ const type: ts.Type = props.checker.getTypeFromTypeNode(props.node);
104
+ if (
105
+ !type.isLiteral() &&
106
+ (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
107
+ )
108
+ throw new TransformerError({
109
+ code: `typia.llm.${props.method}`,
110
+ message: `generic argument "Model" must be constant.`,
111
+ });
112
+
113
+ // GET VALUE AND VALIDATE IT
114
+ const value = type.isLiteral()
115
+ ? type.value
116
+ : props.checker.typeToString(type);
117
+ if (
118
+ typeof value !== "string" ||
119
+ LlmSchemaConverter.defaultConfig(value as "3.0") === undefined
120
+ )
121
+ throw new TransformerError({
122
+ code: "typia.llm.schema",
123
+ message: `invalid value on generic argument "Model".`,
124
+ });
125
+ return value as ILlmSchema.Model;
126
+ };
127
+ }
@@ -13,6 +13,7 @@ export namespace LlmParametersProgrammer {
13
13
  export const write = <Model extends ILlmSchema.Model>(props: {
14
14
  model: Model;
15
15
  metadata: Metadata;
16
+ config?: Partial<ILlmSchema.ModelConfig[Model]>;
16
17
  }): ILlmSchema.ModelParameters[Model] => {
17
18
  const collection: IJsonSchemaCollection<"3.1"> =
18
19
  JsonSchemasProgrammer.write({
@@ -32,7 +33,10 @@ export namespace LlmParametersProgrammer {
32
33
 
33
34
  const parameters: ILlmSchema.ModelParameters[Model] | null =
34
35
  LlmSchemaConverter.parameters(props.model)({
35
- config: LlmSchemaConverter.defaultConfig(props.model) as any,
36
+ config: {
37
+ ...LlmSchemaConverter.defaultConfig(props.model),
38
+ ...props.config,
39
+ } as any,
36
40
  components: collection.components,
37
41
  schema,
38
42
  }) as ILlmSchema.ModelParameters[Model] | null;
@@ -22,6 +22,7 @@ export namespace LlmSchemaProgrammer {
22
22
  export const write = <Model extends ILlmSchema.Model>(props: {
23
23
  model: Model;
24
24
  metadata: Metadata;
25
+ config?: Partial<ILlmSchema.ModelConfig[Model]>;
25
26
  }): IOutput<Model> => {
26
27
  const collection: IJsonSchemaCollection<"3.1"> =
27
28
  JsonSchemasProgrammer.write({
@@ -32,7 +33,10 @@ export namespace LlmSchemaProgrammer {
32
33
  const $defs: Record<string, ILlmSchema.ModelSchema[Model]> = {};
33
34
  const schema: ILlmSchema.ModelSchema[Model] | null =
34
35
  LlmSchemaConverter.schema(props.model)({
35
- config: LlmSchemaConverter.defaultConfig(props.model) as any,
36
+ config: {
37
+ ...LlmSchemaConverter.defaultConfig(props.model),
38
+ ...props.config,
39
+ } as any,
36
40
  components: collection.components,
37
41
  schema: collection.schemas[0]!,
38
42
  $defs: $defs as any,
@@ -1,5 +1,4 @@
1
1
  import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
2
- import { LlmSchemaConverter } from "@samchon/openapi/lib/converters/LlmSchemaConverter";
3
2
  import ts from "typescript";
4
3
 
5
4
  import { ExpressionFactory } from "../../../factories/ExpressionFactory";
@@ -11,6 +10,7 @@ import { StatementFactory } from "../../../factories/StatementFactory";
11
10
  import { Metadata } from "../../../schemas/metadata/Metadata";
12
11
 
13
12
  import { LlmApplicationProgrammer } from "../../../programmers/llm/LlmApplicationProgrammer";
13
+ import { LlmModelPredicator } from "../../../programmers/llm/LlmModelPredicator";
14
14
 
15
15
  import { ValidationPipe } from "../../../typings/ValidationPipe";
16
16
 
@@ -29,18 +29,12 @@ export namespace LlmApplicationTransformer {
29
29
  const top: ts.Node = props.expression.typeArguments[0]!;
30
30
  if (ts.isTypeNode(top) === false) return props.expression;
31
31
 
32
- // GET MODEL
33
- const model: ILlmSchema.Model = getTemplateArgument<ILlmSchema.Model>({
34
- checker: props.context.checker,
35
- name: "Model",
36
- is: (value) =>
37
- LlmSchemaConverter.defaultConfig(value as ILlmSchema.Model) !==
38
- undefined,
39
- cast: (value) => value as ILlmSchema.Model,
40
- default: () => "3.1",
41
- })(props.expression.typeArguments[1]);
42
-
43
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
+ });
44
38
  const type: ts.Type = props.context.checker.getTypeFromTypeNode(top);
45
39
  const collection: MetadataCollection = new MetadataCollection({
46
40
  replace: MetadataCollection.replace,
@@ -70,6 +64,12 @@ export namespace LlmApplicationTransformer {
70
64
  LlmApplicationProgrammer.write({
71
65
  model,
72
66
  metadata: result.data,
67
+ config: LlmModelPredicator.getConfig({
68
+ context: props.context,
69
+ method: "application",
70
+ model,
71
+ node: props.expression.typeArguments[2],
72
+ }),
73
73
  });
74
74
  const literal: ts.Expression = ts.factory.createAsExpression(
75
75
  LiteralFactory.write(schema),
@@ -114,38 +114,4 @@ export namespace LlmApplicationTransformer {
114
114
  ),
115
115
  );
116
116
  };
117
-
118
- const getTemplateArgument =
119
- <Value>(props: {
120
- checker: ts.TypeChecker;
121
- name: string;
122
- is: (value: string) => boolean;
123
- cast: (value: string) => Value;
124
- default: () => Value;
125
- }) =>
126
- (node: ts.TypeNode | undefined): Value => {
127
- if (!node) return props.default();
128
-
129
- // CHECK LITERAL TYPE
130
- const type: ts.Type = props.checker.getTypeFromTypeNode(node);
131
- if (
132
- !type.isLiteral() &&
133
- (type.getFlags() & ts.TypeFlags.BooleanLiteral) === 0
134
- )
135
- throw new TransformerError({
136
- code: "typia.llm.application",
137
- message: `generic argument "${props.name}" must be constant.`,
138
- });
139
-
140
- // GET VALUE AND VALIDATE IT
141
- const value = type.isLiteral()
142
- ? type.value
143
- : props.checker.typeToString(type);
144
- if (typeof value !== "string" || props.is(value) === false)
145
- throw new TransformerError({
146
- code: "typia.llm.application",
147
- message: `invalid value on generic argument "${props.name}".`,
148
- });
149
- return props.cast(value);
150
- };
151
117
  }