Skip to content

Commit

Permalink
Add ILlmApplication type.
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Sep 6, 2024
1 parent 438848f commit a2840c8
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@samchon/openapi",
"version": "0.5.0-dev.20240905",
"version": "0.5.0-dev.20240906-2",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/converters/HttpLlmConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const composeFunction =
? (OpenApiV3Downgrader.downgradeSchema({
original: {},
downgraded: {},
})(output) as ILlmSchema)
})(output as any) as ILlmSchema)
: undefined,
description: (() => {
if (operation.summary && operation.description) {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./structures/IHttpLlmFunction";
export * from "./structures/IHttpMigrateRoute";
export * from "./structures/IHttpMigrateApplication";
export * from "./structures/IHttpResponse";
export * from "./structures/ILlmApplication";
export * from "./structures/ILlmSchema";

// UTILS
Expand Down
2 changes: 1 addition & 1 deletion src/structures/IHttpLlmApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface IHttpLlmApplication<
* Options for the document.
*
* Adjusted options when composing the document through
* {@link OpenApi.llm} function.
* {@link HttpLlm.application} function.
*/
options: IHttpLlmApplication.IOptions<Schema>;
}
Expand Down
48 changes: 48 additions & 0 deletions src/structures/ILlmApplication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ILlmFunction } from "./ILlmFunction";
import { ILlmSchema } from "./ILlmSchema";

export interface ILlmApplication<Schema extends ILlmSchema = ILlmSchema> {
/**
* List of function metadata.
*
* List of function metadata that can be used for the LLM function call.
*/
functions: ILlmFunction<Schema>[];

/**
* Options for the document.
*/
options: ILlmApplication.IOptions<Schema>;
}
export namespace ILlmApplication {
export interface IOptions<Schema extends ILlmSchema = ILlmSchema> {
/**
* Separator function for the parameters.
*
* When composing parameter arguments through LLM function call,
* there can be a case that some parameters must be composed by human,
* or LLM cannot understand the parameter. For example, if the
* parameter type has configured
* {@link ILlmSchema.IString.contentMediaType} which indicates file
* uploading, it must be composed by human, not by LLM
* (Large Language Model).
*
* In that case, if you configure this property with a function that
* predicating whether the schema value must be composed by human or
* not, the parameters would be separated into two parts.
*
* - {@link ILlmFunction.separated.llm}
* - {@link ILlmFunction.separated.human}
*
* When writing the function, note that returning value `true` means
* to be a human composing the value, and `false` means to LLM
* composing the value. Also, when predicating the schema, it would
* better to utilize the {@link LlmTypeChecker} features.
*
* @param schema Schema to be separated.
* @returns Whether the schema value must be composed by human or not.
* @default null
*/
separate: null | ((schema: Schema) => boolean);
}
}
21 changes: 13 additions & 8 deletions src/structures/ILlmSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export namespace ILlmSchema {
/**
* Default value.
*/
default?: boolean;
default?: boolean | null;

/**
* Enumeration values.
*/
enum?: boolean[];
enum?: Array<boolean | null>;
}

/**
Expand All @@ -52,14 +52,14 @@ export namespace ILlmSchema {
*
* @type int64
*/
default?: number;
default?: number | null;

/**
* Enumeration values.
*
* @type int64
*/
enum?: number[];
enum?: Array<number | null>;

/**
* Minimum value restriction.
Expand Down Expand Up @@ -111,12 +111,12 @@ export namespace ILlmSchema {
/**
* Default value.
*/
default?: number;
default?: number | null;

/**
* Enumeration values.
*/
enum?: number[];
enum?: Array<number | null>;

/**
* Minimum value restriction.
Expand Down Expand Up @@ -163,12 +163,12 @@ export namespace ILlmSchema {
/**
* Default value.
*/
default?: string;
default?: string | null;

/**
* Enumeration values.
*/
enum?: string[];
enum?: Array<string | null>;

/**
* Format restriction.
Expand Down Expand Up @@ -352,6 +352,11 @@ export namespace ILlmSchema {
* Type is always `null`.
*/
type: "null";

/**
* Default value.
*/
default?: null;
}

/**
Expand Down

0 comments on commit a2840c8

Please sign in to comment.