import type {
ToolFunction,
ToolFunctionDefinition,
FunctionSchema,
FunctionRequestHttp,
FunctionRequestRetry
} from '@adaline/api';
// Define retry configuration
const retry: FunctionRequestRetry = {
maxAttempts: 3,
initialDelay: 1000,
exponentialFactor: 2
};
// Define HTTP request
const request: FunctionRequestHttp = {
type: 'http',
method: 'post',
url: 'https://api.weather.com/current',
headers: {
'Authorization': 'Bearer sk_abc123',
'Content-Type': 'application/json'
},
body: {
city: '{{city}}',
units: '{{units}}'
},
retry
};
// Define function schema
const schema: FunctionSchema = {
name: 'get_weather',
description: 'Get current weather for a city',
parameters: {
type: 'object',
properties: {
city: {
type: 'string',
description: 'City name'
},
units: {
type: 'string',
enum: ['celsius', 'fahrenheit'],
default: 'celsius'
}
},
required: ['city']
}
};
// Complete tool definition
const tool: ToolFunction = {
type: 'function',
definition: { schema },
request
};
// Use in deployment
const deployment = await adaline.getLatestDeployment({
promptId: 'prompt_with_tools',
deploymentEnvironmentId: 'production'
});
console.log(`Tools available: ${deployment.prompt.tools.length}`);
deployment.prompt.tools.forEach(t => {
const fn = t.definition.schema;
console.log(` - ${fn.name}: ${fn.description}`);
});