1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "request": {
12 "task_contract": {
13 "goal_id": "sentiment-score/v1",
14 "input_schema": {
15 "type": "object",
16 "properties": {
17 "text": {
18 "type": "string",
19 "minLength": 1,
20 "maxLength": 100
21 }
22 },
23 "required": [
24 "text"
25 ],
26 "additionalProperties": false
27 },
28 "output_schema": {
29 "type": "object",
30 "properties": {
31 "score": {
32 "type": "number",
33 "minimum": 0,
34 "maximum": 1
35 }
36 },
37 "required": [
38 "score"
39 ],
40 "additionalProperties": false
41 },
42 "output_semantics": {
43 "score": "positive_sentiment_probability/v1"
44 },
45 "allowed_side_effects": [],
46 "invariants": [
47 {
48 "id": "bounded-score",
49 "field": "score",
50 "constraint": {
51 "type": "number",
52 "minimum": 0,
53 "maximum": 1
54 }
55 }
56 ],
57 "comparison_fields": [
58 "score"
59 ],
60 "minimum_fixtures": 2
61 },
62 "incumbent_capability": {
63 "id": "provider-a/v1",
64 "goal_id": "sentiment-score/v1",
65 "input_schema": {
66 "type": "object",
67 "properties": {
68 "text": {
69 "type": "string",
70 "minLength": 1,
71 "maxLength": 100
72 }
73 },
74 "required": [
75 "text"
76 ],
77 "additionalProperties": false
78 },
79 "output_schema": {
80 "type": "object",
81 "properties": {
82 "score": {
83 "type": "number",
84 "minimum": 0,
85 "maximum": 1
86 }
87 },
88 "required": [
89 "score"
90 ],
91 "additionalProperties": false
92 },
93 "output_semantics": {
94 "score": "positive_sentiment_probability/v1"
95 },
96 "side_effects": []
97 },
98 "candidate_capability": {
99 "id": "provider-b/v1",
100 "goal_id": "sentiment-score/v1",
101 "input_schema": {
102 "type": "object",
103 "properties": {
104 "text": {
105 "type": "string",
106 "minLength": 1,
107 "maxLength": 100
108 }
109 },
110 "required": [
111 "text"
112 ],
113 "additionalProperties": false
114 },
115 "output_schema": {
116 "type": "object",
117 "properties": {
118 "score": {
119 "type": "number",
120 "minimum": 0,
121 "maximum": 1
122 }
123 },
124 "required": [
125 "score"
126 ],
127 "additionalProperties": false
128 },
129 "output_semantics": {
130 "score": "positive_sentiment_probability/v1"
131 },
132 "side_effects": []
133 },
134 "fixtures": [
135 {
136 "id": "positive",
137 "input": {
138 "text": "good"
139 },
140 "incumbent_output": {
141 "score": 0.9
142 },
143 "candidate_output": {
144 "score": 0.9
145 },
146 "incumbent_side_effects": [],
147 "candidate_side_effects": []
148 },
149 {
150 "id": "negative",
151 "input": {
152 "text": "bad"
153 },
154 "incumbent_output": {
155 "score": 0.1
156 },
157 "candidate_output": {
158 "score": 0.1
159 },
160 "incumbent_side_effects": [],
161 "candidate_side_effects": []
162 }
163 ]
164 }
165};
166
167
168const run = await client.actor("bono718/agent-capability-substitution-resolver").call(input);
169
170
171console.log('Results from dataset');
172console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
173const { items } = await client.dataset(run.defaultDatasetId).listItems();
174items.forEach((item) => {
175 console.dir(item);
176});
177
178