1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "items": [
10 {
11 "product": "Wireless earbuds",
12 "review": "Battery lasts all day and pairing was instant. Best purchase this year!",
13 "rating": 5,
14 },
15 {
16 "product": "Wireless earbuds",
17 "review": "Left earbud stopped working after two weeks. Support never answered my emails.",
18 "rating": 1,
19 },
20 {
21 "product": "Coffee grinder",
22 "review": "Grinds evenly but it is louder than I expected. Fine for the price.",
23 "rating": 3,
24 },
25 {
26 "product": "Coffee grinder",
27 "review": "Package arrived three days late and the box was crushed, but the grinder itself works.",
28 "rating": 3,
29 },
30 {
31 "product": "Desk lamp",
32 "review": "Lámpara preciosa, luz cálida y muy buena calidad. La recomiendo.",
33 "rating": 5,
34 },
35 ],
36 "maxRows": 5,
37 "prompt": """Analyze this customer review.
38Product: {{product}}
39Stars: {{rating}}
40Review: {{review}}""",
41 "outputMode": "json",
42 "outputFields": {
43 "sentiment": "positive|negative|neutral|mixed",
44 "mainTopic": "short topic, e.g. battery, shipping, noise, quality",
45 "needsReply": "boolean - true if customer support should respond",
46 "replyDraft": "one polite sentence the shop could reply with, in the review's language",
47 },
48}
49
50
51run = client.actor("gazidev/bulk-ai-dataset-enricher").call(run_input=run_input)
52
53
54print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
55for item in client.dataset(run.default_dataset_id).iterate_items():
56 print(item)
57
58