1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "tool_usage_logs": [
12 {
13 "tool_id": "docs_search",
14 "usage_count": 120,
15 "success_count": 116,
16 "avg_latency_ms": 180,
17 "p95_latency_ms": 320,
18 "avg_cost_usd": 0.0012,
19 "task_types": [
20 "knowledge_search"
21 ]
22 },
23 {
24 "tool_id": "web_search",
25 "usage_count": 40,
26 "success_count": 34,
27 "avg_latency_ms": 850,
28 "p95_latency_ms": 1400,
29 "avg_cost_usd": 0.008,
30 "task_types": [
31 "knowledge_search",
32 "current_web_research"
33 ]
34 }
35 ]
36};
37
38
39const run = await client.actor("quanmatrix/ai-agent-tool-selection-optimizer").call(input);
40
41
42console.log('Results from dataset');
43console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
44const { items } = await client.dataset(run.defaultDatasetId).listItems();
45items.forEach((item) => {
46 console.dir(item);
47});
48
49