Skip to content

Commit

Permalink
Merge pull request #1442 from samchon/feat/llm
Browse files Browse the repository at this point in the history
Fix `ILlmFunction.parameters.description` problem.
  • Loading branch information
samchon authored Dec 22, 2024
2 parents 81ab371 + 8208b96 commit a11ce3d
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "7.5.0",
"version": "7.5.1",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
11 changes: 8 additions & 3 deletions src/programmers/llm/LlmApplicationProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,14 @@ export namespace LlmApplicationProgrammer {
> = LlmSchemaComposer.parameters(props.model)({
config: LlmSchemaComposer.defaultConfig(props.model) as any,
components: props.components,
schema: schema as
| OpenApi.IJsonSchema.IObject
| OpenApi.IJsonSchema.IReference,
schema: {
...(schema as
| OpenApi.IJsonSchema.IObject
| OpenApi.IJsonSchema.IReference),
title: schema.title ?? props.function.parameters[0]?.title,
description:
schema.description ?? props.function.parameters[0]?.description,
},
accessor: props.accessor,
}) as IResult<ILlmSchema.ModelParameters[Model], IOpenApiSchemaError>;
if (result.success === false) {
Expand Down
17 changes: 0 additions & 17 deletions test/src/debug/llm.application.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { ILlmApplication, ILlmFunction } from "@samchon/openapi";
import typia, { tags } from "typia";

import { TestValidator } from "../../helpers/TestValidator";

export const test_pr_1442_llm_function_parameters_description = (): void => {
const app: ILlmApplication<"chatgpt"> = typia.llm.application<
BbsArticleController,
"chatgpt"
>();
for (const func of app.functions)
TestValidator.equals("parameters.description")(
!!func.parameters.description,
)(true);

const func: ILlmFunction<"chatgpt"> | undefined = app.functions.find(
(func) => func.name === "create",
);
TestValidator.equals("parameters.description")(
!!func?.parameters.description,
)(true);
TestValidator.equals("output.description")(!!func?.output?.description)(true);
};

interface BbsArticleController {
/**
* Create a new article.
*
* Writes a new article and archives it into the DB.
*
* @param props Properties of create function
* @returns Newly created article
*/
create(props: {
/**
* Information of the article to create
*/
input: IBbsArticle.ICreate;
}): Promise<IBbsArticle>;

/**
* Update an article.
*
* Updates an article with new content.
*
* @param props Properties of update function
* @param input New content to update
*/
update(props: {
/**
* Target article's {@link IBbsArticle.id}.
*/
id: string & tags.Format<"uuid">;

/**
* New content to update.
*/
input: IBbsArticle.IUpdate;
}): Promise<void>;

/**
* Erase an article.
*
* Erases an article from the DB.
*
* @param props Properties of erase function
*/
erase(props: {
/**
* Target article's {@link IBbsArticle.id}.
*/
id: string & tags.Format<"uuid">;
}): Promise<void>;
}

/**
* Article entity.
*
* `IBbsArticle` is an entity representing an article in the BBS (Bulletin Board System).
*/
interface IBbsArticle extends IBbsArticle.ICreate {
/**
* Primary Key.
*/
id: string & tags.Format<"uuid">;

/**
* Creation time of the article.
*/
created_at: string & tags.Format<"date-time">;

/**
* Last updated time of the article.
*/
updated_at: string & tags.Format<"date-time">;
}
namespace IBbsArticle {
/**
* Information of the article to create.
*/
export interface ICreate {
/**
* Title of the article.
*
* Representative title of the article.
*/
title: string;

/**
* Content body.
*
* Content body of the article writtn in the markdown format.
*/
body: string;

/**
* Thumbnail image URI.
*
* Thumbnail image URI which can represent the article.
*
* If configured as `null`, it means that no thumbnail image in the article.
*/
thumbnail:
| null
| (string & tags.Format<"uri"> & tags.ContentMediaType<"image/*">);
}

/**
* Information of the article to update.
*
* Only the filled properties will be updated.
*/
export type IUpdate = Partial<ICreate>;
}

0 comments on commit a11ce3d

Please sign in to comment.