ultron-ai-sdk 1.0.0
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 +226 -0
- package/dist/index.cjs +44560 -0
- package/dist/index.mjs +44555 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
```markdown
|
|
4
|
+
# Ultron AI SDK
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install ultron-ai-sdk
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
// Import the SDK
|
|
19
|
+
import {SceneCanvas, Character} from './dist/index.mjs';
|
|
20
|
+
|
|
21
|
+
let devices = await navigator.mediaDevices.enumerateDevices();
|
|
22
|
+
console.log(devices)
|
|
23
|
+
let sceneCanvas
|
|
24
|
+
let character
|
|
25
|
+
|
|
26
|
+
const init = async() => {
|
|
27
|
+
sceneCanvas = new SceneCanvas('target-html-element')
|
|
28
|
+
const initializationSetting= {
|
|
29
|
+
avatarId: "AVATAR_ID/REQUEST_ID",
|
|
30
|
+
config:{
|
|
31
|
+
accessToken : "ACCESS_TOKEN",
|
|
32
|
+
refreshToken : "REFRESH_TOKEN",
|
|
33
|
+
// sessionId : "426536db-25a4-4682-9bb4-4e93530f84a0",
|
|
34
|
+
apiKey: "YOUR_ULTRON_API_KEY"
|
|
35
|
+
},
|
|
36
|
+
options:{
|
|
37
|
+
alwaysListen: false // For Push to talk conversation
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await sceneCanvas.init(initializationSetting)
|
|
41
|
+
character = sceneCanvas.character
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
init()
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Target HTML Element
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
|
|
54
|
+
<div id="target-html-element"></div>
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
### Initialization
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const sceneCanvas = new SceneCanvas('target-html-element')
|
|
64
|
+
|
|
65
|
+
ultronSDK.init(config)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Configuration Options
|
|
71
|
+
|
|
72
|
+
| Option | Description |
|
|
73
|
+
|-------------|--------------|
|
|
74
|
+
| `accessToken` | Token recieved on successfull authentication |
|
|
75
|
+
| `refreshToken` |Token recieved on successfull refreshing of existing access token |
|
|
76
|
+
| `sessionId` (optional) | Session Id obtained using API key |
|
|
77
|
+
| `apiKey` | You ultron key which can be found in your profile in Ultron App |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Core Methods
|
|
82
|
+
|
|
83
|
+
### loadAvatar(avatarId)
|
|
84
|
+
|
|
85
|
+
Loads a specific avatar into the container.
|
|
86
|
+
|
|
87
|
+
- `avatarId`: **String** - The unique identifier for the avatar
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Audio Input Device Settings
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
|
|
96
|
+
// to get all microphone input devices
|
|
97
|
+
const devices = ultronSDK.getAudioInputDevices()
|
|
98
|
+
|
|
99
|
+
// You can also use the devices to allow user to choose from the list
|
|
100
|
+
|
|
101
|
+
let myDevice = devices.find(device=> device.label.includes("My_preffered_device_name"))
|
|
102
|
+
|
|
103
|
+
// to set the desired Audio input device
|
|
104
|
+
if(myDevice)
|
|
105
|
+
ultronSDK.setAudioInputDevice(myDevice.deviceId)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## Browser Support
|
|
114
|
+
|
|
115
|
+
✅ Chrome (latest)
|
|
116
|
+
✅ Firefox (latest)
|
|
117
|
+
✅ Safari (latest)
|
|
118
|
+
✅ Edge (latest)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Requirements
|
|
123
|
+
|
|
124
|
+
- WebGL-enabled browser
|
|
125
|
+
- JavaScript enabled
|
|
126
|
+
- Minimum screen resolution: 800x600
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Best Practices
|
|
131
|
+
|
|
132
|
+
- Always initialize the SDK with a valid API key
|
|
133
|
+
- Implement error handling for load failures
|
|
134
|
+
- Clean up resources when removing the avatar
|
|
135
|
+
- Optimize container size for better performance
|
|
136
|
+
- Test across different browsers and devices
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
### Basic Implementation
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
import CharacterCompanionSDK from './dist/index.mjs';
|
|
146
|
+
|
|
147
|
+
init=()=>{
|
|
148
|
+
let sdk = new CharacterCompanionSDK('ultron-model')
|
|
149
|
+
ultronSDK.init({
|
|
150
|
+
accessToken : 'YOUR_ACCESS_TOKEN',
|
|
151
|
+
refreshToken : 'YOUR_REFRESH_TOKEN',
|
|
152
|
+
sessionId : "SESSIOON_ID", // If you have backend or it will create session from apiKey
|
|
153
|
+
apiKey: "YOUR_ULTRON_API_KEY"
|
|
154
|
+
})
|
|
155
|
+
const avatarId = 'AVATAR_ID/REQUEST_ID'
|
|
156
|
+
await ultronSDK.loadAvatarById(avatarId)
|
|
157
|
+
ultronSDK.initAudioListener()
|
|
158
|
+
|
|
159
|
+
// Load an avatar
|
|
160
|
+
await ultron.loadAvatar('avatar-id');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
init()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### Chat with character using AI
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
ultronSDK.chat("your text query to AI")
|
|
172
|
+
|
|
173
|
+
//This will generate a response from AI as per Avatar backstory and character will speak the response
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Make the character say
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
ultronSDK.say("your text that character will speak")
|
|
182
|
+
|
|
183
|
+
// This will simply make the character speak the text you provide
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Switch camera
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
//Switch camera to potrait (closer to face)
|
|
191
|
+
|
|
192
|
+
ultronSDK.switchCameraToPotrait()
|
|
193
|
+
|
|
194
|
+
//Switch camera to normal position (full body view)
|
|
195
|
+
|
|
196
|
+
ultronSDK.switchCameraToNormal()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Support
|
|
203
|
+
|
|
204
|
+
For technical support or questions, please contact our support team or visit our documentation portal.
|
|
205
|
+
|
|
206
|
+
### License
|
|
207
|
+
|
|
208
|
+
This SDK is provided under the terms of our software license agreement.
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
This README.md provides comprehensive documentation for your Ultron AI SDK. You can save this content directly to your project's README.md file. The documentation includes:
|
|
213
|
+
|
|
214
|
+
1. Basic introduction
|
|
215
|
+
2. Feature list
|
|
216
|
+
3. Installation instructions
|
|
217
|
+
4. Quick start guide
|
|
218
|
+
5. Detailed API reference
|
|
219
|
+
6. Usage examples
|
|
220
|
+
7. Browser support
|
|
221
|
+
8. Requirements
|
|
222
|
+
9. Best practices
|
|
223
|
+
10. Support information
|
|
224
|
+
11. License information
|
|
225
|
+
|
|
226
|
+
Would you like me to modify any section or add more specific details about certain features?
|