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

Test program prints "Pass" for none API key cases #143

Merged
merged 1 commit into from
Feb 21, 2025
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@anthropic-ai/sdk": "^0.32.1",
"@google/generative-ai": "^0.21.0",
"@nestia/core": "4.2.0",
"@nestia/e2e": "0.7.0",
"@nestia/e2e": "0.8.2",
"@nestia/fetcher": "4.2.0",
"@nestia/sdk": "4.2.0",
"@nestjs/common": "^10.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,40 @@ import typia, { tags } from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { ChatGptFunctionCaller } from "../../../utils/ChatGptFunctionCaller";

export const test_chatgpt_function_calling_additionalProperties =
(): Promise<void> =>
ChatGptFunctionCaller.test({
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",
content: SYSTEM_MESSAGE,
},
{
role: "user",
content: USER_MESSAGE,
},
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/chatgpt.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
export const test_chatgpt_function_calling_additionalProperties = () =>
ChatGptFunctionCaller.test({
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",
content: SYSTEM_MESSAGE,
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/chatgpt.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
{
role: "user",
content: USER_MESSAGE,
},
});
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/chatgpt.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/chatgpt.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
},
});

interface IPerson {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import typia from "typia";

import { ChatGptFunctionCaller } from "../../../utils/ChatGptFunctionCaller";

export const test_chatgpt_function_calling_description_length = async () => {
await ChatGptFunctionCaller.test({
export const test_chatgpt_function_calling_description_length = () =>
ChatGptFunctionCaller.test({
config: {
reference: true,
},
Expand All @@ -25,7 +25,6 @@ export const test_chatgpt_function_calling_description_length = async () => {
typia.assert<IPerson>(input);
},
});
};

interface IPerson {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import OpenAI from "openai";

import { TestGlobal } from "../../../TestGlobal";

export const test_chatgpt_function_calling_empty = async (): Promise<void> => {
if (TestGlobal.env.CHATGPT_API_KEY === undefined) return;
export const test_chatgpt_function_calling_empty = async () => {
if (TestGlobal.env.CHATGPT_API_KEY === undefined) return false;

const client: OpenAI = new OpenAI({ apiKey: TestGlobal.env.CHATGPT_API_KEY });
const completion: OpenAI.ChatCompletion =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import typia from "typia";

import { ChatGptFunctionCaller } from "../../../utils/ChatGptFunctionCaller";

export const test_chatgpt_function_calling_name_length = async () => {
await ChatGptFunctionCaller.test({
export const test_chatgpt_function_calling_name_length = () =>
ChatGptFunctionCaller.test({
config: {
reference: true,
},
Expand All @@ -25,7 +25,6 @@ export const test_chatgpt_function_calling_name_length = async () => {
typia.assert<IPerson>(input);
},
});
};

interface IPerson {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IShoppingSale } from "../../../structures/IShoppingSale";
import { ChatGptFunctionCaller } from "../../../utils/ChatGptFunctionCaller";
import { ShoppingSalePrompt } from "../../../utils/ShoppingSalePrompt";

export const test_chatgpt_function_calling_sale = async (): Promise<void> =>
export const test_chatgpt_function_calling_sale = async () =>
ChatGptFunctionCaller.test({
config: {
reference: process.argv.includes("--reference"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { ChatGptFunctionCaller } from "../../../utils/ChatGptFunctionCaller";

export const test_chatgpt_function_calling_union = (): Promise<void> =>
export const test_chatgpt_function_calling_union = () =>
ChatGptFunctionCaller.test({
config: {
reference: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,41 @@ import typia, { tags } from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { ClaudeFunctionCaller } from "../../../utils/ClaudeFunctionCaller";

export const test_claude_function_calling_additionalProperties =
(): Promise<void> =>
ClaudeFunctionCaller.test({
model: "claude",
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",
content: SYSTEM_MESSAGE,
},
{
role: "user",
content: USER_MESSAGE,
},
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/claude.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
export const test_claude_function_calling_additionalProperties = () =>
ClaudeFunctionCaller.test({
model: "claude",
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",
content: SYSTEM_MESSAGE,
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/claude.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
{
role: "user",
content: USER_MESSAGE,
},
});
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/claude.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/claude.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
},
});

interface IPerson {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { TestValidator } from "@nestia/e2e";

import { TestGlobal } from "../../../TestGlobal";

export const test_claude_function_calling_empty = async (): Promise<void> => {
if (TestGlobal.env.CLAUDE_API_KEY === undefined) return;
export const test_claude_function_calling_empty = async () => {
if (TestGlobal.env.CLAUDE_API_KEY === undefined) return false;

const client: Anthropic = new Anthropic({
apiKey: TestGlobal.env.CLAUDE_API_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IShoppingSale } from "../../../structures/IShoppingSale";
import { ClaudeFunctionCaller } from "../../../utils/ClaudeFunctionCaller";
import { ShoppingSalePrompt } from "../../../utils/ShoppingSalePrompt";

export const test_claude_function_calling_sale = async (): Promise<void> =>
export const test_claude_function_calling_sale = async () =>
ClaudeFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "claude",
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia, { tags } from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { ClaudeFunctionCaller } from "../../../utils/ClaudeFunctionCaller";

export const test_claude_function_calling_tags = (): Promise<void> =>
export const test_claude_function_calling_tags = () =>
ClaudeFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "claude",
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { ClaudeFunctionCaller } from "../../../utils/ClaudeFunctionCaller";

export const test_claude_function_calling_union = (): Promise<void> =>
export const test_claude_function_calling_union = () =>
ClaudeFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "claude",
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,41 @@ import typia, { tags } from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { DeepSeekFunctionCaller } from "../../../utils/DeepSeekFunctionCaller";

export const test_deepseek_function_calling_additionalProperties =
(): Promise<void> =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
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",
content: SYSTEM_MESSAGE,
},
{
role: "user",
content: USER_MESSAGE,
},
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/deepseek.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
export const test_deepseek_function_calling_additionalProperties = () =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
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",
content: SYSTEM_MESSAGE,
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/deepseek.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
{
role: "user",
content: USER_MESSAGE,
},
});
],
handleParameters: async (parameters) => {
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/schemas/deepseek.additionalProperties.schema.json`,
JSON.stringify(parameters, null, 2),
"utf8",
);
},
handleCompletion: async (input) => {
typia.assert<IPerson>(input);
if (process.argv.includes("--file"))
await fs.promises.writeFile(
`${TestGlobal.ROOT}/examples/function-calling/arguments/deepseek.additionalProperties.input.json`,
JSON.stringify(input, null, 2),
"utf8",
);
},
});

interface IPerson {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import OpenAI from "openai";

import { TestGlobal } from "../../../TestGlobal";

export const test_deepseek_function_calling_empty = async (): Promise<void> => {
if (TestGlobal.env.LLAMA_API_KEY === undefined) return;
export const test_deepseek_function_calling_empty = async () => {
if (TestGlobal.env.LLAMA_API_KEY === undefined) return false;

const client: OpenAI = new OpenAI({
apiKey: TestGlobal.env.LLAMA_API_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { DeepSeekFunctionCaller } from "../../../utils/DeepSeekFunctionCaller";

export const test_deepseek_function_calling_nullable = (): Promise<void> =>
export const test_deepseek_function_calling_nullable = () =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IShoppingSale } from "../../../structures/IShoppingSale";
import { DeepSeekFunctionCaller } from "../../../utils/DeepSeekFunctionCaller";
import { ShoppingSalePrompt } from "../../../utils/ShoppingSalePrompt";

export const test_deepseek_function_calling_sale = async (): Promise<void> =>
export const test_deepseek_function_calling_sale = async () =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
...ShoppingSalePrompt.schema(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia, { tags } from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { DeepSeekFunctionCaller } from "../../../utils/DeepSeekFunctionCaller";

export const test_deepseek_function_calling_tags = (): Promise<void> =>
export const test_deepseek_function_calling_tags = () =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
name: "reserve",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import typia from "typia";
import { TestGlobal } from "../../../TestGlobal";
import { DeepSeekFunctionCaller } from "../../../utils/DeepSeekFunctionCaller";

export const test_deepseek_function_calling_union = (): Promise<void> =>
export const test_deepseek_function_calling_union = () =>
DeepSeekFunctionCaller.test({
model: (TestGlobal.getArguments("model")[0] as any) ?? "chatgpt",
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { TestValidator } from "@nestia/e2e";

import { TestGlobal } from "../../../TestGlobal";

export const test_gemini_function_calling_empty = async (): Promise<void> => {
if (TestGlobal.env.GEMINI_API_KEY === undefined) return;
export const test_gemini_function_calling_empty = async () => {
if (TestGlobal.env.GEMINI_API_KEY === undefined) return false;

const model: GenerativeModel = new GoogleGenerativeAI(
TestGlobal.env.GEMINI_API_KEY,
Expand Down
Loading