Skip to content

Commit 1e9e086

Browse files
authored
Merge pull request #12 from modzy/readmeUpdates
readme updates
2 parents 22c3abb + 779bf6d commit 1e9e086

10 files changed

+366
-92
lines changed

README.adoc

+134-60
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,33 @@
1212
<h1>Javascript SDK</h1>
1313
1414
<div align="center">
15-
1615
<br>
1716
<br>
18-
19-
2017
<img src="https://www.modzy.com/wp-content/uploads/2019/10/modzy-logo-tm.svg" alt="Modzy" width="350" height="auto">
21-
2218
<br>
2319
<br>
2420
<br>
2521
<br>
26-
27-
28-
29-
3022
<p><b>Modzy's Javascript SDK queries models, submits inference jobs, and returns results directly to your editor.</b></p>
31-
32-
3323
<br>
34-
35-
3624
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/modzy/sdk-javascript">
37-
3825
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/modzy/sdk-javascript">
39-
4026
<img alt="GitHub Release Date" src="https://img.shields.io/github/release-date/modzy/sdk-javascript">
41-
4227
</div>
43-
4428
<br>
4529
<br>
46-
4730
<div align="center">
4831
<a href=https://models.modzy.com/docs/how-to-guides/job-lifecycle style="text-decoration:none">The job lifecycle</a> |
4932
<a href=https://models.modzy.com/docs/how-to-guides/api-keys style="text-decoration:none">API keys</a> |
5033
<a href=/samples style="text-decoration:none">Samples</a> |
5134
<a href=https://models.modzy.com/docs/home/home style="text-decoration:none">Documentation</a>
52-
53-
5435
<br>
5536
<br>
5637
<br>
5738
<br>
58-
59-
60-
6139
<br>
62-
6340
</div>
64-
6541
<br>
66-
67-
68-
6942
++++
7043

7144

@@ -74,7 +47,7 @@
7447

7548
++++
7649
<br>
77-
<div align="center>
50+
<div align="center">
7851
<a href="https://asciinema.org/a/B1IkRkW4LjW7sufkjoMWoETH6"><img src="install.gif" style="max-width:100%"/></a>
7952
</div>
8053
<br>
@@ -84,71 +57,165 @@ Clone the repository:
8457

8558
- `$ git clone https://github.com/modzy/sdk-javascript.git`
8659

87-
++++
88-
<p>Use <a href=https://yarnpkg.com/ style="text-decoration:none">yarn</a> to package and install the SDK. </p>
89-
++++
60+
Use https://yarnpkg.com/[yarn] to package and install the SDK:
61+
62+
Globally:
63+
64+
- `$ yarn global add ./sdk-javascript`
65+
66+
In an existing project (directly from github):
67+
68+
- `$ yarn add modzy/sdk-javascript`
69+
9070

91-
- `$ yarn add ./sdk-javascript`
71+
Or you can use https://nodejs.org/[npm]:
9272

93-
//no reference to node.js in here but it is in contributing.
73+
Globally
9474

95-
== Usage
75+
- `$ npm install -g ./sdk-javascript`
9676

77+
In an existing project (directly from github):
9778

98-
=== Initialize
79+
- `$ npm install modzy/sdk-javascript`
9980

100-
Once you have a `model` and `version` identified, authenticate to Modzy with your API key:
81+
== Initialize
82+
83+
Once you have a `model` and `version` identified, get authenticated with your API key.
84+
85+
API keys are security credentials required to perform API requests to Modzy. Our API keys are composed of an ID that is split by a dot into two parts: the prefix and the body. +
86+
The *prefix* is the API keys' visible part. It’s only used to identify the key and by itself, it’s unable to perform API requests.
87+
88+
link:https://models.modzy.com/docs/users-keys/api-keys/retrieve-users-api-keys[List your API keys]:
89+
90+
[source, js]
91+
----
92+
const keys = await modzyClient.getAccountingClient().getAPIKeys('[email protected]');
93+
keys.forEach(
94+
key => {
95+
console.log(JSON.stringify(key));
96+
}
97+
);
98+
----
99+
100+
The *body* is the prefix’s complement and it’s required to perform API requests. Since it’s not stored on Modzy’s servers, it cannot be recovered. Make sure to save it securely. If lost, you can link:https://models.modzy.com/docs/users-keys/api-keys/replace-API-key[replace the API key's body].
101+
102+
link:https://models.modzy.com/docs/users-keys/api-keys/retrieve-full-API-key[Retrieve the API key's body]:
103+
104+
[source, js]
105+
----
106+
107+
const hash = await modzyClient.getAccountingClient().getKeyBody('yourKey');
108+
console.log("The hash is: "+hash);
109+
----
110+
111+
Get authenticated with your API key:
101112

102113
[source, js]
103114
----
104115
const modzy = require('modzy-sdk');
105-
const modzyClient = new modzy.ModzyClient("http://url.to.modzy/api", "my_key.modzy");
116+
const modzyClient = new modzy.ModzyClient("http://url.to.modzy/api", "prefix.body");
106117
----
107118

108-
=== Basic usage
119+
== Basic usage
109120

110121
++++
111122
<br>
123+
<div align="center">
124+
<img src="js.gif" alt="basic usage" style="max-width:100%">
125+
</div>
126+
<br>
112127
++++
113128

114-
The code below is applicable for `text/plain` input type.
115129

116-
++++
117-
<div align="center">
118130

119-
<img src="js.gif" alt="basic usage" style="max-width:100%">
131+
=== Browse models
120132

121-
</div>
133+
Modzy’s Marketplace includes pre-trained and re-trainable AI models from industry-leading machine learning companies, accelerating the process from data to value.
122134

123-
<br>
124-
++++
135+
The Model service drives the Marketplace and can be integrated with other applications, scripts, and systems. It provides routes to list, search, and filter model and model-version details.
125136

126-
Browse models:
137+
link:https://models.modzy.com/docs/marketplace/models/retrieve-models[List models]
127138

128139
[source, js]
129140
----
130-
try{
131-
const models = await modzyClient.getAllModels();
132-
models.forEach(
133-
model => {
134-
console.log(JSON.stringify(model));
135-
}
136-
);
137-
}
141+
const models = await modzyClient.getAllModels();
142+
models.forEach(
143+
model => {
144+
console.log(JSON.stringify(model));
145+
}
146+
);
147+
----
148+
149+
Tags help categorize and filter models. They make model browsing easier.
138150

151+
link:https://models.modzy.com/docs/marketplace/tags/retrieve-tags[List tags]:
152+
153+
[source, js]
154+
----
155+
const tags = await modzyClient.getAllTags();
156+
tags.forEach(
157+
tag => {
158+
console.log(JSON.stringify(tag));
159+
}
160+
);
139161
----
140162

163+
link:https://models.modzy.com/docs/marketplace/tags/retrieve-models-by-tags[List models by tag]:
141164

142-
Get a model's details:
165+
[source, js]
166+
----
167+
const tagsModels = await modzyClient.getTagsAndModels("language_and_text");
168+
tagsModels.models.forEach(
169+
model => {
170+
console.log(JSON.stringify(model));
171+
}
172+
);
173+
----
174+
175+
=== Get a model's details
176+
177+
Models accept specific *input file link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types[MIME] types*. Some models may require multiple input file types to run data accordingly. In this sample, we use a model that requires `text/plain`.
178+
179+
Models require inputs to have a specific *input name* declared in the job request. This name can be found in the model’s details. In this sample, we use a model that requires `input.txt`.
180+
181+
Additionally, users can set their own input names. When multiple input items are processed in a job, these names are helpful to identify and get each input’s results. In this sample, we use a model that requires `input-1` and `input-2`.
182+
183+
link:https://models.modzy.com/docs/marketplace/models/retrieve-model-details[Get a model's details]:
143184

144185
[source, js]
145186
----
146187
const saModel = await modzyClient.getModel("ed542963de");
147188
console.log(JSON.stringify(saModel));
148189
----
149190

191+
Model specific sample requests are available in the version details and in the Model Details page.
192+
193+
link:https://models.modzy.com/docs/marketplace/versions/retrieve-version-details[Get version details]:
194+
195+
[source, js]
196+
----
197+
let modelVersion = await modzyClient.getModelVersion("ed542963de", "0.0.27");
198+
console.log("inputs:");
199+
for(key in modelVersion.inputs){
200+
let input = modelVersion.inputs[key];
201+
console.log(` key ${input.name}, type ${input.acceptedMediaTypes}, description: ${input.description}`);
202+
}
203+
console.log("outputs:");
204+
for(key in modelVersion.outputs){
205+
let output = modelVersion.outputs[key];
206+
console.log(` key ${output.name}, type ${output.mediaType}, description: ${output.description}`);
207+
}
208+
----
209+
210+
=== Submit a job and get results
211+
212+
A *job* is the process that sends data to a model, sets the model to run the data, and returns results.
213+
214+
Modzy supports several *input types* such as `text`, `embedded` for Base64 strings, `aws-s3` and `aws-s3-folder` for inputs hosted in buckets, and `jdbc` for inputs stored in databases. In this sample, we use `text`.
215+
216+
link:https://github.com/modzy/sdk-javascript/blob/readmeUpdates/samples.adoc[Here] are samples to submit jobs with `embedded`, `aws-s3`, `aws-s3-folder`, and `jdbc` input types.
150217

151-
Submit a job providing the model, version, and input file:
218+
link:https://models.modzy.com/docs/jobs/jobs/submit-job-text[Submit a job with the model, version, and input items]:
152219

153220
[source, js]
154221
----
@@ -162,15 +229,18 @@ let job = await modzyClient.submitJobText(
162229
);
163230
----
164231

165-
Hold until the inference is complete and results become available:
232+
link:https://models.modzy.com/docs/jobs/jobs/retrieve-job-details[Hold until the inference is complete and results become available]:
166233

167234
[source, js]
168235
----
169236
job = await modzyClient.blockUntilComplete(job);
170-
171237
----
172238

173-
Get the output results:
239+
link:https://models.modzy.com/docs/jobs/results/retrieve-results[Get the results]:
240+
241+
Results are available per input item and can be identified with the name provided for each input item upon job request. You can also add an input name to the route and limit the results to any given input item.
242+
243+
Jobs requested for multiple input items may have partial results available prior to job completion.
174244

175245
[source, js]
176246
----
@@ -202,7 +272,11 @@ catch(error){
202272

203273
== Features
204274

205-
Currently we support the following api routes:
275+
Modzy supports link:https://models.modzy.com/docs/features/batch-processing[batch processing], link:https://models.modzy.com/docs/features/explainability[explainability], and link:https://models.modzy.com/docs/features/model-drift[model drift detection].
276+
277+
== APIs
278+
279+
Here is a list of Modzy APIs. To see all the APIs, check our link:https://models.modzy.com/docs/home/home[Documentation].
206280

207281
:doc-pages: https://models.modzy.com/docs/
208282
[cols=3*, stripes=even]

contributing.adoc

+7-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Clone the repository:
8686

8787
Install dependencies:
8888

89-
- `$ yarn install`
89+
- `$ yarn install` or `$ npm install`
9090

9191
Create a branch for your awesome new feature:
9292

@@ -134,19 +134,23 @@ MODZY_API_KEY=my_key.modzy
134134

135135
Run tests:
136136

137-
- `$ yarn test`
137+
- `$ yarn test` or `$ npm test`
138138

139139
Or specify the test that you want to run:
140140

141141
- `$ yarn test -- model-client.test.js`
142142

143+
With npm:
144+
145+
- `$ npm test -- model-client.test.js`
146+
143147
=== 4. Document your changes
144148

145149
Add supporting documentation for your code.
146150

147151
=== 5. Transpile the code
148152

149-
- `$ yarn build`
153+
- `$ yarn build` or `$ npm run-script build`
150154

151155
=== 6. Send a pull request
152156

package.json

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
{
22
"name": "modzy-sdk",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
4+
"description": "Javascript SDK for Modzy",
45
"main": "dist/main.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/modzy/sdk-javascript.git"
9+
},
10+
"keywords": [
11+
"Modzy",
12+
"SDK"
13+
],
14+
"author": "Modzy",
15+
"bugs": {
16+
"url": "https://github.com/modzy/sdk-javascript/issues"
17+
},
18+
"homepage": "https://github.com/modzy/sdk-javascript#readme",
519
"scripts": {
620
"docs": "jsdoc -c jsdoc.json",
721
"build": "babel src --out-dir=dist",
822
"test": "jest --detectOpenHandles"
923
},
1024
"dependencies": {
11-
"axios": "^0.19.2",
25+
"axios": "^0.21.1",
1226
"dotenv": "^8.2.0",
13-
"log4js": "^6.1.2"
27+
"log4js": "^6.1.2",
28+
"string-similarity": "^4.0.4"
1429
},
1530
"devDependencies": {
1631
"@babel/cli": "^7.8.4",
1732
"@babel/core": "^7.8.7",
1833
"@babel/plugin-proposal-class-properties": "^7.8.3",
19-
"@babel/preset-env": "^7.8.7",
34+
"@babel/preset-env": "^7.8.7",
2035
"babel-jest": "^25.1.0",
2136
"jest": "^25.1.0",
2237
"jsdoc": "^3.6.4"
2338
}
24-
}
39+
}

0 commit comments

Comments
 (0)