hume 0.14.2-beta.3 → 0.14.2-beta.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/api/resources/empathicVoice/resources/chat/client/Client.d.ts +1 -1
- package/api/resources/empathicVoice/resources/chat/client/Client.js +27 -2
- package/core/fetcher/Supplier.d.ts +1 -1
- package/dist/api/resources/empathicVoice/resources/chat/client/Client.d.ts +1 -1
- package/dist/api/resources/empathicVoice/resources/chat/client/Client.js +27 -2
- package/dist/core/fetcher/Supplier.d.ts +1 -1
- package/dist/wrapper/HumeClient.d.ts +5 -2
- package/dist/wrapper/HumeClient.js +50 -4
- package/hume-v0.14.2-beta.4.tgz +0 -0
- package/hume-v0.14.2-beta.5.tgz +0 -0
- package/package.json +1 -1
- package/wrapper/HumeClient.d.ts +5 -2
- package/wrapper/HumeClient.js +50 -4
|
@@ -5,7 +5,7 @@ import * as Hume from "../../../../../index.js";
|
|
|
5
5
|
import { ChatSocket } from "./Socket.js";
|
|
6
6
|
export declare namespace Chat {
|
|
7
7
|
interface Options {
|
|
8
|
-
environment?: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls>;
|
|
8
|
+
environment?: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls | string>;
|
|
9
9
|
/** Specify a custom URL to connect the client to. */
|
|
10
10
|
baseUrl?: core.Supplier<string>;
|
|
11
11
|
apiKey?: core.Supplier<string | undefined>;
|
|
@@ -40,12 +40,21 @@ const core = __importStar(require("../../../../../../core/index.js"));
|
|
|
40
40
|
const headers_js_1 = require("../../../../../../core/headers.js");
|
|
41
41
|
const serializers = __importStar(require("../../../../../../serialization/index.js"));
|
|
42
42
|
const Socket_js_1 = require("./Socket.js");
|
|
43
|
+
function createHostnameWithProtocol(url) {
|
|
44
|
+
const protocol = /(https|http|wss|ws):\/\//.exec(url);
|
|
45
|
+
if (protocol) {
|
|
46
|
+
return url.replace("https://", "wss://").replace("http://", "ws://");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return `wss://${url}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
class Chat {
|
|
44
53
|
constructor(_options = {}) {
|
|
45
54
|
this._options = _options;
|
|
46
55
|
}
|
|
47
56
|
connect(args = {}) {
|
|
48
|
-
var _a
|
|
57
|
+
var _a;
|
|
49
58
|
const { accessToken, configId, configVersion, eventLimit, resumedChatGroupId, verboseTranscription, voiceId, apiKey, sessionSettings, queryParams, headers, debug, reconnectAttempts, } = args;
|
|
50
59
|
const _queryParams = {};
|
|
51
60
|
if (accessToken != null) {
|
|
@@ -89,8 +98,24 @@ class Chat {
|
|
|
89
98
|
}
|
|
90
99
|
}
|
|
91
100
|
let _headers = (0, headers_js_1.mergeHeaders)((0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, this._getCustomAuthorizationHeaders())), headers);
|
|
101
|
+
// Construct WebSocket URL with protocol conversion
|
|
102
|
+
const baseUrl = core.Supplier.get(this._options["baseUrl"]);
|
|
103
|
+
const environment = (_a = core.Supplier.get(this._options["environment"])) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Prod;
|
|
104
|
+
let websocketUrl;
|
|
105
|
+
if (baseUrl) {
|
|
106
|
+
// baseUrl takes precedence - apply protocol conversion
|
|
107
|
+
websocketUrl = core.url.join(createHostnameWithProtocol(baseUrl), "/v0/evi/chat");
|
|
108
|
+
}
|
|
109
|
+
else if (typeof environment === "string") {
|
|
110
|
+
// String environment - apply protocol conversion
|
|
111
|
+
websocketUrl = core.url.join(createHostnameWithProtocol(environment), "/v0/evi/chat");
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Structured environment object - use .evi property directly
|
|
115
|
+
websocketUrl = core.url.join(environment.evi, "/chat");
|
|
116
|
+
}
|
|
92
117
|
const socket = new core.ReconnectingWebSocket({
|
|
93
|
-
url:
|
|
118
|
+
url: websocketUrl,
|
|
94
119
|
protocols: [],
|
|
95
120
|
queryParameters: _queryParams,
|
|
96
121
|
headers: _headers,
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
export type Supplier<T> = T | (() => T);
|
|
3
3
|
export declare const Supplier: {
|
|
4
4
|
get: <T>(supplier: Supplier<T>) => T;
|
|
5
|
-
map: <T, U>(supplier: Supplier<T>, f: (value: T) =>
|
|
5
|
+
map: <T, U, R = U>(supplier: Supplier<T>, f: (value: T) => R) => Supplier<R>;
|
|
6
6
|
};
|
|
@@ -5,7 +5,7 @@ import * as Hume from "../../../../../index.js";
|
|
|
5
5
|
import { ChatSocket } from "./Socket.js";
|
|
6
6
|
export declare namespace Chat {
|
|
7
7
|
interface Options {
|
|
8
|
-
environment?: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls>;
|
|
8
|
+
environment?: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls | string>;
|
|
9
9
|
/** Specify a custom URL to connect the client to. */
|
|
10
10
|
baseUrl?: core.Supplier<string>;
|
|
11
11
|
apiKey?: core.Supplier<string | undefined>;
|
|
@@ -40,12 +40,21 @@ const core = __importStar(require("../../../../../../core/index.js"));
|
|
|
40
40
|
const headers_js_1 = require("../../../../../../core/headers.js");
|
|
41
41
|
const serializers = __importStar(require("../../../../../../serialization/index.js"));
|
|
42
42
|
const Socket_js_1 = require("./Socket.js");
|
|
43
|
+
function createHostnameWithProtocol(url) {
|
|
44
|
+
const protocol = /(https|http|wss|ws):\/\//.exec(url);
|
|
45
|
+
if (protocol) {
|
|
46
|
+
return url.replace("https://", "wss://").replace("http://", "ws://");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return `wss://${url}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
class Chat {
|
|
44
53
|
constructor(_options = {}) {
|
|
45
54
|
this._options = _options;
|
|
46
55
|
}
|
|
47
56
|
connect(args = {}) {
|
|
48
|
-
var _a
|
|
57
|
+
var _a;
|
|
49
58
|
const { accessToken, configId, configVersion, eventLimit, resumedChatGroupId, verboseTranscription, voiceId, apiKey, sessionSettings, queryParams, headers, debug, reconnectAttempts, } = args;
|
|
50
59
|
const _queryParams = {};
|
|
51
60
|
if (accessToken != null) {
|
|
@@ -89,8 +98,24 @@ class Chat {
|
|
|
89
98
|
}
|
|
90
99
|
}
|
|
91
100
|
let _headers = (0, headers_js_1.mergeHeaders)((0, headers_js_1.mergeOnlyDefinedHeaders)(Object.assign({}, this._getCustomAuthorizationHeaders())), headers);
|
|
101
|
+
// Construct WebSocket URL with protocol conversion
|
|
102
|
+
const baseUrl = core.Supplier.get(this._options["baseUrl"]);
|
|
103
|
+
const environment = (_a = core.Supplier.get(this._options["environment"])) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Prod;
|
|
104
|
+
let websocketUrl;
|
|
105
|
+
if (baseUrl) {
|
|
106
|
+
// baseUrl takes precedence - apply protocol conversion
|
|
107
|
+
websocketUrl = core.url.join(createHostnameWithProtocol(baseUrl), "/v0/evi/chat");
|
|
108
|
+
}
|
|
109
|
+
else if (typeof environment === "string") {
|
|
110
|
+
// String environment - apply protocol conversion
|
|
111
|
+
websocketUrl = core.url.join(createHostnameWithProtocol(environment), "/v0/evi/chat");
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Structured environment object - use .evi property directly
|
|
115
|
+
websocketUrl = core.url.join(environment.evi, "/chat");
|
|
116
|
+
}
|
|
92
117
|
const socket = new core.ReconnectingWebSocket({
|
|
93
|
-
url:
|
|
118
|
+
url: websocketUrl,
|
|
94
119
|
protocols: [],
|
|
95
120
|
queryParameters: _queryParams,
|
|
96
121
|
headers: _headers,
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
export type Supplier<T> = T | (() => T);
|
|
3
3
|
export declare const Supplier: {
|
|
4
4
|
get: <T>(supplier: Supplier<T>) => T;
|
|
5
|
-
map: <T, U>(supplier: Supplier<T>, f: (value: T) =>
|
|
5
|
+
map: <T, U, R = U>(supplier: Supplier<T>, f: (value: T) => R) => Supplier<R>;
|
|
6
6
|
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { HumeClient as FernClient } from "../Client";
|
|
2
2
|
import * as core from "../core/index.js";
|
|
3
3
|
import { ExpressionMeasurement } from "./expressionMeasurement/ExpressionMeasurementClient";
|
|
4
|
+
import * as environments from "../environments.js";
|
|
4
5
|
export declare namespace HumeClient {
|
|
5
|
-
type Options = FernClient.Options & {
|
|
6
|
+
type Options = Omit<FernClient.Options, 'environment'> & {
|
|
6
7
|
secretKey?: string;
|
|
7
8
|
accessToken?: string;
|
|
8
9
|
} & ({
|
|
9
10
|
accessToken: NonNullable<core.Supplier<string>>;
|
|
10
11
|
} | {
|
|
11
12
|
apiKey: NonNullable<FernClient.Options["apiKey"]>;
|
|
12
|
-
})
|
|
13
|
+
}) & {
|
|
14
|
+
environment: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls | string>;
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
export declare class HumeClient extends FernClient {
|
|
15
18
|
constructor(_options: HumeClient.Options);
|
|
@@ -32,6 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.HumeClient = void 0;
|
|
37
48
|
const Client_1 = require("../Client");
|
|
@@ -39,6 +50,10 @@ const core = __importStar(require("../core/index.js"));
|
|
|
39
50
|
const ExpressionMeasurementClient_1 = require("./expressionMeasurement/ExpressionMeasurementClient");
|
|
40
51
|
class HumeClient extends Client_1.HumeClient {
|
|
41
52
|
constructor(_options) {
|
|
53
|
+
var _a;
|
|
54
|
+
let options;
|
|
55
|
+
let oldEnvironment;
|
|
56
|
+
(_a = _options || {}, { environment: oldEnvironment } = _a, options = __rest(_a, ["environment"]));
|
|
42
57
|
// Check if both accessToken and Authorization header are provided (case-insensitive)
|
|
43
58
|
if (_options.accessToken && _options.headers) {
|
|
44
59
|
const hasAuthHeader = Object.keys(_options.headers).some((key) => key.toLowerCase() === "authorization");
|
|
@@ -46,12 +61,43 @@ class HumeClient extends Client_1.HumeClient {
|
|
|
46
61
|
throw new Error("Cannot provide both 'accessToken' and 'headers.Authorization'. Please use only one.");
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
|
-
// If accessToken is provided, add Authorization header
|
|
50
|
-
let optionsWithAuth = _options || {};
|
|
51
64
|
if (_options.accessToken) {
|
|
52
|
-
|
|
65
|
+
options.headers = Object.assign(Object.assign({}, options.headers), { Authorization: core.Supplier.map(_options.accessToken, (token) => `Bearer ${token}`) });
|
|
66
|
+
}
|
|
67
|
+
// Allow setting a single url http://... or https://... for environment'
|
|
68
|
+
if (oldEnvironment) {
|
|
69
|
+
const environment = _options.environment ? core.Supplier.map(_options.environment, (e) => {
|
|
70
|
+
if (typeof e === "string") {
|
|
71
|
+
if (e.startsWith("http://")) {
|
|
72
|
+
return {
|
|
73
|
+
base: e,
|
|
74
|
+
evi: e.replace('http://', 'ws://') + "/v0/evi",
|
|
75
|
+
tts: e.replace('http://', 'ws://') + "/v0/tts",
|
|
76
|
+
stream: e.replace('http://', 'ws://') + "/v0/stream",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (e.startsWith("https://")) {
|
|
80
|
+
return {
|
|
81
|
+
base: e,
|
|
82
|
+
evi: e.replace('https://', 'wss://') + "/v0/evi",
|
|
83
|
+
tts: e.replace('https://', 'wss://') + "/v0/tts",
|
|
84
|
+
stream: e.replace('https://', 'wss://') + "/v0/stream",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
base: 'https://' + e,
|
|
89
|
+
evi: 'wss://' + e + "/v0/evi",
|
|
90
|
+
tts: 'wss://' + e + "/v0/tts",
|
|
91
|
+
stream: 'wss://' + e + "/v0/stream",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return e;
|
|
96
|
+
}
|
|
97
|
+
}) : undefined;
|
|
98
|
+
options.environment = environment;
|
|
53
99
|
}
|
|
54
|
-
super(
|
|
100
|
+
super(options);
|
|
55
101
|
}
|
|
56
102
|
get expressionMeasurement() {
|
|
57
103
|
var _a;
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
package/wrapper/HumeClient.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { HumeClient as FernClient } from "../Client";
|
|
2
2
|
import * as core from "../core/index.js";
|
|
3
3
|
import { ExpressionMeasurement } from "./expressionMeasurement/ExpressionMeasurementClient";
|
|
4
|
+
import * as environments from "../environments.js";
|
|
4
5
|
export declare namespace HumeClient {
|
|
5
|
-
type Options = FernClient.Options & {
|
|
6
|
+
type Options = Omit<FernClient.Options, 'environment'> & {
|
|
6
7
|
secretKey?: string;
|
|
7
8
|
accessToken?: string;
|
|
8
9
|
} & ({
|
|
9
10
|
accessToken: NonNullable<core.Supplier<string>>;
|
|
10
11
|
} | {
|
|
11
12
|
apiKey: NonNullable<FernClient.Options["apiKey"]>;
|
|
12
|
-
})
|
|
13
|
+
}) & {
|
|
14
|
+
environment: core.Supplier<environments.HumeEnvironment | environments.HumeEnvironmentUrls | string>;
|
|
15
|
+
};
|
|
13
16
|
}
|
|
14
17
|
export declare class HumeClient extends FernClient {
|
|
15
18
|
constructor(_options: HumeClient.Options);
|
package/wrapper/HumeClient.js
CHANGED
|
@@ -32,6 +32,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
35
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
47
|
exports.HumeClient = void 0;
|
|
37
48
|
const Client_1 = require("../Client");
|
|
@@ -39,6 +50,10 @@ const core = __importStar(require("../core/index.js"));
|
|
|
39
50
|
const ExpressionMeasurementClient_1 = require("./expressionMeasurement/ExpressionMeasurementClient");
|
|
40
51
|
class HumeClient extends Client_1.HumeClient {
|
|
41
52
|
constructor(_options) {
|
|
53
|
+
var _a;
|
|
54
|
+
let options;
|
|
55
|
+
let oldEnvironment;
|
|
56
|
+
(_a = _options || {}, { environment: oldEnvironment } = _a, options = __rest(_a, ["environment"]));
|
|
42
57
|
// Check if both accessToken and Authorization header are provided (case-insensitive)
|
|
43
58
|
if (_options.accessToken && _options.headers) {
|
|
44
59
|
const hasAuthHeader = Object.keys(_options.headers).some((key) => key.toLowerCase() === "authorization");
|
|
@@ -46,12 +61,43 @@ class HumeClient extends Client_1.HumeClient {
|
|
|
46
61
|
throw new Error("Cannot provide both 'accessToken' and 'headers.Authorization'. Please use only one.");
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
|
-
// If accessToken is provided, add Authorization header
|
|
50
|
-
let optionsWithAuth = _options || {};
|
|
51
64
|
if (_options.accessToken) {
|
|
52
|
-
|
|
65
|
+
options.headers = Object.assign(Object.assign({}, options.headers), { Authorization: core.Supplier.map(_options.accessToken, (token) => `Bearer ${token}`) });
|
|
66
|
+
}
|
|
67
|
+
// Allow setting a single url http://... or https://... for environment'
|
|
68
|
+
if (oldEnvironment) {
|
|
69
|
+
const environment = _options.environment ? core.Supplier.map(_options.environment, (e) => {
|
|
70
|
+
if (typeof e === "string") {
|
|
71
|
+
if (e.startsWith("http://")) {
|
|
72
|
+
return {
|
|
73
|
+
base: e,
|
|
74
|
+
evi: e.replace('http://', 'ws://') + "/v0/evi",
|
|
75
|
+
tts: e.replace('http://', 'ws://') + "/v0/tts",
|
|
76
|
+
stream: e.replace('http://', 'ws://') + "/v0/stream",
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (e.startsWith("https://")) {
|
|
80
|
+
return {
|
|
81
|
+
base: e,
|
|
82
|
+
evi: e.replace('https://', 'wss://') + "/v0/evi",
|
|
83
|
+
tts: e.replace('https://', 'wss://') + "/v0/tts",
|
|
84
|
+
stream: e.replace('https://', 'wss://') + "/v0/stream",
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
base: 'https://' + e,
|
|
89
|
+
evi: 'wss://' + e + "/v0/evi",
|
|
90
|
+
tts: 'wss://' + e + "/v0/tts",
|
|
91
|
+
stream: 'wss://' + e + "/v0/stream",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return e;
|
|
96
|
+
}
|
|
97
|
+
}) : undefined;
|
|
98
|
+
options.environment = environment;
|
|
53
99
|
}
|
|
54
|
-
super(
|
|
100
|
+
super(options);
|
|
55
101
|
}
|
|
56
102
|
get expressionMeasurement() {
|
|
57
103
|
var _a;
|