@samchon/openapi
Advanced tools
Comparing version 2.0.0-dev.20241126 to 2.0.0-dev.20241127
@@ -5,10 +5,10 @@ import { OpenApi } from "../OpenApi"; | ||
const parameters: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}) => IGeminiSchema.IParameters | null; | ||
const schema: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}) => IGeminiSchema | null; | ||
@@ -15,0 +15,0 @@ const separate: (props: { |
@@ -1,17 +0,16 @@ | ||
import { OpenApi } from "../OpenApi"; | ||
import { IHttpLlmApplication } from "../structures/IHttpLlmApplication"; | ||
import { IHttpLlmFunction } from "../structures/IHttpLlmFunction"; | ||
import { IHttpMigrateApplication } from "../structures/IHttpMigrateApplication"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
export declare namespace HttpLlmConverter { | ||
const application: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>, Route extends IHttpMigrateRoute = IHttpMigrateRoute<OpenApi.IJsonSchema, Operation>>(props: { | ||
const application: <Model extends ILlmSchema.Model>(props: { | ||
model: Model; | ||
migrate: IHttpMigrateApplication<OpenApi.IJsonSchema, Operation>; | ||
migrate: IHttpMigrateApplication; | ||
options: IHttpLlmApplication.IOptions<Model>; | ||
}) => IHttpLlmApplication<Model, Parameters, Operation, Route>; | ||
const separate: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model]>(props: { | ||
}) => IHttpLlmApplication<Model>; | ||
const separate: <Model extends ILlmSchema.Model>(props: { | ||
model: Model; | ||
parameters: Parameters; | ||
predicate: (schema: Parameters["properties"][string]) => boolean; | ||
}) => IHttpLlmFunction.ISeparated<Parameters>; | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
predicate: (schema: ILlmSchema.ModelSchema[Model]) => boolean; | ||
}) => IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
} |
@@ -65,5 +65,3 @@ "use strict"; | ||
path: route.path, | ||
messages: [ | ||
"HEAD method is not supported in the LLM application.", | ||
], | ||
messages: ["HEAD method is not supported in the LLM application."], | ||
operation: function () { return route.operation(); }, | ||
@@ -103,5 +101,3 @@ route: function () { return route; }, | ||
}) | ||
.filter(function (v) { | ||
return v !== null; | ||
}); | ||
.filter(function (v) { return v !== null; }); | ||
return { | ||
@@ -108,0 +104,0 @@ model: props.model, |
@@ -5,10 +5,10 @@ import { OpenApi } from "../OpenApi"; | ||
const parameters: (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3.IConfig; | ||
}) => ILlmSchemaV3.IParameters | null; | ||
const schema: (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: Omit<ILlmSchemaV3.IConfig, "separate">; | ||
}) => ILlmSchemaV3 | null; | ||
@@ -15,0 +15,0 @@ const separate: (props: { |
@@ -6,75 +6,75 @@ import { OpenApi } from "../OpenApi"; | ||
import { ILlamaSchema } from "../structures/ILlamaSchema"; | ||
import { ILlmApplication } from "../structures/ILlmApplication"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
export declare namespace LlmSchemaConverter { | ||
const parameters: <Model extends ILlmApplication.Model>(model: Model) => { | ||
const parameters: <Model extends ILlmSchema.Model>(model: Model) => { | ||
chatgpt: (props: { | ||
config: IChatGptSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IChatGptSchema.IConfig; | ||
}) => IChatGptSchema.IParameters | null; | ||
claude: (props: { | ||
config: IClaudeSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IClaudeSchema.IConfig; | ||
}) => IClaudeSchema.IParameters | null; | ||
gemini: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IGeminiSchema.IConfig; | ||
}) => IGeminiSchema.IObject | null; | ||
llama: (props: { | ||
config: ILlamaSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlamaSchema.IConfig; | ||
}) => IClaudeSchema.IParameters | null; | ||
"3.0": (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3.IConfig; | ||
}) => ILlmSchemaV3.IParameters | null; | ||
}) => ILlmSchemaV3.IObject | null; | ||
"3.1": (props: { | ||
config: ILlmSchemaV3_1.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3_1.IConfig; | ||
}) => IClaudeSchema.IParameters | null; | ||
}[Model]; | ||
const schema: <Model extends ILlmApplication.Model>(model: Model) => { | ||
const schema: <Model extends ILlmSchema.Model>(model: Model) => { | ||
chatgpt: (props: { | ||
config: IChatGptSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, IChatGptSchema>; | ||
config: IChatGptSchema.IConfig; | ||
}) => IChatGptSchema | null; | ||
claude: (props: { | ||
config: IClaudeSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, IClaudeSchema>; | ||
config: IClaudeSchema.IConfig; | ||
}) => IClaudeSchema | null; | ||
gemini: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}) => IGeminiSchema | null; | ||
llama: (props: { | ||
config: ILlamaSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, ILlamaSchema>; | ||
config: ILlamaSchema.IConfig; | ||
}) => ILlamaSchema | null; | ||
"3.0": (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: ILlmSchemaV3.IConfig; | ||
}) => ILlmSchemaV3 | null; | ||
"3.1": (props: { | ||
config: ILlmSchemaV3_1.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
config: ILlmSchemaV3_1.IConfig; | ||
}) => ILlmSchemaV3_1 | null; | ||
}[Model]; | ||
const defaultConfig: <Model extends ILlmApplication.Model>(model: Model) => { | ||
const defaultConfig: <Model extends ILlmSchema.Model>(model: Model) => { | ||
chatgpt: { | ||
@@ -81,0 +81,0 @@ reference: false; |
@@ -12,7 +12,11 @@ "use strict"; | ||
(function (LlmSchemaConverter) { | ||
LlmSchemaConverter.parameters = function (model) { return PARAMETERS_CASTERS[model]; }; | ||
LlmSchemaConverter.parameters = function (model) { | ||
return PARAMETERS_CASTERS[model]; | ||
}; | ||
LlmSchemaConverter.schema = function (model) { | ||
return SCHEMA_CASTERS[model]; | ||
}; | ||
LlmSchemaConverter.defaultConfig = function (model) { return DEFAULT_CONFIGS[model]; }; | ||
LlmSchemaConverter.defaultConfig = function (model) { | ||
return DEFAULT_CONFIGS[model]; | ||
}; | ||
})(LlmSchemaConverter || (exports.LlmSchemaConverter = LlmSchemaConverter = {})); | ||
@@ -19,0 +23,0 @@ var PARAMETERS_CASTERS = { |
import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateApplication } from "../structures/IHttpMigrateApplication"; | ||
export declare namespace MigrateConverter { | ||
const convert: <Schema extends OpenApi.IJsonSchema, Operation extends OpenApi.IOperation<Schema>>(document: OpenApi.IDocument<Schema, Operation>) => IHttpMigrateApplication<Schema, Operation>; | ||
const convert: (document: OpenApi.IDocument) => IHttpMigrateApplication; | ||
} |
@@ -1,5 +0,4 @@ | ||
import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
export declare namespace MigrateRouteAccessor { | ||
const overwrite: <Schema extends OpenApi.IJsonSchema, Operation extends OpenApi.IOperation<Schema>>(routes: IHttpMigrateRoute<Schema, Operation>[]) => void; | ||
const overwrite: (routes: IHttpMigrateRoute[]) => void; | ||
} |
@@ -253,4 +253,4 @@ "use strict"; | ||
query: query || null, | ||
body: body, | ||
success: success, | ||
body: body || null, | ||
success: success || null, | ||
exceptions: Object.fromEntries(Object.entries((_l = props.operation.responses) !== null && _l !== void 0 ? _l : {}) | ||
@@ -267,5 +267,8 @@ .filter(function (_a) { | ||
{ | ||
schema: (_d = (_c = (_b = response.content) === null || _b === void 0 ? void 0 : _b["application/json"]) === null || _c === void 0 ? void 0 : _c.schema) !== null && _d !== void 0 ? _d : {}, | ||
schema: ((_d = (_c = (_b = response.content) === null || _b === void 0 ? void 0 : _b["application/json"]) === null || _c === void 0 ? void 0 : _c.schema) !== null && _d !== void 0 ? _d : {}), | ||
response: function () { return response; }, | ||
media: function () { var _a, _b; return (_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) !== null && _b !== void 0 ? _b : {}; }, | ||
media: function () { | ||
var _a, _b; | ||
return ((_b = (_a = response.content) === null || _a === void 0 ? void 0 : _a["application/json"]) !== null && _b !== void 0 ? _b : {}); | ||
}, | ||
}, | ||
@@ -460,3 +463,5 @@ ]; | ||
props.document.components.schemas[props.name] = props.schema; | ||
return { $ref: "#/components/schemas/".concat(props.name) }; | ||
return { | ||
$ref: "#/components/schemas/".concat(props.name), | ||
}; | ||
}; | ||
@@ -463,0 +468,0 @@ var isNotObjectLiteral = function (schema) { |
import type { HttpLlm } from "../HttpLlm"; | ||
import { OpenApi } from "../OpenApi"; | ||
import { IHttpLlmApplication } from "../structures/IHttpLlmApplication"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
import { IHttpResponse } from "../structures/IHttpResponse"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
export declare namespace HttpLlmFunctionFetcher { | ||
const execute: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>, Route extends IHttpMigrateRoute = IHttpMigrateRoute<OpenApi.IJsonSchema, Operation>>(props: HttpLlm.IFetchProps<Model, Parameters, Operation, Route>) => Promise<unknown>; | ||
const propagate: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>, Route extends IHttpMigrateRoute = IHttpMigrateRoute<OpenApi.IJsonSchema, Operation>>(props: HttpLlm.IFetchProps<Model, Parameters, Operation, Route>) => Promise<IHttpResponse>; | ||
const execute: <Model extends ILlmSchema.Model>(props: HttpLlm.IFetchProps<Model>) => Promise<unknown>; | ||
const propagate: <Model extends ILlmSchema.Model>(props: HttpLlm.IFetchProps<Model>) => Promise<IHttpResponse>; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); | ||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -43,9 +7,8 @@ exports.HttpLlmFunctionFetcher = void 0; | ||
(function (HttpLlmFunctionFetcher) { | ||
var _this = this; | ||
HttpLlmFunctionFetcher.execute = function (props) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, HttpMigrateRouteFetcher_1.HttpMigrateRouteFetcher.execute(getFetchArguments("execute", props))]; | ||
}); }); }; | ||
HttpLlmFunctionFetcher.propagate = function (props) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) { | ||
return [2 /*return*/, HttpMigrateRouteFetcher_1.HttpMigrateRouteFetcher.propagate(getFetchArguments("propagate", props))]; | ||
}); }); }; | ||
HttpLlmFunctionFetcher.execute = function (props) { | ||
return HttpMigrateRouteFetcher_1.HttpMigrateRouteFetcher.execute(getFetchArguments("execute", props)); | ||
}; | ||
HttpLlmFunctionFetcher.propagate = function (props) { | ||
return HttpMigrateRouteFetcher_1.HttpMigrateRouteFetcher.propagate(getFetchArguments("propagate", props)); | ||
}; | ||
var getFetchArguments = function (from, props) { | ||
@@ -52,0 +15,0 @@ var route = props.function.route(); |
import { OpenApi } from "./OpenApi"; | ||
import { IChatGptSchema } from "./structures/IChatGptSchema"; | ||
import { IGeminiSchema } from "./structures/IGeminiSchema"; | ||
import { IHttpConnection } from "./structures/IHttpConnection"; | ||
import { IHttpLlmApplication } from "./structures/IHttpLlmApplication"; | ||
import { IHttpLlmFunction } from "./structures/IHttpLlmFunction"; | ||
import { IHttpMigrateApplication } from "./structures/IHttpMigrateApplication"; | ||
import { IHttpMigrateRoute } from "./structures/IHttpMigrateRoute"; | ||
import { IHttpResponse } from "./structures/IHttpResponse"; | ||
import { ILlmFunction } from "./structures/ILlmFunction"; | ||
import { ILlmSchemaV3 } from "./structures/ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./structures/ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "./structures/ILlmSchema"; | ||
/** | ||
@@ -37,2 +32,12 @@ * LLM function calling application composer from OpenAPI document. | ||
/** | ||
* Properties for the LLM function calling application composer. | ||
* | ||
* @template Model Target LLM model | ||
*/ | ||
interface IApplicationProps<Model extends ILlmSchema.Model> { | ||
model: Model; | ||
document: OpenApi.IDocument; | ||
options?: Partial<IHttpLlmApplication.IOptions<Model>>; | ||
} | ||
/** | ||
* Convert OpenAPI document to LLM function calling application. | ||
@@ -62,19 +67,15 @@ * | ||
*/ | ||
const application: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>>(props: { | ||
model: Model; | ||
document: OpenApi.IDocument<OpenApi.IJsonSchema, Operation> | IHttpMigrateApplication<OpenApi.IJsonSchema, Operation>; | ||
options?: Partial<IHttpLlmApplication.IOptions<Model, IHttpLlmApplication.ModelSchema[Model]>>; | ||
}) => IHttpLlmApplication<Model, Parameters>; | ||
const application: <Model extends ILlmSchema.Model>(props: IApplicationProps<Model>) => IHttpLlmApplication<Model>; | ||
/** | ||
* Properties for the LLM function call. | ||
*/ | ||
interface IFetchProps<Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute<OpenApi.IJsonSchema, Operation>> { | ||
interface IFetchProps<Model extends ILlmSchema.Model> { | ||
/** | ||
* Application of the LLM function calling. | ||
*/ | ||
application: IHttpLlmApplication<Model, Parameters, Operation>; | ||
application: IHttpLlmApplication<Model>; | ||
/** | ||
* LLM function schema to call. | ||
*/ | ||
function: IHttpLlmFunction<Parameters, Operation, Route>; | ||
function: IHttpLlmFunction<ILlmSchema.Model>; | ||
/** | ||
@@ -114,3 +115,3 @@ * Connection info to the HTTP server. | ||
*/ | ||
const execute: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>>(props: IFetchProps<Model, Parameters, Operation>) => Promise<unknown>; | ||
const execute: <Model extends ILlmSchema.Model>(props: IFetchProps<Model>) => Promise<unknown>; | ||
/** | ||
@@ -140,11 +141,11 @@ * Propagate the LLM function call. | ||
*/ | ||
const propagate: <Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation<OpenApi.IJsonSchema>>(props: IFetchProps<Model, Parameters, Operation>) => Promise<IHttpResponse>; | ||
const propagate: <Model extends ILlmSchema.Model>(props: IFetchProps<Model>) => Promise<IHttpResponse>; | ||
/** | ||
* Properties for the parameters' merging. | ||
*/ | ||
interface IMergeProps<Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters> { | ||
interface IMergeProps { | ||
/** | ||
* Metadata of the target function. | ||
*/ | ||
function: ILlmFunction<Parameters>; | ||
function: ILlmFunction<any>; | ||
/** | ||
@@ -174,3 +175,3 @@ * Arguments composed by the LLM. | ||
*/ | ||
const mergeParameters: <Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters>(props: IMergeProps<Parameters>) => object; | ||
const mergeParameters: (props: IMergeProps) => object; | ||
/** | ||
@@ -177,0 +178,0 @@ * Merge two values. |
@@ -44,5 +44,2 @@ "use strict"; | ||
(function (HttpLlm) { | ||
/* ----------------------------------------------------------- | ||
COMPOSERS | ||
----------------------------------------------------------- */ | ||
/** | ||
@@ -76,5 +73,3 @@ * Convert OpenAPI document to LLM function calling application. | ||
// MIGRATE | ||
var migrate = props.document["x-samchon-emended"] === true | ||
? HttpMigration_1.HttpMigration.application(props.document) | ||
: props.document; | ||
var migrate = HttpMigration_1.HttpMigration.application(props.document); | ||
return HttpLlmConverter_1.HttpLlmConverter.application({ | ||
@@ -152,3 +147,5 @@ migrate: migrate, | ||
*/ | ||
HttpLlm.mergeParameters = function (props) { return LlmDataMerger_1.LlmDataMerger.parameters(props); }; | ||
HttpLlm.mergeParameters = function (props) { | ||
return LlmDataMerger_1.LlmDataMerger.parameters(props); | ||
}; | ||
/** | ||
@@ -155,0 +152,0 @@ * Merge two values. |
@@ -69,3 +69,3 @@ import { OpenApi } from "./OpenApi"; | ||
*/ | ||
const application: <Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>>(document: OpenApi.IDocument<Schema, Operation>) => IHttpMigrateApplication<Schema, Operation>; | ||
const application: (document: OpenApi.IDocument) => IHttpMigrateApplication; | ||
/** | ||
@@ -72,0 +72,0 @@ * Properties for the request to the HTTP server. |
@@ -73,5 +73,3 @@ "use strict"; | ||
*/ | ||
HttpMigration.application = function (document) { | ||
return MigrateConverter_1.MigrateConverter.convert(document); | ||
}; | ||
HttpMigration.application = function (document) { return MigrateConverter_1.MigrateConverter.convert(document); }; | ||
/* ----------------------------------------------------------- | ||
@@ -78,0 +76,0 @@ FETCHERS |
@@ -49,3 +49,3 @@ import { OpenApiV3 } from "./OpenApiV3"; | ||
*/ | ||
function convert<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>>(input: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument<Schema, Operation>): IDocument<Schema, Operation>; | ||
function convert(input: SwaggerV2.IDocument | OpenApiV3.IDocument | OpenApiV3_1.IDocument | OpenApi.IDocument): IDocument; | ||
/** | ||
@@ -60,3 +60,3 @@ * Downgrade to Swagger v2.0 document. | ||
*/ | ||
function downgrade<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>>(document: IDocument<Schema, Operation>, version: "2.0"): SwaggerV2.IDocument; | ||
function downgrade(document: IDocument, version: "2.0"): SwaggerV2.IDocument; | ||
/** | ||
@@ -71,3 +71,3 @@ * Downgrade to OpenAPI v3.0 document. | ||
*/ | ||
function downgrade<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>>(document: IDocument<Schema, Operation>, version: "3.0"): OpenApiV3.IDocument; | ||
function downgrade(document: IDocument, version: "3.0"): OpenApiV3.IDocument; | ||
/** | ||
@@ -81,7 +81,4 @@ * OpenAPI document. | ||
* duplicated expressions of OpenAPI v3.1 for the convenience and clarity. | ||
* | ||
* @template Schema JSON schema type | ||
* @template Operation HTTP operation type | ||
*/ | ||
interface IDocument<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>> { | ||
interface IDocument { | ||
/** | ||
@@ -107,3 +104,3 @@ * OpenAPI version number. | ||
*/ | ||
components: IComponents<Schema>; | ||
components: IComponents; | ||
/** | ||
@@ -114,3 +111,3 @@ * The available paths and operations for the API. | ||
*/ | ||
paths?: Record<string, IPath<Schema, Operation>>; | ||
paths?: Record<string, IPath>; | ||
/** | ||
@@ -122,3 +119,3 @@ * An object to hold Webhooks. | ||
*/ | ||
webhooks?: Record<string, IPath<Schema, Operation>>; | ||
webhooks?: Record<string, IPath>; | ||
/** | ||
@@ -286,3 +283,3 @@ * A declaration of which security mechanisms can be used across the API. | ||
*/ | ||
interface IPath<Schema extends IJsonSchema = IJsonSchema, Operation extends IOperation<Schema> = IOperation<Schema>> extends Partial<Record<Method, Operation>> { | ||
interface IPath extends Partial<Record<Method, IOperation>> { | ||
/** | ||
@@ -307,3 +304,3 @@ * Servers that provide the path operations. | ||
*/ | ||
interface IOperation<Schema extends IJsonSchema = IJsonSchema> { | ||
interface IOperation { | ||
/** | ||
@@ -316,7 +313,7 @@ * Unique string used to identify the operation. | ||
*/ | ||
parameters?: IOperation.IParameter<Schema>[]; | ||
parameters?: IOperation.IParameter[]; | ||
/** | ||
* The request body applicable for this operation. | ||
*/ | ||
requestBody?: IOperation.IRequestBody<Schema>; | ||
requestBody?: IOperation.IRequestBody; | ||
/** | ||
@@ -327,3 +324,3 @@ * The list of possible responses as they are returned from executing this | ||
*/ | ||
responses?: Record<string, IOperation.IResponse<Schema>>; | ||
responses?: Record<string, IOperation.IResponse>; | ||
/** | ||
@@ -367,3 +364,3 @@ * A list of servers providing this API operation. | ||
*/ | ||
interface IParameter<Schema extends IJsonSchema = IJsonSchema> { | ||
interface IParameter { | ||
/** | ||
@@ -395,3 +392,3 @@ * Representative name of the parameter. | ||
*/ | ||
schema: Schema; | ||
schema: IJsonSchema; | ||
/** | ||
@@ -428,4 +425,4 @@ * Whether the parameter is required for execution or not. | ||
*/ | ||
interface IRequestBody<Schema extends IJsonSchema = IJsonSchema> { | ||
content?: IContent<Schema>; | ||
interface IRequestBody { | ||
content?: IContent; | ||
description?: string; | ||
@@ -438,5 +435,5 @@ required?: boolean; | ||
*/ | ||
interface IResponse<Schema extends IJsonSchema = IJsonSchema> { | ||
headers?: Record<string, IOperation.IParameter<Schema>>; | ||
content?: IContent<Schema>; | ||
interface IResponse { | ||
headers?: Record<string, IOperation.IParameter>; | ||
content?: IContent; | ||
description?: string; | ||
@@ -448,3 +445,3 @@ "x-nestia-encrypted"?: boolean; | ||
*/ | ||
interface IContent<Schema extends IJsonSchema = IJsonSchema> extends Partial<Record<ContentType, IMediaType<Schema>>> { | ||
interface IContent extends Partial<Record<ContentType, IMediaType>> { | ||
} | ||
@@ -454,4 +451,4 @@ /** | ||
*/ | ||
interface IMediaType<Schema extends IJsonSchema = IJsonSchema> { | ||
schema?: Schema; | ||
interface IMediaType { | ||
schema?: IJsonSchema; | ||
example?: any; | ||
@@ -481,3 +478,3 @@ examples?: Record<string, IExample>; | ||
*/ | ||
interface IComponents<Schema extends IJsonSchema = IJsonSchema> { | ||
interface IComponents { | ||
/** | ||
@@ -488,3 +485,3 @@ * An object to hold reusable DTO schemas. | ||
*/ | ||
schemas?: Record<string, Schema>; | ||
schemas?: Record<string, IJsonSchema>; | ||
/** | ||
@@ -659,3 +656,3 @@ * An object to hold reusable security schemes. | ||
*/ | ||
interface IArray<Schema extends IJsonSchema = IJsonSchema> extends __ISignificant<"array"> { | ||
interface IArray extends __ISignificant<"array"> { | ||
/** | ||
@@ -667,3 +664,3 @@ * Items type info. | ||
*/ | ||
items: Schema; | ||
items: IJsonSchema; | ||
/** | ||
@@ -695,3 +692,3 @@ * Unique items restriction. | ||
*/ | ||
interface ITuple<Schema extends IJsonSchema = IJsonSchema> extends __ISignificant<"array"> { | ||
interface ITuple extends __ISignificant<"array"> { | ||
/** | ||
@@ -706,3 +703,3 @@ * Prefix items. | ||
*/ | ||
prefixItems: Schema[]; | ||
prefixItems: IJsonSchema[]; | ||
/** | ||
@@ -723,3 +720,3 @@ * Additional items. | ||
*/ | ||
additionalItems?: boolean | Schema; | ||
additionalItems?: boolean | IJsonSchema; | ||
/** | ||
@@ -751,3 +748,3 @@ * Unique items restriction. | ||
*/ | ||
interface IObject<Schema extends IJsonSchema = IJsonSchema> extends __ISignificant<"object"> { | ||
interface IObject extends __ISignificant<"object"> { | ||
/** | ||
@@ -763,3 +760,3 @@ * Properties of the object. | ||
*/ | ||
properties?: Record<string, Schema>; | ||
properties?: Record<string, IJsonSchema>; | ||
/** | ||
@@ -779,3 +776,3 @@ * Additional properties' info. | ||
*/ | ||
additionalProperties?: boolean | Schema; | ||
additionalProperties?: boolean | IJsonSchema; | ||
/** | ||
@@ -842,7 +839,7 @@ * List of key values of the required properties. | ||
*/ | ||
interface IOneOf<Schema extends IJsonSchema = IJsonSchema> extends __IAttribute { | ||
interface IOneOf extends __IAttribute { | ||
/** | ||
* List of the union types. | ||
*/ | ||
oneOf: Exclude<Schema, IJsonSchema.IOneOf<Schema>>[]; | ||
oneOf: Exclude<IJsonSchema, IJsonSchema.IOneOf>[]; | ||
/** | ||
@@ -849,0 +846,0 @@ * Discriminator info of the union type. |
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
export interface IHttpConnection<Headers extends object | undefined = object | undefined> { | ||
export interface IHttpConnection { | ||
/** | ||
@@ -25,3 +25,3 @@ * Host address of the remote HTTP server. | ||
*/ | ||
headers?: Record<string, IHttpConnection.HeaderValue> & IHttpConnection.Headerify<Headers>; | ||
headers?: Record<string, IHttpConnection.HeaderValue>; | ||
/** | ||
@@ -112,35 +112,2 @@ * Additional options for the `fetch` function. | ||
type HeaderValue = string | boolean | number | bigint | string | Array<boolean> | Array<number> | Array<bigint> | Array<number> | Array<string>; | ||
/** | ||
* Type of headers | ||
* | ||
* `Headerify` removes every properties that are not allowed in the | ||
* HTTP headers type. | ||
* | ||
* Below are list of prohibited in HTTP headers. | ||
* | ||
* 1. Value type one of {@link HeaderValue} | ||
* 2. Key is "set-cookie", but value is not an Array type | ||
* 3. Key is one of them, but value is Array type | ||
* - "age" | ||
* - "authorization" | ||
* - "content-length" | ||
* - "content-type" | ||
* - "etag" | ||
* - "expires" | ||
* - "from" | ||
* - "host" | ||
* - "if-modified-since" | ||
* - "if-unmodified-since" | ||
* - "last-modified" | ||
* - "location" | ||
* - "max-forwards" | ||
* - "proxy-authorization" | ||
* - "referer" | ||
* - "retry-after" | ||
* - "server" | ||
* - "user-agent" | ||
*/ | ||
type Headerify<T extends object | undefined> = { | ||
[P in keyof T]?: T[P] extends HeaderValue | undefined ? P extends string ? Lowercase<P> extends "set-cookie" ? T[P] extends Array<HeaderValue> ? T[P] | undefined : never : Lowercase<P> extends "age" | "authorization" | "content-length" | "content-type" | "etag" | "expires" | "from" | "host" | "if-modified-since" | "if-unmodified-since" | "last-modified" | "location" | "max-forwards" | "proxy-authorization" | "referer" | "retry-after" | "server" | "user-agent" ? T[P] extends Array<HeaderValue> ? never : T[P] | undefined : T[P] | undefined : never : never; | ||
}; | ||
} |
@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { ILlmApplication } from "./ILlmApplication"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
/** | ||
@@ -69,3 +70,3 @@ * Application of LLM function call from OpenAPI document. | ||
*/ | ||
export interface IHttpLlmApplication<Model extends IHttpLlmApplication.Model, Parameters extends IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
export interface IHttpLlmApplication<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -83,17 +84,13 @@ * Model of the target LLM. | ||
*/ | ||
functions: IHttpLlmFunction<Parameters, Operation, Route>[]; | ||
functions: IHttpLlmFunction<Model>[]; | ||
/** | ||
* List of errors occurred during the composition. | ||
*/ | ||
errors: IHttpLlmApplication.IError<Operation, Route>[]; | ||
errors: IHttpLlmApplication.IError[]; | ||
/** | ||
* Configuration for the application. | ||
*/ | ||
options: IHttpLlmApplication.IOptions<Model, IHttpLlmApplication.ModelSchema[Model]>; | ||
options: IHttpLlmApplication.IOptions<Model>; | ||
} | ||
export declare namespace IHttpLlmApplication { | ||
export import Model = ILlmApplication.Model; | ||
export import ModelParameters = ILlmApplication.ModelParameters; | ||
export import ModelSchema = ILlmApplication.ModelSchema; | ||
export import ModelConfig = ILlmApplication.ModelConfig; | ||
export import IOptions = ILlmApplication.IOptions; | ||
@@ -103,3 +100,3 @@ /** | ||
*/ | ||
interface IError<Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
interface IError { | ||
/** | ||
@@ -122,3 +119,3 @@ * HTTP method of the endpoint. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
/** | ||
@@ -134,4 +131,4 @@ * Get the migration route metadata. | ||
*/ | ||
route: () => Route | undefined; | ||
route: () => IHttpMigrateRoute | undefined; | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateRoute } from "./IHttpMigrateRoute"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
@@ -60,3 +61,3 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
*/ | ||
export interface IHttpLlmFunction<Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters, Operation extends OpenApi.IOperation = OpenApi.IOperation, Route extends IHttpMigrateRoute = IHttpMigrateRoute> { | ||
export interface IHttpLlmFunction<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -142,3 +143,3 @@ * HTTP method of the endpoint. | ||
*/ | ||
parameters: Parameters; | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
/** | ||
@@ -149,3 +150,3 @@ * Collection of separated parameters. | ||
*/ | ||
separated?: IHttpLlmFunction.ISeparated<Parameters>; | ||
separated?: IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
/** | ||
@@ -157,3 +158,3 @@ * Expected return type. | ||
*/ | ||
output?: Parameters | undefined; | ||
output?: ILlmSchema.ModelSchema[Model] | undefined; | ||
/** | ||
@@ -205,3 +206,3 @@ * Description of the function. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
/** | ||
@@ -214,3 +215,3 @@ * Get the migration route metadata. | ||
*/ | ||
route: () => Route; | ||
route: () => IHttpMigrateRoute; | ||
} | ||
@@ -217,0 +218,0 @@ export declare namespace IHttpLlmFunction { |
@@ -17,15 +17,15 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpMigrateApplication<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>> { | ||
export interface IHttpMigrateApplication { | ||
/** | ||
* List of routes for migration. | ||
*/ | ||
routes: IHttpMigrateRoute<Schema, Operation>[]; | ||
routes: IHttpMigrateRoute[]; | ||
/** | ||
* List of errors occurred during the migration. | ||
*/ | ||
errors: IHttpMigrateApplication.IError<Operation>[]; | ||
errors: IHttpMigrateApplication.IError[]; | ||
/** | ||
* Source OpenAPI document. | ||
*/ | ||
document: () => OpenApi.IDocument<Schema, Operation>; | ||
document: () => OpenApi.IDocument; | ||
} | ||
@@ -36,7 +36,7 @@ export declare namespace IHttpMigrateApplication { | ||
*/ | ||
interface IError<Operation extends OpenApi.IOperation<any> = OpenApi.IOperation<OpenApi.IJsonSchema>> { | ||
interface IError { | ||
/** | ||
* Target operation causing the error. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
/** | ||
@@ -43,0 +43,0 @@ * Method of the operation. |
@@ -15,3 +15,3 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpMigrateRoute<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>> { | ||
export interface IHttpMigrateRoute { | ||
/** | ||
@@ -74,3 +74,3 @@ * Method of the route. | ||
*/ | ||
parameters: IHttpMigrateRoute.IParameter<Schema>[]; | ||
parameters: IHttpMigrateRoute.IParameter[]; | ||
/** | ||
@@ -91,3 +91,3 @@ * Metadata of headers. | ||
*/ | ||
headers: IHttpMigrateRoute.IHeaders<Schema> | null; | ||
headers: IHttpMigrateRoute.IHeaders | null; | ||
/** | ||
@@ -108,3 +108,3 @@ * Metadata of query values. | ||
*/ | ||
query: IHttpMigrateRoute.IQuery<Schema> | null; | ||
query: IHttpMigrateRoute.IQuery | null; | ||
/** | ||
@@ -119,3 +119,3 @@ * Metadata of request body. | ||
*/ | ||
body: IHttpMigrateRoute.IBody<Schema> | null; | ||
body: IHttpMigrateRoute.IBody | null; | ||
/** | ||
@@ -130,3 +130,3 @@ * Metadata of response body for success case. | ||
*/ | ||
success: IHttpMigrateRoute.IBody<Schema> | null; | ||
success: IHttpMigrateRoute.IBody | null; | ||
/** | ||
@@ -143,3 +143,3 @@ * Metadata of response body for exceptional status cases. | ||
*/ | ||
exceptions: Record<string, IHttpMigrateRoute.IException<Schema>>; | ||
exceptions: Record<string, IHttpMigrateRoute.IException>; | ||
/** | ||
@@ -166,3 +166,3 @@ * Description comment for the route function. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
} | ||
@@ -173,3 +173,3 @@ export declare namespace IHttpMigrateRoute { | ||
*/ | ||
interface IParameter<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema> { | ||
interface IParameter { | ||
/** | ||
@@ -186,3 +186,3 @@ * Name of the path parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
/** | ||
@@ -194,3 +194,3 @@ * Original parameter info from the OpenAPI document. | ||
*/ | ||
parameter: () => OpenApi.IOperation.IParameter<Schema>; | ||
parameter: () => OpenApi.IOperation.IParameter; | ||
} | ||
@@ -200,3 +200,3 @@ /** | ||
*/ | ||
interface IHeaders<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema> { | ||
interface IHeaders { | ||
/** | ||
@@ -213,3 +213,3 @@ * Name of the headers parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
title: () => string | undefined; | ||
@@ -223,6 +223,6 @@ description: () => string | undefined; | ||
*/ | ||
interface IQuery<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema> { | ||
interface IQuery { | ||
name: string; | ||
key: string; | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
title: () => string | undefined; | ||
@@ -236,3 +236,3 @@ description: () => string | undefined; | ||
*/ | ||
interface IBody<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema> { | ||
interface IBody { | ||
/** | ||
@@ -253,3 +253,3 @@ * Name of the body parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
/** | ||
@@ -262,3 +262,3 @@ * Description comment for the request/response body. | ||
*/ | ||
media: () => OpenApi.IOperation.IMediaType<Schema>; | ||
media: () => OpenApi.IOperation.IMediaType; | ||
/** | ||
@@ -272,16 +272,16 @@ * Whether the body is encrypted or not. | ||
*/ | ||
interface IException<Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema> { | ||
interface IException { | ||
/** | ||
* Metadata of response body data type. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
/** | ||
* Description comment for the exception. | ||
*/ | ||
response: () => OpenApi.IOperation.IResponse<Schema>; | ||
response: () => OpenApi.IOperation.IResponse; | ||
/** | ||
* Media type of the response body. | ||
*/ | ||
media: () => OpenApi.IOperation.IMediaType<Schema>; | ||
media: () => OpenApi.IOperation.IMediaType; | ||
} | ||
} |
@@ -1,8 +0,3 @@ | ||
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlamaSchema } from "./ILlamaSchema"; | ||
import { ILlmFunction } from "./ILlmFunction"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
/** | ||
@@ -13,3 +8,3 @@ * Application of LLM function calling. | ||
* {@link ILlmFunction LLM function calling schemas}, composed from a native | ||
* TypeScript class (or interface) type by the `typia.llm.application<App>()` | ||
* TypeScript class (or interface) type by the `typia.llm.application<App, Model>()` | ||
* function. | ||
@@ -32,3 +27,3 @@ * | ||
*/ | ||
export interface ILlmApplication<Model extends ILlmApplication.Model, Parameters extends ILlmApplication.ModelParameters[Model] = ILlmApplication.ModelParameters[Model]> { | ||
export interface ILlmApplication<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -43,38 +38,13 @@ * Model of the LLM. | ||
*/ | ||
functions: ILlmFunction<Parameters>[]; | ||
functions: ILlmFunction<Model>[]; | ||
/** | ||
* Configuration for the application. | ||
*/ | ||
options: ILlmApplication.IOptions<Model, ILlmApplication.ModelSchema[Model]>; | ||
options: ILlmApplication.IOptions<Model>; | ||
} | ||
export declare namespace ILlmApplication { | ||
type Model = "chatgpt" | "claude" | "gemini" | "llama" | "3.0" | "3.1"; | ||
type ModelParameters = { | ||
chatgpt: IChatGptSchema.IParameters; | ||
claude: IClaudeSchema.IParameters; | ||
gemini: IGeminiSchema.IParameters; | ||
llama: ILlamaSchema.IParameters; | ||
"3.0": ILlmSchemaV3.IParameters; | ||
"3.1": ILlmSchemaV3_1.IParameters; | ||
}; | ||
type ModelSchema = { | ||
chatgpt: IChatGptSchema; | ||
claude: IClaudeSchema; | ||
gemini: IGeminiSchema; | ||
llama: ILlamaSchema; | ||
"3.0": ILlmSchemaV3; | ||
"3.1": ILlmSchemaV3_1; | ||
}; | ||
type ModelConfig = { | ||
chatgpt: IChatGptSchema.IConfig; | ||
claude: IClaudeSchema.IConfig; | ||
gemini: IGeminiSchema.IConfig; | ||
llama: ILlamaSchema.IConfig; | ||
"3.0": ILlmSchemaV3.IConfig; | ||
"3.1": ILlmSchemaV3_1.IConfig; | ||
}; | ||
/** | ||
* Options for application composition. | ||
*/ | ||
type IOptions<Model extends ILlmApplication.Model, Schema extends ModelSchema[Model] = ModelSchema[Model]> = { | ||
type IOptions<Model extends ILlmSchema.Model> = { | ||
/** | ||
@@ -108,4 +78,4 @@ * Separator function for the parameters. | ||
*/ | ||
separate: null | ((schema: Schema) => boolean); | ||
} & ModelConfig[Model]; | ||
separate: null | ((schema: ILlmSchema.ModelSchema[Model]) => boolean); | ||
} & ILlmSchema.ModelConfig[Model]; | ||
} |
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
@@ -28,3 +29,3 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
*/ | ||
export interface ILlmFunction<Parameters extends IChatGptSchema.IParameters | IClaudeSchema.IParameters | IGeminiSchema.IParameters | ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters> { | ||
export interface ILlmFunction<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -37,7 +38,7 @@ * Representative name of the function. | ||
*/ | ||
parameters: Parameters; | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
/** | ||
* Collection of separated parameters. | ||
*/ | ||
separated?: ILlmFunction.ISeparated<Parameters>; | ||
separated?: ILlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
/** | ||
@@ -49,3 +50,3 @@ * Expected return type. | ||
*/ | ||
output?: Parameters["properties"][string]; | ||
output?: ILlmSchema.ModelSchema[Model]; | ||
/** | ||
@@ -52,0 +53,0 @@ * Whether the function schema types are strict or not. |
@@ -1,2 +0,7 @@ | ||
import { ILlmApplication } from "./ILlmApplication"; | ||
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlamaSchema } from "./ILlamaSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
/** | ||
@@ -15,4 +20,29 @@ * The schemas for the LLM function calling. | ||
*/ | ||
export type ILlmSchema<Model extends ILlmApplication.Model = ILlmApplication.Model> = ILlmApplication.ModelSchema[Model]; | ||
export type ILlmSchema<Model extends ILlmSchema.Model = ILlmSchema.Model> = ILlmSchema.ModelSchema[Model]; | ||
export declare namespace ILlmSchema { | ||
type Model = "chatgpt" | "claude" | "gemini" | "llama" | "3.0" | "3.1"; | ||
interface ModelConfig { | ||
chatgpt: IChatGptSchema.IConfig; | ||
claude: IClaudeSchema.IConfig; | ||
gemini: IGeminiSchema.IConfig; | ||
llama: ILlamaSchema.IConfig; | ||
"3.0": ILlmSchemaV3.IConfig; | ||
"3.1": ILlmSchemaV3_1.IConfig; | ||
} | ||
interface ModelParameters { | ||
chatgpt: IChatGptSchema.IParameters; | ||
claude: IClaudeSchema.IParameters; | ||
gemini: IGeminiSchema.IParameters; | ||
llama: ILlamaSchema.IParameters; | ||
"3.0": ILlmSchemaV3.IParameters; | ||
"3.1": ILlmSchemaV3_1.IParameters; | ||
} | ||
interface ModelSchema { | ||
chatgpt: IChatGptSchema; | ||
claude: IClaudeSchema; | ||
gemini: IGeminiSchema; | ||
llama: ILlamaSchema; | ||
"3.0": ILlmSchemaV3; | ||
"3.1": ILlmSchemaV3_1; | ||
} | ||
/** | ||
@@ -28,7 +58,7 @@ * Type of function parameters. | ||
*/ | ||
type IParameters<Model extends ILlmApplication.Model = ILlmApplication.Model> = ILlmApplication.ModelParameters[Model]; | ||
type IParameters<Model extends ILlmSchema.Model = ILlmSchema.Model> = ILlmSchema.ModelParameters[Model]; | ||
/** | ||
* Configuration for the LLM schema composition. | ||
*/ | ||
type IConfig<Model extends ILlmApplication.Model = ILlmApplication.Model> = ILlmApplication.ModelConfig[Model]; | ||
type IConfig<Model extends ILlmSchema.Model = ILlmSchema.Model> = ILlmSchema.ModelConfig[Model]; | ||
} |
@@ -7,5 +7,9 @@ /** | ||
* is not the final type for the LLM function calling, but the intermediate | ||
* structure for the conversion to the final type like {@link IChatGptSchema}. | ||
* structure for the conversion to the final type of below: | ||
* | ||
* However, the `IChatGptSchema` does not follow the entire specification of | ||
* - {@link IChatGptSchema} | ||
* - {@link IClaudeSchema} | ||
* - {@link ILlamaSchema} | ||
* | ||
* However, the `ILlmSchemaV3_1` does not follow the entire specification of | ||
* the OpenAPI v3.1. It has own specific restrictions and definitions. Here is the | ||
@@ -12,0 +16,0 @@ * list of how `ILlmSchemaV3_1` is different with the OpenAPI v3.1 JSON schema. |
@@ -207,3 +207,3 @@ /** | ||
*/ | ||
interface IArray<Schema extends ILlmSchemaV3 = ILlmSchemaV3> extends __ISignificant<"array"> { | ||
interface IArray extends __ISignificant<"array"> { | ||
/** | ||
@@ -215,3 +215,3 @@ * Items type schema info. | ||
*/ | ||
items: Schema; | ||
items: ILlmSchemaV3; | ||
/** | ||
@@ -243,3 +243,3 @@ * Unique items restriction. | ||
*/ | ||
interface IObject<Schema extends ILlmSchemaV3 = ILlmSchemaV3> extends __ISignificant<"object"> { | ||
interface IObject extends __ISignificant<"object"> { | ||
/** | ||
@@ -255,3 +255,3 @@ * Properties of the object. | ||
*/ | ||
properties: Record<string, Schema>; | ||
properties: Record<string, ILlmSchemaV3>; | ||
/** | ||
@@ -335,7 +335,7 @@ * List of key values of the required properties. | ||
*/ | ||
interface IOneOf<Schema extends ILlmSchemaV3 = ILlmSchemaV3> extends __IAttribute { | ||
interface IOneOf extends __IAttribute { | ||
/** | ||
* List of the union types. | ||
*/ | ||
oneOf: Exclude<Schema, ILlmSchemaV3.IOneOf<Schema>>[]; | ||
oneOf: Exclude<ILlmSchemaV3, ILlmSchemaV3.IOneOf>[]; | ||
} | ||
@@ -342,0 +342,0 @@ /** |
@@ -1,6 +0,3 @@ | ||
import { IChatGptSchema } from "../structures/IChatGptSchema"; | ||
import { IGeminiSchema } from "../structures/IGeminiSchema"; | ||
import { ILlmFunction } from "../structures/ILlmFunction"; | ||
import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
/** | ||
@@ -15,7 +12,7 @@ * Data combiner for LLM function call. | ||
*/ | ||
interface IProps<Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters> { | ||
interface IProps { | ||
/** | ||
* Target function to call. | ||
*/ | ||
function: ILlmFunction<Parameters>; | ||
function: ILlmFunction<ILlmSchema.Model>; | ||
/** | ||
@@ -45,3 +42,3 @@ * Arguments composed by LLM (Large Language Model). | ||
*/ | ||
const parameters: <Parameters extends ILlmSchemaV3.IParameters | ILlmSchemaV3_1.IParameters | IChatGptSchema.IParameters | IGeminiSchema.IParameters>(props: IProps<Parameters>) => object; | ||
const parameters: (props: IProps) => object; | ||
/** | ||
@@ -48,0 +45,0 @@ * Combine two values into one. |
{ | ||
"name": "@samchon/openapi", | ||
"version": "2.0.0-dev.20241126", | ||
"version": "2.0.0-dev.20241127", | ||
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.", | ||
@@ -64,3 +64,3 @@ "main": "./lib/index.js", | ||
"tstl": "^3.0.0", | ||
"typescript": "^5.6.3", | ||
"typescript": "~5.6.3", | ||
"typescript-transform-paths": "^3.4.7", | ||
@@ -67,0 +67,0 @@ "typia": "7.0.0-dev.20241123", |
202
README.md
@@ -46,5 +46,5 @@ > ## Next version is coming. | ||
- [`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts): OpenAI ChatGPT | ||
- [`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts)) | ||
- [`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude | ||
- [`IGeminiSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IGeminiSchema.ts): Google Gemini | ||
- [`ILlamaSchema`](https://github.com/samchon/openapi/blob/master/src/structures/ILlamaSchema.ts): Meta (Facebook) Llama | ||
- [`ILlamaSchema`](https://github.com/samchon/openapi/blob/master/src/structures/ILlamaSchema.ts): Meta Llama | ||
- Midldle layer schemas | ||
@@ -54,13 +54,5 @@ - [`ILlmSchemaV3`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3.ts): middle layer based on OpenAPI v3.0 specification | ||
> [!TIP] | ||
> | ||
> LLM selects proper function and fill arguments. | ||
> | ||
> In nowadays, most LLM (Large Language Model) like OpenAI are supporting "function calling" feature. The "LLM function calling" means that LLM automatically selects a proper function and fills parameter values from conversation with the user (may by chatting text). | ||
> | ||
> https://platform.openai.com/docs/guides/function-calling | ||
## Setup | ||
@@ -122,4 +114,5 @@ ```bash | ||
function: func, | ||
arguments: [ | ||
{ | ||
arguments: { | ||
// arguments composed by LLM | ||
body: { | ||
title: "Hello, world!", | ||
@@ -129,3 +122,3 @@ body: "Let's imagine that this argument is composed by LLM.", | ||
}, | ||
], | ||
}, | ||
}); | ||
@@ -244,6 +237,8 @@ console.log("article", article); | ||
- Schemas | ||
- [`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts) | ||
- [`IGeminiSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IGeminiSchema.ts) | ||
- [`ILlmSchemaV3`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3.ts) | ||
- [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts) | ||
- [`IChatGptSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IChatGptSchema.ts): OpenAI ChatGPT | ||
- [`IClaudeSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IClaudeSchema.ts): Anthropic Claude (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts)) | ||
- [`IGeminiSchema`](https://github.com/samchon/openapi/blob/master/src/structures/IGeminiSchema.ts): Google Gemini | ||
- [`ILlamaSchema`](https://github.com/samchon/openapi/blob/master/src/structures/ILlamaSchema.ts): Meta (Facebook) Llama (same with [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts)) | ||
- [`ILlmSchemaV3`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3.ts): middle layer based on OpenAPI v3.0 specification | ||
- [`ILlmSchemaV3_1`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmSchemaV3_1.ts): middle layer based on OpenAPI v3.1 specification | ||
- Type Checkers | ||
@@ -253,2 +248,3 @@ - [`ChatGptTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/ChatGptTypeChecker.ts) | ||
- [`GeminiTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/GeminiTypeChecker.ts) | ||
- [`LlamaTypeChecker`](https://github.com/samchon/openapi/blob/master/src/utils/LlamaTypeChecker.ts) | ||
- [`LlmTypeCheckerV3`](https://github.com/samchon/openapi/blob/master/src/utils/LlmTypeCheckerV3.ts) | ||
@@ -259,4 +255,6 @@ - [`LlmTypeCheckerV3_1`](https://github.com/samchon/openapi/blob/master/src/utils/LlmTypeCheckerV3_1.ts) | ||
> | ||
> You also can compose `ILlmApplication` from a class type through `typia`. | ||
> You also can compose [`ILlmApplication`](https://github.com/samchon/openapi/blob/master/src/structures/ILlmApplication.ts) from a class type with `typia`. | ||
> | ||
> https://typia.io/docs/llm/application | ||
> | ||
> ```typescript | ||
@@ -269,4 +267,2 @@ > import { ILlmApplication } from "@samchon/openapi"; | ||
> ``` | ||
> | ||
> https://typia.io/docs/llm/application | ||
@@ -293,2 +289,8 @@ > [!TIP] | ||
Here is the example code executing the LLM function call with `@samchon/openapi`. | ||
- Example Code: [`test/examples/chatgpt-function-call-to-sale-create.ts`](https://github.com/samchon/openapi/blob/master/test/examples/chatgpt-function-call-to-sale-create.ts) | ||
- Prompt describing the produc to create: [`Microsoft Surpace Pro 9`](https://github.com/samchon/openapi/blob/master/test/executable/chatgpt-function-calling.ts) | ||
- Result of the Function Calling: [`examples/arguments/chatgpt.microsoft-surface-pro-9.input.json`](https://github.com/samchon/openapi/blob/master/examples/function-calling/arguments/chatgpt.microsoft-surface-pro-9.input.json) | ||
```typescript | ||
@@ -305,8 +307,7 @@ import { | ||
} from "@samchon/openapi"; | ||
import fs from "fs"; | ||
import OpenAI from "openai"; | ||
import typia from "typia"; | ||
import { v4 } from "uuid"; | ||
const main = async (): Promise<void> => { | ||
// read swagger document and validate it | ||
// Read swagger document and validate it | ||
const swagger: | ||
@@ -316,3 +317,5 @@ | SwaggerV2.IDocument | ||
| OpenApiV3_1.IDocument = JSON.parse( | ||
await fs.promises.readFile("swagger.json", "utf8"), | ||
await fetch( | ||
"https://github.com/samchon/shopping-backend/blob/master/packages/api/swagger.json", | ||
).then((r) => r.json()), | ||
); | ||
@@ -330,29 +333,51 @@ typia.assert(swagger); // recommended | ||
// Let's imagine that LLM has selected a function to call | ||
const func: IHttpLlmFunction<IChatGptSchema.IParameters> | undefined = | ||
const func: IHttpLlmFunction<"chatgpt"> | undefined = | ||
application.functions.find( | ||
// (f) => f.name === "llm_selected_fuction_name" | ||
(f) => f.path === "/bbs/{section}/articles/{id}" && f.method === "put", | ||
(f) => f.path === "/shoppings/sellers/sale" && f.method === "post", | ||
); | ||
if (func === undefined) throw new Error("No matched function exists."); | ||
// actual execution is by yourself | ||
// Get arguments by ChatGPT function calling | ||
const client: OpenAI = new OpenAI({ | ||
apiKey: "<YOUR_OPENAI_API_KEY>", | ||
}); | ||
const completion: OpenAI.ChatCompletion = | ||
await client.chat.completions.create({ | ||
model: "gpt-4o", | ||
messages: [ | ||
{ | ||
role: "assistant", | ||
content: | ||
"You are a helpful customer support assistant. Use the supplied tools to assist the user.", | ||
}, | ||
{ | ||
role: "user", | ||
content: "<DESCRIPTION ABOUT THE SALE>", | ||
// https://github.com/samchon/openapi/blob/master/examples/function-calling/prompts/microsoft-surface-pro-9.md | ||
}, | ||
], | ||
tools: [ | ||
{ | ||
type: "function", | ||
function: { | ||
name: func.name, | ||
description: func.description, | ||
parameters: func.parameters as Record<string, any>, | ||
strict: true, | ||
}, | ||
}, | ||
], | ||
}); | ||
const toolCall: OpenAI.ChatCompletionMessageToolCall = | ||
completion.choices[0].message.tool_calls![0]; | ||
// Actual execution by yourself | ||
const article = await HttpLlm.execute({ | ||
connection: { | ||
host: "http://localhost:3000", | ||
host: "http://localhost:37001", | ||
}, | ||
application, | ||
function: func, | ||
input: { | ||
section: "general", | ||
id: v4(), | ||
query: { | ||
language: "en-US", | ||
format: "markdown", | ||
}, | ||
body: { | ||
title: "Hello, world!", | ||
body: "Let's imagine that this argument is composed by LLM.", | ||
thumbnail: null, | ||
}, | ||
}, | ||
input: JSON.parse(toolCall.function.arguments), | ||
}); | ||
@@ -373,7 +398,12 @@ console.log("article", article); | ||
- Example Code: [`test/examples/claude-function-call-separate-to-sale-create.ts`](https://github.com/samchon/openapi/blob/master/test/examples/claude-function-call-separate-to-sale-create.ts.ts) | ||
- Prompt describing the produc to create: [`Microsoft Surpace Pro 9`](https://github.com/samchon/openapi/blob/master/test/executable/chatgpt-function-calling.ts) | ||
- Result of the Function Calling: [`examples/arguments/claude.microsoft-surface-pro-9.input.json`](https://github.com/samchon/openapi/blob/master/examples/function-calling/arguments/claude.microsoft-surface-pro-9.input.json) | ||
```typescript | ||
import Anthropic from "@anthropic-ai/sdk"; | ||
import { | ||
ClaudeTypeChecker, | ||
HttpLlm, | ||
ChatGptTypeChecker, | ||
IChatGptSchema, | ||
IClaudeSchema, | ||
IHttpLlmApplication, | ||
@@ -386,8 +416,6 @@ IHttpLlmFunction, | ||
} from "@samchon/openapi"; | ||
import fs from "fs"; | ||
import typia from "typia"; | ||
import { v4 } from "uuid"; | ||
const main = async (): Promise<void> => { | ||
// read swagger document and validate it | ||
// Read swagger document and validate it | ||
const swagger: | ||
@@ -397,3 +425,5 @@ | SwaggerV2.IDocument | ||
| OpenApiV3_1.IDocument = JSON.parse( | ||
await fs.promises.readFile("swagger.json", "utf8"), | ||
await fetch( | ||
"https://github.com/samchon/shopping-backend/blob/master/packages/api/swagger.json", | ||
).then((r) => r.json()), | ||
); | ||
@@ -405,9 +435,10 @@ typia.assert(swagger); // recommended | ||
const document: OpenApi.IDocument = OpenApi.convert(swagger); | ||
const application: IHttpLlmApplication<"chatgpt"> = HttpLlm.application({ | ||
model: "chatgpt", | ||
document, | ||
const application: IHttpLlmApplication<"claude"> = HttpLlm.application({ | ||
model: "claude", | ||
document, | ||
options: { | ||
keyword: false, | ||
reference: true, | ||
separate: (schema) => | ||
ChatGptTypeChecker.isString(schema) && schema.contentMediaType !== undefined, | ||
ClaudeTypeChecker.isString(schema) && | ||
!!schema.contentMediaType?.startsWith("image"), | ||
}, | ||
@@ -417,35 +448,62 @@ }); | ||
// Let's imagine that LLM has selected a function to call | ||
const func: IHttpLlmFunction<IChatGptSchema.IParameters> | undefined = | ||
const func: IHttpLlmFunction<"claude"> | undefined = | ||
application.functions.find( | ||
// (f) => f.name === "llm_selected_fuction_name" | ||
(f) => f.path === "/bbs/articles/{id}" && f.method === "put", | ||
(f) => f.path === "/shoppings/sellers/sale" && f.method === "post", | ||
); | ||
if (func === undefined) throw new Error("No matched function exists."); | ||
// actual execution is by yourself | ||
// Get arguments by ChatGPT function calling | ||
const client: Anthropic = new Anthropic({ | ||
apiKey: "<YOUR_ANTHROPIC_API_KEY>", | ||
}); | ||
const completion: Anthropic.Message = await client.messages.create({ | ||
model: "claude-3-5-sonnet-latest", | ||
max_tokens: 8_192, | ||
messages: [ | ||
{ | ||
role: "assistant", | ||
content: | ||
"You are a helpful customer support assistant. Use the supplied tools to assist the user.", | ||
}, | ||
{ | ||
role: "user", | ||
content: "<DESCRIPTION ABOUT THE SALE>", | ||
// https://github.com/samchon/openapi/blob/master/examples/function-calling/prompts/microsoft-surface-pro-9.md | ||
}, | ||
], | ||
tools: [ | ||
{ | ||
name: func.name, | ||
description: func.description, | ||
input_schema: func.separated!.llm as any, | ||
}, | ||
], | ||
}); | ||
const toolCall: Anthropic.ToolUseBlock = completion.content.filter( | ||
(c) => c.type === "tool_use", | ||
)[0]!; | ||
// Actual execution by yourself | ||
const article = await HttpLlm.execute({ | ||
connection: { | ||
host: "http://localhost:3000", | ||
host: "http://localhost:37001", | ||
}, | ||
application, | ||
function: func, | ||
arguments: HttpLlm.mergeParameters({ | ||
input: HttpLlm.mergeParameters({ | ||
function: func, | ||
llm: { | ||
// LLM composed parameter values | ||
section: "general", | ||
id: v4(), | ||
query: { | ||
language: "en-US", | ||
format: "markdown", | ||
}, | ||
body: { | ||
title: "Hello, world!", | ||
content: "Let's imagine that this argument is composed by LLM.", | ||
}, | ||
}, | ||
llm: toolCall.input as any, | ||
human: { | ||
// Human composed parameter values | ||
body: { | ||
thumbnail: "https://example.com/thumbnail.jpg", | ||
content: { | ||
files: [], | ||
thumbnails: [ | ||
{ | ||
name: "thumbnail", | ||
extension: "jpeg", | ||
url: "https://serpapi.com/searches/673d3a37e45f3316ecd8ab3e/images/1be25e6e2b1fb7509f1af89c326cb41749301b94375eb5680b9bddcdf88fabcb.jpeg", | ||
}, | ||
// ... | ||
], | ||
}, | ||
@@ -452,0 +510,0 @@ }, |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -9,5 +9,5 @@ import { OpenApi } from "../OpenApi"; | ||
export const parameters = (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}): IGeminiSchema.IParameters | null => | ||
@@ -17,5 +17,5 @@ schema(props) as IGeminiSchema.IParameters | null; | ||
export const schema = (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}): IGeminiSchema | null => { | ||
@@ -22,0 +22,0 @@ const schema: ILlmSchemaV3 | null = LlmConverterV3.schema({ |
@@ -7,2 +7,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
import { ChatGptConverter } from "./ChatGptConverter"; | ||
@@ -17,19 +18,10 @@ import { ClaudeConverter } from "./ClaudeConverter"; | ||
export namespace HttpLlmConverter { | ||
export const application = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
>(props: { | ||
export const application = <Model extends ILlmSchema.Model>(props: { | ||
model: Model; | ||
migrate: IHttpMigrateApplication<OpenApi.IJsonSchema, Operation>; | ||
migrate: IHttpMigrateApplication; | ||
options: IHttpLlmApplication.IOptions<Model>; | ||
}): IHttpLlmApplication<Model, Parameters, Operation, Route> => { | ||
}): IHttpLlmApplication<Model> => { | ||
// COMPOSE FUNCTIONS | ||
const errors: IHttpLlmApplication.IError<Operation, Route>[] = | ||
props.migrate.errors.map((e) => ({ | ||
const errors: IHttpLlmApplication.IError[] = props.migrate.errors.map( | ||
(e) => ({ | ||
method: e.method, | ||
@@ -40,52 +32,47 @@ path: e.path, | ||
route: () => undefined, | ||
})); | ||
const functions: IHttpLlmFunction<Parameters, Operation, Route>[] = | ||
props.migrate.routes | ||
.map((route) => { | ||
if (route.method === "head") { | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: [ | ||
"HEAD method is not supported in the LLM application.", | ||
], | ||
operation: () => route.operation(), | ||
route: () => route as any as Route, | ||
}); | ||
return null; | ||
} else if ( | ||
route.body?.type === "multipart/form-data" || | ||
route.success?.type === "multipart/form-data" | ||
) { | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: [ | ||
`The "multipart/form-data" content type is not supported in the LLM application.`, | ||
], | ||
operation: () => route.operation(), | ||
route: () => route as any as Route, | ||
}); | ||
return null; | ||
} | ||
const func: IHttpLlmFunction<Parameters> | null = composeFunction({ | ||
model: props.model, | ||
options: props.options, | ||
components: props.migrate.document().components, | ||
route, | ||
}), | ||
); | ||
const functions: IHttpLlmFunction<Model>[] = props.migrate.routes | ||
.map((route) => { | ||
if (route.method === "head") { | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: ["HEAD method is not supported in the LLM application."], | ||
operation: () => route.operation(), | ||
route: () => route as any as IHttpMigrateRoute, | ||
}); | ||
if (func === null) | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: ["Failed to escape $ref"], | ||
operation: () => route.operation(), | ||
route: () => route as any as Route, | ||
}); | ||
return func; | ||
}) | ||
.filter( | ||
(v): v is IHttpLlmFunction<Parameters, Operation, Route> => | ||
v !== null, | ||
); | ||
return null; | ||
} else if ( | ||
route.body?.type === "multipart/form-data" || | ||
route.success?.type === "multipart/form-data" | ||
) { | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: [ | ||
`The "multipart/form-data" content type is not supported in the LLM application.`, | ||
], | ||
operation: () => route.operation(), | ||
route: () => route as any as IHttpMigrateRoute, | ||
}); | ||
return null; | ||
} | ||
const func: IHttpLlmFunction<Model> | null = composeFunction<Model>({ | ||
model: props.model, | ||
options: props.options, | ||
components: props.migrate.document().components, | ||
route: route, | ||
}); | ||
if (func === null) | ||
errors.push({ | ||
method: route.method, | ||
path: route.path, | ||
messages: ["Failed to escape $ref"], | ||
operation: () => route.operation(), | ||
route: () => route as any as IHttpMigrateRoute, | ||
}); | ||
return func; | ||
}) | ||
.filter((v): v is IHttpLlmFunction<Model> => v !== null); | ||
return { | ||
@@ -99,47 +86,36 @@ model: props.model, | ||
export const separate = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
>(props: { | ||
export const separate = <Model extends ILlmSchema.Model>(props: { | ||
model: Model; | ||
parameters: Parameters; | ||
predicate: (schema: Parameters["properties"][string]) => boolean; | ||
}): IHttpLlmFunction.ISeparated<Parameters> => { | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
predicate: (schema: ILlmSchema.ModelSchema[Model]) => boolean; | ||
}): IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]> => { | ||
const separator: (props: { | ||
predicate: (schema: Parameters["properties"][string]) => boolean; | ||
schema: Parameters["properties"][string]; | ||
predicate: (schema: ILlmSchema.ModelSchema[Model]) => boolean; | ||
schema: ILlmSchema.ModelSchema[Model]; | ||
}) => [ | ||
Parameters["properties"][string] | null, | ||
Parameters["properties"][string] | null, | ||
ILlmSchema.ModelParameters[Model] | null, | ||
ILlmSchema.ModelParameters[Model] | null, | ||
] = SEPARATORS[props.model] as any; | ||
const [llm, human] = separator({ | ||
predicate: props.predicate, | ||
schema: props.parameters as Parameters["properties"][string], | ||
schema: props.parameters, | ||
}); | ||
return { | ||
llm: llm as Parameters | null, | ||
human: human as Parameters | null, | ||
}; | ||
llm, | ||
human, | ||
} satisfies IHttpLlmFunction.ISeparated< | ||
ILlmSchema.ModelParameters[Model] | ||
> as IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
}; | ||
const composeFunction = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
>(props: { | ||
const composeFunction = <Model extends ILlmSchema.Model>(props: { | ||
model: Model; | ||
components: OpenApi.IComponents; | ||
route: IHttpMigrateRoute<OpenApi.IJsonSchema, Operation>; | ||
route: IHttpMigrateRoute; | ||
options: IHttpLlmApplication.IOptions<Model>; | ||
}): IHttpLlmFunction<Parameters, Operation, Route> | null => { | ||
}): IHttpLlmFunction<Model> | null => { | ||
const $defs: Record<string, IChatGptSchema> = {}; | ||
const cast = ( | ||
s: OpenApi.IJsonSchema, | ||
): Parameters["properties"][string] | null => | ||
): ILlmSchema.ModelSchema[Model] | null => | ||
LlmSchemaConverter.schema(props.model)({ | ||
@@ -150,4 +126,4 @@ config: props.options as any, | ||
$defs, | ||
}) as Parameters["properties"][string] | null; | ||
const output: Parameters["properties"][string] | null | undefined = | ||
}) as ILlmSchema.ModelSchema[Model] | null; | ||
const output: ILlmSchema.ModelSchema[Model] | null | undefined = | ||
props.route.success && props.route.success | ||
@@ -157,3 +133,3 @@ ? cast(props.route.success.schema) | ||
if (output === null) return null; | ||
const properties: [string, Parameters["properties"][string] | null][] = [ | ||
const properties: [string, ILlmSchema.ModelSchema[Model] | null][] = [ | ||
...props.route.parameters.map((p) => ({ | ||
@@ -199,10 +175,10 @@ key: p.key, | ||
// COMPOSE PARAMETERS | ||
const parameters: Parameters = { | ||
const parameters: ILlmSchema.ModelParameters[Model] = { | ||
type: "object", | ||
properties: Object.fromEntries( | ||
properties as [string, Parameters["properties"][string]][], | ||
properties as [string, ILlmSchema.ModelSchema[Model]][], | ||
), | ||
additionalProperties: false, | ||
required: properties.map(([k]) => k), | ||
} as any as Parameters; | ||
} as any as ILlmSchema.ModelParameters[Model]; | ||
if (Object.keys($defs).length) | ||
@@ -222,3 +198,3 @@ (parameters as any as IChatGptSchema.IParameters).$defs = $defs; | ||
model: props.model, | ||
predicate: props.options.separate as any, | ||
predicate: props.options.separate, | ||
parameters, | ||
@@ -225,0 +201,0 @@ }) |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -10,5 +10,5 @@ import { OpenApi } from "../OpenApi"; | ||
export const parameters = (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3.IConfig; | ||
}): ILlmSchemaV3.IParameters | null => | ||
@@ -18,5 +18,5 @@ schema(props) as ILlmSchemaV3.IParameters | null; | ||
export const schema = (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: Omit<ILlmSchemaV3.IConfig, "separate">; | ||
}): ILlmSchemaV3 | null => { | ||
@@ -23,0 +23,0 @@ const resolved: OpenApi.IJsonSchema | null = OpenApiTypeChecker.escape({ |
@@ -6,3 +6,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { ILlamaSchema } from "../structures/ILlamaSchema"; | ||
import { ILlmApplication } from "../structures/ILlmApplication"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
@@ -18,12 +18,10 @@ import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
export namespace LlmSchemaConverter { | ||
export const parameters = <Model extends ILlmApplication.Model>( | ||
model: Model, | ||
) => PARAMETERS_CASTERS[model]; | ||
export const parameters = <Model extends ILlmSchema.Model>(model: Model) => | ||
PARAMETERS_CASTERS[model]; | ||
export const schema = <Model extends ILlmApplication.Model>(model: Model) => | ||
export const schema = <Model extends ILlmSchema.Model>(model: Model) => | ||
SCHEMA_CASTERS[model]; | ||
export const defaultConfig = <Model extends ILlmApplication.Model>( | ||
model: Model, | ||
) => DEFAULT_CONFIGS[model]; | ||
export const defaultConfig = <Model extends ILlmSchema.Model>(model: Model) => | ||
DEFAULT_CONFIGS[model]; | ||
} | ||
@@ -33,30 +31,30 @@ | ||
chatgpt: (props: { | ||
config: IChatGptSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IChatGptSchema.IConfig; | ||
}) => ChatGptConverter.parameters(props), | ||
claude: (props: { | ||
config: IClaudeSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IClaudeSchema.IConfig; | ||
}) => ClaudeConverter.parameters(props), | ||
gemini: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: IGeminiSchema.IConfig; | ||
}) => GeminiConverter.parameters(props), | ||
llama: (props: { | ||
config: ILlamaSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlamaSchema.IConfig; | ||
}) => LlamaConverter.parameters(props), | ||
"3.0": (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3.IConfig; | ||
}) => LlmConverterV3.parameters(props), | ||
"3.1": (props: { | ||
config: ILlmSchemaV3_1.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema.IObject; | ||
config: ILlmSchemaV3_1.IConfig; | ||
}) => LlmConverterV3_1.parameters(props), | ||
@@ -67,6 +65,6 @@ }; | ||
chatgpt: (props: { | ||
config: IChatGptSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, IChatGptSchema>; | ||
config: IChatGptSchema.IConfig; | ||
}) => | ||
@@ -80,6 +78,6 @@ ChatGptConverter.schema({ | ||
claude: (props: { | ||
config: IClaudeSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, IClaudeSchema>; | ||
config: IClaudeSchema.IConfig; | ||
}) => | ||
@@ -93,5 +91,5 @@ ClaudeConverter.schema({ | ||
gemini: (props: { | ||
config: IGeminiSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: IGeminiSchema.IConfig; | ||
}) => | ||
@@ -104,6 +102,6 @@ GeminiConverter.schema({ | ||
llama: (props: { | ||
config: ILlamaSchema.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, ILlamaSchema>; | ||
config: ILlamaSchema.IConfig; | ||
}) => | ||
@@ -117,5 +115,5 @@ LlamaConverter.schema({ | ||
"3.0": (props: { | ||
config: ILlmSchemaV3.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
config: ILlmSchemaV3.IConfig; | ||
}) => | ||
@@ -128,6 +126,6 @@ LlmConverterV3.schema({ | ||
"3.1": (props: { | ||
config: ILlmSchemaV3_1.IConfig; | ||
components: OpenApi.IComponents; | ||
schema: OpenApi.IJsonSchema; | ||
$defs: Record<string, ILlmSchemaV3_1>; | ||
config: ILlmSchemaV3_1.IConfig; | ||
}) => | ||
@@ -134,0 +132,0 @@ LlmConverterV3_1.schema({ |
@@ -9,42 +9,38 @@ import { OpenApi } from "../OpenApi"; | ||
export namespace MigrateConverter { | ||
export const convert = < | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
>( | ||
document: OpenApi.IDocument<Schema, Operation>, | ||
): IHttpMigrateApplication<Schema, Operation> => { | ||
const errors: IHttpMigrateApplication.IError<Operation>[] = []; | ||
const entire: Array<IHttpMigrateRoute<Schema, Operation> | null> = | ||
Object.entries({ | ||
...(document.paths ?? {}), | ||
...(document.webhooks ?? {}), | ||
}) | ||
.map(([path, collection]) => | ||
(["head", "get", "post", "put", "patch", "delete"] as const) | ||
.filter((method) => collection[method] !== undefined) | ||
.map((method) => { | ||
const operation: Operation = collection[method]!; | ||
const migrated: IHttpMigrateRoute<Schema, Operation> | string[] = | ||
MigrateRouteConverter.convert({ | ||
document, | ||
method, | ||
path, | ||
emendedPath: StringUtil.reJoinWithDecimalParameters(path), | ||
operation, | ||
}) as IHttpMigrateRoute<Schema, Operation> | string[]; | ||
if (Array.isArray(migrated)) { | ||
errors.push({ | ||
method, | ||
path, | ||
operation: () => operation, | ||
messages: migrated, | ||
}); | ||
return null; | ||
} | ||
return migrated; | ||
}), | ||
) | ||
.flat(); | ||
const operations: IHttpMigrateRoute<Schema, Operation>[] = entire.filter( | ||
(o): o is IHttpMigrateRoute<Schema, Operation> => !!o, | ||
export const convert = ( | ||
document: OpenApi.IDocument, | ||
): IHttpMigrateApplication => { | ||
const errors: IHttpMigrateApplication.IError[] = []; | ||
const entire: Array<IHttpMigrateRoute | null> = Object.entries({ | ||
...(document.paths ?? {}), | ||
...(document.webhooks ?? {}), | ||
}) | ||
.map(([path, collection]) => | ||
(["head", "get", "post", "put", "patch", "delete"] as const) | ||
.filter((method) => collection[method] !== undefined) | ||
.map((method) => { | ||
const operation: OpenApi.IOperation = collection[method]!; | ||
const migrated: IHttpMigrateRoute | string[] = | ||
MigrateRouteConverter.convert({ | ||
document, | ||
method, | ||
path, | ||
emendedPath: StringUtil.reJoinWithDecimalParameters(path), | ||
operation, | ||
}); | ||
if (Array.isArray(migrated)) { | ||
errors.push({ | ||
method, | ||
path, | ||
operation: () => operation, | ||
messages: migrated, | ||
}); | ||
return null; | ||
} | ||
return migrated; | ||
}), | ||
) | ||
.flat(); | ||
const operations: IHttpMigrateRoute[] = entire.filter( | ||
(o): o is IHttpMigrateRoute => !!o, | ||
); | ||
@@ -56,4 +52,4 @@ MigrateRouteAccessor.overwrite(operations); | ||
errors, | ||
}; | ||
} satisfies IHttpMigrateApplication as IHttpMigrateApplication; | ||
}; | ||
} |
@@ -1,2 +0,1 @@ | ||
import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
@@ -8,9 +7,4 @@ import { Escaper } from "../utils/Escaper"; | ||
export namespace MigrateRouteAccessor { | ||
export const overwrite = < | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
>( | ||
routes: IHttpMigrateRoute<Schema, Operation>[], | ||
): void => { | ||
const dict: Map<string, IElement<Schema, Operation>> = collect((op) => | ||
export const overwrite = (routes: IHttpMigrateRoute[]): void => { | ||
const dict: Map<string, IElement> = collect((op) => | ||
op.emendedPath | ||
@@ -21,3 +15,3 @@ .split("/") | ||
.map((str) => (Escaper.variable(str) ? str : `_${str}`)), | ||
)(routes) as Map<string, IElement<Schema, Operation>>; | ||
)(routes) as Map<string, IElement>; | ||
for (const props of dict.values()) | ||
@@ -51,17 +45,8 @@ props.entries.forEach((entry, i) => { | ||
const collect = | ||
< | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
>( | ||
getter: (r: IHttpMigrateRoute<Schema, Operation>) => string[], | ||
) => | ||
( | ||
routes: IHttpMigrateRoute<Schema, Operation>[], | ||
): Map<string, IElement<Schema, Operation>> => { | ||
const dict: Map<string, IElement<Schema, Operation>> = new Map(); | ||
(getter: (r: IHttpMigrateRoute) => string[]) => | ||
(routes: IHttpMigrateRoute[]): Map<string, IElement> => { | ||
const dict: Map<string, IElement> = new Map(); | ||
for (const r of routes) { | ||
const namespace: string[] = getter(r); | ||
let last: IElement<Schema, Operation> = MapUtil.take(dict)( | ||
namespace.join("."), | ||
)(() => ({ | ||
let last: IElement = MapUtil.take(dict)(namespace.join("."))(() => ({ | ||
namespace, | ||
@@ -77,9 +62,9 @@ children: new Set(), | ||
const partial: string[] = namespace.slice(0, array.length - i); | ||
const element: IElement<Schema, Operation> = MapUtil.take(dict)( | ||
partial.join("."), | ||
)(() => ({ | ||
namespace: partial, | ||
children: new Set(), | ||
entries: [], | ||
})); | ||
const element: IElement = MapUtil.take(dict)(partial.join("."))( | ||
() => ({ | ||
namespace: partial, | ||
children: new Set(), | ||
entries: [], | ||
}), | ||
); | ||
element.children.add(last.namespace.at(-1)!); | ||
@@ -97,8 +82,3 @@ }); | ||
const getName = < | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
>( | ||
op: IHttpMigrateRoute<Schema, Operation>, | ||
): string => { | ||
const getName = (op: IHttpMigrateRoute): string => { | ||
const method = op.method === "delete" ? "erase" : op.method; | ||
@@ -113,17 +93,11 @@ if (op.parameters.length === 0) return method; | ||
interface IElement< | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
> { | ||
interface IElement { | ||
namespace: string[]; | ||
entries: IEntry<Schema, Operation>[]; | ||
entries: IEntry[]; | ||
children: Set<string>; | ||
} | ||
interface IEntry< | ||
Schema extends OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema>, | ||
> { | ||
route: IHttpMigrateRoute<Schema, Operation>; | ||
interface IEntry { | ||
route: IHttpMigrateRoute; | ||
alias: string; | ||
} | ||
} |
@@ -181,3 +181,3 @@ import { OpenApi } from "../OpenApi"; | ||
], | ||
}, | ||
} satisfies OpenApi.IJsonSchema.IObject, | ||
}), | ||
@@ -267,4 +267,4 @@ }); | ||
query: query || null, | ||
body: body as IHttpMigrateRoute.IBody | null, | ||
success: success as IHttpMigrateRoute.IBody | null, | ||
body: body || null, | ||
success: success || null, | ||
exceptions: Object.fromEntries( | ||
@@ -278,6 +278,9 @@ Object.entries(props.operation.responses ?? {}) | ||
{ | ||
schema: response.content?.["application/json"]?.schema ?? {}, | ||
schema: (response.content?.["application/json"]?.schema ?? | ||
{}) satisfies OpenApi.IJsonSchema, | ||
response: () => response, | ||
media: () => response.content?.["application/json"] ?? {}, | ||
}, | ||
media: () => | ||
(response.content?.["application/json"] ?? | ||
{}) satisfies OpenApi.IJsonSchema, | ||
} satisfies IHttpMigrateRoute.IException, | ||
]), | ||
@@ -293,3 +296,3 @@ ), | ||
operation: () => props.operation, | ||
}; | ||
} satisfies IHttpMigrateRoute as IHttpMigrateRoute; | ||
}; | ||
@@ -456,3 +459,5 @@ | ||
props.document.components.schemas[props.name] = props.schema; | ||
return { $ref: `#/components/schemas/${props.name}` }; | ||
return { | ||
$ref: `#/components/schemas/${props.name}`, | ||
} satisfies OpenApi.IJsonSchema.IReference; | ||
}; | ||
@@ -459,0 +464,0 @@ |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ /** |
import type { HttpLlm } from "../HttpLlm"; | ||
import type { HttpMigration } from "../HttpMigration"; | ||
import { OpenApi } from "../OpenApi"; | ||
import { IHttpLlmApplication } from "../structures/IHttpLlmApplication"; | ||
import { IHttpMigrateRoute } from "../structures/IHttpMigrateRoute"; | ||
import { IHttpResponse } from "../structures/IHttpResponse"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
import { HttpMigrateRouteFetcher } from "./HttpMigrateRouteFetcher"; | ||
export namespace HttpLlmFunctionFetcher { | ||
export const execute = async < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
>( | ||
props: HttpLlm.IFetchProps<Model, Parameters, Operation, Route>, | ||
export const execute = <Model extends ILlmSchema.Model>( | ||
props: HttpLlm.IFetchProps<Model>, | ||
): Promise<unknown> => | ||
HttpMigrateRouteFetcher.execute(getFetchArguments("execute", props)); | ||
HttpMigrateRouteFetcher.execute(getFetchArguments<Model>("execute", props)); | ||
export const propagate = async < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
>( | ||
props: HttpLlm.IFetchProps<Model, Parameters, Operation, Route>, | ||
export const propagate = <Model extends ILlmSchema.Model>( | ||
props: HttpLlm.IFetchProps<Model>, | ||
): Promise<IHttpResponse> => | ||
HttpMigrateRouteFetcher.propagate(getFetchArguments("propagate", props)); | ||
HttpMigrateRouteFetcher.propagate( | ||
getFetchArguments<Model>("propagate", props), | ||
); | ||
const getFetchArguments = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
>( | ||
const getFetchArguments = <Model extends ILlmSchema.Model>( | ||
from: string, | ||
props: HttpLlm.IFetchProps<Model, Parameters, Operation, Route>, | ||
props: HttpLlm.IFetchProps<Model>, | ||
): HttpMigration.IFetchProps => { | ||
const route: Route = props.function.route(); | ||
const route: IHttpMigrateRoute = props.function.route(); | ||
const input: Record<string, any> = props.input; | ||
@@ -53,0 +27,0 @@ const valid: boolean = typeof input === "object" && input !== null; |
@@ -0,0 +0,0 @@ import type { HttpMigration } from "../HttpMigration"; |
@@ -6,4 +6,2 @@ import { HttpMigration } from "./HttpMigration"; | ||
import { HttpLlmFunctionFetcher } from "./http/HttpLlmFunctionFetcher"; | ||
import { IChatGptSchema } from "./structures/IChatGptSchema"; | ||
import { IGeminiSchema } from "./structures/IGeminiSchema"; | ||
import { IHttpConnection } from "./structures/IHttpConnection"; | ||
@@ -13,7 +11,5 @@ import { IHttpLlmApplication } from "./structures/IHttpLlmApplication"; | ||
import { IHttpMigrateApplication } from "./structures/IHttpMigrateApplication"; | ||
import { IHttpMigrateRoute } from "./structures/IHttpMigrateRoute"; | ||
import { IHttpResponse } from "./structures/IHttpResponse"; | ||
import { ILlmFunction } from "./structures/ILlmFunction"; | ||
import { ILlmSchemaV3 } from "./structures/ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./structures/ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "./structures/ILlmSchema"; | ||
import { LlmDataMerger } from "./utils/LlmDataMerger"; | ||
@@ -48,2 +44,13 @@ | ||
/** | ||
* Properties for the LLM function calling application composer. | ||
* | ||
* @template Model Target LLM model | ||
*/ | ||
export interface IApplicationProps<Model extends ILlmSchema.Model> { | ||
model: Model; | ||
document: OpenApi.IDocument; | ||
options?: Partial<IHttpLlmApplication.IOptions<Model>>; | ||
} | ||
/** | ||
* Convert OpenAPI document to LLM function calling application. | ||
@@ -73,25 +80,10 @@ * | ||
*/ | ||
export const application = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
>(props: { | ||
model: Model; | ||
document: | ||
| OpenApi.IDocument<OpenApi.IJsonSchema, Operation> | ||
| IHttpMigrateApplication<OpenApi.IJsonSchema, Operation>; | ||
options?: Partial< | ||
IHttpLlmApplication.IOptions< | ||
Model, | ||
IHttpLlmApplication.ModelSchema[Model] | ||
> | ||
>; | ||
}): IHttpLlmApplication<Model, Parameters> => { | ||
export const application = <Model extends ILlmSchema.Model>( | ||
props: IApplicationProps<Model>, | ||
): IHttpLlmApplication<Model> => { | ||
// MIGRATE | ||
const migrate: IHttpMigrateApplication = | ||
(props.document as OpenApi.IDocument)["x-samchon-emended"] === true | ||
? HttpMigration.application(props.document as OpenApi.IDocument) | ||
: (props.document as IHttpMigrateApplication); | ||
return HttpLlmConverter.application<Model, Parameters>({ | ||
const migrate: IHttpMigrateApplication = HttpMigration.application( | ||
props.document as OpenApi.IDocument, | ||
); | ||
return HttpLlmConverter.application<Model>({ | ||
migrate, | ||
@@ -112,16 +104,7 @@ model: props.model, | ||
*/ | ||
export interface IFetchProps< | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute< | ||
OpenApi.IJsonSchema, | ||
Operation | ||
>, | ||
> { | ||
export interface IFetchProps<Model extends ILlmSchema.Model> { | ||
/** | ||
* Application of the LLM function calling. | ||
*/ | ||
application: IHttpLlmApplication<Model, Parameters, Operation>; | ||
application: IHttpLlmApplication<Model>; | ||
@@ -131,3 +114,3 @@ /** | ||
*/ | ||
function: IHttpLlmFunction<Parameters, Operation, Route>; | ||
function: IHttpLlmFunction<ILlmSchema.Model>; | ||
@@ -170,10 +153,5 @@ /** | ||
*/ | ||
export const execute = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
>( | ||
props: IFetchProps<Model, Parameters, Operation>, | ||
): Promise<unknown> => HttpLlmFunctionFetcher.execute(props); | ||
export const execute = <Model extends ILlmSchema.Model>( | ||
props: IFetchProps<Model>, | ||
): Promise<unknown> => HttpLlmFunctionFetcher.execute<Model>(props); | ||
@@ -204,10 +182,5 @@ /** | ||
*/ | ||
export const propagate = < | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
>( | ||
props: IFetchProps<Model, Parameters, Operation>, | ||
): Promise<IHttpResponse> => HttpLlmFunctionFetcher.propagate(props); | ||
export const propagate = <Model extends ILlmSchema.Model>( | ||
props: IFetchProps<Model>, | ||
): Promise<IHttpResponse> => HttpLlmFunctionFetcher.propagate<Model>(props); | ||
@@ -220,13 +193,7 @@ /* ----------------------------------------------------------- | ||
*/ | ||
export interface IMergeProps< | ||
Parameters extends | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters | ||
| IChatGptSchema.IParameters | ||
| IGeminiSchema.IParameters, | ||
> { | ||
export interface IMergeProps { | ||
/** | ||
* Metadata of the target function. | ||
*/ | ||
function: ILlmFunction<Parameters>; | ||
function: ILlmFunction<any>; | ||
@@ -259,11 +226,4 @@ /** | ||
*/ | ||
export const mergeParameters = < | ||
Parameters extends | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters | ||
| IChatGptSchema.IParameters | ||
| IGeminiSchema.IParameters, | ||
>( | ||
props: IMergeProps<Parameters>, | ||
): object => LlmDataMerger.parameters(props); | ||
export const mergeParameters = (props: IMergeProps): object => | ||
LlmDataMerger.parameters(props); | ||
@@ -270,0 +230,0 @@ /** |
@@ -75,9 +75,5 @@ import { OpenApi } from "./OpenApi"; | ||
*/ | ||
export const application = < | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>, | ||
>( | ||
document: OpenApi.IDocument<Schema, Operation>, | ||
): IHttpMigrateApplication<Schema, Operation> => | ||
MigrateConverter.convert(document); | ||
export const application = ( | ||
document: OpenApi.IDocument, | ||
): IHttpMigrateApplication => MigrateConverter.convert(document); | ||
@@ -84,0 +80,0 @@ /** |
@@ -0,0 +0,0 @@ //---- |
@@ -64,6 +64,3 @@ import { OpenApiV3 } from "./OpenApiV3"; | ||
*/ | ||
export function convert< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
>( | ||
export function convert( | ||
input: | ||
@@ -73,13 +70,10 @@ | SwaggerV2.IDocument | ||
| OpenApiV3_1.IDocument | ||
| OpenApi.IDocument<Schema, Operation>, | ||
): IDocument<Schema, Operation> { | ||
| OpenApi.IDocument, | ||
): IDocument { | ||
if (OpenApiV3_1.is(input)) | ||
return OpenApiV3_1Converter.convert(input) as IDocument< | ||
Schema, | ||
Operation | ||
>; | ||
return OpenApiV3_1Converter.convert(input) as IDocument; | ||
else if (OpenApiV3.is(input)) | ||
return OpenApiV3Converter.convert(input) as IDocument<Schema, Operation>; | ||
return OpenApiV3Converter.convert(input) as IDocument; | ||
else if (SwaggerV2.is(input)) | ||
return SwaggerV2Converter.convert(input) as IDocument<Schema, Operation>; | ||
return SwaggerV2Converter.convert(input) as IDocument; | ||
throw new TypeError("Unrecognized Swagger/OpenAPI version."); | ||
@@ -97,7 +91,4 @@ } | ||
*/ | ||
export function downgrade< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
>( | ||
document: IDocument<Schema, Operation>, | ||
export function downgrade( | ||
document: IDocument, | ||
version: "2.0", | ||
@@ -115,7 +106,4 @@ ): SwaggerV2.IDocument; | ||
*/ | ||
export function downgrade< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
>( | ||
document: IDocument<Schema, Operation>, | ||
export function downgrade( | ||
document: IDocument, | ||
version: "3.0", | ||
@@ -127,7 +115,4 @@ ): OpenApiV3.IDocument; | ||
*/ | ||
export function downgrade< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
>( | ||
document: IDocument<Schema, Operation>, | ||
export function downgrade( | ||
document: IDocument, | ||
version: string, | ||
@@ -151,10 +136,4 @@ ): SwaggerV2.IDocument | OpenApiV3.IDocument { | ||
* duplicated expressions of OpenAPI v3.1 for the convenience and clarity. | ||
* | ||
* @template Schema JSON schema type | ||
* @template Operation HTTP operation type | ||
*/ | ||
export interface IDocument< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
> { | ||
export interface IDocument { | ||
/** | ||
@@ -183,3 +162,3 @@ * OpenAPI version number. | ||
*/ | ||
components: IComponents<Schema>; | ||
components: IComponents; | ||
@@ -191,3 +170,3 @@ /** | ||
*/ | ||
paths?: Record<string, IPath<Schema, Operation>>; | ||
paths?: Record<string, IPath>; | ||
@@ -200,3 +179,3 @@ /** | ||
*/ | ||
webhooks?: Record<string, IPath<Schema, Operation>>; | ||
webhooks?: Record<string, IPath>; | ||
@@ -390,6 +369,3 @@ /** | ||
*/ | ||
export interface IPath< | ||
Schema extends IJsonSchema = IJsonSchema, | ||
Operation extends IOperation<Schema> = IOperation<Schema>, | ||
> extends Partial<Record<Method, Operation>> { | ||
export interface IPath extends Partial<Record<Method, IOperation>> { | ||
/** | ||
@@ -417,3 +393,3 @@ * Servers that provide the path operations. | ||
*/ | ||
export interface IOperation<Schema extends IJsonSchema = IJsonSchema> { | ||
export interface IOperation { | ||
/** | ||
@@ -427,3 +403,3 @@ * Unique string used to identify the operation. | ||
*/ | ||
parameters?: IOperation.IParameter<Schema>[]; | ||
parameters?: IOperation.IParameter[]; | ||
@@ -433,3 +409,3 @@ /** | ||
*/ | ||
requestBody?: IOperation.IRequestBody<Schema>; | ||
requestBody?: IOperation.IRequestBody; | ||
@@ -441,3 +417,3 @@ /** | ||
*/ | ||
responses?: Record<string, IOperation.IResponse<Schema>>; | ||
responses?: Record<string, IOperation.IResponse>; | ||
@@ -487,3 +463,3 @@ /** | ||
*/ | ||
export interface IParameter<Schema extends IJsonSchema = IJsonSchema> { | ||
export interface IParameter { | ||
/** | ||
@@ -517,3 +493,3 @@ * Representative name of the parameter. | ||
*/ | ||
schema: Schema; | ||
schema: IJsonSchema; | ||
@@ -556,4 +532,4 @@ /** | ||
*/ | ||
export interface IRequestBody<Schema extends IJsonSchema = IJsonSchema> { | ||
content?: IContent<Schema>; | ||
export interface IRequestBody { | ||
content?: IContent; | ||
description?: string; | ||
@@ -567,5 +543,5 @@ required?: boolean; | ||
*/ | ||
export interface IResponse<Schema extends IJsonSchema = IJsonSchema> { | ||
headers?: Record<string, IOperation.IParameter<Schema>>; | ||
content?: IContent<Schema>; | ||
export interface IResponse { | ||
headers?: Record<string, IOperation.IParameter>; | ||
content?: IContent; | ||
description?: string; | ||
@@ -578,4 +554,4 @@ "x-nestia-encrypted"?: boolean; | ||
*/ | ||
export interface IContent<Schema extends IJsonSchema = IJsonSchema> | ||
extends Partial<Record<ContentType, IMediaType<Schema>>> {} | ||
export interface IContent | ||
extends Partial<Record<ContentType, IMediaType>> {} | ||
@@ -585,4 +561,4 @@ /** | ||
*/ | ||
export interface IMediaType<Schema extends IJsonSchema = IJsonSchema> { | ||
schema?: Schema; | ||
export interface IMediaType { | ||
schema?: IJsonSchema; | ||
example?: any; | ||
@@ -624,3 +600,3 @@ examples?: Record<string, IExample>; | ||
*/ | ||
export interface IComponents<Schema extends IJsonSchema = IJsonSchema> { | ||
export interface IComponents { | ||
/** | ||
@@ -631,3 +607,3 @@ * An object to hold reusable DTO schemas. | ||
*/ | ||
schemas?: Record<string, Schema>; | ||
schemas?: Record<string, IJsonSchema>; | ||
@@ -860,4 +836,3 @@ /** | ||
*/ | ||
export interface IArray<Schema extends IJsonSchema = IJsonSchema> | ||
extends __ISignificant<"array"> { | ||
export interface IArray extends __ISignificant<"array"> { | ||
/** | ||
@@ -869,3 +844,3 @@ * Items type info. | ||
*/ | ||
items: Schema; | ||
items: IJsonSchema; | ||
@@ -901,4 +876,3 @@ /** | ||
*/ | ||
export interface ITuple<Schema extends IJsonSchema = IJsonSchema> | ||
extends __ISignificant<"array"> { | ||
export interface ITuple extends __ISignificant<"array"> { | ||
/** | ||
@@ -913,3 +887,3 @@ * Prefix items. | ||
*/ | ||
prefixItems: Schema[]; | ||
prefixItems: IJsonSchema[]; | ||
@@ -931,3 +905,3 @@ /** | ||
*/ | ||
additionalItems?: boolean | Schema; | ||
additionalItems?: boolean | IJsonSchema; | ||
@@ -963,4 +937,3 @@ /** | ||
*/ | ||
export interface IObject<Schema extends IJsonSchema = IJsonSchema> | ||
extends __ISignificant<"object"> { | ||
export interface IObject extends __ISignificant<"object"> { | ||
/** | ||
@@ -976,3 +949,3 @@ * Properties of the object. | ||
*/ | ||
properties?: Record<string, Schema>; | ||
properties?: Record<string, IJsonSchema>; | ||
@@ -993,3 +966,3 @@ /** | ||
*/ | ||
additionalProperties?: boolean | Schema; | ||
additionalProperties?: boolean | IJsonSchema; | ||
@@ -1059,8 +1032,7 @@ /** | ||
*/ | ||
export interface IOneOf<Schema extends IJsonSchema = IJsonSchema> | ||
extends __IAttribute { | ||
export interface IOneOf extends __IAttribute { | ||
/** | ||
* List of the union types. | ||
*/ | ||
oneOf: Exclude<Schema, IJsonSchema.IOneOf<Schema>>[]; | ||
oneOf: Exclude<IJsonSchema, IJsonSchema.IOneOf>[]; | ||
@@ -1067,0 +1039,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; |
@@ -0,0 +0,0 @@ /** |
@@ -18,5 +18,3 @@ /// <reference lib="dom" /> | ||
*/ | ||
export interface IHttpConnection< | ||
Headers extends object | undefined = object | undefined, | ||
> { | ||
export interface IHttpConnection { | ||
/** | ||
@@ -30,4 +28,3 @@ * Host address of the remote HTTP server. | ||
*/ | ||
headers?: Record<string, IHttpConnection.HeaderValue> & | ||
IHttpConnection.Headerify<Headers>; | ||
headers?: Record<string, IHttpConnection.HeaderValue>; | ||
@@ -155,65 +152,65 @@ /** | ||
/** | ||
* Type of headers | ||
* | ||
* `Headerify` removes every properties that are not allowed in the | ||
* HTTP headers type. | ||
* | ||
* Below are list of prohibited in HTTP headers. | ||
* | ||
* 1. Value type one of {@link HeaderValue} | ||
* 2. Key is "set-cookie", but value is not an Array type | ||
* 3. Key is one of them, but value is Array type | ||
* - "age" | ||
* - "authorization" | ||
* - "content-length" | ||
* - "content-type" | ||
* - "etag" | ||
* - "expires" | ||
* - "from" | ||
* - "host" | ||
* - "if-modified-since" | ||
* - "if-unmodified-since" | ||
* - "last-modified" | ||
* - "location" | ||
* - "max-forwards" | ||
* - "proxy-authorization" | ||
* - "referer" | ||
* - "retry-after" | ||
* - "server" | ||
* - "user-agent" | ||
*/ | ||
export type Headerify<T extends object | undefined> = { | ||
[P in keyof T]?: T[P] extends HeaderValue | undefined | ||
? P extends string | ||
? Lowercase<P> extends "set-cookie" | ||
? T[P] extends Array<HeaderValue> | ||
? T[P] | undefined | ||
: never | ||
: Lowercase<P> extends | ||
| "age" | ||
| "authorization" | ||
| "content-length" | ||
| "content-type" | ||
| "etag" | ||
| "expires" | ||
| "from" | ||
| "host" | ||
| "if-modified-since" | ||
| "if-unmodified-since" | ||
| "last-modified" | ||
| "location" | ||
| "max-forwards" | ||
| "proxy-authorization" | ||
| "referer" | ||
| "retry-after" | ||
| "server" | ||
| "user-agent" | ||
? T[P] extends Array<HeaderValue> | ||
? never | ||
: T[P] | undefined | ||
: T[P] | undefined | ||
: never | ||
: never; | ||
}; | ||
// /** | ||
// * Type of headers | ||
// * | ||
// * `Headerify` removes every properties that are not allowed in the | ||
// * HTTP headers type. | ||
// * | ||
// * Below are list of prohibited in HTTP headers. | ||
// * | ||
// * 1. Value type one of {@link HeaderValue} | ||
// * 2. Key is "set-cookie", but value is not an Array type | ||
// * 3. Key is one of them, but value is Array type | ||
// * - "age" | ||
// * - "authorization" | ||
// * - "content-length" | ||
// * - "content-type" | ||
// * - "etag" | ||
// * - "expires" | ||
// * - "from" | ||
// * - "host" | ||
// * - "if-modified-since" | ||
// * - "if-unmodified-since" | ||
// * - "last-modified" | ||
// * - "location" | ||
// * - "max-forwards" | ||
// * - "proxy-authorization" | ||
// * - "referer" | ||
// * - "retry-after" | ||
// * - "server" | ||
// * - "user-agent" | ||
// */ | ||
// export type Headerify<T extends object | undefined> = { | ||
// [P in keyof T]?: T[P] extends HeaderValue | undefined | ||
// ? P extends string | ||
// ? Lowercase<P> extends "set-cookie" | ||
// ? T[P] extends Array<HeaderValue> | ||
// ? T[P] | undefined | ||
// : never | ||
// : Lowercase<P> extends | ||
// | "age" | ||
// | "authorization" | ||
// | "content-length" | ||
// | "content-type" | ||
// | "etag" | ||
// | "expires" | ||
// | "from" | ||
// | "host" | ||
// | "if-modified-since" | ||
// | "if-unmodified-since" | ||
// | "last-modified" | ||
// | "location" | ||
// | "max-forwards" | ||
// | "proxy-authorization" | ||
// | "referer" | ||
// | "retry-after" | ||
// | "server" | ||
// | "user-agent" | ||
// ? T[P] extends Array<HeaderValue> | ||
// ? never | ||
// : T[P] | undefined | ||
// : T[P] | undefined | ||
// : never | ||
// : never; | ||
// }; | ||
} |
@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { ILlmApplication } from "./ILlmApplication"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
@@ -71,9 +72,3 @@ | ||
*/ | ||
export interface IHttpLlmApplication< | ||
Model extends IHttpLlmApplication.Model, | ||
Parameters extends | ||
IHttpLlmApplication.ModelParameters[Model] = IHttpLlmApplication.ModelParameters[Model], | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute, | ||
> { | ||
export interface IHttpLlmApplication<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -92,3 +87,3 @@ * Model of the target LLM. | ||
*/ | ||
functions: IHttpLlmFunction<Parameters, Operation, Route>[]; | ||
functions: IHttpLlmFunction<Model>[]; | ||
@@ -98,3 +93,3 @@ /** | ||
*/ | ||
errors: IHttpLlmApplication.IError<Operation, Route>[]; | ||
errors: IHttpLlmApplication.IError[]; | ||
@@ -104,13 +99,5 @@ /** | ||
*/ | ||
options: IHttpLlmApplication.IOptions< | ||
Model, | ||
IHttpLlmApplication.ModelSchema[Model] | ||
>; | ||
options: IHttpLlmApplication.IOptions<Model>; | ||
} | ||
export namespace IHttpLlmApplication { | ||
export import Model = ILlmApplication.Model; | ||
export import ModelParameters = ILlmApplication.ModelParameters; | ||
export import ModelSchema = ILlmApplication.ModelSchema; | ||
export import ModelConfig = ILlmApplication.ModelConfig; | ||
export import IOptions = ILlmApplication.IOptions; | ||
@@ -121,6 +108,3 @@ | ||
*/ | ||
export interface IError< | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute, | ||
> { | ||
export interface IError { | ||
/** | ||
@@ -146,3 +130,3 @@ * HTTP method of the endpoint. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
@@ -159,4 +143,4 @@ /** | ||
*/ | ||
route: () => Route | undefined; | ||
route: () => IHttpMigrateRoute | undefined; | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { OpenApi } from "../OpenApi"; | ||
import { IHttpMigrateRoute } from "./IHttpMigrateRoute"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
@@ -61,11 +62,3 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
*/ | ||
export interface IHttpLlmFunction< | ||
Parameters extends | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters | ||
| IChatGptSchema.IParameters | ||
| IGeminiSchema.IParameters, | ||
Operation extends OpenApi.IOperation = OpenApi.IOperation, | ||
Route extends IHttpMigrateRoute = IHttpMigrateRoute, | ||
> { | ||
export interface IHttpLlmFunction<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -155,3 +148,3 @@ * HTTP method of the endpoint. | ||
*/ | ||
parameters: Parameters; | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
@@ -163,3 +156,3 @@ /** | ||
*/ | ||
separated?: IHttpLlmFunction.ISeparated<Parameters>; | ||
separated?: IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
@@ -172,3 +165,3 @@ /** | ||
*/ | ||
output?: Parameters | undefined; | ||
output?: ILlmSchema.ModelSchema[Model] | undefined; | ||
@@ -224,3 +217,3 @@ /** | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
@@ -234,3 +227,3 @@ /** | ||
*/ | ||
route: () => Route; | ||
route: () => IHttpMigrateRoute; | ||
} | ||
@@ -237,0 +230,0 @@ export namespace IHttpLlmFunction { |
@@ -18,10 +18,7 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpMigrateApplication< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>, | ||
> { | ||
export interface IHttpMigrateApplication { | ||
/** | ||
* List of routes for migration. | ||
*/ | ||
routes: IHttpMigrateRoute<Schema, Operation>[]; | ||
routes: IHttpMigrateRoute[]; | ||
@@ -31,3 +28,3 @@ /** | ||
*/ | ||
errors: IHttpMigrateApplication.IError<Operation>[]; | ||
errors: IHttpMigrateApplication.IError[]; | ||
@@ -37,3 +34,3 @@ /** | ||
*/ | ||
document: () => OpenApi.IDocument<Schema, Operation>; | ||
document: () => OpenApi.IDocument; | ||
} | ||
@@ -44,10 +41,7 @@ export namespace IHttpMigrateApplication { | ||
*/ | ||
export interface IError< | ||
Operation extends | ||
OpenApi.IOperation<any> = OpenApi.IOperation<OpenApi.IJsonSchema>, | ||
> { | ||
export interface IError { | ||
/** | ||
* Target operation causing the error. | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
@@ -54,0 +48,0 @@ /** |
@@ -16,6 +16,3 @@ import { OpenApi } from "../OpenApi"; | ||
*/ | ||
export interface IHttpMigrateRoute< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
Operation extends OpenApi.IOperation<Schema> = OpenApi.IOperation<Schema>, | ||
> { | ||
export interface IHttpMigrateRoute { | ||
/** | ||
@@ -82,3 +79,3 @@ * Method of the route. | ||
*/ | ||
parameters: IHttpMigrateRoute.IParameter<Schema>[]; | ||
parameters: IHttpMigrateRoute.IParameter[]; | ||
@@ -100,3 +97,3 @@ /** | ||
*/ | ||
headers: IHttpMigrateRoute.IHeaders<Schema> | null; | ||
headers: IHttpMigrateRoute.IHeaders | null; | ||
@@ -118,3 +115,3 @@ /** | ||
*/ | ||
query: IHttpMigrateRoute.IQuery<Schema> | null; | ||
query: IHttpMigrateRoute.IQuery | null; | ||
@@ -130,3 +127,3 @@ /** | ||
*/ | ||
body: IHttpMigrateRoute.IBody<Schema> | null; | ||
body: IHttpMigrateRoute.IBody | null; | ||
@@ -142,3 +139,3 @@ /** | ||
*/ | ||
success: IHttpMigrateRoute.IBody<Schema> | null; | ||
success: IHttpMigrateRoute.IBody | null; | ||
@@ -156,3 +153,3 @@ /** | ||
*/ | ||
exceptions: Record<string, IHttpMigrateRoute.IException<Schema>>; | ||
exceptions: Record<string, IHttpMigrateRoute.IException>; | ||
@@ -181,3 +178,3 @@ /** | ||
*/ | ||
operation: () => Operation; | ||
operation: () => OpenApi.IOperation; | ||
} | ||
@@ -188,5 +185,3 @@ export namespace IHttpMigrateRoute { | ||
*/ | ||
export interface IParameter< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
> { | ||
export interface IParameter { | ||
/** | ||
@@ -205,3 +200,3 @@ * Name of the path parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
@@ -214,3 +209,3 @@ /** | ||
*/ | ||
parameter: () => OpenApi.IOperation.IParameter<Schema>; | ||
parameter: () => OpenApi.IOperation.IParameter; | ||
} | ||
@@ -221,5 +216,3 @@ | ||
*/ | ||
export interface IHeaders< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
> { | ||
export interface IHeaders { | ||
/** | ||
@@ -238,3 +231,3 @@ * Name of the headers parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
title: () => string | undefined; | ||
@@ -249,8 +242,6 @@ description: () => string | undefined; | ||
*/ | ||
export interface IQuery< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
> { | ||
export interface IQuery { | ||
name: string; | ||
key: string; | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
title: () => string | undefined; | ||
@@ -265,5 +256,3 @@ description: () => string | undefined; | ||
*/ | ||
export interface IBody< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
> { | ||
export interface IBody { | ||
/** | ||
@@ -291,3 +280,3 @@ * Name of the body parameter. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
@@ -302,3 +291,3 @@ /** | ||
*/ | ||
media: () => OpenApi.IOperation.IMediaType<Schema>; | ||
media: () => OpenApi.IOperation.IMediaType; | ||
@@ -314,9 +303,7 @@ /** | ||
*/ | ||
export interface IException< | ||
Schema extends OpenApi.IJsonSchema = OpenApi.IJsonSchema, | ||
> { | ||
export interface IException { | ||
/** | ||
* Metadata of response body data type. | ||
*/ | ||
schema: Schema; | ||
schema: OpenApi.IJsonSchema; | ||
@@ -326,3 +313,3 @@ /** | ||
*/ | ||
response: () => OpenApi.IOperation.IResponse<Schema>; | ||
response: () => OpenApi.IOperation.IResponse; | ||
@@ -332,4 +319,4 @@ /** | ||
*/ | ||
media: () => OpenApi.IOperation.IMediaType<Schema>; | ||
media: () => OpenApi.IOperation.IMediaType; | ||
} | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; |
@@ -1,8 +0,4 @@ | ||
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlamaSchema } from "./ILlamaSchema"; | ||
import { ILlmFunction } from "./ILlmFunction"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
@@ -14,3 +10,3 @@ /** | ||
* {@link ILlmFunction LLM function calling schemas}, composed from a native | ||
* TypeScript class (or interface) type by the `typia.llm.application<App>()` | ||
* TypeScript class (or interface) type by the `typia.llm.application<App, Model>()` | ||
* function. | ||
@@ -33,7 +29,3 @@ * | ||
*/ | ||
export interface ILlmApplication< | ||
Model extends ILlmApplication.Model, | ||
Parameters extends | ||
ILlmApplication.ModelParameters[Model] = ILlmApplication.ModelParameters[Model], | ||
> { | ||
export interface ILlmApplication<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -49,3 +41,3 @@ * Model of the LLM. | ||
*/ | ||
functions: ILlmFunction<Parameters>[]; | ||
functions: ILlmFunction<Model>[]; | ||
@@ -55,38 +47,9 @@ /** | ||
*/ | ||
options: ILlmApplication.IOptions<Model, ILlmApplication.ModelSchema[Model]>; | ||
options: ILlmApplication.IOptions<Model>; | ||
} | ||
export namespace ILlmApplication { | ||
export type Model = "chatgpt" | "claude" | "gemini" | "llama" | "3.0" | "3.1"; | ||
export type ModelParameters = { | ||
chatgpt: IChatGptSchema.IParameters; | ||
claude: IClaudeSchema.IParameters; | ||
gemini: IGeminiSchema.IParameters; | ||
llama: ILlamaSchema.IParameters; | ||
"3.0": ILlmSchemaV3.IParameters; | ||
"3.1": ILlmSchemaV3_1.IParameters; | ||
}; | ||
export type ModelSchema = { | ||
chatgpt: IChatGptSchema; | ||
claude: IClaudeSchema; | ||
gemini: IGeminiSchema; | ||
llama: ILlamaSchema; | ||
"3.0": ILlmSchemaV3; | ||
"3.1": ILlmSchemaV3_1; | ||
}; | ||
export type ModelConfig = { | ||
chatgpt: IChatGptSchema.IConfig; | ||
claude: IClaudeSchema.IConfig; | ||
gemini: IGeminiSchema.IConfig; | ||
llama: ILlamaSchema.IConfig; | ||
"3.0": ILlmSchemaV3.IConfig; | ||
"3.1": ILlmSchemaV3_1.IConfig; | ||
}; | ||
/** | ||
* Options for application composition. | ||
*/ | ||
export type IOptions< | ||
Model extends ILlmApplication.Model, | ||
Schema extends ModelSchema[Model] = ModelSchema[Model], | ||
> = { | ||
export type IOptions<Model extends ILlmSchema.Model> = { | ||
/** | ||
@@ -120,4 +83,4 @@ * Separator function for the parameters. | ||
*/ | ||
separate: null | ((schema: Schema) => boolean); | ||
} & ModelConfig[Model]; | ||
separate: null | ((schema: ILlmSchema.ModelSchema[Model]) => boolean); | ||
} & ILlmSchema.ModelConfig[Model]; | ||
} |
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlmSchema } from "./ILlmSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
@@ -29,10 +30,3 @@ import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
*/ | ||
export interface ILlmFunction< | ||
Parameters extends | ||
| IChatGptSchema.IParameters | ||
| IClaudeSchema.IParameters | ||
| IGeminiSchema.IParameters | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters, | ||
> { | ||
export interface ILlmFunction<Model extends ILlmSchema.Model> { | ||
/** | ||
@@ -46,3 +40,3 @@ * Representative name of the function. | ||
*/ | ||
parameters: Parameters; | ||
parameters: ILlmSchema.ModelParameters[Model]; | ||
@@ -52,3 +46,3 @@ /** | ||
*/ | ||
separated?: ILlmFunction.ISeparated<Parameters>; | ||
separated?: ILlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>; | ||
@@ -61,3 +55,3 @@ /** | ||
*/ | ||
output?: Parameters["properties"][string]; | ||
output?: ILlmSchema.ModelSchema[Model]; | ||
@@ -64,0 +58,0 @@ /** |
@@ -1,2 +0,7 @@ | ||
import { ILlmApplication } from "./ILlmApplication"; | ||
import { IChatGptSchema } from "./IChatGptSchema"; | ||
import { IClaudeSchema } from "./IClaudeSchema"; | ||
import { IGeminiSchema } from "./IGeminiSchema"; | ||
import { ILlamaSchema } from "./ILlamaSchema"; | ||
import { ILlmSchemaV3 } from "./ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1"; | ||
@@ -16,7 +21,32 @@ /** | ||
*/ | ||
export type ILlmSchema< | ||
Model extends ILlmApplication.Model = ILlmApplication.Model, | ||
> = ILlmApplication.ModelSchema[Model]; | ||
export type ILlmSchema<Model extends ILlmSchema.Model = ILlmSchema.Model> = | ||
ILlmSchema.ModelSchema[Model]; | ||
export namespace ILlmSchema { | ||
export type Model = "chatgpt" | "claude" | "gemini" | "llama" | "3.0" | "3.1"; | ||
export interface ModelConfig { | ||
chatgpt: IChatGptSchema.IConfig; | ||
claude: IClaudeSchema.IConfig; | ||
gemini: IGeminiSchema.IConfig; | ||
llama: ILlamaSchema.IConfig; | ||
"3.0": ILlmSchemaV3.IConfig; | ||
"3.1": ILlmSchemaV3_1.IConfig; | ||
} | ||
export interface ModelParameters { | ||
chatgpt: IChatGptSchema.IParameters; | ||
claude: IClaudeSchema.IParameters; | ||
gemini: IGeminiSchema.IParameters; | ||
llama: ILlamaSchema.IParameters; | ||
"3.0": ILlmSchemaV3.IParameters; | ||
"3.1": ILlmSchemaV3_1.IParameters; | ||
} | ||
export interface ModelSchema { | ||
chatgpt: IChatGptSchema; | ||
claude: IClaudeSchema; | ||
gemini: IGeminiSchema; | ||
llama: ILlamaSchema; | ||
"3.0": ILlmSchemaV3; | ||
"3.1": ILlmSchemaV3_1; | ||
} | ||
/** | ||
@@ -32,5 +62,4 @@ * Type of function parameters. | ||
*/ | ||
export type IParameters< | ||
Model extends ILlmApplication.Model = ILlmApplication.Model, | ||
> = ILlmApplication.ModelParameters[Model]; | ||
export type IParameters<Model extends ILlmSchema.Model = ILlmSchema.Model> = | ||
ILlmSchema.ModelParameters[Model]; | ||
@@ -40,5 +69,4 @@ /** | ||
*/ | ||
export type IConfig< | ||
Model extends ILlmApplication.Model = ILlmApplication.Model, | ||
> = ILlmApplication.ModelConfig[Model]; | ||
export type IConfig<Model extends ILlmSchema.Model = ILlmSchema.Model> = | ||
ILlmSchema.ModelConfig[Model]; | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -264,4 +264,3 @@ /** | ||
*/ | ||
export interface IArray<Schema extends ILlmSchemaV3 = ILlmSchemaV3> | ||
extends __ISignificant<"array"> { | ||
export interface IArray extends __ISignificant<"array"> { | ||
/** | ||
@@ -273,3 +272,3 @@ * Items type schema info. | ||
*/ | ||
items: Schema; | ||
items: ILlmSchemaV3; | ||
@@ -305,4 +304,3 @@ /** | ||
*/ | ||
export interface IObject<Schema extends ILlmSchemaV3 = ILlmSchemaV3> | ||
extends __ISignificant<"object"> { | ||
export interface IObject extends __ISignificant<"object"> { | ||
/** | ||
@@ -318,3 +316,3 @@ * Properties of the object. | ||
*/ | ||
properties: Record<string, Schema>; | ||
properties: Record<string, ILlmSchemaV3>; | ||
@@ -404,8 +402,7 @@ /** | ||
*/ | ||
export interface IOneOf<Schema extends ILlmSchemaV3 = ILlmSchemaV3> | ||
extends __IAttribute { | ||
export interface IOneOf extends __IAttribute { | ||
/** | ||
* List of the union types. | ||
*/ | ||
oneOf: Exclude<Schema, ILlmSchemaV3.IOneOf<Schema>>[]; | ||
oneOf: Exclude<ILlmSchemaV3, ILlmSchemaV3.IOneOf>[]; | ||
} | ||
@@ -412,0 +409,0 @@ |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { IChatGptSchema } from "../structures/IChatGptSchema"; |
import { LlmTypeCheckerV3_1 } from "./LlmTypeCheckerV3_1"; | ||
export import ClaudeTypeChecker = LlmTypeCheckerV3_1; |
@@ -0,0 +0,0 @@ export namespace Escaper { |
@@ -0,0 +0,0 @@ import { IGeminiSchema } from "../structures/IGeminiSchema"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../../OpenApi"; |
import { LlmTypeCheckerV3_1 } from "./LlmTypeCheckerV3_1"; | ||
export import LlamaTypeChecker = LlmTypeCheckerV3_1; |
@@ -1,6 +0,3 @@ | ||
import { IChatGptSchema } from "../structures/IChatGptSchema"; | ||
import { IGeminiSchema } from "../structures/IGeminiSchema"; | ||
import { ILlmFunction } from "../structures/ILlmFunction"; | ||
import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; | ||
import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; | ||
import { ILlmSchema } from "../structures/ILlmSchema"; | ||
@@ -16,13 +13,7 @@ /** | ||
*/ | ||
export interface IProps< | ||
Parameters extends | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters | ||
| IChatGptSchema.IParameters | ||
| IGeminiSchema.IParameters, | ||
> { | ||
export interface IProps { | ||
/** | ||
* Target function to call. | ||
*/ | ||
function: ILlmFunction<Parameters>; | ||
function: ILlmFunction<ILlmSchema.Model>; | ||
@@ -55,11 +46,3 @@ /** | ||
*/ | ||
export const parameters = < | ||
Parameters extends | ||
| ILlmSchemaV3.IParameters | ||
| ILlmSchemaV3_1.IParameters | ||
| IChatGptSchema.IParameters | ||
| IGeminiSchema.IParameters, | ||
>( | ||
props: IProps<Parameters>, | ||
): object => { | ||
export const parameters = (props: IProps): object => { | ||
const separated = props.function.separated; | ||
@@ -66,0 +49,0 @@ if (separated === undefined) |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3_1 } from "../structures/ILlmSchemaV3_1"; |
@@ -0,0 +0,0 @@ import { ILlmSchemaV3 } from "../structures/ILlmSchemaV3"; |
@@ -0,0 +0,0 @@ export namespace MapUtil { |
@@ -0,0 +0,0 @@ import { StringUtil } from "./StringUtil"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { OpenApi } from "../OpenApi"; |
@@ -0,0 +0,0 @@ import { NamingConvention } from "./NamingConvention"; |
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
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
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
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
499
1558273
27577