hume 0.14.0 → 0.14.1

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.
@@ -98,17 +98,111 @@ channel:
98
98
  Use the GET `/v0/evi/chat_groups` endpoint to obtain the Chat Group IDs
99
99
  of all Chat Groups associated with an API key. This endpoint returns a
100
100
  list of all available chat groups.
101
- session_settings[audio][channels]: optional<integer>
102
- session_settings[audio][encoding]: optional<string>
103
- session_settings[audio][sample_rate]: optional<integer>
104
- session_settings[context][text]: optional<string>
105
- session_settings[context][type]: optional<string>
106
- session_settings[custom_session_id]: optional<string>
107
- session_settings[event_limit]: optional<integer>
108
- session_settings[language_model_api_key]: optional<string>
109
- session_settings[system_prompt]: optional<string>
110
- session_settings[variables]: optional<string>
111
- session_settings[voice_id]: optional<string>
101
+ session_settings[audio][channels]:
102
+ type: optional<integer>
103
+ docs: Sets number of audio channels for audio input.
104
+ session_settings[audio][encoding]:
105
+ type: optional<string>
106
+ docs: Sets encoding format of the audio input, such as `linear16`.
107
+ session_settings[audio][sample_rate]:
108
+ type: optional<integer>
109
+ docs: >-
110
+ Sets the sample rate for audio input. (Number of samples per second in
111
+ the audio input, measured in Hertz.)
112
+ session_settings[context][text]:
113
+ type: optional<string>
114
+ docs: >-
115
+ The context to be injected into the conversation. Helps inform the LLM's
116
+ response by providing relevant information about the ongoing
117
+ conversation.
118
+
119
+
120
+ This text will be appended to the end of
121
+ [user_messages](/reference/speech-to-speech-evi/chat#receive.UserMessage.message.content)
122
+ based on the chosen persistence level. For example, if you want to
123
+ remind EVI of its role as a helpful weather assistant, the context you
124
+ insert will be appended to the end of user messages as `{Context: You
125
+ are a helpful weather assistant}`.
126
+ session_settings[context][type]:
127
+ type: optional<string>
128
+ docs: >-
129
+ The persistence level of the injected context. Specifies how long the
130
+ injected context will remain active in the session.
131
+
132
+
133
+ - **Temporary**: Context that is only applied to the following assistant
134
+ response.
135
+
136
+
137
+ - **Persistent**: Context that is applied to all subsequent assistant
138
+ responses for the remainder of the Chat.
139
+ session_settings[custom_session_id]:
140
+ type: optional<string>
141
+ docs: >-
142
+ Used to manage conversational state, correlate frontend and backend
143
+ data, and persist conversations across EVI sessions.
144
+ session_settings[event_limit]:
145
+ type: optional<integer>
146
+ docs: >-
147
+ The maximum number of chat events to return from chat history. By
148
+ default, the system returns up to 300 events (100 events per page × 3
149
+ pages). Set this parameter to a smaller value to limit the number of
150
+ events returned.
151
+ session_settings[language_model_api_key]:
152
+ type: optional<string>
153
+ docs: >-
154
+ Third party API key for the supplemental language model.
155
+
156
+
157
+ When provided, EVI will use this key instead of Hume's API key for the
158
+ supplemental LLM. This allows you to bypass rate limits and utilize your
159
+ own API key as needed.
160
+ session_settings[system_prompt]:
161
+ type: optional<string>
162
+ docs: >-
163
+ Instructions used to shape EVI's behavior, responses, and style for the
164
+ session.
165
+
166
+
167
+ When included in a Session Settings message, the provided Prompt
168
+ overrides the existing one specified in the EVI configuration. If no
169
+ Prompt was defined in the configuration, this Prompt will be the one
170
+ used for the session.
171
+
172
+
173
+ You can use the Prompt to define a specific goal or role for EVI,
174
+ specifying how it should act or what it should focus on during the
175
+ conversation. For example, EVI can be instructed to act as a customer
176
+ support representative, a fitness coach, or a travel advisor, each with
177
+ its own set of behaviors and response styles.
178
+
179
+
180
+ For help writing a system prompt, see our [Prompting
181
+ Guide](/docs/speech-to-speech-evi/guides/prompting).
182
+ session_settings[variables]:
183
+ type: optional<string>
184
+ docs: >-
185
+ This field allows you to assign values to dynamic variables referenced
186
+ in your system prompt.
187
+
188
+
189
+ Each key represents the variable name, and the corresponding value is
190
+ the specific content you wish to assign to that variable within the
191
+ session. While the values for variables can be strings, numbers, or
192
+ booleans, the value will ultimately be converted to a string when
193
+ injected into your system prompt.
194
+
195
+
196
+ Using this field, you can personalize responses based on
197
+ session-specific details. For more guidance, see our [guide on using
198
+ dynamic
199
+ variables](/docs/speech-to-speech-evi/features/dynamic-variables).
200
+ session_settings[voice_id]:
201
+ type: optional<string>
202
+ docs: >-
203
+ The name or ID of the voice from the `Voice Library` to be used as the
204
+ speaker for this EVI session. This will override the speaker set in the
205
+ selected configuration.
112
206
  verbose_transcription:
113
207
  type: optional<boolean>
114
208
  default: false
@@ -2,6 +2,7 @@
2
2
  import * as environments from "../../../../../../environments";
3
3
  import * as core from "../../../../../../core";
4
4
  import { ChatSocket } from "./Socket";
5
+ import { SessionSettings } from "../../../types/SessionSettings";
5
6
  export declare function createHostnameWithProtocol(environment: string): string;
6
7
  export declare namespace Chat {
7
8
  interface Options {
@@ -24,6 +25,9 @@ export declare namespace Chat {
24
25
  verboseTranscription?: boolean;
25
26
  /** ID of the Voice to use for this chat. If specified, will override the voice set in the Config */
26
27
  voiceId?: string;
28
+ sessionSettings?: Pick<SessionSettings, Exclude<keyof SessionSettings, "builtinTools" | "type" | "metadata" | "tools">> & {
29
+ eventLimit?: number;
30
+ };
27
31
  /** Extra query parameters sent at WebSocket connection */
28
32
  queryParams?: Record<string, string | string[] | object | object[]>;
29
33
  }
@@ -58,7 +58,7 @@ class Chat {
58
58
  this._options = _options;
59
59
  }
60
60
  connect(args = {}) {
61
- var _a, _b, _c;
61
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
62
62
  const queryParams = {};
63
63
  queryParams["fernSdkLanguage"] = "JavaScript";
64
64
  queryParams["fernSdkVersion"] = version_1.SDK_VERSION;
@@ -85,15 +85,58 @@ class Chat {
85
85
  if (args.voiceId !== null && args.voiceId !== undefined && args.voiceId !== "") {
86
86
  queryParams["voice_id"] = args.voiceId;
87
87
  }
88
+ if (args.sessionSettings !== null && args.sessionSettings !== undefined) {
89
+ if (args.sessionSettings.audio !== null && args.sessionSettings.audio !== undefined) {
90
+ if (((_a = args.sessionSettings.audio) === null || _a === void 0 ? void 0 : _a.channels) !== null &&
91
+ ((_b = args.sessionSettings.audio) === null || _b === void 0 ? void 0 : _b.channels) !== undefined) {
92
+ queryParams["session_settings[audio][channels]"] = String(args.sessionSettings.audio.channels);
93
+ }
94
+ if (((_c = args.sessionSettings.audio) === null || _c === void 0 ? void 0 : _c.encoding) !== null &&
95
+ ((_d = args.sessionSettings.audio) === null || _d === void 0 ? void 0 : _d.encoding) !== undefined) {
96
+ queryParams["session_settings[audio][encoding]"] = String(args.sessionSettings.audio.encoding);
97
+ }
98
+ if (((_e = args.sessionSettings.audio) === null || _e === void 0 ? void 0 : _e.sampleRate) !== null &&
99
+ ((_f = args.sessionSettings.audio) === null || _f === void 0 ? void 0 : _f.sampleRate) !== undefined) {
100
+ queryParams["session_settings[audio][sample_rate]"] = String(args.sessionSettings.audio.sampleRate);
101
+ }
102
+ }
103
+ if (args.sessionSettings.context !== null && args.sessionSettings.context !== undefined) {
104
+ if (((_h = (_g = args.sessionSettings) === null || _g === void 0 ? void 0 : _g.context) === null || _h === void 0 ? void 0 : _h.text) !== null && ((_k = (_j = args.sessionSettings) === null || _j === void 0 ? void 0 : _j.context) === null || _k === void 0 ? void 0 : _k.text) !== undefined) {
105
+ queryParams["session_settings[context][text]"] = String(args.sessionSettings.context.text);
106
+ }
107
+ if (((_m = (_l = args.sessionSettings) === null || _l === void 0 ? void 0 : _l.context) === null || _m === void 0 ? void 0 : _m.type) !== null && ((_p = (_o = args.sessionSettings) === null || _o === void 0 ? void 0 : _o.context) === null || _p === void 0 ? void 0 : _p.type) !== undefined) {
108
+ queryParams["session_settings[context][type]"] = String(args.sessionSettings.context.type);
109
+ }
110
+ }
111
+ if (((_q = args.sessionSettings) === null || _q === void 0 ? void 0 : _q.customSessionId) !== null && ((_r = args.sessionSettings) === null || _r === void 0 ? void 0 : _r.customSessionId) !== undefined) {
112
+ queryParams["session_settings[custom_session_id]"] = String(args.sessionSettings.customSessionId);
113
+ }
114
+ if (((_s = args.sessionSettings) === null || _s === void 0 ? void 0 : _s.eventLimit) !== null && ((_t = args.sessionSettings) === null || _t === void 0 ? void 0 : _t.eventLimit) !== undefined) {
115
+ queryParams["session_settings[event_limit]"] = String(args.sessionSettings.eventLimit);
116
+ }
117
+ if (((_u = args.sessionSettings) === null || _u === void 0 ? void 0 : _u.languageModelApiKey) !== null &&
118
+ ((_v = args.sessionSettings) === null || _v === void 0 ? void 0 : _v.languageModelApiKey) !== undefined) {
119
+ queryParams["session_settings[language_model_api_key]"] = String(args.sessionSettings.languageModelApiKey);
120
+ }
121
+ if (((_w = args.sessionSettings) === null || _w === void 0 ? void 0 : _w.systemPrompt) !== null && ((_x = args.sessionSettings) === null || _x === void 0 ? void 0 : _x.systemPrompt) !== undefined) {
122
+ queryParams["session_settings[system_prompt]"] = String(args.sessionSettings.systemPrompt);
123
+ }
124
+ if (((_y = args.sessionSettings) === null || _y === void 0 ? void 0 : _y.variables) !== null && ((_z = args.sessionSettings) === null || _z === void 0 ? void 0 : _z.variables) !== undefined) {
125
+ queryParams["session_settings[variables]"] = String(args.sessionSettings.variables);
126
+ }
127
+ if (((_0 = args.sessionSettings) === null || _0 === void 0 ? void 0 : _0.voiceId) !== null && ((_1 = args.sessionSettings) === null || _1 === void 0 ? void 0 : _1.voiceId) !== undefined) {
128
+ queryParams["session_settings[voice_id]"] = String(args.sessionSettings.voiceId);
129
+ }
130
+ }
88
131
  if (args.queryParams !== null && args.queryParams !== undefined) {
89
132
  for (const [name, value] of Object.entries(args.queryParams)) {
90
133
  queryParams[name] = value;
91
134
  }
92
135
  }
93
- const hostname = createHostnameWithProtocol((_a = core.Supplier.get(this._options.environment)) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Production);
136
+ const hostname = createHostnameWithProtocol((_2 = core.Supplier.get(this._options.environment)) !== null && _2 !== void 0 ? _2 : environments.HumeEnvironment.Production);
94
137
  const socket = new core.ReconnectingWebSocket(`${hostname}/v0/evi/chat?${qs_1.default.stringify(queryParams)}`, [], {
95
- debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false,
96
- maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30,
138
+ debug: (_3 = args.debug) !== null && _3 !== void 0 ? _3 : false,
139
+ maxRetries: (_4 = args.reconnectAttempts) !== null && _4 !== void 0 ? _4 : 30,
97
140
  });
98
141
  return new Socket_1.ChatSocket({
99
142
  socket,
@@ -2,6 +2,7 @@
2
2
  import * as environments from "../../../../../../environments";
3
3
  import * as core from "../../../../../../core";
4
4
  import { ChatSocket } from "./Socket";
5
+ import { SessionSettings } from "../../../types/SessionSettings";
5
6
  export declare function createHostnameWithProtocol(environment: string): string;
6
7
  export declare namespace Chat {
7
8
  interface Options {
@@ -24,6 +25,9 @@ export declare namespace Chat {
24
25
  verboseTranscription?: boolean;
25
26
  /** ID of the Voice to use for this chat. If specified, will override the voice set in the Config */
26
27
  voiceId?: string;
28
+ sessionSettings?: Pick<SessionSettings, Exclude<keyof SessionSettings, "builtinTools" | "type" | "metadata" | "tools">> & {
29
+ eventLimit?: number;
30
+ };
27
31
  /** Extra query parameters sent at WebSocket connection */
28
32
  queryParams?: Record<string, string | string[] | object | object[]>;
29
33
  }
@@ -58,7 +58,7 @@ class Chat {
58
58
  this._options = _options;
59
59
  }
60
60
  connect(args = {}) {
61
- var _a, _b, _c;
61
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
62
62
  const queryParams = {};
63
63
  queryParams["fernSdkLanguage"] = "JavaScript";
64
64
  queryParams["fernSdkVersion"] = version_1.SDK_VERSION;
@@ -85,15 +85,58 @@ class Chat {
85
85
  if (args.voiceId !== null && args.voiceId !== undefined && args.voiceId !== "") {
86
86
  queryParams["voice_id"] = args.voiceId;
87
87
  }
88
+ if (args.sessionSettings !== null && args.sessionSettings !== undefined) {
89
+ if (args.sessionSettings.audio !== null && args.sessionSettings.audio !== undefined) {
90
+ if (((_a = args.sessionSettings.audio) === null || _a === void 0 ? void 0 : _a.channels) !== null &&
91
+ ((_b = args.sessionSettings.audio) === null || _b === void 0 ? void 0 : _b.channels) !== undefined) {
92
+ queryParams["session_settings[audio][channels]"] = String(args.sessionSettings.audio.channels);
93
+ }
94
+ if (((_c = args.sessionSettings.audio) === null || _c === void 0 ? void 0 : _c.encoding) !== null &&
95
+ ((_d = args.sessionSettings.audio) === null || _d === void 0 ? void 0 : _d.encoding) !== undefined) {
96
+ queryParams["session_settings[audio][encoding]"] = String(args.sessionSettings.audio.encoding);
97
+ }
98
+ if (((_e = args.sessionSettings.audio) === null || _e === void 0 ? void 0 : _e.sampleRate) !== null &&
99
+ ((_f = args.sessionSettings.audio) === null || _f === void 0 ? void 0 : _f.sampleRate) !== undefined) {
100
+ queryParams["session_settings[audio][sample_rate]"] = String(args.sessionSettings.audio.sampleRate);
101
+ }
102
+ }
103
+ if (args.sessionSettings.context !== null && args.sessionSettings.context !== undefined) {
104
+ if (((_h = (_g = args.sessionSettings) === null || _g === void 0 ? void 0 : _g.context) === null || _h === void 0 ? void 0 : _h.text) !== null && ((_k = (_j = args.sessionSettings) === null || _j === void 0 ? void 0 : _j.context) === null || _k === void 0 ? void 0 : _k.text) !== undefined) {
105
+ queryParams["session_settings[context][text]"] = String(args.sessionSettings.context.text);
106
+ }
107
+ if (((_m = (_l = args.sessionSettings) === null || _l === void 0 ? void 0 : _l.context) === null || _m === void 0 ? void 0 : _m.type) !== null && ((_p = (_o = args.sessionSettings) === null || _o === void 0 ? void 0 : _o.context) === null || _p === void 0 ? void 0 : _p.type) !== undefined) {
108
+ queryParams["session_settings[context][type]"] = String(args.sessionSettings.context.type);
109
+ }
110
+ }
111
+ if (((_q = args.sessionSettings) === null || _q === void 0 ? void 0 : _q.customSessionId) !== null && ((_r = args.sessionSettings) === null || _r === void 0 ? void 0 : _r.customSessionId) !== undefined) {
112
+ queryParams["session_settings[custom_session_id]"] = String(args.sessionSettings.customSessionId);
113
+ }
114
+ if (((_s = args.sessionSettings) === null || _s === void 0 ? void 0 : _s.eventLimit) !== null && ((_t = args.sessionSettings) === null || _t === void 0 ? void 0 : _t.eventLimit) !== undefined) {
115
+ queryParams["session_settings[event_limit]"] = String(args.sessionSettings.eventLimit);
116
+ }
117
+ if (((_u = args.sessionSettings) === null || _u === void 0 ? void 0 : _u.languageModelApiKey) !== null &&
118
+ ((_v = args.sessionSettings) === null || _v === void 0 ? void 0 : _v.languageModelApiKey) !== undefined) {
119
+ queryParams["session_settings[language_model_api_key]"] = String(args.sessionSettings.languageModelApiKey);
120
+ }
121
+ if (((_w = args.sessionSettings) === null || _w === void 0 ? void 0 : _w.systemPrompt) !== null && ((_x = args.sessionSettings) === null || _x === void 0 ? void 0 : _x.systemPrompt) !== undefined) {
122
+ queryParams["session_settings[system_prompt]"] = String(args.sessionSettings.systemPrompt);
123
+ }
124
+ if (((_y = args.sessionSettings) === null || _y === void 0 ? void 0 : _y.variables) !== null && ((_z = args.sessionSettings) === null || _z === void 0 ? void 0 : _z.variables) !== undefined) {
125
+ queryParams["session_settings[variables]"] = String(args.sessionSettings.variables);
126
+ }
127
+ if (((_0 = args.sessionSettings) === null || _0 === void 0 ? void 0 : _0.voiceId) !== null && ((_1 = args.sessionSettings) === null || _1 === void 0 ? void 0 : _1.voiceId) !== undefined) {
128
+ queryParams["session_settings[voice_id]"] = String(args.sessionSettings.voiceId);
129
+ }
130
+ }
88
131
  if (args.queryParams !== null && args.queryParams !== undefined) {
89
132
  for (const [name, value] of Object.entries(args.queryParams)) {
90
133
  queryParams[name] = value;
91
134
  }
92
135
  }
93
- const hostname = createHostnameWithProtocol((_a = core.Supplier.get(this._options.environment)) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Production);
136
+ const hostname = createHostnameWithProtocol((_2 = core.Supplier.get(this._options.environment)) !== null && _2 !== void 0 ? _2 : environments.HumeEnvironment.Production);
94
137
  const socket = new core.ReconnectingWebSocket(`${hostname}/v0/evi/chat?${qs_1.default.stringify(queryParams)}`, [], {
95
- debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false,
96
- maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30,
138
+ debug: (_3 = args.debug) !== null && _3 !== void 0 ? _3 : false,
139
+ maxRetries: (_4 = args.reconnectAttempts) !== null && _4 !== void 0 ? _4 : 30,
97
140
  });
98
141
  return new Socket_1.ChatSocket({
99
142
  socket,
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.14.0";
1
+ export declare const SDK_VERSION = "0.14.1";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.14.0";
4
+ exports.SDK_VERSION = "0.14.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hume",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "private": false,
5
5
  "repository": "https://github.com/HumeAI/hume-typescript-sdk",
6
6
  "main": "./index.js",
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.14.0";
1
+ export declare const SDK_VERSION = "0.14.1";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.14.0";
4
+ exports.SDK_VERSION = "0.14.1";