@sinch/mcp
Version:
Sinch MCP server
60 lines • 2.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const genai_1 = require("@google/genai");
const list_tools_1 = require("../list-tools");
const toolsTestCases_1 = require("../toolsTestCases");
const configuration_1 = require("../configuration");
const transformToGeminiFormat = (tools) => {
return tools.map((t) => ({
functionDeclarations: [
{
name: t.name,
description: t.description,
parametersJsonSchema: t.inputSchema,
}
]
}));
};
const targetModel = process.env.TARGET_MODEL || 'gemini-2.0-flash';
describe(`Tool invocation tests - Gemini - ${targetModel}`, () => {
let tools;
let gemini;
beforeAll(async () => {
tools = transformToGeminiFormat(await (0, list_tools_1.listTools)());
gemini = new genai_1.GoogleGenAI({
apiKey: process.env.GEMINI_API_KEY,
});
});
it.each(toolsTestCases_1.toolTestCases)('should handle prompt "%s"', async ({ prompt, expectedToolName, expectedArguments }) => {
const response = await gemini.models.generateContent({
model: targetModel,
contents: {
text: prompt
},
config: {
maxOutputTokens: configuration_1.MAX_TOKENS,
temperature: configuration_1.TEMPERATURE,
tools: tools,
toolConfig: {
functionCallingConfig: {
mode: genai_1.FunctionCallingConfigMode.AUTO
}
}
},
});
expect(response.candidates).toBeDefined();
const toolCall = response.candidates
?.map(c => c.content?.parts?.find(p => p.functionCall)?.functionCall)
.find(fc => fc !== undefined);
if (!expectedToolName) {
expect(toolCall).toBeUndefined();
return;
}
expect(toolCall).toBeDefined();
expect(toolCall.name).toEqual(expectedToolName);
if (expectedArguments) {
expect(toolCall.args).toEqual(expectedArguments);
}
}, configuration_1.TIMEOUT);
});
//# sourceMappingURL=gemini.int.test.js.map