1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "rows": [
12 {
13 "id": "r1",
14 "product": "Steel kettle",
15 "text": "Boils fast and the handle stays cool. Exactly what I wanted for the price."
16 },
17 {
18 "id": "r2",
19 "product": "Steel kettle",
20 "text": "Started leaking from the base after two weeks, and support never answered my emails."
21 },
22 {
23 "id": "r3",
24 "product": "Desk lamp",
25 "text": "Lovely warm light and easy to assemble, but the switch feels flimsy."
26 }
27 ],
28 "textFields": [
29 "text"
30 ],
31 "labels": [
32 "positive",
33 "negative",
34 "mixed"
35 ],
36 "model": "openai/gpt-4.1-mini",
37 "keepFields": [
38 "id"
39 ]
40};
41
42
43const run = await client.actor("humble-echidna/ai-rows").call(input);
44
45
46console.log('Results from dataset');
47console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
48const { items } = await client.dataset(run.defaultDatasetId).listItems();
49items.forEach((item) => {
50 console.dir(item);
51});
52
53