Skip to content

Commit 8b87358

Browse files
authored
(feat): websocket respects environment (#94)
1 parent af6bd56 commit 8b87358

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.fernignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ src/wrapper
1919
src/index.ts
2020

2121
# EVI WebSocket
22+
src/core/fetcher/Supplier.ts
2223
src/Client.ts
2324
src/api/resources/empathicVoice/client/Client.ts
2425
src/api/resources/empathicVoice/resources/chat/index.ts

package.json

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

src/api/resources/empathicVoice/resources/chat/client/Client.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import * as environments from '../../../../../../environments';
12
import * as core from '../../../../../../core';
23
import qs from 'qs';
34
import { ChatSocket } from './Socket';
45

56
export declare namespace Chat {
67
interface Options {
8+
environment?: core.Supplier<environments.HumeEnvironment | string>;
79
apiKey?: core.Supplier<string | undefined>;
810
accessToken?: core.Supplier<string | undefined>;
911
}
@@ -58,7 +60,10 @@ export class Chat {
5860
}
5961

6062
const socket = new core.ReconnectingWebSocket(
61-
`wss://api.hume.ai/v0/evi/chat?${qs.stringify(queryParams)}`,
63+
`wss://${(
64+
core.Supplier.get(this._options.environment) ??
65+
environments.HumeEnvironment.Production
66+
).replace('https://', '')}/v0/evi/chat?${qs.stringify(queryParams)}`,
6267
[],
6368
{
6469
debug: args.debug ?? false,

src/core/fetcher/Supplier.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
1+
export type Supplier<T> = T | (() => T);
22

33
export const Supplier = {
4-
get: async <T>(supplier: Supplier<T>): Promise<T> => {
4+
get: <T>(supplier: Supplier<T>): T => {
55
if (typeof supplier === 'function') {
66
return (supplier as () => T)();
77
} else {

0 commit comments

Comments
 (0)