import Inception from 'inceptionai';
const client = new Inception(); // reads INCEPTION_API_KEY from the environment
const tools = [
{
type: 'function',
function: {
name: 'get_weather',
description: 'Get the current weather in a given location',
parameters: {
type: 'object',
properties: {
location: { type: 'string', description: "City and state, e.g., 'San Francisco, CA'" },
unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
},
required: ['location', 'unit'],
},
},
},
];
const completion = await client.chat.completions.create({
model: 'mercury-2',
messages: [{ role: 'user', content: "What's the weather like in San Francisco?" }],
tools,
});
const toolCall = completion.choices[0]?.message.tool_calls?.[0]?.function;
console.log(`Function called: ${toolCall?.name}`);
console.log(`Arguments: ${toolCall?.arguments}`);