1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "items": [
12 {
13 "id": 1,
14 "product": "Wireless earbuds",
15 "rating": 5,
16 "review": "Great sound for the price and the battery lasts two full days. Pairing took seconds."
17 },
18 {
19 "id": 2,
20 "product": "Wireless earbuds",
21 "rating": 2,
22 "review": "The left earbud stopped charging after three weeks. Support has not answered my emails."
23 },
24 {
25 "id": 3,
26 "product": "Standing desk",
27 "rating": 4,
28 "review": "Sturdy and easy to assemble. The motor is a bit loud when the desk goes up."
29 },
30 {
31 "id": 4,
32 "product": "Standing desk",
33 "rating": 1,
34 "review": "Arrived with a scratched top and two screws missing. I am sending it back."
35 },
36 {
37 "id": 5,
38 "product": "Coffee grinder",
39 "rating": 3,
40 "review": "Grinds evenly, but cleaning it is a chore and the lid feels flimsy."
41 }
42 ],
43 "instruction": "Classify the sentiment of the review and name the main complaint in at most 8 words.",
44 "outputFields": [
45 {
46 "name": "sentiment",
47 "type": "category",
48 "options": [
49 "positive",
50 "neutral",
51 "negative"
52 ],
53 "description": "Overall tone of the review"
54 },
55 {
56 "name": "mainComplaint",
57 "type": "text",
58 "description": "The main complaint in at most 8 words"
59 }
60 ]
61};
62
63
64const run = await client.actor("istmobot/ai-data-enricher").call(input);
65
66
67console.log('Results from dataset');
68console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
69const { items } = await client.dataset(run.defaultDatasetId).listItems();
70items.forEach((item) => {
71 console.dir(item);
72});
73
74