@drawdream/livespeech 0.1.4 → 0.1.6
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 +30 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +4 -0
- package/dist/index.mjs +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@ connect() → startSession() → audioStart() → sendAudioChunk()* → audioEnd
|
|
|
90
90
|
const client = new LiveSpeechClient({
|
|
91
91
|
region: 'ap-northeast-2', // Required: Seoul region
|
|
92
92
|
apiKey: 'your-api-key', // Required: Your API key
|
|
93
|
+
userId: 'user-123', // Optional: Enable conversation memory
|
|
93
94
|
autoReconnect: true, // Auto-reconnect on disconnect
|
|
94
95
|
maxReconnectAttempts: 5, // Maximum reconnection attempts
|
|
95
96
|
debug: false, // Enable debug logging
|
|
@@ -101,6 +102,35 @@ await client.startSession({
|
|
|
101
102
|
});
|
|
102
103
|
```
|
|
103
104
|
|
|
105
|
+
## Conversation Memory
|
|
106
|
+
|
|
107
|
+
When you provide a `userId`, the SDK enables persistent conversation memory:
|
|
108
|
+
|
|
109
|
+
- **Entity Memory**: AI remembers facts shared in previous sessions (names, preferences, relationships)
|
|
110
|
+
- **Session Summaries**: Recent conversation summaries are available to the AI
|
|
111
|
+
- **Cross-Session**: Memory persists across sessions for the same `userId`
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// With memory (authenticated user)
|
|
115
|
+
const client = new LiveSpeechClient({
|
|
116
|
+
region: 'ap-northeast-2',
|
|
117
|
+
apiKey: 'your-api-key',
|
|
118
|
+
userId: 'user-123', // Enables conversation memory
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Without memory (guest)
|
|
122
|
+
const client = new LiveSpeechClient({
|
|
123
|
+
region: 'ap-northeast-2',
|
|
124
|
+
apiKey: 'your-api-key',
|
|
125
|
+
// No userId = guest mode, no persistent memory
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Mode | Memory Persistence | Use Case |
|
|
130
|
+
|------|-------------------|----------|
|
|
131
|
+
| With `userId` | Permanent | Authenticated users |
|
|
132
|
+
| Without `userId` | Session only | Guests, anonymous users |
|
|
133
|
+
|
|
104
134
|
## Events
|
|
105
135
|
|
|
106
136
|
| Event | Description | Key Properties |
|
package/dist/index.d.mts
CHANGED
|
@@ -46,6 +46,15 @@ interface LiveSpeechConfig {
|
|
|
46
46
|
* API key for authentication
|
|
47
47
|
*/
|
|
48
48
|
apiKey: string;
|
|
49
|
+
/**
|
|
50
|
+
* User identifier for conversation memory persistence.
|
|
51
|
+
* When provided, conversation history is stored and can be retrieved across sessions.
|
|
52
|
+
* If not provided, the user is treated as a "guest" and conversations are stored
|
|
53
|
+
* temporarily per connection.
|
|
54
|
+
*
|
|
55
|
+
* @example "user-123"
|
|
56
|
+
*/
|
|
57
|
+
userId?: string;
|
|
49
58
|
/**
|
|
50
59
|
* Connection timeout in milliseconds
|
|
51
60
|
* @default 30000
|
|
@@ -112,6 +121,7 @@ interface SessionConfig {
|
|
|
112
121
|
interface ResolvedConfig {
|
|
113
122
|
endpoint: string;
|
|
114
123
|
apiKey: string;
|
|
124
|
+
userId?: string;
|
|
115
125
|
connectionTimeout: number;
|
|
116
126
|
autoReconnect: boolean;
|
|
117
127
|
maxReconnectAttempts: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ interface LiveSpeechConfig {
|
|
|
46
46
|
* API key for authentication
|
|
47
47
|
*/
|
|
48
48
|
apiKey: string;
|
|
49
|
+
/**
|
|
50
|
+
* User identifier for conversation memory persistence.
|
|
51
|
+
* When provided, conversation history is stored and can be retrieved across sessions.
|
|
52
|
+
* If not provided, the user is treated as a "guest" and conversations are stored
|
|
53
|
+
* temporarily per connection.
|
|
54
|
+
*
|
|
55
|
+
* @example "user-123"
|
|
56
|
+
*/
|
|
57
|
+
userId?: string;
|
|
49
58
|
/**
|
|
50
59
|
* Connection timeout in milliseconds
|
|
51
60
|
* @default 30000
|
|
@@ -112,6 +121,7 @@ interface SessionConfig {
|
|
|
112
121
|
interface ResolvedConfig {
|
|
113
122
|
endpoint: string;
|
|
114
123
|
apiKey: string;
|
|
124
|
+
userId?: string;
|
|
115
125
|
connectionTimeout: number;
|
|
116
126
|
autoReconnect: boolean;
|
|
117
127
|
maxReconnectAttempts: number;
|
package/dist/index.js
CHANGED
|
@@ -281,6 +281,9 @@ var WebSocketConnection = class {
|
|
|
281
281
|
try {
|
|
282
282
|
const url = new URL(this.config.endpoint);
|
|
283
283
|
url.searchParams.set("apiKey", this.config.apiKey);
|
|
284
|
+
if (this.config.userId) {
|
|
285
|
+
url.searchParams.set("userId", this.config.userId);
|
|
286
|
+
}
|
|
284
287
|
this.logger.info("Connecting to", url.origin);
|
|
285
288
|
this.ws = new WebSocket(url.toString());
|
|
286
289
|
const timeoutId = setTimeout(() => {
|
|
@@ -629,6 +632,7 @@ var LiveSpeechClient = class {
|
|
|
629
632
|
this.config = {
|
|
630
633
|
endpoint,
|
|
631
634
|
apiKey: config.apiKey,
|
|
635
|
+
...config.userId && { userId: config.userId },
|
|
632
636
|
connectionTimeout: config.connectionTimeout ?? CONFIG_DEFAULTS.connectionTimeout,
|
|
633
637
|
autoReconnect: config.autoReconnect ?? CONFIG_DEFAULTS.autoReconnect,
|
|
634
638
|
maxReconnectAttempts: config.maxReconnectAttempts ?? CONFIG_DEFAULTS.maxReconnectAttempts,
|
package/dist/index.mjs
CHANGED
|
@@ -242,6 +242,9 @@ var WebSocketConnection = class {
|
|
|
242
242
|
try {
|
|
243
243
|
const url = new URL(this.config.endpoint);
|
|
244
244
|
url.searchParams.set("apiKey", this.config.apiKey);
|
|
245
|
+
if (this.config.userId) {
|
|
246
|
+
url.searchParams.set("userId", this.config.userId);
|
|
247
|
+
}
|
|
245
248
|
this.logger.info("Connecting to", url.origin);
|
|
246
249
|
this.ws = new WebSocket(url.toString());
|
|
247
250
|
const timeoutId = setTimeout(() => {
|
|
@@ -590,6 +593,7 @@ var LiveSpeechClient = class {
|
|
|
590
593
|
this.config = {
|
|
591
594
|
endpoint,
|
|
592
595
|
apiKey: config.apiKey,
|
|
596
|
+
...config.userId && { userId: config.userId },
|
|
593
597
|
connectionTimeout: config.connectionTimeout ?? CONFIG_DEFAULTS.connectionTimeout,
|
|
594
598
|
autoReconnect: config.autoReconnect ?? CONFIG_DEFAULTS.autoReconnect,
|
|
595
599
|
maxReconnectAttempts: config.maxReconnectAttempts ?? CONFIG_DEFAULTS.maxReconnectAttempts,
|