Skip to content

Commit

Permalink
Add ILlmFunction.tags properties for categorization.
Browse files Browse the repository at this point in the history
It would be helpful for indicating the function's category.
  • Loading branch information
samchon committed Sep 25, 2024
1 parent 409f052 commit 5b8633e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
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
}

0 comments on commit 5b8633e

Please sign in to comment.