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