@samchon/openapi
Advanced tools
Comparing version 2.5.2 to 2.5.3
@@ -23,4 +23,5 @@ import { OpenApi } from "../../OpenApi"; | ||
const separateParameters: (props: { | ||
parameters: IChatGptSchema.IParameters; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
parameters: IChatGptSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => ILlmFunction.ISeparated<"chatgpt">; | ||
@@ -27,0 +28,0 @@ const invert: (props: { |
@@ -44,2 +44,3 @@ "use strict"; | ||
var LlmTypeCheckerV3_1_1 = require("../../utils/LlmTypeCheckerV3_1"); | ||
var NamingConvention_1 = require("../../utils/NamingConvention"); | ||
var OpenApiTypeChecker_1 = require("../../utils/OpenApiTypeChecker"); | ||
@@ -243,11 +244,13 @@ var LlmDescriptionInverter_1 = require("./LlmDescriptionInverter"); | ||
var e_4, _a; | ||
var _b; | ||
var _c = __read(separateObject({ | ||
var _b, _c; | ||
var convention = (_b = props.convention) !== null && _b !== void 0 ? _b : (function (key, type) { return "".concat(key, ".").concat(NamingConvention_1.NamingConvention.capitalize(type)); }); | ||
var _d = __read(separateObject({ | ||
predicate: props.predicate, | ||
convention: convention, | ||
$defs: props.parameters.$defs, | ||
predicate: props.predicate, | ||
schema: props.parameters, | ||
}), 2), llm = _c[0], human = _c[1]; | ||
}), 2), llm = _d[0], human = _d[1]; | ||
if (llm === null || human === null) | ||
return { | ||
llm: (_b = llm) !== null && _b !== void 0 ? _b : { | ||
llm: (_c = llm) !== null && _c !== void 0 ? _c : { | ||
type: "object", | ||
@@ -272,4 +275,4 @@ properties: {}, | ||
try { | ||
for (var _d = __values(Object.keys(props.parameters.$defs)), _e = _d.next(); !_e.done; _e = _d.next()) { | ||
var key = _e.value; | ||
for (var _e = __values(Object.keys(props.parameters.$defs)), _f = _e.next(); !_f.done; _f = _e.next()) { | ||
var key = _f.value; | ||
if (key.endsWith(".Llm") === false && key.endsWith(".Human") === false) | ||
@@ -282,3 +285,3 @@ delete props.parameters.$defs[key]; | ||
try { | ||
if (_e && !_e.done && (_a = _d.return)) _a.call(_d); | ||
if (_f && !_f.done && (_a = _e.return)) _a.call(_e); | ||
} | ||
@@ -297,4 +300,5 @@ finally { if (e_4) throw e_4.error; } | ||
return separateObject({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -304,4 +308,5 @@ }); | ||
return separateArray({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -311,4 +316,5 @@ }); | ||
return separateReference({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -320,4 +326,5 @@ }); | ||
var _a = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.items, | ||
@@ -345,4 +352,5 @@ }), 2), x = _a[0], y = _a[1]; | ||
var _g = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: value, | ||
@@ -366,4 +374,5 @@ }), 2), x = _g[0], y = _g[1]; | ||
var _h = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.additionalProperties, | ||
@@ -386,18 +395,21 @@ }), 2), dx = _h[0], dy = _h[1]; | ||
var key = props.schema.$ref.split("#/$defs/")[1]; | ||
var humanKey = props.convention(key, "human"); | ||
var llmKey = props.convention(key, "llm"); | ||
// FIND EXISTING | ||
if (((_a = props.$defs) === null || _a === void 0 ? void 0 : _a["".concat(key, ".Human")]) || ((_b = props.$defs) === null || _b === void 0 ? void 0 : _b["".concat(key, ".Llm")])) | ||
if (((_a = props.$defs) === null || _a === void 0 ? void 0 : _a[humanKey]) || ((_b = props.$defs) === null || _b === void 0 ? void 0 : _b[llmKey])) | ||
return [ | ||
((_c = props.$defs) === null || _c === void 0 ? void 0 : _c["".concat(key, ".Llm")]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Llm") }) : null, | ||
((_d = props.$defs) === null || _d === void 0 ? void 0 : _d["".concat(key, ".Human")]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Human") }) : null, | ||
((_c = props.$defs) === null || _c === void 0 ? void 0 : _c[llmKey]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(llmKey) }) : null, | ||
((_d = props.$defs) === null || _d === void 0 ? void 0 : _d[humanKey]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(humanKey) }) : null, | ||
]; | ||
// PRE-ASSIGNMENT | ||
props.$defs["".concat(key, ".Llm")] = {}; | ||
props.$defs["".concat(key, ".Human")] = {}; | ||
props.$defs[llmKey] = {}; | ||
props.$defs[humanKey] = {}; | ||
// DO COMPOSE | ||
var schema = (_e = props.$defs) === null || _e === void 0 ? void 0 : _e[key]; | ||
var _f = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: schema, | ||
@@ -407,4 +419,4 @@ }), 2), llm = _f[0], human = _f[1]; | ||
if (llm === null || human === null) { | ||
delete props.$defs["".concat(key, ".Llm")]; | ||
delete props.$defs["".concat(key, ".Human")]; | ||
delete props.$defs[llmKey]; | ||
delete props.$defs[humanKey]; | ||
return llm === null ? [null, props.schema] : [props.schema, null]; | ||
@@ -415,5 +427,5 @@ } | ||
llm !== null | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Llm") }) : null, | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(llmKey) }) : null, | ||
human !== null | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Human") }) : null, | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(humanKey) }) : null, | ||
]; | ||
@@ -420,0 +432,0 @@ }; |
@@ -23,4 +23,5 @@ import { OpenApi } from "../../OpenApi"; | ||
const separateParameters: (props: { | ||
parameters: IClaudeSchema.IParameters; | ||
predicate: (schema: IClaudeSchema) => boolean; | ||
parameters: IClaudeSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => ILlmFunction.ISeparated<"claude">; | ||
@@ -27,0 +28,0 @@ const invert: (props: { |
@@ -19,4 +19,5 @@ import { OpenApi } from "../../OpenApi"; | ||
const separateParameters: (props: { | ||
parameters: ILlamaSchema.IParameters; | ||
predicate: (schema: ILlamaSchema) => boolean; | ||
parameters: ILlamaSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => ILlmFunction.ISeparated<"llama">; | ||
@@ -23,0 +24,0 @@ const invert: (props: { |
@@ -28,4 +28,5 @@ import { OpenApi } from "../../OpenApi"; | ||
const separateParameters: (props: { | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => ILlmFunction.ISeparated<"3.1">; | ||
@@ -32,0 +33,0 @@ const invert: (props: { |
@@ -52,2 +52,3 @@ "use strict"; | ||
var LlmTypeCheckerV3_1_1 = require("../../utils/LlmTypeCheckerV3_1"); | ||
var NamingConvention_1 = require("../../utils/NamingConvention"); | ||
var OpenApiConstraintShifter_1 = require("../../utils/OpenApiConstraintShifter"); | ||
@@ -301,11 +302,13 @@ var OpenApiTypeChecker_1 = require("../../utils/OpenApiTypeChecker"); | ||
var e_1, _a; | ||
var _b; | ||
var _c = __read(separateObject({ | ||
var _b, _c; | ||
var convention = (_b = props.convention) !== null && _b !== void 0 ? _b : (function (key, type) { return "".concat(key, ".").concat(NamingConvention_1.NamingConvention.capitalize(type)); }); | ||
var _d = __read(separateObject({ | ||
$defs: props.parameters.$defs, | ||
schema: props.parameters, | ||
predicate: props.predicate, | ||
schema: props.parameters, | ||
}), 2), llm = _c[0], human = _c[1]; | ||
convention: convention, | ||
}), 2), llm = _d[0], human = _d[1]; | ||
if (llm === null || human === null) | ||
return { | ||
llm: (_b = llm) !== null && _b !== void 0 ? _b : { | ||
llm: (_c = llm) !== null && _c !== void 0 ? _c : { | ||
type: "object", | ||
@@ -330,4 +333,4 @@ properties: {}, | ||
try { | ||
for (var _d = __values(Object.keys(props.parameters.$defs)), _e = _d.next(); !_e.done; _e = _d.next()) { | ||
var key = _e.value; | ||
for (var _e = __values(Object.keys(props.parameters.$defs)), _f = _e.next(); !_f.done; _f = _e.next()) { | ||
var key = _f.value; | ||
if (key.endsWith(".Llm") === false && key.endsWith(".Human") === false) | ||
@@ -340,3 +343,3 @@ delete props.parameters.$defs[key]; | ||
try { | ||
if (_e && !_e.done && (_a = _d.return)) _a.call(_d); | ||
if (_f && !_f.done && (_a = _e.return)) _a.call(_e); | ||
} | ||
@@ -355,4 +358,5 @@ finally { if (e_1) throw e_1.error; } | ||
return separateObject({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -362,4 +366,5 @@ }); | ||
return separateArray({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -369,4 +374,5 @@ }); | ||
return separateReference({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -378,4 +384,5 @@ }); | ||
var _a = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.items, | ||
@@ -403,4 +410,5 @@ }), 2), x = _a[0], y = _a[1]; | ||
var _g = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: value, | ||
@@ -424,4 +432,5 @@ }), 2), x = _g[0], y = _g[1]; | ||
var _h = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.additionalProperties, | ||
@@ -444,18 +453,21 @@ }), 2), dx = _h[0], dy = _h[1]; | ||
var key = props.schema.$ref.split("#/$defs/")[1]; | ||
var humanKey = props.convention(key, "human"); | ||
var llmKey = props.convention(key, "llm"); | ||
// FIND EXISTING | ||
if (((_a = props.$defs) === null || _a === void 0 ? void 0 : _a["".concat(key, ".Human")]) || ((_b = props.$defs) === null || _b === void 0 ? void 0 : _b["".concat(key, ".Llm")])) | ||
if (((_a = props.$defs) === null || _a === void 0 ? void 0 : _a[humanKey]) || ((_b = props.$defs) === null || _b === void 0 ? void 0 : _b[llmKey])) | ||
return [ | ||
((_c = props.$defs) === null || _c === void 0 ? void 0 : _c["".concat(key, ".Llm")]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Llm") }) : null, | ||
((_d = props.$defs) === null || _d === void 0 ? void 0 : _d["".concat(key, ".Human")]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Human") }) : null, | ||
((_c = props.$defs) === null || _c === void 0 ? void 0 : _c[llmKey]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(llmKey) }) : null, | ||
((_d = props.$defs) === null || _d === void 0 ? void 0 : _d[humanKey]) | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(humanKey) }) : null, | ||
]; | ||
// PRE-ASSIGNMENT | ||
props.$defs["".concat(key, ".Llm")] = {}; | ||
props.$defs["".concat(key, ".Human")] = {}; | ||
props.$defs[llmKey] = {}; | ||
props.$defs[humanKey] = {}; | ||
// DO COMPOSE | ||
var schema = (_e = props.$defs) === null || _e === void 0 ? void 0 : _e[key]; | ||
var _f = __read(separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: schema, | ||
@@ -465,12 +477,12 @@ }), 2), llm = _f[0], human = _f[1]; | ||
if (llm === null || human === null) { | ||
delete props.$defs["".concat(key, ".Llm")]; | ||
delete props.$defs["".concat(key, ".Human")]; | ||
delete props.$defs[llmKey]; | ||
delete props.$defs[humanKey]; | ||
return llm === null ? [null, props.schema] : [props.schema, null]; | ||
} | ||
// FINALIZE | ||
// BOTH OF THEM | ||
return [ | ||
llm !== null | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Llm") }) : null, | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(llmKey) }) : null, | ||
human !== null | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(key, ".Human") }) : null, | ||
? __assign(__assign({}, props.schema), { $ref: "#/$defs/".concat(humanKey) }) : null, | ||
]; | ||
@@ -477,0 +489,0 @@ }; |
@@ -139,8 +139,10 @@ import { IChatGptSchema } from "../structures/IChatGptSchema"; | ||
chatgpt: (props: { | ||
parameters: IChatGptSchema.IParameters; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
parameters: IChatGptSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => import("..").ILlmFunction.ISeparated<"chatgpt">; | ||
claude: (props: { | ||
parameters: IClaudeSchema.IParameters; | ||
predicate: (schema: IClaudeSchema) => boolean; | ||
parameters: IClaudeSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => import("..").ILlmFunction.ISeparated<"claude">; | ||
@@ -152,4 +154,5 @@ gemini: (props: { | ||
llama: (props: { | ||
parameters: ILlamaSchema.IParameters; | ||
predicate: (schema: ILlamaSchema) => boolean; | ||
parameters: ILlamaSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => import("..").ILlmFunction.ISeparated<"llama">; | ||
@@ -161,4 +164,5 @@ "3.0": (props: { | ||
"3.1": (props: { | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}) => import("..").ILlmFunction.ISeparated<"3.1">; | ||
@@ -165,0 +169,0 @@ }[Model]; |
@@ -5,2 +5,3 @@ export declare namespace NamingConvention { | ||
function pascal(str: string): string; | ||
const capitalize: (str: string) => string; | ||
} |
@@ -110,3 +110,3 @@ "use strict"; | ||
if (piece_1.length) | ||
ret += capitalize(piece_1); | ||
ret += NamingConvention.capitalize(piece_1); | ||
} | ||
@@ -117,9 +117,9 @@ } | ||
if (last.length) | ||
ret += capitalize(piece); | ||
ret += NamingConvention.capitalize(piece); | ||
return prefix + escaper(ret); | ||
}; | ||
}; | ||
NamingConvention.capitalize = function (str) { | ||
return str.length !== 0 ? str[0].toUpperCase() + str.slice(1).toLowerCase() : str; | ||
}; | ||
})(NamingConvention || (exports.NamingConvention = NamingConvention = {})); | ||
var capitalize = function (str) { | ||
return str.length !== 0 ? str[0].toUpperCase() + str.slice(1).toLowerCase() : str; | ||
}; |
{ | ||
"name": "@samchon/openapi", | ||
"version": "2.5.2", | ||
"version": "2.5.3", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -9,2 +9,3 @@ import { OpenApi } from "../../OpenApi"; | ||
import { LlmTypeCheckerV3_1 } from "../../utils/LlmTypeCheckerV3_1"; | ||
import { NamingConvention } from "../../utils/NamingConvention"; | ||
import { OpenApiTypeChecker } from "../../utils/OpenApiTypeChecker"; | ||
@@ -227,8 +228,13 @@ import { LlmDescriptionInverter } from "./LlmDescriptionInverter"; | ||
export const separateParameters = (props: { | ||
parameters: IChatGptSchema.IParameters; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
parameters: IChatGptSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}): ILlmFunction.ISeparated<"chatgpt"> => { | ||
const convention = | ||
props.convention ?? | ||
((key, type) => `${key}.${NamingConvention.capitalize(type)}`); | ||
const [llm, human] = separateObject({ | ||
predicate: props.predicate, | ||
convention, | ||
$defs: props.parameters.$defs, | ||
predicate: props.predicate, | ||
schema: props.parameters, | ||
@@ -274,4 +280,5 @@ }); | ||
const separateStation = (props: { | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, IChatGptSchema>; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
schema: IChatGptSchema; | ||
@@ -287,4 +294,5 @@ }): [IChatGptSchema | null, IChatGptSchema | null] => { | ||
return separateObject({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -294,4 +302,5 @@ }); | ||
return separateArray({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -301,4 +310,5 @@ }); | ||
return separateReference({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -310,9 +320,11 @@ }); | ||
const separateArray = (props: { | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, IChatGptSchema>; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
schema: IChatGptSchema.IArray; | ||
}): [IChatGptSchema.IArray | null, IChatGptSchema.IArray | null] => { | ||
const [x, y] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.items, | ||
@@ -339,2 +351,3 @@ }); | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
schema: IChatGptSchema.IObject; | ||
@@ -361,4 +374,5 @@ }): [IChatGptSchema.IObject | null, IChatGptSchema.IObject | null] => { | ||
const [x, y] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: value, | ||
@@ -374,4 +388,5 @@ }); | ||
const [dx, dy] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.additionalProperties, | ||
@@ -393,21 +408,24 @@ }); | ||
const separateReference = (props: { | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, IChatGptSchema>; | ||
predicate: (schema: IChatGptSchema) => boolean; | ||
schema: IChatGptSchema.IReference; | ||
}): [IChatGptSchema.IReference | null, IChatGptSchema.IReference | null] => { | ||
const key: string = props.schema.$ref.split("#/$defs/")[1]; | ||
const humanKey: string = props.convention(key, "human"); | ||
const llmKey: string = props.convention(key, "llm"); | ||
// FIND EXISTING | ||
if (props.$defs?.[`${key}.Human`] || props.$defs?.[`${key}.Llm`]) | ||
if (props.$defs?.[humanKey] || props.$defs?.[llmKey]) | ||
return [ | ||
props.$defs?.[`${key}.Llm`] | ||
props.$defs?.[llmKey] | ||
? { | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Llm`, | ||
$ref: `#/$defs/${llmKey}`, | ||
} | ||
: null, | ||
props.$defs?.[`${key}.Human`] | ||
props.$defs?.[humanKey] | ||
? { | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Human`, | ||
$ref: `#/$defs/${humanKey}`, | ||
} | ||
@@ -418,4 +436,4 @@ : null, | ||
// PRE-ASSIGNMENT | ||
props.$defs![`${key}.Llm`] = {}; | ||
props.$defs![`${key}.Human`] = {}; | ||
props.$defs![llmKey] = {}; | ||
props.$defs![humanKey] = {}; | ||
@@ -425,4 +443,5 @@ // DO COMPOSE | ||
const [llm, human] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema, | ||
@@ -433,4 +452,4 @@ }); | ||
if (llm === null || human === null) { | ||
delete props.$defs[`${key}.Llm`]; | ||
delete props.$defs[`${key}.Human`]; | ||
delete props.$defs[llmKey]; | ||
delete props.$defs[humanKey]; | ||
return llm === null ? [null, props.schema] : [props.schema, null]; | ||
@@ -444,3 +463,3 @@ } | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Llm`, | ||
$ref: `#/$defs/${llmKey}`, | ||
} | ||
@@ -451,3 +470,3 @@ : null, | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Human`, | ||
$ref: `#/$defs/${humanKey}`, | ||
} | ||
@@ -454,0 +473,0 @@ : null, |
@@ -46,4 +46,5 @@ import { OpenApi } from "../../OpenApi"; | ||
export const separateParameters = (props: { | ||
parameters: IClaudeSchema.IParameters; | ||
predicate: (schema: IClaudeSchema) => boolean; | ||
parameters: IClaudeSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}): ILlmFunction.ISeparated<"claude"> => { | ||
@@ -50,0 +51,0 @@ const separated: ILlmFunction.ISeparated<"3.1"> = |
@@ -42,4 +42,5 @@ import { OpenApi } from "../../OpenApi"; | ||
export const separateParameters = (props: { | ||
parameters: ILlamaSchema.IParameters; | ||
predicate: (schema: ILlamaSchema) => boolean; | ||
parameters: ILlamaSchema.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}): ILlmFunction.ISeparated<"llama"> => | ||
@@ -46,0 +47,0 @@ LlmSchemaV3_1Composer.separateParameters( |
@@ -7,2 +7,3 @@ import { OpenApi } from "../../OpenApi"; | ||
import { LlmTypeCheckerV3_1 } from "../../utils/LlmTypeCheckerV3_1"; | ||
import { NamingConvention } from "../../utils/NamingConvention"; | ||
import { OpenApiConstraintShifter } from "../../utils/OpenApiConstraintShifter"; | ||
@@ -340,9 +341,14 @@ import { OpenApiTypeChecker } from "../../utils/OpenApiTypeChecker"; | ||
export const separateParameters = (props: { | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
parameters: ILlmSchemaV3_1.IParameters; | ||
convention?: (key: string, type: "llm" | "human") => string; | ||
}): ILlmFunction.ISeparated<"3.1"> => { | ||
const convention = | ||
props.convention ?? | ||
((key, type) => `${key}.${NamingConvention.capitalize(type)}`); | ||
const [llm, human] = separateObject({ | ||
$defs: props.parameters.$defs, | ||
schema: props.parameters, | ||
predicate: props.predicate, | ||
schema: props.parameters, | ||
convention, | ||
}); | ||
@@ -387,4 +393,5 @@ if (llm === null || human === null) | ||
const separateStation = (props: { | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
schema: ILlmSchemaV3_1; | ||
@@ -400,4 +407,5 @@ }): [ILlmSchemaV3_1 | null, ILlmSchemaV3_1 | null] => { | ||
return separateObject({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -407,4 +415,5 @@ }); | ||
return separateArray({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -414,4 +423,5 @@ }); | ||
return separateReference({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema, | ||
@@ -423,9 +433,11 @@ }); | ||
const separateArray = (props: { | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
schema: ILlmSchemaV3_1.IArray; | ||
}): [ILlmSchemaV3_1.IArray | null, ILlmSchemaV3_1.IArray | null] => { | ||
const [x, y] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.items, | ||
@@ -450,4 +462,5 @@ }); | ||
const separateObject = (props: { | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
schema: ILlmSchemaV3_1.IObject; | ||
@@ -474,4 +487,5 @@ }): [ILlmSchemaV3_1.IObject | null, ILlmSchemaV3_1.IObject | null] => { | ||
const [x, y] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: value, | ||
@@ -487,4 +501,5 @@ }); | ||
const [dx, dy] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema: props.schema.additionalProperties, | ||
@@ -506,21 +521,24 @@ }); | ||
const separateReference = (props: { | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
convention: (key: string, type: "llm" | "human") => string; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
predicate: (schema: ILlmSchemaV3_1) => boolean; | ||
schema: ILlmSchemaV3_1.IReference; | ||
}): [ILlmSchemaV3_1.IReference | null, ILlmSchemaV3_1.IReference | null] => { | ||
const key: string = props.schema.$ref.split("#/$defs/")[1]; | ||
const humanKey: string = props.convention(key, "human"); | ||
const llmKey: string = props.convention(key, "llm"); | ||
// FIND EXISTING | ||
if (props.$defs?.[`${key}.Human`] || props.$defs?.[`${key}.Llm`]) | ||
if (props.$defs?.[humanKey] || props.$defs?.[llmKey]) | ||
return [ | ||
props.$defs?.[`${key}.Llm`] | ||
props.$defs?.[llmKey] | ||
? { | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Llm`, | ||
$ref: `#/$defs/${llmKey}`, | ||
} | ||
: null, | ||
props.$defs?.[`${key}.Human`] | ||
props.$defs?.[humanKey] | ||
? { | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Human`, | ||
$ref: `#/$defs/${humanKey}`, | ||
} | ||
@@ -531,4 +549,4 @@ : null, | ||
// PRE-ASSIGNMENT | ||
props.$defs![`${key}.Llm`] = {}; | ||
props.$defs![`${key}.Human`] = {}; | ||
props.$defs![llmKey] = {}; | ||
props.$defs![humanKey] = {}; | ||
@@ -538,4 +556,5 @@ // DO COMPOSE | ||
const [llm, human] = separateStation({ | ||
predicate: props.predicate, | ||
convention: props.convention, | ||
$defs: props.$defs, | ||
predicate: props.predicate, | ||
schema, | ||
@@ -546,8 +565,8 @@ }); | ||
if (llm === null || human === null) { | ||
delete props.$defs[`${key}.Llm`]; | ||
delete props.$defs[`${key}.Human`]; | ||
delete props.$defs[llmKey]; | ||
delete props.$defs[humanKey]; | ||
return llm === null ? [null, props.schema] : [props.schema, null]; | ||
} | ||
// FINALIZE | ||
// BOTH OF THEM | ||
return [ | ||
@@ -557,3 +576,3 @@ llm !== null | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Llm`, | ||
$ref: `#/$defs/${llmKey}`, | ||
} | ||
@@ -564,3 +583,3 @@ : null, | ||
...props.schema, | ||
$ref: `#/$defs/${key}.Human`, | ||
$ref: `#/$defs/${humanKey}`, | ||
} | ||
@@ -567,0 +586,0 @@ : null, |
@@ -86,5 +86,5 @@ export namespace NamingConvention { | ||
}; | ||
export const capitalize = (str: string): string => | ||
str.length !== 0 ? str[0].toUpperCase() + str.slice(1).toLowerCase() : str; | ||
} | ||
const capitalize = (str: string): string => | ||
str.length !== 0 ? str[0].toUpperCase() + str.slice(1).toLowerCase() : str; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1877783
33037