onairos 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -14
- package/package.json +1 -1
- package/src/onairos.jsx +4 -3
package/README.md
CHANGED
|
@@ -18,31 +18,45 @@ npm install onairos
|
|
|
18
18
|
First create the Request Object which Users will Authorize (or not) in the extension popup
|
|
19
19
|
```json
|
|
20
20
|
"RequestObject":{
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"Small": {
|
|
22
|
+
"type":"Personality",
|
|
23
23
|
"descriptions":"Insight into your Interests",
|
|
24
24
|
"reward":"10% Discount"
|
|
25
25
|
},
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"Medium":{
|
|
27
|
+
"type":"Personality",
|
|
28
28
|
"descriptions":"Insight into your Interests",
|
|
29
29
|
"reward":"2 USDC"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"Large":{
|
|
32
|
+
"type":"Personality",
|
|
33
33
|
"descriptions":"Insight into your Interests",
|
|
34
34
|
"reward":"2 USDC"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
|
|
39
|
+
RequestObject.size key:
|
|
40
|
+
Small - Upto 16 inference items
|
|
41
|
+
Medium - Upto 32 inference items
|
|
42
|
+
Large - Upto 64 inference items
|
|
43
|
+
|
|
44
|
+
type: Only the Personality key is valid at this time (represents the users Onairos Personality)
|
|
45
|
+
description: Description to display to users about your request
|
|
46
|
+
reward: Reward Given to User for granting Data Request
|
|
40
47
|
|
|
41
48
|
Then instantiate the Onairos object from the Onairos package - passing in your Onairos Developer ID and your Request Object
|
|
42
49
|
```jsx
|
|
43
|
-
<Onairos
|
|
50
|
+
<Onairos requestData={requestData} onairosID={onairosID} access_token={access_token} webpageName={webpageName} proofMode={proofMode} />
|
|
44
51
|
```
|
|
45
52
|
|
|
53
|
+
Onairos Object fields:
|
|
54
|
+
requestData - Request Object - Json
|
|
55
|
+
onairosID - App Assigned Onairos ID - String
|
|
56
|
+
access_token - App Assigned Access Token - String
|
|
57
|
+
webpageName - App Display Name - String
|
|
58
|
+
proofMode - Wish to recieve ZK proof after recieving Data , default FALSE - boolean
|
|
59
|
+
|
|
46
60
|
That is all for the initial setup
|
|
47
61
|
|
|
48
62
|
### 4. Recieving the Inference API
|
|
@@ -54,6 +68,22 @@ event.data.source === 'content-script'
|
|
|
54
68
|
event.data.type === 'API_URL_RESPONSE'
|
|
55
69
|
```
|
|
56
70
|
|
|
71
|
+
For example:
|
|
72
|
+
|
|
73
|
+
``` jsx
|
|
74
|
+
export default async function UseAPIURL(event){
|
|
75
|
+
if (event.data && event.data.source === 'content-script' && event.data.type === 'API_URL_RESPONSE') {
|
|
76
|
+
//Fetch Onairos Data from Returned API url
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
window.addEventListener('message', UseAPIURL);
|
|
81
|
+
return () => {
|
|
82
|
+
window.removeEventListener('message', UseAPIURL);
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
```
|
|
86
|
+
|
|
57
87
|
## Using the Inference API
|
|
58
88
|
|
|
59
89
|
The Inference API provides a machine learning model that can generate predictions based on the provided data. This documentation will guide you on how to properly format your input for the API and interpret the results received from the API.
|
|
@@ -62,9 +92,9 @@ The Inference API provides a machine learning model that can generate prediction
|
|
|
62
92
|
|
|
63
93
|
Send a POST request to the API endpoint with a JSON payload containing a set of entries for prediction. Each entry should include the following information:
|
|
64
94
|
|
|
65
|
-
- `
|
|
66
|
-
- `category`: The category to which the content belongs (String)
|
|
67
|
-
- `img_url`: The URL of an image associated with the content (String)
|
|
95
|
+
- `text`: The text input for the inference result (String) - required
|
|
96
|
+
- `category`: The category to which the content belongs (String) - required
|
|
97
|
+
- `img_url`: The URL of an image associated with the content (String) - optional
|
|
68
98
|
|
|
69
99
|
Example JSON body for the POST request:
|
|
70
100
|
|
|
@@ -72,17 +102,17 @@ Example JSON body for the POST request:
|
|
|
72
102
|
|
|
73
103
|
"Input": {
|
|
74
104
|
"input1": {
|
|
75
|
-
"
|
|
105
|
+
"text": "Example text input 1",
|
|
76
106
|
"category": "Example Category 1",
|
|
77
107
|
"img_url": "http://example.com/image1.jpg"
|
|
78
108
|
},
|
|
79
109
|
"input2": {
|
|
80
|
-
"
|
|
110
|
+
"text": "Example text input 2",
|
|
81
111
|
"category": "Example Category 2",
|
|
82
112
|
"img_url": "http://example.com/image2.jpg"
|
|
83
113
|
},
|
|
84
114
|
"input3": {
|
|
85
|
-
"
|
|
115
|
+
"text": "Example text input 3",
|
|
86
116
|
"category": "Example Category 3",
|
|
87
117
|
"img_url": "http://example.com/image3.jpg"
|
|
88
118
|
}
|
|
@@ -110,6 +140,7 @@ export default async function UseAPIURL(event){
|
|
|
110
140
|
.catch(error => console.error(error));
|
|
111
141
|
|
|
112
142
|
}}
|
|
143
|
+
|
|
113
144
|
```
|
|
114
145
|
|
|
115
146
|
### 6. Output Format
|
package/package.json
CHANGED
package/src/onairos.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import onairosLogo from "./OnairosBlack.png";
|
|
3
3
|
|
|
4
|
-
function Onairos( {
|
|
4
|
+
function Onairos( {requestData, onairosID, access_token, proofMode=false,webpageName}) {
|
|
5
5
|
const OnairosAnime = async () => {
|
|
6
6
|
try {
|
|
7
7
|
console.log("Clicked Onairos Connect")
|
|
@@ -19,11 +19,12 @@ function Onairos( {sendData, onairosID, access_token}) {
|
|
|
19
19
|
window.postMessage({
|
|
20
20
|
source: 'webpage',
|
|
21
21
|
type: 'GET_API_URL',
|
|
22
|
-
|
|
22
|
+
webpageName: webpageName,
|
|
23
23
|
onairosID:onairosID,
|
|
24
24
|
access_token:access_token,
|
|
25
25
|
account:"ConnectedAccountRef.current", //No Longer needed, REMOVE
|
|
26
|
-
requestData:
|
|
26
|
+
requestData: requestData,
|
|
27
|
+
proofMode:proofMode
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
30
|
|