|
1 |
| -# Modzy JavaScript SDK |
| 1 | +<div align="center"> |
2 | 2 |
|
3 |
| -Modzy's Javascript SDK simplifies tasks such as querying models, submitting jobs, and returning results. It supports both Node.js and browser JavaScript applications using the output target of your build system to know which code to use. |
| 3 | + |
4 | 4 |
|
5 |
| -## Visit [docs.modzy.com](https://docs.modzy.com/docs/javascript) for docs, guides, API and more. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
6 | 9 |
|
7 |
| -These instructions are for Modzy JavaScript SDK v2, which is substantially different from v1. |
| 10 | + |
| 11 | + |
8 | 12 |
|
9 |
| ---- |
| 13 | +**[JavaScript SDK Documentation Page](https://docs.modzy.com/docs/javascript)** |
| 14 | + |
| 15 | +</div> |
10 | 16 |
|
11 |
| -## Installation |
| 17 | +# Installation |
12 | 18 |
|
13 |
| -From the command line in your project directory, run `yarn add @modzy/modzy-sdk` or `npm install @modzy/modzy-sdk`. |
14 |
| -Then import the ModzyClient class into your code: |
| 19 | +Intall Modzy's JavaScript SDK with NPM |
15 | 20 |
|
16 | 21 | ```bash
|
17 |
| -yarn add @modzy/modzy-sdk |
18 |
| -# or |
19 | 22 | npm install @modzy/modzy-sdk
|
20 | 23 | ```
|
| 24 | +or YARN |
21 | 25 |
|
22 |
| -```javascript |
23 |
| -import { ModzyClient } from "@modzy/modzy-sdk"; |
| 26 | +```bash |
| 27 | +yarn add @modzy/modzy-sdk |
24 | 28 | ```
|
25 | 29 |
|
26 |
| ---- |
27 |
| - |
28 |
| -## Initialize |
| 30 | +# Usage/Examples |
29 | 31 |
|
30 |
| -To initialize `ModzyClient`, you need an [api key](https://docs.modzy.com/docs/getting-started#key-download-your-api-key). If using an installation of Modzy other than app.modzy.com, you'll also need to provide the url for your instance of Modzy. For debugging purposes, you can also turn on logging. |
31 |
| - |
32 |
| -⚠️ _Warning: Keep your API key secret. Do not include it in a git repo or store it on GitHub_ |
| 32 | +## Initializing the SDK |
| 33 | +Initialize your client by authenticating with an API key. You can [download an API Key](https://docs.modzy.com/docs/view-and-manage-api-keys#download-team-api-key) from your instance of Modzy. |
33 | 34 |
|
34 | 35 | ```javascript
|
35 |
| -// app.modzy.com |
36 |
| -const modzyClient = new ModzyClient({ |
37 |
| - apiKey: "xxxxxxxxxxxxx.xxxxxxxxxxxxx", |
38 |
| -}); |
| 36 | +import { ModzyClient } from "@modzy/modzy-sdk"; |
39 | 37 |
|
40 |
| -// or for private Modzy instances |
41 | 38 | const modzyClient = new ModzyClient({
|
42 |
| - apiKey: "xxxxxxxxxxxxx.xxxxxxxxxxxxx", |
43 |
| - url: "https://modzy.yourdomain.com", |
| 39 | + apiKey: "Valid Modzy API Key", //e.g., "JbFkWZMx4Ea3epIrxSgA.a2fR36fZi3sdFPoztAXT" |
| 40 | + url: "Valid Modzy URL", //e.g., "https://trial.app.modzy.com" |
44 | 41 | });
|
45 | 42 | ```
|
46 | 43 |
|
47 | 44 | ---
|
48 | 45 |
|
49 |
| -## Basic usage |
50 |
| - |
51 |
| -Submit a job providing the model, version and input text: |
| 46 | +## Running Inferences |
| 47 | +### Raw Text Inputs |
| 48 | +Submit an inference job to a text-based model by providing the model ID, version, and raw input text. |
52 | 49 |
|
53 | 50 | ```javascript
|
| 51 | +//Submit text to v1.0.1 of a Sentiment Analysis model, and to make the job explainable, change explain=True |
54 | 52 | const { jobIdentifier } = await modzyClient.submitJobText({
|
55 | 53 | modelId: "ed542963de",
|
56 | 54 | version: "1.0.1",
|
57 | 55 | sources: {
|
58 |
| - yourInputKey: { |
59 |
| - "input.txt": "Sometimes I really hate ribs", |
| 56 | + firstPhoneCall: { |
| 57 | + "input.txt": "Mr Watson, come here. I want to see you.", |
60 | 58 | },
|
61 | 59 | },
|
62 | 60 | });
|
63 | 61 | ```
|
64 | 62 |
|
| 63 | +## Getting Results |
65 | 64 | Hold until the inference is complete:
|
66 | 65 |
|
67 | 66 | ```javascript
|
@@ -94,13 +93,17 @@ API_KEY=xxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxx
|
94 | 93 |
|
95 | 94 | ---
|
96 | 95 |
|
97 |
| -## Contributing |
| 96 | +# Support |
98 | 97 |
|
99 |
| -We are happy to receive contributions from all of our users. Check out our [contributing file](https://github.com/modzy/sdk-javascript/tree/main/contributing.adoc) to learn more. |
| 98 | +For support, email [email protected] or join our [Slack ](https://www.modzy.com/slack). |
| 99 | +# Contributing |
100 | 100 |
|
101 |
| ---- |
| 101 | +Contributions are always welcome! |
| 102 | + |
| 103 | +See [`contributing.md`](https://github.com/modzy/sdk-javascript/tree/main/contributing.adoc) for ways to get started. |
| 104 | + |
| 105 | +Please adhere to this project's `code of conduct`. |
102 | 106 |
|
103 |
| -## Code of conduct |
| 107 | +We are happy to receive contributions from all of our users. Check out our contributing file to learn more. |
104 | 108 |
|
105 |
| -Please see our [code of conduct](https://github.com/modzy/sdk-javascript/tree/main//CODE_OF_CONDUCT.md) for any questions about the kind of community we are trying to build. |
106 |
| -[](https://github.com/modzy/sdk-javascript/tree/main//CODE_OF_CONDUCT.md) |
| 109 | +[](https://github.com/modzy/sdk-javascript/tree/main/CODE_OF_CONDUCT.md) |
0 commit comments