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

Add ILlmFunction.tags properties for categorization. #55

Merged
merged 1 commit into from
Sep 25, 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
1 change: 1 addition & 0 deletions src/converters/HttpLlmConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const composeFunction =
return operation.description ?? operation.summary;
})(),
deprecated: operation.deprecated,
tags: operation.tags,
route: () => route,
operation: () => operation,
};
Expand Down
7 changes: 7 additions & 0 deletions src/structures/IHttpLlmFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ export interface IHttpLlmFunction<
*/
deprecated?: boolean | undefined;

/**
* Category tags for the function.
*
* Same with {@link OpenApi.IOperation.tags} indicating the category of the function.
*/
tags?: string[];

/**
* Get the Swagger operation metadata.
*
Expand Down
7 changes: 7 additions & 0 deletions src/structures/ILlmFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export interface ILlmFunction<Schema extends ILlmSchema = ILlmSchema> {
* LLM (Large Language Model) may not use the deprecated function.
*/
deprecated?: boolean | undefined;

/**
* Category tags for the function.
*
* You can fill this property by the `@tag ${name}` comment tag.
*/
tags?: string[];
}
export namespace ILlmFunction {
/**
Expand Down
4 changes: 4 additions & 0 deletions test/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class AppController {
return { index, level, optimal, query };
}

/**
* @tag body
* @tag post
*/
@TypedRoute.Post(":index/:level/:optimal/body")
public body(
@TypedParam("index")
Expand Down
20 changes: 20 additions & 0 deletions test/features/llm/test_http_llm_function_tags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { TestValidator } from "@nestia/e2e";
import {
HttpLlm,
IHttpLlmApplication,
IHttpLlmFunction,
OpenApi,
} from "@samchon/openapi";

import swagger from "../../swagger.json";

export const test_http_llm_function_deprecated = (): void => {
const document: OpenApi.IDocument = OpenApi.convert(swagger as any);
const application: IHttpLlmApplication = HttpLlm.application(document, {
keyword: true,
});
const func: IHttpLlmFunction | undefined = application.functions.find(
(f) => f.method === "post" && f.path === "/{index}/{level}/{optimal}/body",
);
TestValidator.equals("tags")(func?.tags)(["body", "post"]);
};
16 changes: 13 additions & 3 deletions test/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "1.0.4",
"version": "1.0.5",
"title": "@samchon/openapi",
"description": "OpenAPI definitions and converters for 'typia' and 'nestia'.",
"license": {
Expand Down Expand Up @@ -127,7 +127,10 @@
},
"/{index}/{level}/{optimal}/body": {
"post": {
"tags": [],
"tags": [
"body",
"post"
],
"parameters": [
{
"name": "index",
Expand Down Expand Up @@ -437,6 +440,13 @@
}
}
},
"tags": [],
"tags": [
{
"name": "body"
},
{
"name": "post"
}
],
"x-samchon-emended": true
}