0.1.399 • Published 8 months ago

onairos v0.1.399

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

Onairos Developer Documentation v0.0.0

1. Create a Developer Account

Create a Developer account to access Onairos services. Register your domain to ensure secure API access.

https://Onairos.uk/dev-board

2. Download the Onairos NPM package

npm install onairos

Import the package as a default import

import Onairos from 'onairos';

3. Setup the Onairos Connection Object

First create the Request Object which Users will Authorize (or not) in the extension popup

"RequestObject":{ 
    "Small": {
      "type":"Personality",
      "descriptions":"Insight into your Interests",
      "reward":"10% Discount"
    },
    "Medium":{
      "type":"Personality",
      "descriptions":"Insight into your Interests",
      "reward":"2 USDC"
    },
    "Large":{
      "type":"Personality",
      "descriptions":"Insight into your Interests",
      "reward":"2 USDC"
    }
  }

RequestObject.size key:

  • Small - Upto 16 inference items
  • Medium - Upto 32 inference items
  • Large - Upto 64 inference items

Individual Request Information:

  • type: Only the Personality key is valid at this time (represents the users Onairos Personality)
  • description: Description to display to users about your request
  • reward: Reward Given to User for granting Data Request

Then instantiate the Onairos object from the Onairos package - passing in your Request Object and other meta info

<Onairos requestData={requestData} webpageName={webpageName} proofMode={proofMode} />

Onairos Object fields:

  • requestData - Request Object - Json
  • webpageName - App Display Name - String
  • proofMode - Wish to recieve ZK proof after recieving Data , default FALSE - boolean

That is all for the initial setup

4. Recieving the Inference API

Once the user has clicked to Connect their Onairos account and authroized their data, you will recieve the Inference API via window.sendMessage with the following event types:

event.data.source === 'content-script'
&&
event.data.type === 'API_URL_RESPONSE'
&&
event.data.unique ==='Onairos-Response'

You will also be given an ACCESS TOKEN which you must use in any API requests from that specific client.

This is a short lived token, for usage on your developer registered domain only, and lasts for 1 hour from issue.

For example:

export default async function UseAPIURL(event){
    if (event.data && event.data.source === 'content-script' && event.data.type === 'API_URL_RESPONSE') {
      const { APIurl, accessToken } = event.data;
      //Fetch Onairos Data from Returned API url
  }
}
useEffect(() => {
  window.addEventListener('message', UseAPIURL);
  return () => {
    window.removeEventListener('message', UseAPIURL);
  };
}, []);

Using the Inference API

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.

5. Input Format

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:

  • text: The text input for the inference result (String) - required
  • category: The category to which the content belongs (String) - required
  • img_url: The URL of an image associated with the content (String) - optional

Example JSON body for the POST request:

  "Input": {
    "input1": {
      "text": "Example text input 1",
      "category": "Example Category 1",
      "img_url": "http://example.com/image1.jpg"
    },
    "input2": {
      "text": "Example text input 2",
      "category": "Example Category 2",
      "img_url": "http://example.com/image2.jpg"
    },
    "input3": {
      "text": "Example text input 3",
      "category": "Example Category 3",
      "img_url": "http://example.com/image3.jpg"
    },
  }
    // Additional entries can be added here
  

You can then call the Inference API with the Inference object created above.

Remember to include the access token in the Authorization header of your API request.

export default async function UseAPIURL(event){
    if (event.data && event.data.source === 'content-script' && event.data.type === 'API_URL_RESPONSE') {
      const { apiUrl, accessToken } = event.data;
      await fetch(apiUrl, {
          method: 'POST',
          headers: {
              'Content-Type': 'application/json',
              'Authorization': `Bearer ${accessToken}` // Include the access token in the Authorization header
          },
          body: JSON.stringify(InputData),
      }).then(async (data)=>{
            // process Onairos Data
      })
      .catch(error => console.error(error));
      
    }}
  

6. Output Format

The API responds with a JSON object containing an output field. This field is an array of arrays, where each sub-array contains a single element representing the prediction score from the model. This score is a floating-point number reflecting the model's confidence for the input provided.

Example of the output format:

{
  "output": [
    [[0.9998]],
    [[0.9999]],
    [[0.9922]],
    [[0.0013]],
    // Additional scores for more entries
  ]
}

Each score is deeply nested within two arrays to maintain compatibility with batch processing systems that may require this format.

Errors and Debugging

All Errors and Debugging from the Inference API will be of the form

    res.status(statusCode).send({ error: message }); 

Statuses of 200 are valid, and all others indicate potential issues

Integrating the onairos Package into Your Application

When integrating the onairos package into your application, please ensure the following steps are taken to correctly handle dynamically loaded modules:

Webpack Configuration:

Your application's Webpack configuration needs to be set up to handle dynamic imports. Specifically, the output.publicPath in your webpack.config.js should be configured to reflect the URL path from which your application will serve its assets. If your application is served from a subdirectory, make sure to include the subdirectory path in the publicPath.

Serving Chunks:

Ensure that your server is configured to serve the necessary chunk files located within the node_modules/onairos/dist directory. These files are essential for the dynamic modules to load correctly at runtime.

Include Chunks in Your Deployment: When deploying your application, include the dist directory of the onairos package in your deployment artifacts. This directory contains the chunk files generated by Webpack and is necessary for the proper functioning of the package.

Version Management:

The onairos package uses semantic versioning. Please note that major version changes may introduce breaking changes and require additional steps to integrate. Always refer to the release notes for guidance on upgrading.

Local Testing:

Prior to deployment, you can link the onairos package locally to ensure that dynamic imports work as expected. Use the npm link command for this purpose and verify that the application behaves correctly and loads all necessary modules.

If you encounter any issues while integrating the onairos package, please refer to the troubleshooting guide provided in our documentation, or reach out to our support team for assistance.

Interpretation of Output

  • A score close to 1 indicates a high confidence level in the prediction.
  • A score close to 0 indicates a low confidence level in the prediction.
  • The sequence of scores corresponds to the order of the input entries.

Example Usage in a React Application

The following React component demonstrates how to send a prediction request to the API and display the results:

import React, { useState } from 'react';

function App() {

    async function UseAPIURL(event){
     if (event.data && event.data.source === 'content-script' && event.data.type === 'API_URL_RESPONSE') {
      const { apiUrl, accessToken } = event.data;
       await fetch(apiUrl, {
           method: 'POST',
           headers: {
               'Content-Type': 'application/json',
               'Authorization': `Bearer ${accessToken}` // Include the access token in the Authorization header
           },
           body: JSON.stringify(InputData),
       }).then(async (data)=>{
             // process Onairos Data
       })
       .catch(error => console.error(error));
      
    }}

  const requestData = { 
    Small: {
      type:"Personality",
      descriptions:"Insight into your Interests",
      reward:"10% Discount"
    },
    Medium:{
      type:"Personality",
      descriptions:"Insight into your Interests",
      reward:"2 USDC"
    },
    Large:{
      type:"Personality",
      descriptions:"Insight into your Interests",
      reward:"2 USDC"
    },
  };
  useEffect(() => {
    window.addEventListener('message', UseAPIURL);
    return () => {
      window.removeEventListener('message', UseAPIURL);
    };
    }, []);

  const onairosID = 'test';
  return (
      <Onairos requestData={requestData} webpageName={webpageName} proofMode={proofMode} />

  );
}
export default InferenceComponent;
0.1.239

10 months ago

0.1.359

10 months ago

0.1.238

10 months ago

0.1.235

10 months ago

0.1.355

10 months ago

0.1.234

10 months ago

0.1.237

10 months ago

0.1.357

10 months ago

0.1.236

10 months ago

0.1.352

10 months ago

0.1.231

10 months ago

0.1.351

10 months ago

0.1.230

10 months ago

0.1.354

10 months ago

0.1.233

10 months ago

0.1.353

10 months ago

0.1.232

10 months ago

0.1.350

10 months ago

0.1.249

10 months ago

0.1.367

9 months ago

0.1.246

10 months ago

0.1.366

9 months ago

0.1.369

9 months ago

0.1.248

10 months ago

0.1.368

9 months ago

0.1.247

10 months ago

0.1.363

9 months ago

0.1.242

10 months ago

0.1.241

10 months ago

0.1.365

9 months ago

0.1.244

10 months ago

0.1.364

9 months ago

0.1.243

10 months ago

0.1.361

9 months ago

0.1.240

10 months ago

0.1.360

10 months ago

0.1.378

9 months ago

0.1.377

9 months ago

0.1.256

10 months ago

0.1.259

10 months ago

0.1.379

9 months ago

0.1.258

10 months ago

0.1.374

9 months ago

0.1.253

10 months ago

0.1.373

9 months ago

0.1.252

10 months ago

0.1.376

9 months ago

0.1.255

10 months ago

0.1.375

9 months ago

0.1.254

10 months ago

0.1.370

9 months ago

0.1.372

9 months ago

0.1.251

10 months ago

0.1.371

9 months ago

0.1.250

10 months ago

0.1.389

9 months ago

0.1.268

10 months ago

0.1.267

10 months ago

0.1.385

9 months ago

0.1.264

10 months ago

0.1.384

9 months ago

0.1.263

10 months ago

0.1.387

9 months ago

0.1.266

10 months ago

0.1.386

9 months ago

0.1.265

10 months ago

0.1.381

9 months ago

0.1.260

10 months ago

0.1.380

9 months ago

0.1.383

9 months ago

0.1.262

10 months ago

0.1.382

9 months ago

0.1.261

10 months ago

0.1.309

10 months ago

0.1.308

10 months ago

0.1.316

10 months ago

0.1.315

10 months ago

0.1.318

10 months ago

0.1.317

10 months ago

0.1.312

10 months ago

0.1.311

10 months ago

0.1.314

10 months ago

0.1.313

10 months ago

0.1.310

10 months ago

0.1.319

10 months ago

0.1.327

10 months ago

0.1.206

10 months ago

0.1.326

10 months ago

0.1.205

10 months ago

0.1.329

10 months ago

0.1.208

10 months ago

0.1.328

10 months ago

0.1.207

10 months ago

0.1.323

10 months ago

0.1.202

10 months ago

0.1.322

10 months ago

0.1.201

10 months ago

0.1.325

10 months ago

0.1.204

10 months ago

0.1.324

10 months ago

0.1.203

10 months ago

0.1.321

10 months ago

0.1.200

10 months ago

0.1.320

10 months ago

0.1.209

10 months ago

0.1.338

10 months ago

0.1.217

10 months ago

0.1.337

10 months ago

0.1.216

10 months ago

0.1.219

10 months ago

0.1.339

10 months ago

0.1.218

10 months ago

0.1.334

10 months ago

0.1.213

10 months ago

0.1.333

10 months ago

0.1.212

10 months ago

0.1.336

10 months ago

0.1.215

10 months ago

0.1.335

10 months ago

0.1.214

10 months ago

0.1.330

10 months ago

0.1.332

10 months ago

0.1.211

10 months ago

0.1.210

10 months ago

0.1.349

10 months ago

0.1.228

10 months ago

0.1.348

10 months ago

0.1.227

10 months ago

0.1.229

10 months ago

0.1.345

10 months ago

0.1.224

10 months ago

0.1.344

10 months ago

0.1.223

10 months ago

0.1.347

10 months ago

0.1.226

10 months ago

0.1.346

10 months ago

0.1.225

10 months ago

0.1.341

10 months ago

0.1.220

10 months ago

0.1.340

10 months ago

0.1.222

10 months ago

0.1.342

10 months ago

0.1.221

10 months ago

0.1.305

10 months ago

0.1.304

10 months ago

0.1.307

10 months ago

0.1.306

10 months ago

0.1.301

10 months ago

0.1.303

10 months ago

0.1.302

10 months ago

0.1.190

11 months ago

0.1.192

10 months ago

0.1.191

10 months ago

0.1.198

10 months ago

0.1.197

10 months ago

0.1.199

10 months ago

0.1.194

10 months ago

0.1.193

10 months ago

0.1.196

10 months ago

0.1.195

10 months ago

0.1.390

9 months ago

0.1.279

10 months ago

0.1.399

8 months ago

0.1.278

10 months ago

0.1.396

9 months ago

0.1.275

10 months ago

0.1.395

9 months ago

0.1.274

10 months ago

0.1.398

9 months ago

0.1.277

10 months ago

0.1.397

9 months ago

0.1.276

10 months ago

0.1.392

9 months ago

0.1.271

10 months ago

0.1.391

9 months ago

0.1.270

10 months ago

0.1.394

9 months ago

0.1.273

10 months ago

0.1.393

9 months ago

0.1.272

10 months ago

0.1.280

10 months ago

0.1.289

10 months ago

0.1.286

10 months ago

0.1.285

10 months ago

0.1.288

10 months ago

0.1.287

10 months ago

0.1.282

10 months ago

0.1.281

10 months ago

0.1.284

10 months ago

0.1.283

10 months ago

0.1.291

10 months ago

0.1.290

10 months ago

0.1.297

10 months ago

0.1.296

10 months ago

0.1.299

10 months ago

0.1.298

10 months ago

0.1.293

10 months ago

0.1.292

10 months ago

0.1.295

10 months ago

0.1.294

10 months ago

0.1.187

1 year ago

0.1.186

1 year ago

0.1.189

1 year ago

0.1.188

1 year ago

0.1.185

1 year ago

0.1.184

1 year ago

0.1.147

1 year ago

0.1.146

1 year ago

0.1.149

1 year ago

0.1.148

1 year ago

0.1.143

1 year ago

0.1.142

1 year ago

0.1.145

1 year ago

0.1.144

1 year ago

0.1.141

1 year ago

0.1.158

1 year ago

0.1.157

1 year ago

0.1.159

1 year ago

0.1.154

1 year ago

0.1.153

1 year ago

0.1.156

1 year ago

0.1.155

1 year ago

0.1.150

1 year ago

0.1.152

1 year ago

0.1.151

1 year ago

0.1.169

1 year ago

0.1.168

1 year ago

0.1.165

1 year ago

0.1.167

1 year ago

0.1.166

1 year ago

0.1.161

1 year ago

0.1.160

1 year ago

0.1.163

1 year ago

0.1.162

1 year ago

0.1.170

1 year ago

0.1.179

1 year ago

0.1.175

1 year ago

0.1.178

1 year ago

0.1.177

1 year ago

0.1.172

1 year ago

0.1.171

1 year ago

0.1.174

1 year ago

0.1.173

1 year ago

0.1.181

1 year ago

0.1.180

1 year ago

0.1.183

1 year ago

0.1.182

1 year ago

0.1.140

2 years ago

0.1.139

2 years ago

0.1.136

2 years ago

0.1.138

2 years ago

0.1.137

2 years ago

0.1.135

2 years ago

0.1.132

2 years ago

0.1.131

2 years ago

0.1.134

2 years ago

0.1.133

2 years ago

0.1.130

2 years ago

0.1.118

2 years ago

0.1.117

2 years ago

0.1.119

2 years ago

0.1.114

2 years ago

0.1.113

2 years ago

0.1.116

2 years ago

0.1.115

2 years ago

0.1.110

2 years ago

0.1.112

2 years ago

0.1.111

2 years ago

0.1.129

2 years ago

0.1.128

2 years ago

0.1.125

2 years ago

0.1.124

2 years ago

0.1.127

2 years ago

0.1.126

2 years ago

0.1.121

2 years ago

0.1.120

2 years ago

0.1.123

2 years ago

0.1.122

2 years ago

0.1.99

2 years ago

0.1.107

2 years ago

0.1.106

2 years ago

0.1.109

2 years ago

0.1.108

2 years ago

0.1.103

2 years ago

0.1.102

2 years ago

0.1.105

2 years ago

0.1.104

2 years ago

0.1.101

2 years ago

0.1.100

2 years ago

0.1.96

2 years ago

0.1.97

2 years ago

0.1.98

2 years ago

0.1.90

2 years ago

0.1.91

2 years ago

0.1.92

2 years ago

0.1.93

2 years ago

0.1.94

2 years ago

0.1.95

2 years ago

0.1.85

2 years ago

0.1.86

2 years ago

0.1.87

2 years ago

0.1.88

2 years ago

0.1.89

2 years ago

0.1.81

2 years ago

0.1.82

2 years ago

0.1.83

2 years ago

0.1.84

2 years ago

0.1.80

2 years ago

0.1.77

2 years ago

0.1.78

2 years ago

0.1.79

2 years ago

0.1.74

2 years ago

0.1.75

2 years ago

0.1.76

2 years ago

0.1.71

2 years ago

0.1.72

2 years ago

0.1.73

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.1.40

2 years ago

0.1.70

2 years ago

0.1.63

2 years ago

0.1.64

2 years ago

0.1.65

2 years ago

0.1.66

2 years ago

0.1.67

2 years ago

0.1.68

2 years ago

0.1.69

2 years ago

0.1.60

2 years ago

0.1.61

2 years ago

0.1.62

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.37

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.23

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.13

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago