whio-api-sdk 1.0.177-beta → 1.0.178-beta
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 +83 -0
- package/dist/src/sdk/sdk.d.ts +8 -1
- package/dist/src/sdk/sdk.js +37 -2
- package/dist/src/sdk/types.d.ts +13 -0
- package/package.json +1 -1
- package/src/sdk/sdk.ts +37 -1
- package/src/sdk/types.ts +15 -0
package/README.md
CHANGED
|
@@ -1,2 +1,85 @@
|
|
|
1
1
|
# whio-sdk
|
|
2
2
|
A JS SDK that interacts with our medical-assistant-api
|
|
3
|
+
|
|
4
|
+
## Audio Transcription Queue
|
|
5
|
+
|
|
6
|
+
The SDK now supports automatic audio transcription through a background queue system. When you upload audio files, they are automatically processed and transcribed.
|
|
7
|
+
|
|
8
|
+
### Upload Audio with Transcription Queue
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { ApiSDK, AudioFileStatus } from 'whio-sdk';
|
|
12
|
+
|
|
13
|
+
const sdk = new ApiSDK({ baseUrl: 'https://your-api.com' });
|
|
14
|
+
|
|
15
|
+
// Simple upload (automatically triggers transcription)
|
|
16
|
+
const audioFile = await sdk.uploadAudioFileToSession(sessionId, file);
|
|
17
|
+
|
|
18
|
+
// Upload with cultural context
|
|
19
|
+
const audioFileWithContext = await sdk.uploadAudioFileToSession(
|
|
20
|
+
sessionId,
|
|
21
|
+
file,
|
|
22
|
+
'audio.mp3',
|
|
23
|
+
'This is cultural context for the audio'
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Alternative method with options object
|
|
27
|
+
const audioFileAlt = await sdk.uploadAudioFileWithTranscriptionQueue(sessionId, file, {
|
|
28
|
+
fileName: 'recording.mp3',
|
|
29
|
+
culturalTranscription: 'Patient discussing symptoms in Māori'
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Check Transcription Results
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Get specific audio file with transcription results
|
|
37
|
+
const audioFile = await sdk.getAudioFile(audioFileId);
|
|
38
|
+
|
|
39
|
+
if (audioFile.status === AudioFileStatus.TRANSCRIBED) {
|
|
40
|
+
console.log('Transcription:', audioFile.transcription);
|
|
41
|
+
console.log('Cultural Context:', audioFile.cultural_transcription);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Get all transcribed files
|
|
45
|
+
const transcribedFiles = await sdk.getTranscribedAudioFiles();
|
|
46
|
+
|
|
47
|
+
// Get files currently being processed
|
|
48
|
+
const processingFiles = await sdk.getProcessingAudioFiles();
|
|
49
|
+
|
|
50
|
+
// Get failed transcriptions
|
|
51
|
+
const failedFiles = await sdk.getFailedAudioFiles();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Audio File Status
|
|
55
|
+
|
|
56
|
+
Audio files have the following status values:
|
|
57
|
+
- `UPLOADED` - File uploaded, waiting for transcription
|
|
58
|
+
- `PROCESSING` - Currently being transcribed
|
|
59
|
+
- `TRANSCRIBED` - Transcription complete
|
|
60
|
+
- `FAILED` - Transcription failed
|
|
61
|
+
|
|
62
|
+
### Key Features
|
|
63
|
+
|
|
64
|
+
- **Automatic Processing**: Upload triggers transcription automatically
|
|
65
|
+
- **Serial Processing**: Files are processed one at a time for reliability
|
|
66
|
+
- **Cultural Context**: Optional cultural transcription field for context
|
|
67
|
+
- **Status Tracking**: Monitor transcription progress
|
|
68
|
+
- **Error Handling**: Graceful handling of transcription failures
|
|
69
|
+
- **Fire and Forget**: No polling required - just upload and check later
|
|
70
|
+
|
|
71
|
+
### Example Usage
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
// Upload and get immediate response
|
|
75
|
+
const audioFile = await sdk.uploadAudioFileToSession(sessionId, audioBlob, 'recording.wav');
|
|
76
|
+
console.log('Status:', audioFile.status); // 'UPLOADED'
|
|
77
|
+
|
|
78
|
+
// Check later for transcription results
|
|
79
|
+
setTimeout(async () => {
|
|
80
|
+
const updatedFile = await sdk.getAudioFile(audioFile.id);
|
|
81
|
+
if (updatedFile.status === AudioFileStatus.TRANSCRIBED) {
|
|
82
|
+
console.log('Transcription ready:', updatedFile.transcription);
|
|
83
|
+
}
|
|
84
|
+
}, 10000); // Check after 10 seconds
|
|
85
|
+
```
|
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -102,7 +102,11 @@ export declare class ApiSDK {
|
|
|
102
102
|
getAgentSettingsByAgentAndOrganization(agentId: string, organizationId: string): Promise<AgentSettings>;
|
|
103
103
|
updateAgentSettings(id: string, settingsData: UpdateAgentSettingsDto): Promise<AgentSettings>;
|
|
104
104
|
deleteAgentSettings(id: string): Promise<void>;
|
|
105
|
-
uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile>;
|
|
105
|
+
uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, culturalTranscription?: string): Promise<AudioFile>;
|
|
106
|
+
uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: {
|
|
107
|
+
fileName?: string;
|
|
108
|
+
culturalTranscription?: string;
|
|
109
|
+
}): Promise<AudioFile>;
|
|
106
110
|
getMyAudioFiles(): Promise<AudioFile[]>;
|
|
107
111
|
getAllAudioFiles(): Promise<AudioFile[]>;
|
|
108
112
|
getOrganizationAudioFiles(): Promise<AudioFile[]>;
|
|
@@ -112,4 +116,7 @@ export declare class ApiSDK {
|
|
|
112
116
|
deleteAudioFile(id: string): Promise<void>;
|
|
113
117
|
downloadAudioFile(id: string): Promise<Blob>;
|
|
114
118
|
downloadAudioFileAsUrl(id: string): Promise<string>;
|
|
119
|
+
getTranscribedAudioFiles(): Promise<AudioFile[]>;
|
|
120
|
+
getProcessingAudioFiles(): Promise<AudioFile[]>;
|
|
121
|
+
getFailedAudioFiles(): Promise<AudioFile[]>;
|
|
115
122
|
}
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
// sdk.ts
|
|
11
|
-
import { OrganizationRoleType, } from './types';
|
|
11
|
+
import { OrganizationRoleType, AudioFileStatus, } from './types';
|
|
12
12
|
import urls from './urls';
|
|
13
13
|
import { jwtDecode } from 'jwt-decode';
|
|
14
14
|
export class ApiSDK {
|
|
@@ -766,10 +766,24 @@ export class ApiSDK {
|
|
|
766
766
|
// ======================
|
|
767
767
|
// AUDIO FILE METHODS
|
|
768
768
|
// ======================
|
|
769
|
-
uploadAudioFileToSession(sessionId, file, fileName) {
|
|
769
|
+
uploadAudioFileToSession(sessionId, file, fileName, culturalTranscription) {
|
|
770
770
|
return __awaiter(this, void 0, void 0, function* () {
|
|
771
771
|
const formData = new FormData();
|
|
772
772
|
formData.append('file', file, fileName);
|
|
773
|
+
if (culturalTranscription) {
|
|
774
|
+
formData.append('cultural_transcription', culturalTranscription);
|
|
775
|
+
}
|
|
776
|
+
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
uploadAudioFileWithTranscriptionQueue(sessionId, file, options) {
|
|
780
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
781
|
+
const formData = new FormData();
|
|
782
|
+
formData.append('file', file, options === null || options === void 0 ? void 0 : options.fileName);
|
|
783
|
+
if (options === null || options === void 0 ? void 0 : options.culturalTranscription) {
|
|
784
|
+
formData.append('cultural_transcription', options.culturalTranscription);
|
|
785
|
+
}
|
|
786
|
+
// This will automatically trigger the transcription queue
|
|
773
787
|
return this.fileUploadRequest(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
774
788
|
});
|
|
775
789
|
}
|
|
@@ -837,4 +851,25 @@ export class ApiSDK {
|
|
|
837
851
|
return URL.createObjectURL(blob);
|
|
838
852
|
});
|
|
839
853
|
}
|
|
854
|
+
// ======================
|
|
855
|
+
// TRANSCRIPTION QUEUE HELPER METHODS
|
|
856
|
+
// ======================
|
|
857
|
+
getTranscribedAudioFiles() {
|
|
858
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
859
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
860
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.TRANSCRIBED && file.transcription);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
getProcessingAudioFiles() {
|
|
864
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
865
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
866
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.PROCESSING);
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
getFailedAudioFiles() {
|
|
870
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
871
|
+
const audioFiles = yield this.getMyAudioFiles();
|
|
872
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.FAILED);
|
|
873
|
+
});
|
|
874
|
+
}
|
|
840
875
|
}
|
package/dist/src/sdk/types.d.ts
CHANGED
|
@@ -270,6 +270,8 @@ export interface PasswordChangeResponse {
|
|
|
270
270
|
export interface Session {
|
|
271
271
|
id: string;
|
|
272
272
|
transcript: string;
|
|
273
|
+
medicalTranscription?: string;
|
|
274
|
+
culturalTranscription?: string;
|
|
273
275
|
dateTime: string;
|
|
274
276
|
startDateTime?: string;
|
|
275
277
|
stopDateTime?: string;
|
|
@@ -288,6 +290,8 @@ export interface Session {
|
|
|
288
290
|
}
|
|
289
291
|
export interface CreateSessionDto {
|
|
290
292
|
transcript: string;
|
|
293
|
+
medicalTranscription?: string;
|
|
294
|
+
culturalTranscription?: string;
|
|
291
295
|
dateTime: string;
|
|
292
296
|
startDateTime?: string;
|
|
293
297
|
stopDateTime?: string;
|
|
@@ -299,6 +303,8 @@ export interface CreateSessionDto {
|
|
|
299
303
|
}
|
|
300
304
|
export interface UpdateSessionDto {
|
|
301
305
|
transcript?: string;
|
|
306
|
+
medicalTranscription?: string;
|
|
307
|
+
culturalTranscription?: string;
|
|
302
308
|
dateTime?: string;
|
|
303
309
|
startDateTime?: string;
|
|
304
310
|
stopDateTime?: string;
|
|
@@ -343,6 +349,8 @@ export interface AudioFile {
|
|
|
343
349
|
mimeType: string;
|
|
344
350
|
uploadId?: string;
|
|
345
351
|
transcriptionUrl?: string;
|
|
352
|
+
transcription?: string;
|
|
353
|
+
cultural_transcription?: string;
|
|
346
354
|
status: AudioFileStatus;
|
|
347
355
|
createdAt: string;
|
|
348
356
|
updatedAt: string;
|
|
@@ -362,8 +370,13 @@ export interface CreateAudioFileDto {
|
|
|
362
370
|
}
|
|
363
371
|
export interface UpdateAudioFileDto {
|
|
364
372
|
transcriptionUrl?: string;
|
|
373
|
+
transcription?: string;
|
|
374
|
+
cultural_transcription?: string;
|
|
365
375
|
status?: AudioFileStatus;
|
|
366
376
|
}
|
|
377
|
+
export interface UploadAudioFileDto {
|
|
378
|
+
cultural_transcription?: string;
|
|
379
|
+
}
|
|
367
380
|
export interface AgentSettings {
|
|
368
381
|
id: string;
|
|
369
382
|
temperature: number;
|
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
AudioFileStatus,
|
|
45
45
|
CreateAudioFileDto,
|
|
46
46
|
UpdateAudioFileDto,
|
|
47
|
+
UploadAudioFileDto,
|
|
47
48
|
AgentSettings,
|
|
48
49
|
CreateAgentSettingsDto,
|
|
49
50
|
UpdateAgentSettingsDto,
|
|
@@ -832,10 +833,26 @@ export class ApiSDK {
|
|
|
832
833
|
// AUDIO FILE METHODS
|
|
833
834
|
// ======================
|
|
834
835
|
|
|
835
|
-
public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile> {
|
|
836
|
+
public async uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string, culturalTranscription?: string): Promise<AudioFile> {
|
|
836
837
|
const formData = new FormData();
|
|
837
838
|
formData.append('file', file, fileName);
|
|
838
839
|
|
|
840
|
+
if (culturalTranscription) {
|
|
841
|
+
formData.append('cultural_transcription', culturalTranscription);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
public async uploadAudioFileWithTranscriptionQueue(sessionId: string, file: File | Blob, options?: { fileName?: string; culturalTranscription?: string }): Promise<AudioFile> {
|
|
848
|
+
const formData = new FormData();
|
|
849
|
+
formData.append('file', file, options?.fileName);
|
|
850
|
+
|
|
851
|
+
if (options?.culturalTranscription) {
|
|
852
|
+
formData.append('cultural_transcription', options.culturalTranscription);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// This will automatically trigger the transcription queue
|
|
839
856
|
return this.fileUploadRequest<AudioFile>(`${urls.audioFiles}/upload/${sessionId}`, formData);
|
|
840
857
|
}
|
|
841
858
|
|
|
@@ -902,4 +919,23 @@ export class ApiSDK {
|
|
|
902
919
|
return URL.createObjectURL(blob);
|
|
903
920
|
}
|
|
904
921
|
|
|
922
|
+
// ======================
|
|
923
|
+
// TRANSCRIPTION QUEUE HELPER METHODS
|
|
924
|
+
// ======================
|
|
925
|
+
|
|
926
|
+
public async getTranscribedAudioFiles(): Promise<AudioFile[]> {
|
|
927
|
+
const audioFiles = await this.getMyAudioFiles();
|
|
928
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.TRANSCRIBED && file.transcription);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
public async getProcessingAudioFiles(): Promise<AudioFile[]> {
|
|
932
|
+
const audioFiles = await this.getMyAudioFiles();
|
|
933
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.PROCESSING);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
public async getFailedAudioFiles(): Promise<AudioFile[]> {
|
|
937
|
+
const audioFiles = await this.getMyAudioFiles();
|
|
938
|
+
return audioFiles.filter(file => file.status === AudioFileStatus.FAILED);
|
|
939
|
+
}
|
|
940
|
+
|
|
905
941
|
}
|
package/src/sdk/types.ts
CHANGED
|
@@ -345,6 +345,8 @@ export interface PasswordChangeResponse {
|
|
|
345
345
|
export interface Session {
|
|
346
346
|
id: string;
|
|
347
347
|
transcript: string;
|
|
348
|
+
medicalTranscription?: string;
|
|
349
|
+
culturalTranscription?: string;
|
|
348
350
|
dateTime: string;
|
|
349
351
|
startDateTime?: string;
|
|
350
352
|
stopDateTime?: string;
|
|
@@ -367,6 +369,8 @@ export interface Session {
|
|
|
367
369
|
// Session DTOs
|
|
368
370
|
export interface CreateSessionDto {
|
|
369
371
|
transcript: string;
|
|
372
|
+
medicalTranscription?: string;
|
|
373
|
+
culturalTranscription?: string;
|
|
370
374
|
dateTime: string;
|
|
371
375
|
startDateTime?: string;
|
|
372
376
|
stopDateTime?: string;
|
|
@@ -380,6 +384,8 @@ export interface CreateSessionDto {
|
|
|
380
384
|
|
|
381
385
|
export interface UpdateSessionDto {
|
|
382
386
|
transcript?: string;
|
|
387
|
+
medicalTranscription?: string;
|
|
388
|
+
culturalTranscription?: string;
|
|
383
389
|
dateTime?: string;
|
|
384
390
|
startDateTime?: string;
|
|
385
391
|
stopDateTime?: string;
|
|
@@ -434,6 +440,8 @@ export interface AudioFile {
|
|
|
434
440
|
mimeType: string;
|
|
435
441
|
uploadId?: string;
|
|
436
442
|
transcriptionUrl?: string;
|
|
443
|
+
transcription?: string;
|
|
444
|
+
cultural_transcription?: string;
|
|
437
445
|
status: AudioFileStatus;
|
|
438
446
|
createdAt: string;
|
|
439
447
|
updatedAt: string;
|
|
@@ -459,9 +467,16 @@ export interface CreateAudioFileDto {
|
|
|
459
467
|
|
|
460
468
|
export interface UpdateAudioFileDto {
|
|
461
469
|
transcriptionUrl?: string;
|
|
470
|
+
transcription?: string;
|
|
471
|
+
cultural_transcription?: string;
|
|
462
472
|
status?: AudioFileStatus;
|
|
463
473
|
}
|
|
464
474
|
|
|
475
|
+
// Audio File Upload DTO (for transcription queue)
|
|
476
|
+
export interface UploadAudioFileDto {
|
|
477
|
+
cultural_transcription?: string;
|
|
478
|
+
}
|
|
479
|
+
|
|
465
480
|
// Agent Settings types
|
|
466
481
|
export interface AgentSettings {
|
|
467
482
|
id: string;
|