Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precise ILlmFunction.ISeparated<Model> #95

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions examples/function-calling/arguments/claude.sale.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"tags": [
"Surface Pro",
"2-in-1",
"Laptop",
"Tablet",
"Tablet PC",
"Windows",
"Microsoft"
],
Expand Down Expand Up @@ -100,7 +99,7 @@
],
"stocks": [
{
"name": "Surface Pro 9 (i3/8GB/128GB)",
"name": "Surface Pro 9 - i3/8GB/128GB",
"price": {
"nominal": 1000000,
"real": 899000
Expand All @@ -122,7 +121,7 @@
]
},
{
"name": "Surface Pro 9 (i3/16GB/256GB)",
"name": "Surface Pro 9 - i3/16GB/256GB",
"price": {
"nominal": 1200000,
"real": 1099000
Expand All @@ -144,7 +143,7 @@
]
},
{
"name": "Surface Pro 9 (i3/16GB/512GB)",
"name": "Surface Pro 9 - i3/16GB/512GB",
"price": {
"nominal": 1400000,
"real": 1299000
Expand All @@ -166,7 +165,7 @@
]
},
{
"name": "Surface Pro 9 (i5/16GB/256GB)",
"name": "Surface Pro 9 - i5/16GB/256GB",
"price": {
"nominal": 1500000,
"real": 1399000
Expand All @@ -188,7 +187,7 @@
]
},
{
"name": "Surface Pro 9 (i5/32GB/512GB)",
"name": "Surface Pro 9 - i5/32GB/512GB",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -210,7 +209,7 @@
]
},
{
"name": "Surface Pro 9 (i7/16GB/512GB)",
"name": "Surface Pro 9 - i7/16GB/512GB",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -232,7 +231,7 @@
]
},
{
"name": "Surface Pro 9 (i7/32GB/512GB)",
"name": "Surface Pro 9 - i7/32GB/512GB",
"price": {
"nominal": 2000000,
"real": 1899000
Expand Down Expand Up @@ -262,7 +261,7 @@
"options": [],
"stocks": [
{
"name": "Warranty Program",
"name": "Surface Pro 9 Warranty Program",
"price": {
"nominal": 100000,
"real": 89000
Expand All @@ -279,7 +278,7 @@
"options": [],
"stocks": [
{
"name": "Magnetic Keyboard",
"name": "Surface Pro 9 Magnetic Keyboard",
"price": {
"nominal": 200000,
"real": 169000
Expand Down
1 change: 1 addition & 0 deletions examples/function-calling/schemas/claude.sale.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,6 @@
"required": [
"input"
],
"additionalProperties": false,
"$defs": {}
}
1 change: 1 addition & 0 deletions examples/function-calling/schemas/llama.sale.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,6 @@
"required": [
"input"
],
"additionalProperties": false,
"$defs": {}
}
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": "2.0.0-dev.20241129-8",
"version": "2.0.0-dev.20241130",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"main": "./lib/index.js",
"module": "./lib/index.mjs",
Expand Down
6 changes: 2 additions & 4 deletions src/converters/HttpLlmConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export namespace HttpLlmConverter {
model: Model;
parameters: ILlmSchema.ModelParameters[Model];
predicate: (schema: ILlmSchema.ModelSchema[Model]) => boolean;
}): IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]> => {
}): IHttpLlmFunction.ISeparated<Model> => {
const separator: (props: {
predicate: (schema: ILlmSchema.ModelSchema[Model]) => boolean;
schema: ILlmSchema.ModelSchema[Model];
Expand All @@ -102,9 +102,7 @@ export namespace HttpLlmConverter {
return {
llm,
human,
} satisfies IHttpLlmFunction.ISeparated<
ILlmSchema.ModelParameters[Model]
> as IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>;
} satisfies IHttpLlmFunction.ISeparated<Model>;
};

const composeFunction = <Model extends ILlmSchema.Model>(props: {
Expand Down
18 changes: 4 additions & 14 deletions src/structures/IHttpLlmFunction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { OpenApi } from "../OpenApi";
import { IChatGptSchema } from "./IChatGptSchema";
import { IGeminiSchema } from "./IGeminiSchema";
import { IHttpMigrateRoute } from "./IHttpMigrateRoute";
import { ILlmSchema } from "./ILlmSchema";
import { ILlmSchemaV3 } from "./ILlmSchemaV3";
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1";

/**
* LLM function calling schema from HTTP (OpenAPI) operation.
Expand Down Expand Up @@ -150,7 +146,7 @@ export interface IHttpLlmFunction<Model extends ILlmSchema.Model> {
*
* Filled only when {@link IHttpLlmApplication.IOptions.separate} is configured.
*/
separated?: IHttpLlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>;
separated?: IHttpLlmFunction.ISeparated<Model>;

/**
* Expected return type.
Expand Down Expand Up @@ -224,21 +220,15 @@ export namespace IHttpLlmFunction {
/**
* Collection of separated parameters.
*/
export interface ISeparated<
Parameters extends
| ILlmSchemaV3.IParameters
| ILlmSchemaV3_1.IParameters
| IChatGptSchema.IParameters
| IGeminiSchema.IParameters,
> {
export interface ISeparated<Model extends ILlmSchema.Model> {
/**
* Parameters that would be composed by the LLM.
*/
llm: Parameters | null;
llm: ILlmSchema.ModelParameters[Model] | null;

/**
* Parameters that would be composed by the human.
*/
human: Parameters | null;
human: ILlmSchema.ModelParameters[Model] | null;
}
}
20 changes: 4 additions & 16 deletions src/structures/ILlmFunction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { IChatGptSchema } from "./IChatGptSchema";
import { IClaudeSchema } from "./IClaudeSchema";
import { IGeminiSchema } from "./IGeminiSchema";
import { ILlmSchema } from "./ILlmSchema";
import { ILlmSchemaV3 } from "./ILlmSchemaV3";
import { ILlmSchemaV3_1 } from "./ILlmSchemaV3_1";

/**
* LLM function metadata.
Expand Down Expand Up @@ -41,7 +36,7 @@ export interface ILlmFunction<Model extends ILlmSchema.Model> {
/**
* Collection of separated parameters.
*/
separated?: ILlmFunction.ISeparated<ILlmSchema.ModelParameters[Model]>;
separated?: ILlmFunction.ISeparated<Model>;

/**
* Expected return type.
Expand Down Expand Up @@ -93,22 +88,15 @@ export namespace ILlmFunction {
/**
* Collection of separated parameters.
*/
export interface ISeparated<
Parameters extends
| IChatGptSchema.IParameters
| IClaudeSchema.IParameters
| IGeminiSchema.IParameters
| ILlmSchemaV3.IParameters
| ILlmSchemaV3_1.IParameters,
> {
export interface ISeparated<Model extends ILlmSchema.Model> {
/**
* Parameters that would be composed by the LLM.
*/
llm: Parameters | null;
llm: ILlmSchema.ModelParameters[Model] | null;

/**
* Parameters that would be composed by the human.
*/
human: Parameters | null;
human: ILlmSchema.ModelParameters[Model] | null;
}
}