Skip to content

Commit 7eeae44

Browse files
authored
(feat): add chat resumability (#34)
1 parent 40f4b6d commit 7eeae44

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hume",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"private": false,
55
"repository": "https://github.com/HumeAI/hume-typescript-sdk",
66
"main": "./index.js",

src/api/resources/empathicVoice/client/StreamSocket.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class StreamSocket {
3535
}
3636

3737
/**
38-
* Send session settings
38+
* Send assistant input
3939
*/
4040
public async sendAssistantInput(message: Omit<Hume.empathicVoice.AssistantInput, "type">): Promise<void> {
4141
await this.sendJson({
@@ -44,6 +44,26 @@ export class StreamSocket {
4444
});
4545
}
4646

47+
/**
48+
* Send pause assistant message
49+
*/
50+
public async pauseAssistant(message: Omit<Hume.empathicVoice.PauseAssistantMessage, "type">): Promise<void> {
51+
await this.sendJson({
52+
type: "pause_assistant_message",
53+
...message,
54+
});
55+
}
56+
57+
/**
58+
* Send resume assistant message
59+
*/
60+
public async resumeAssistant(message: Omit<Hume.empathicVoice.ResumeAssistantMessage, "type">): Promise<void> {
61+
await this.sendJson({
62+
type: "resume_assistant_message",
63+
...message,
64+
});
65+
}
66+
4767
/**
4868
* Send text input
4969
*/

src/wrapper/empathicVoice/chat/ChatClient.ts

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export declare namespace ChatClient {
1818
/** The version of the configuration. */
1919
configVersion?: string;
2020

21+
/** The ID of a chat group, used to resume a previous chat. */
22+
resumedChatGroupId?: string;
23+
2124
onOpen?: () => void;
2225
onMessage?: (message: Hume.empathicVoice.SubscribeEvent) => void;
2326
onError?: (error: Hume.empathicVoice.WebSocketError) => void;
@@ -39,6 +42,9 @@ export class ChatClient {
3942
if (args.configVersion != null) {
4043
queryParams["config_version"] = args.configVersion;
4144
}
45+
if (args.resumedChatGroupId != null) {
46+
queryParams["resumed_chat_group_id"] = args.resumedChatGroupId;
47+
}
4248

4349
const websocket = await core.connect(`wss://api.hume.ai/v0/evi/chat?${qs.stringify(queryParams)}`);
4450

0 commit comments

Comments
 (0)