ultron-ai-sdk 1.0.4 β 1.0.5
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 +125 -1
- package/dist/index.cjs +2 -45241
- package/dist/index.mjs +1 -45235
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
|
+
### Via npm
|
|
11
|
+
|
|
10
12
|
```bash
|
|
11
13
|
npm install ultron-ai-sdk
|
|
12
14
|
|
|
@@ -41,6 +43,57 @@ npm install ultron-ai-sdk
|
|
|
41
43
|
|
|
42
44
|
```
|
|
43
45
|
|
|
46
|
+
### In HTML Via CDN like [jsDelivr](https://www.jsdelivr.com/).
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
|
|
51
|
+
<script type="importmap">
|
|
52
|
+
{
|
|
53
|
+
"imports": {
|
|
54
|
+
"ultron-ai-sdk": "https://cdn.jsdelivr.net/npm/ultron-ai-sdk@1.0.4/dist/index.mjs?module"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="module">
|
|
60
|
+
import {SceneCanvas, Character} from 'ultron-ai-sdk';
|
|
61
|
+
|
|
62
|
+
let sceneCanvas
|
|
63
|
+
let character
|
|
64
|
+
|
|
65
|
+
const init = async() => {
|
|
66
|
+
sceneCanvas = new SceneCanvas('target-html-element')
|
|
67
|
+
const initializationSetting= {
|
|
68
|
+
avatarId: "AVATAR_ID", // AvatarId and Request Id are same
|
|
69
|
+
config:{
|
|
70
|
+
accessToken: 'YOUR_CURRENT_AUTH_TOKEN', // Can be accessed from your app.ultronai.me localstorage data
|
|
71
|
+
apiKey: "YOUR_ULTRON_API_KEY" // Not required if you can create and access "sessionId"
|
|
72
|
+
// sessionId: "SESSION_ID_FOR_CURRENT_USER" // Recomended method for secure access
|
|
73
|
+
},
|
|
74
|
+
options:{
|
|
75
|
+
hideClickMessage: true //remove default "Click message" on the avatar
|
|
76
|
+
alwaysListen: false // For Push to talk conversation
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
await sceneCanvas.init(initializationSetting)
|
|
80
|
+
character = sceneCanvas.character
|
|
81
|
+
|
|
82
|
+
// Use "character" object to call various methods like .chat() or .say()
|
|
83
|
+
|
|
84
|
+
// character.say("Hello world")
|
|
85
|
+
// character.chat("Please introduce yourself")
|
|
86
|
+
|
|
87
|
+
//IMPORTANT --->
|
|
88
|
+
// User interaction like click is necessory for the talking of the Avatar to work due to inbuilt security in variuos browser
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
init() // You can also call this on user interaction like clicking on support/chat icon.
|
|
92
|
+
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
|
|
44
97
|
#### Quick Demo
|
|
45
98
|
|
|
46
99
|
Check out our website for demo at: [πTalk to Avatar in metabrix website](https://dev-website.ultronai.me)
|
|
@@ -62,8 +115,10 @@ Check out our website for demo at: [πTalk to Avatar in metabrix website](http
|
|
|
62
115
|
### Initialization
|
|
63
116
|
|
|
64
117
|
```javascript
|
|
118
|
+
|
|
65
119
|
const sceneCanvas = new SceneCanvas('target-html-element')
|
|
66
|
-
sceneCanvas.init(
|
|
120
|
+
sceneCanvas.init({sessionId: "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxx"})
|
|
121
|
+
|
|
67
122
|
```
|
|
68
123
|
|
|
69
124
|
---
|
|
@@ -92,9 +147,78 @@ To get API key of your ultron account follow the steps below
|
|
|
92
147
|
|
|
93
148
|

|
|
94
149
|
|
|
150
|
+
#### Session Id (sessionId)
|
|
151
|
+
|
|
152
|
+
## π Create Session API
|
|
153
|
+
|
|
154
|
+
This API allows you to create a new session.
|
|
155
|
+
|
|
156
|
+
### π Endpoint
|
|
157
|
+
**POST** `/session/create`
|
|
158
|
+
|
|
159
|
+
### π§ Headers:
|
|
160
|
+
| Key | Value |
|
|
161
|
+
|-----------|-----------------|
|
|
162
|
+
| `x-api-key` | your_api_key |
|
|
163
|
+
| `Content-Type` | application/json |
|
|
164
|
+
|
|
165
|
+
### π€ Request Body:
|
|
166
|
+
```json
|
|
167
|
+
{
|
|
168
|
+
"expiresIn": "100",
|
|
169
|
+
"requestID": "xxxxx"
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
### Response:
|
|
173
|
+
```json
|
|
174
|
+
|
|
175
|
+
{
|
|
176
|
+
"sessionId": "string",
|
|
177
|
+
"status": "string"
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
async function createSession(apiKey, requestID, expiresIn) {
|
|
184
|
+
const response = await fetch('https://api.ultronai.me/session/create', {
|
|
185
|
+
method: 'POST',
|
|
186
|
+
headers: {
|
|
187
|
+
'x-api-key': apiKey,
|
|
188
|
+
'Content-Type': 'application/json'
|
|
189
|
+
},
|
|
190
|
+
body: JSON.stringify({ requestID, expiresIn })
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const data = await response.json();
|
|
194
|
+
console.log('Session Created:', data);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
createSession('your_api_key', '123', 10);
|
|
198
|
+
|
|
199
|
+
// Use this sessionId in the SDK in your Web App
|
|
200
|
+
// Call this method on your server side for security and avoid exposing your API key
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Note: Please use the method above to get session id on your server side for a secure workflow
|
|
95
204
|
|
|
96
205
|
---
|
|
97
206
|
|
|
207
|
+
## Options
|
|
208
|
+
|
|
209
|
+
## Always listen
|
|
210
|
+
|
|
211
|
+
Makes the character listen all the time once click for continous conversation (voice to voice)
|
|
212
|
+
|
|
213
|
+
- `alwaysListen`: **Boolean** - The unique identifier for the avatar
|
|
214
|
+
|
|
215
|
+
## Hide default click message
|
|
216
|
+
|
|
217
|
+
Hides the default text message on the avatar to prompt user to click as an initial click is required for any audio to play in any browser
|
|
218
|
+
|
|
219
|
+
- `hideClickMessage`: **Boolean** - The unique identifier for the avatar
|
|
220
|
+
|
|
221
|
+
|
|
98
222
|
## Core Methods
|
|
99
223
|
|
|
100
224
|
### loadAvatar(avatarId)
|