Ce Este Function Calling
Function calling permite AI-ului să execute acțiuni reale: să caute în CRM, să programeze întâlniri, să verifice stocuri. Transformă conversația în acțiune.
Function Types
| Type | Examples | Typical Latency |
|---|---|---|
| Data Retrieval | CRM lookup, order status, inventory check | Low (100-500ms) |
| Actions | Book appointment, send email, create ticket | Medium (500-2000ms) |
| Calculations | Price quote, availability check | Low (50-200ms) |
| External APIs | Weather, shipping rates, payment | Variable |
Function Definition Example
const functions = [{
name: "get_order_status",
description: "Retrieve the current status of a customer order. Use when customer asks about their order, delivery, or shipment.",
parameters: {
type: "object",
properties: {
order_id: {
type: "string",
description: "Order ID (format: ORD-XXXXX or just the numbers)"
},
customer_email: {
type: "string",
description: "Customer email for verification (optional)"
}
},
required: ["order_id"]
}
}];
// Handler function
async function get_order_status({ order_id, customer_email }) {
try {
const order = await db.orders.findOne({
id: normalizeOrderId(order_id)
});
if (!order) {
return { error: "Order not found", suggestion: "verify_order_id" };
}
return {
status: order.status,
estimated_delivery: order.eta,
tracking_number: order.tracking,
last_update: order.updated_at
};
} catch (error) {
return { error: "System temporarily unavailable" };
}
}Execution Flow
Best Practices
Clear Descriptions
Write detailed function descriptions - LLM uses them to decide when to call
Validate Parameters
Validate all parameters before execution to avoid errors
Handle Timeouts
Set reasonable timeouts (3-5s) and have fallback messages
Parallel When Possible
Use parallel function calling for independent operations
Graceful Errors
Return helpful error messages the AI can relay to user
Kallina: Pre-Built Functions
Library de funcții pentru CRM, calendar, ticketing și mai mult.
Vezi Demo →