1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = { "request": {
9 "task_contract": {
10 "goal_id": "sentiment-score/v1",
11 "input_schema": {
12 "type": "object",
13 "properties": { "text": {
14 "type": "string",
15 "minLength": 1,
16 "maxLength": 100,
17 } },
18 "required": ["text"],
19 "additionalProperties": False,
20 },
21 "output_schema": {
22 "type": "object",
23 "properties": { "score": {
24 "type": "number",
25 "minimum": 0,
26 "maximum": 1,
27 } },
28 "required": ["score"],
29 "additionalProperties": False,
30 },
31 "output_semantics": { "score": "positive_sentiment_probability/v1" },
32 "allowed_side_effects": [],
33 "invariants": [{
34 "id": "bounded-score",
35 "field": "score",
36 "constraint": {
37 "type": "number",
38 "minimum": 0,
39 "maximum": 1,
40 },
41 }],
42 "comparison_fields": ["score"],
43 "minimum_fixtures": 2,
44 },
45 "incumbent_capability": {
46 "id": "provider-a/v1",
47 "goal_id": "sentiment-score/v1",
48 "input_schema": {
49 "type": "object",
50 "properties": { "text": {
51 "type": "string",
52 "minLength": 1,
53 "maxLength": 100,
54 } },
55 "required": ["text"],
56 "additionalProperties": False,
57 },
58 "output_schema": {
59 "type": "object",
60 "properties": { "score": {
61 "type": "number",
62 "minimum": 0,
63 "maximum": 1,
64 } },
65 "required": ["score"],
66 "additionalProperties": False,
67 },
68 "output_semantics": { "score": "positive_sentiment_probability/v1" },
69 "side_effects": [],
70 },
71 "candidate_capability": {
72 "id": "provider-b/v1",
73 "goal_id": "sentiment-score/v1",
74 "input_schema": {
75 "type": "object",
76 "properties": { "text": {
77 "type": "string",
78 "minLength": 1,
79 "maxLength": 100,
80 } },
81 "required": ["text"],
82 "additionalProperties": False,
83 },
84 "output_schema": {
85 "type": "object",
86 "properties": { "score": {
87 "type": "number",
88 "minimum": 0,
89 "maximum": 1,
90 } },
91 "required": ["score"],
92 "additionalProperties": False,
93 },
94 "output_semantics": { "score": "positive_sentiment_probability/v1" },
95 "side_effects": [],
96 },
97 "fixtures": [
98 {
99 "id": "positive",
100 "input": { "text": "good" },
101 "incumbent_output": { "score": 0.9 },
102 "candidate_output": { "score": 0.9 },
103 "incumbent_side_effects": [],
104 "candidate_side_effects": [],
105 },
106 {
107 "id": "negative",
108 "input": { "text": "bad" },
109 "incumbent_output": { "score": 0.1 },
110 "candidate_output": { "score": 0.1 },
111 "incumbent_side_effects": [],
112 "candidate_side_effects": [],
113 },
114 ],
115 } }
116
117
118run = client.actor("bono718/agent-capability-substitution-resolver").call(run_input=run_input)
119
120
121print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
122for item in client.dataset(run.default_dataset_id).iterate_items():
123 print(item)
124
125