Skip to content

Commit

Permalink
Merge pull request #111 from samchon/feat/test
Browse files Browse the repository at this point in the history
Enhance function calling test functions
  • Loading branch information
samchon authored Dec 13, 2024
2 parents 63428dd + f3fb958 commit ab3fc2c
Show file tree
Hide file tree
Showing 29 changed files with 234 additions and 77 deletions.
45 changes: 24 additions & 21 deletions examples/function-calling/arguments/claude.sale.input.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,16 @@
"code": "samchon",
"category_codes": [
"electronics",
"2in1_laptops",
"windows_tablets"
"laptops",
"2in1_laptops"
]
}
],
"tags": [
"Surface Pro",
"2-in-1",
"Windows",
"Laptop",
"Tablet"
],
"units": [
{
"name": "Surface Pro 9 Entity",
"required": true,
"primary": true,
"required": true,
"options": [
{
"type": "select",
Expand Down Expand Up @@ -100,7 +93,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 +115,7 @@
]
},
{
"name": "Surface Pro 9 - i3/16GB/256GB",
"name": "Surface Pro 9 (i3/16GB/256GB)",
"price": {
"nominal": 1200000,
"real": 1099000
Expand All @@ -144,7 +137,7 @@
]
},
{
"name": "Surface Pro 9 - i3/16GB/512GB",
"name": "Surface Pro 9 (i3/16GB/512GB)",
"price": {
"nominal": 1400000,
"real": 1299000
Expand All @@ -166,7 +159,7 @@
]
},
{
"name": "Surface Pro 9 - i5/16GB/256GB",
"name": "Surface Pro 9 (i5/16GB/256GB)",
"price": {
"nominal": 1500000,
"real": 1399000
Expand All @@ -188,7 +181,7 @@
]
},
{
"name": "Surface Pro 9 - i5/32GB/512GB",
"name": "Surface Pro 9 (i5/32GB/512GB)",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -210,7 +203,7 @@
]
},
{
"name": "Surface Pro 9 - i7/16GB/512GB",
"name": "Surface Pro 9 (i7/16GB/512GB)",
"price": {
"nominal": 1800000,
"real": 1699000
Expand All @@ -232,7 +225,7 @@
]
},
{
"name": "Surface Pro 9 - i7/32GB/512GB",
"name": "Surface Pro 9 (i7/32GB/512GB)",
"price": {
"nominal": 2000000,
"real": 1899000
Expand All @@ -257,12 +250,12 @@
},
{
"name": "Warranty Program",
"required": false,
"primary": false,
"required": false,
"options": [],
"stocks": [
{
"name": "Surface Pro 9 Warranty Program",
"name": "Warranty Program",
"price": {
"nominal": 100000,
"real": 89000
Expand All @@ -274,12 +267,12 @@
},
{
"name": "Magnetic Keyboard",
"required": false,
"primary": false,
"required": false,
"options": [],
"stocks": [
{
"name": "Surface Pro 9 Magnetic Keyboard",
"name": "Magnetic Keyboard",
"price": {
"nominal": 200000,
"real": 169000
Expand All @@ -289,5 +282,15 @@
}
]
}
],
"tags": [
"Surface",
"Pro",
"9",
"Microsoft",
"2-in-1",
"Tablet",
"Laptop",
"Windows"
]
}
12 changes: 6 additions & 6 deletions examples/function-calling/schemas/claude.sale.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,16 @@
},
"minItems": 1
},
"name": {
"title": "Representative name of the unit",
"description": "Representative name of the unit.",
"type": "string"
},
"required": {
"title": "Whether the unit is required or not",
"description": "Whether the unit is required or not.\n\nWhen the unit is required, the customer must select the unit. If do not\nselect, customer can't buy it.\n\nFor example, if there's a sale \"Macbook Set\" and one of the unit is the\n\"Main Body\", is it possible to buy the \"Macbook Set\" without the\n\"Main Body\" unit? This property is for that case.",
"type": "boolean"
},
"name": {
"title": "Representative name of the unit",
"description": "Representative name of the unit.",
"type": "string"
},
"primary": {
"title": "Whether the unit is primary or not",
"description": "Whether the unit is primary or not.\n\nJust a labeling value.",
Expand All @@ -346,8 +346,8 @@
"required": [
"options",
"stocks",
"name",
"required",
"name",
"primary"
]
},
Expand Down
12 changes: 6 additions & 6 deletions examples/function-calling/schemas/llama.sale.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,16 @@
},
"minItems": 1
},
"name": {
"title": "Representative name of the unit",
"description": "Representative name of the unit.",
"type": "string"
},
"required": {
"title": "Whether the unit is required or not",
"description": "Whether the unit is required or not.\n\nWhen the unit is required, the customer must select the unit. If do not\nselect, customer can't buy it.\n\nFor example, if there's a sale \"Macbook Set\" and one of the unit is the\n\"Main Body\", is it possible to buy the \"Macbook Set\" without the\n\"Main Body\" unit? This property is for that case.",
"type": "boolean"
},
"name": {
"title": "Representative name of the unit",
"description": "Representative name of the unit.",
"type": "string"
},
"primary": {
"title": "Whether the unit is primary or not",
"description": "Whether the unit is primary or not.\n\nJust a labeling value.",
Expand All @@ -346,8 +346,8 @@
"required": [
"options",
"stocks",
"name",
"required",
"name",
"primary"
]
},
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,38 @@
"devDependencies": {
"@anthropic-ai/sdk": "^0.32.1",
"@google/generative-ai": "^0.21.0",
"@nestia/core": "4.0.0-dev.20241116",
"@nestia/core": "4.2.0",
"@nestia/e2e": "0.7.0",
"@nestia/fetcher": "4.0.0-dev.20241116",
"@nestia/sdk": "4.0.0-dev.20241116",
"@nestia/fetcher": "4.2.0",
"@nestia/sdk": "4.2.0",
"@nestjs/common": "^10.4.1",
"@nestjs/core": "^10.4.1",
"@nestjs/platform-express": "^10.4.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/js-yaml": "^4.0.9",
"@types/multer": "^1.4.12",
"@types/node": "^20.12.7",
"@types/uuid": "^10.0.0",
"axios": "^1.7.7",
"chalk": "^4.1.2",
"dotenv": "^16.4.5",
"dotenv-expand": "^12.0.0",
"js-yaml": "^4.1.0",
"multer": "^1.4.5-lts.1",
"nestia": "^6.0.1",
"openai": "^4.72.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup": "^4.18.1",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"ts-patch": "^3.2.1",
"ts-patch": "^3.3.0",
"tstl": "^3.0.0",
"typescript": "~5.6.3",
"typescript-transform-paths": "^3.4.7",
"typia": "7.0.0-dev.20241201",
"typescript": "~5.7.2",
"typescript-transform-paths": "^3.5.2",
"typia": "7.3.0",
"uuid": "^10.0.0"
},
"sideEffects": false,
Expand Down
3 changes: 2 additions & 1 deletion test/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TypedRoute,
} from "@nestia/core";
import { Controller, Query } from "@nestjs/common";
import Multer from "multer";
import { tags } from "typia";

@Controller()
Expand Down Expand Up @@ -76,7 +77,7 @@ export class AppController {
@TypedParam("level") level: number,
@TypedParam("optimal") optimal: boolean,
@TypedQuery() query: IQuery,
@TypedFormData.Body()
@TypedFormData.Body(() => Multer())
body: IMultipart,
) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const test_chatgpt_function_calling_default = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[IParameters]>(),
validate: typia.createValidate<IParameters>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const test_chatgpt_function_calling_example = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const test_chatgpt_function_calling_recursive = () =>
name: "composeCategories",
description: "Compose categories from the input.",
collection: typia.json.schemas<[{ input: IShoppingCategory[] }]>(),
validate: typia.createValidate<[{ input: IShoppingCategory[] }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const test_chatgpt_function_calling_union = (): Promise<void> =>
name: "draw",
description: "Draw a shape with following geometry.",
collection: typia.json.schemas<[{ input: Shape }]>(),
validate: typia.createValidate<[{ input: Shape }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const test_claude_function_calling_additionalProperties =
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_claude_function_calling_default = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_claude_function_calling_example = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_claude_function_calling_recursive = () =>
name: "composeCategories",
description: "Compose categories from the input.",
collection: typia.json.schemas<[{ input: IShoppingCategory[] }]>(),
validate: typia.createValidate<[{ input: IShoppingCategory[] }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_claude_function_calling_tags = (): Promise<void> =>
name: "reserve",
description: "Reserve some opening time.",
collection: typia.json.schemas<[{ input: OpeningTime }]>(),
validate: typia.createValidate<[{ input: OpeningTime }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_claude_function_calling_union = (): Promise<void> =>
name: "draw",
description: "Draw a shape with following geometry.",
collection: typia.json.schemas<[{ input: Shape }]>(),
validate: typia.createValidate<[{ input: Shape }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const test_gemini_function_calling_default = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const test_gemini_function_calling_example = (): Promise<void> =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const test_llama_function_calling_additionalProperties =
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const test_llama_function_calling_default = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const test_llama_function_calling_example = () =>
name: "enrollPerson",
description: "Enroll a person to the restaurant reservation list.",
collection: typia.json.schemas<[{ input: IPerson }]>(),
validate: typia.createValidate<[{ input: IPerson }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const test_llama_function_calling_nullable = (): Promise<void> =>
name: "drawPolygon",
description: "Draw a polygon with given geometry.",
collection: typia.json.schemas<[{ input: IPolygon }]>(),
validate: typia.createValidate<[{ input: IPolygon }]>(),
texts: [
{
role: "assistant",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const test_llama_function_calling_recursive = () =>
name: "composeCategories",
description: "Compose categories from the input.",
collection: typia.json.schemas<[{ input: IShoppingCategory[] }]>(),
validate: typia.createValidate<[{ input: IShoppingCategory[] }]>(),
texts: [
{
role: "assistant",
Expand Down
Loading

0 comments on commit ab3fc2c

Please sign in to comment.