Documentation IndexFetch the complete documentation index at: /docs/llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
interface ToolFunction { type: 'function'; definition: ToolFunctionDefinition; request?: FunctionRequestHttp | null; }
const tool: ToolFunction = { type: 'function', definition: { schema: { name: 'get_weather', description: 'Get current weather', parameters: { type: 'object', properties: { city: { type: 'string' } }, required: ['city'] } } } };
interface ToolFunctionDefinition { schema: FunctionSchema; }
const definition: ToolFunctionDefinition = { schema: { name: 'search_database', description: 'Search internal database', parameters: { type: 'object', properties: { query: { type: 'string', description: 'Search query' }, limit: { type: 'number', default: 10 } }, required: ['query'] } } };
interface FunctionSchema { name: string; // pattern: ^[a-zA-Z0-9_]{1,64}$ description: string; // max 4096 chars parameters: any; // JSON schema strict?: boolean | null; }
const weatherFunction: 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', description: 'Temperature units' } }, required: ['city'] }, strict: true };
{ "name": "get_weather", "description": "Get weather for a city", "parameters": { "type": "object", "properties": { "city": { "type": "string" } }, "required": ["city"] } }
interface FunctionRequestHttp { type: 'http'; method: 'get' | 'post'; url: string; headers?: Record<string, string> | null; query?: Record<string, string> | null; body?: Record<string, any> | null; proxyUrl?: string | null; proxyHeaders?: Record<string, string> | null; retry?: FunctionRequestRetry | null; }
const httpRequest: FunctionRequestHttp = { type: 'http', method: 'post', url: 'https://api.weather.com/v1/current', headers: { 'Authorization': 'Bearer {{API_KEY}}', 'Content-Type': 'application/json' }, query: { 'units': 'metric' }, body: { location: '{{city}}' }, retry: { maxAttempts: 3, initialDelay: 1000, exponentialFactor: 2 } };
{ "type": "http", "method": "post", "url": "https://api.example.com/function", "headers": { "Authorization": "Bearer token" }, "retry": { "maxAttempts": 3, "initialDelay": 1000, "exponentialFactor": 2 } }
interface FunctionRequestRetry { maxAttempts: number; // minimum: 1 initialDelay: number; // minimum: 1 (milliseconds) exponentialFactor: number; // minimum: 1 }
const retryConfig: FunctionRequestRetry = { maxAttempts: 3, initialDelay: 1000, // Start with 1 second exponentialFactor: 2 // Double each retry: 1s, 2s, 4s }; // More aggressive const aggressiveRetry: FunctionRequestRetry = { maxAttempts: 5, initialDelay: 500, exponentialFactor: 3 // 0.5s, 1.5s, 4.5s, 13.5s, 40.5s };
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}`); });
Was this page helpful?