whio-api-sdk 1.0.175 → 1.0.177-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/dist/src/sdk/sdk.d.ts +7 -1
- package/dist/src/sdk/sdk.js +51 -12
- package/dist/src/sdk/types.d.ts +27 -0
- package/dist/src/sdk/urls.d.ts +1 -0
- package/dist/src/sdk/urls.js +2 -0
- package/example-agent-settings.ts +77 -0
- package/package.json +1 -1
- package/src/sdk/sdk.ts +49 -14
- package/src/sdk/types.ts +34 -0
- package/src/sdk/urls.ts +3 -0
package/dist/src/sdk/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto } from './types';
|
|
1
|
+
import { LoginResponse, LoginCredentials, SDKConfig, User, UpdateUserDto, Organization, TemplateCategory, Template, Team, UserTemplate, TranscriptionSummary, TranscriptionAudioUploadResponse, PasswordChangeResponse, Session, CreateSessionDto, UpdateSessionDto, Agent, AudioFile, UpdateAudioFileDto, AgentSettings, CreateAgentSettingsDto, UpdateAgentSettingsDto } from './types';
|
|
2
2
|
export declare class ApiSDK {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private storage;
|
|
@@ -96,6 +96,12 @@ export declare class ApiSDK {
|
|
|
96
96
|
deleteAgent(id: string): Promise<void>;
|
|
97
97
|
addAgentToOrganization(agentId: string, organizationId: string): Promise<void>;
|
|
98
98
|
removeAgentFromOrganization(agentId: string, organizationId: string): Promise<void>;
|
|
99
|
+
createAgentSettings(settingsData: CreateAgentSettingsDto): Promise<AgentSettings>;
|
|
100
|
+
getAgentSettings(organizationId?: string, agentId?: string): Promise<AgentSettings[]>;
|
|
101
|
+
getAgentSettingsById(id: string): Promise<AgentSettings>;
|
|
102
|
+
getAgentSettingsByAgentAndOrganization(agentId: string, organizationId: string): Promise<AgentSettings>;
|
|
103
|
+
updateAgentSettings(id: string, settingsData: UpdateAgentSettingsDto): Promise<AgentSettings>;
|
|
104
|
+
deleteAgentSettings(id: string): Promise<void>;
|
|
99
105
|
uploadAudioFileToSession(sessionId: string, file: File | Blob, fileName?: string): Promise<AudioFile>;
|
|
100
106
|
getMyAudioFiles(): Promise<AudioFile[]>;
|
|
101
107
|
getAllAudioFiles(): Promise<AudioFile[]>;
|
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -17,11 +17,7 @@ export class ApiSDK {
|
|
|
17
17
|
this.refreshToken = null;
|
|
18
18
|
this.user = null;
|
|
19
19
|
this.baseUrl = config.baseUrl || '/api';
|
|
20
|
-
this.storage = config.storage
|
|
21
|
-
getItem: (key) => localStorage.getItem(key),
|
|
22
|
-
setItem: (key, value) => localStorage.setItem(key, value),
|
|
23
|
-
removeItem: (key) => localStorage.removeItem(key),
|
|
24
|
-
};
|
|
20
|
+
this.storage = config.storage;
|
|
25
21
|
this.initialize();
|
|
26
22
|
}
|
|
27
23
|
fetchConfig(url) {
|
|
@@ -36,7 +32,8 @@ export class ApiSDK {
|
|
|
36
32
|
}
|
|
37
33
|
getToken() {
|
|
38
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
|
|
35
|
+
const accessToken = yield this.storage.getItem('access_token');
|
|
36
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
40
37
|
if (!this.accessToken) {
|
|
41
38
|
throw new Error('Access token not found');
|
|
42
39
|
}
|
|
@@ -54,10 +51,12 @@ export class ApiSDK {
|
|
|
54
51
|
}
|
|
55
52
|
initialize() {
|
|
56
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const accessToken = yield this.storage.getItem('access_token');
|
|
55
|
+
const refreshToken = yield this.storage.getItem('refresh_token');
|
|
59
56
|
const userString = yield this.storage.getItem('user');
|
|
60
57
|
this.user = userString ? JSON.parse(userString) : null;
|
|
58
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
59
|
+
this.refreshToken = refreshToken ? JSON.parse(refreshToken) : null;
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
request(endpoint, method = 'GET', body, headers = {}, noToken = false) {
|
|
@@ -119,8 +118,8 @@ export class ApiSDK {
|
|
|
119
118
|
this.accessToken = response.access_token;
|
|
120
119
|
this.refreshToken = response.refresh_token;
|
|
121
120
|
this.user = response.user;
|
|
122
|
-
yield this.storage.setItem('access_token', response.access_token);
|
|
123
|
-
yield this.storage.setItem('refresh_token', response.refresh_token);
|
|
121
|
+
yield this.storage.setItem('access_token', JSON.stringify(response.access_token));
|
|
122
|
+
yield this.storage.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
124
123
|
yield this.storage.setItem('user', JSON.stringify(response.user));
|
|
125
124
|
return response;
|
|
126
125
|
}
|
|
@@ -173,8 +172,8 @@ export class ApiSDK {
|
|
|
173
172
|
this.accessToken = response.access_token;
|
|
174
173
|
this.refreshToken = response.refresh_token;
|
|
175
174
|
this.user = response.user;
|
|
176
|
-
yield this.storage.setItem('access_token', response.access_token);
|
|
177
|
-
yield this.storage.setItem('refresh_token', response.refresh_token);
|
|
175
|
+
yield this.storage.setItem('access_token', JSON.stringify(response.access_token));
|
|
176
|
+
yield this.storage.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
178
177
|
yield this.storage.setItem('user', JSON.stringify(response.user));
|
|
179
178
|
}
|
|
180
179
|
catch (error) {
|
|
@@ -725,6 +724,46 @@ export class ApiSDK {
|
|
|
725
724
|
});
|
|
726
725
|
}
|
|
727
726
|
// ======================
|
|
727
|
+
// AGENT SETTINGS METHODS
|
|
728
|
+
// ======================
|
|
729
|
+
createAgentSettings(settingsData) {
|
|
730
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
731
|
+
return this.request(urls.agentSettings, 'POST', settingsData);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
getAgentSettings(organizationId, agentId) {
|
|
735
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
736
|
+
const params = new URLSearchParams();
|
|
737
|
+
if (organizationId)
|
|
738
|
+
params.append('organizationId', organizationId);
|
|
739
|
+
if (agentId)
|
|
740
|
+
params.append('agentId', agentId);
|
|
741
|
+
const queryString = params.toString();
|
|
742
|
+
const endpoint = queryString ? `${urls.agentSettings}?${queryString}` : urls.agentSettings;
|
|
743
|
+
return this.request(endpoint, 'GET');
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
getAgentSettingsById(id) {
|
|
747
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
748
|
+
return this.request(`${urls.agentSettings}/${id}`, 'GET');
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
getAgentSettingsByAgentAndOrganization(agentId, organizationId) {
|
|
752
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
753
|
+
return this.request(`${urls.agentSettings}/agent/${agentId}/organization/${organizationId}`, 'GET');
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
updateAgentSettings(id, settingsData) {
|
|
757
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
758
|
+
return this.request(`${urls.agentSettings}/${id}`, 'PATCH', settingsData);
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
deleteAgentSettings(id) {
|
|
762
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
763
|
+
yield this.request(`${urls.agentSettings}/${id}`, 'DELETE');
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
// ======================
|
|
728
767
|
// AUDIO FILE METHODS
|
|
729
768
|
// ======================
|
|
730
769
|
uploadAudioFileToSession(sessionId, file, fileName) {
|
package/dist/src/sdk/types.d.ts
CHANGED
|
@@ -364,3 +364,30 @@ export interface UpdateAudioFileDto {
|
|
|
364
364
|
transcriptionUrl?: string;
|
|
365
365
|
status?: AudioFileStatus;
|
|
366
366
|
}
|
|
367
|
+
export interface AgentSettings {
|
|
368
|
+
id: string;
|
|
369
|
+
temperature: number;
|
|
370
|
+
topK: number;
|
|
371
|
+
topP: number;
|
|
372
|
+
repetitionPenalty: number;
|
|
373
|
+
createdAt: string;
|
|
374
|
+
updatedAt: string;
|
|
375
|
+
agentId: string;
|
|
376
|
+
organizationId: string;
|
|
377
|
+
agent?: Agent;
|
|
378
|
+
organization?: Organization;
|
|
379
|
+
}
|
|
380
|
+
export interface CreateAgentSettingsDto {
|
|
381
|
+
agentId: string;
|
|
382
|
+
organizationId: string;
|
|
383
|
+
temperature?: number;
|
|
384
|
+
topK?: number;
|
|
385
|
+
topP?: number;
|
|
386
|
+
repetitionPenalty?: number;
|
|
387
|
+
}
|
|
388
|
+
export interface UpdateAgentSettingsDto {
|
|
389
|
+
temperature?: number;
|
|
390
|
+
topK?: number;
|
|
391
|
+
topP?: number;
|
|
392
|
+
repetitionPenalty?: number;
|
|
393
|
+
}
|
package/dist/src/sdk/urls.d.ts
CHANGED
package/dist/src/sdk/urls.js
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Example usage of AgentSettings functionality
|
|
2
|
+
import { ApiSDK, CreateAgentSettingsDto, UpdateAgentSettingsDto } from './src/sdk';
|
|
3
|
+
|
|
4
|
+
async function exampleAgentSettingsUsage() {
|
|
5
|
+
// Initialize SDK
|
|
6
|
+
const sdk = new ApiSDK({
|
|
7
|
+
baseUrl: 'http://localhost:3000',
|
|
8
|
+
storage: {
|
|
9
|
+
getItem: (key) => localStorage.getItem(key),
|
|
10
|
+
setItem: (key, value) => localStorage.setItem(key, value),
|
|
11
|
+
removeItem: (key) => localStorage.removeItem(key),
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
// Login first (superuser required for agent settings)
|
|
17
|
+
await sdk.login({
|
|
18
|
+
email: 'superuser@example.com',
|
|
19
|
+
password: 'password123'
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Create agent settings
|
|
23
|
+
const createData: CreateAgentSettingsDto = {
|
|
24
|
+
agentId: 'agent-uuid-here',
|
|
25
|
+
organizationId: 'org-uuid-here',
|
|
26
|
+
temperature: 0.7,
|
|
27
|
+
topK: 40,
|
|
28
|
+
topP: 0.9,
|
|
29
|
+
repetitionPenalty: 1.1
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const newSettings = await sdk.createAgentSettings(createData);
|
|
33
|
+
console.log('Created agent settings:', newSettings);
|
|
34
|
+
|
|
35
|
+
// Get all agent settings
|
|
36
|
+
const allSettings = await sdk.getAgentSettings();
|
|
37
|
+
console.log('All agent settings:', allSettings);
|
|
38
|
+
|
|
39
|
+
// Get settings for specific organization
|
|
40
|
+
const orgSettings = await sdk.getAgentSettings('org-uuid-here');
|
|
41
|
+
console.log('Organization settings:', orgSettings);
|
|
42
|
+
|
|
43
|
+
// Get settings for specific agent
|
|
44
|
+
const agentSettings = await sdk.getAgentSettings(undefined, 'agent-uuid-here');
|
|
45
|
+
console.log('Agent settings:', agentSettings);
|
|
46
|
+
|
|
47
|
+
// Get specific settings by agent and organization
|
|
48
|
+
const specificSettings = await sdk.getAgentSettingsByAgentAndOrganization(
|
|
49
|
+
'agent-uuid-here',
|
|
50
|
+
'org-uuid-here'
|
|
51
|
+
);
|
|
52
|
+
console.log('Specific settings:', specificSettings);
|
|
53
|
+
|
|
54
|
+
// Update agent settings
|
|
55
|
+
const updateData: UpdateAgentSettingsDto = {
|
|
56
|
+
temperature: 0.8,
|
|
57
|
+
topK: 50
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const updatedSettings = await sdk.updateAgentSettings(newSettings.id, updateData);
|
|
61
|
+
console.log('Updated settings:', updatedSettings);
|
|
62
|
+
|
|
63
|
+
// Get settings by ID
|
|
64
|
+
const settingsById = await sdk.getAgentSettingsById(newSettings.id);
|
|
65
|
+
console.log('Settings by ID:', settingsById);
|
|
66
|
+
|
|
67
|
+
// Delete agent settings
|
|
68
|
+
await sdk.deleteAgentSettings(newSettings.id);
|
|
69
|
+
console.log('Agent settings deleted');
|
|
70
|
+
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error('Error:', error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Export for use in other files
|
|
77
|
+
export { exampleAgentSettingsUsage };
|
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -44,6 +44,9 @@ import {
|
|
|
44
44
|
AudioFileStatus,
|
|
45
45
|
CreateAudioFileDto,
|
|
46
46
|
UpdateAudioFileDto,
|
|
47
|
+
AgentSettings,
|
|
48
|
+
CreateAgentSettingsDto,
|
|
49
|
+
UpdateAgentSettingsDto,
|
|
47
50
|
} from './types';
|
|
48
51
|
import urls from './urls';
|
|
49
52
|
import { jwtDecode } from 'jwt-decode';
|
|
@@ -57,12 +60,7 @@ export class ApiSDK {
|
|
|
57
60
|
|
|
58
61
|
constructor(config: SDKConfig = {}) {
|
|
59
62
|
this.baseUrl = config.baseUrl || '/api';
|
|
60
|
-
this.storage = config.storage
|
|
61
|
-
getItem: (key) => localStorage.getItem(key),
|
|
62
|
-
setItem: (key, value) => localStorage.setItem(key, value),
|
|
63
|
-
removeItem: (key) => localStorage.removeItem(key),
|
|
64
|
-
};
|
|
65
|
-
|
|
63
|
+
this.storage = config.storage;
|
|
66
64
|
this.initialize();
|
|
67
65
|
}
|
|
68
66
|
|
|
@@ -76,8 +74,8 @@ export class ApiSDK {
|
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
private async getToken() {
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const accessToken = await this.storage!.getItem('access_token');
|
|
78
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
81
79
|
if (!this.accessToken) {
|
|
82
80
|
throw new Error('Access token not found');
|
|
83
81
|
}
|
|
@@ -94,10 +92,12 @@ export class ApiSDK {
|
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
private async initialize() {
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const accessToken = await this.storage!.getItem('access_token');
|
|
96
|
+
const refreshToken = await this.storage!.getItem('refresh_token');
|
|
99
97
|
const userString = await this.storage!.getItem('user');
|
|
100
98
|
this.user = userString ? JSON.parse(userString) : null;
|
|
99
|
+
this.accessToken = accessToken ? JSON.parse(accessToken) : null;
|
|
100
|
+
this.refreshToken = refreshToken ? JSON.parse(refreshToken) : null;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
private async request<T>(
|
|
@@ -187,8 +187,8 @@ export class ApiSDK {
|
|
|
187
187
|
|
|
188
188
|
this.user = response.user;
|
|
189
189
|
|
|
190
|
-
await this.storage!.setItem('access_token', response.access_token);
|
|
191
|
-
await this.storage!.setItem('refresh_token', response.refresh_token);
|
|
190
|
+
await this.storage!.setItem('access_token', JSON.stringify(response.access_token));
|
|
191
|
+
await this.storage!.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
192
192
|
await this.storage!.setItem('user', JSON.stringify(response.user));
|
|
193
193
|
|
|
194
194
|
return response;
|
|
@@ -246,8 +246,8 @@ export class ApiSDK {
|
|
|
246
246
|
this.refreshToken = response.refresh_token;
|
|
247
247
|
this.user = response.user;
|
|
248
248
|
|
|
249
|
-
await this.storage!.setItem('access_token', response.access_token);
|
|
250
|
-
await this.storage!.setItem('refresh_token', response.refresh_token);
|
|
249
|
+
await this.storage!.setItem('access_token', JSON.stringify(response.access_token));
|
|
250
|
+
await this.storage!.setItem('refresh_token', JSON.stringify(response.refresh_token));
|
|
251
251
|
await this.storage!.setItem('user', JSON.stringify(response.user));
|
|
252
252
|
} catch (error) {
|
|
253
253
|
await this.clearAuth();
|
|
@@ -793,6 +793,41 @@ export class ApiSDK {
|
|
|
793
793
|
await this.request(`${urls.agents}/${agentId}/organizations/${organizationId}`, 'DELETE');
|
|
794
794
|
}
|
|
795
795
|
|
|
796
|
+
// ======================
|
|
797
|
+
// AGENT SETTINGS METHODS
|
|
798
|
+
// ======================
|
|
799
|
+
|
|
800
|
+
public async createAgentSettings(settingsData: CreateAgentSettingsDto): Promise<AgentSettings> {
|
|
801
|
+
return this.request<AgentSettings>(urls.agentSettings, 'POST', settingsData);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
public async getAgentSettings(organizationId?: string, agentId?: string): Promise<AgentSettings[]> {
|
|
805
|
+
const params = new URLSearchParams();
|
|
806
|
+
if (organizationId) params.append('organizationId', organizationId);
|
|
807
|
+
if (agentId) params.append('agentId', agentId);
|
|
808
|
+
|
|
809
|
+
const queryString = params.toString();
|
|
810
|
+
const endpoint = queryString ? `${urls.agentSettings}?${queryString}` : urls.agentSettings;
|
|
811
|
+
|
|
812
|
+
return this.request<AgentSettings[]>(endpoint, 'GET');
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
public async getAgentSettingsById(id: string): Promise<AgentSettings> {
|
|
816
|
+
return this.request<AgentSettings>(`${urls.agentSettings}/${id}`, 'GET');
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
public async getAgentSettingsByAgentAndOrganization(agentId: string, organizationId: string): Promise<AgentSettings> {
|
|
820
|
+
return this.request<AgentSettings>(`${urls.agentSettings}/agent/${agentId}/organization/${organizationId}`, 'GET');
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
public async updateAgentSettings(id: string, settingsData: UpdateAgentSettingsDto): Promise<AgentSettings> {
|
|
824
|
+
return this.request<AgentSettings>(`${urls.agentSettings}/${id}`, 'PATCH', settingsData);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
public async deleteAgentSettings(id: string): Promise<void> {
|
|
828
|
+
await this.request(`${urls.agentSettings}/${id}`, 'DELETE');
|
|
829
|
+
}
|
|
830
|
+
|
|
796
831
|
// ======================
|
|
797
832
|
// AUDIO FILE METHODS
|
|
798
833
|
// ======================
|
package/src/sdk/types.ts
CHANGED
|
@@ -461,3 +461,37 @@ export interface UpdateAudioFileDto {
|
|
|
461
461
|
transcriptionUrl?: string;
|
|
462
462
|
status?: AudioFileStatus;
|
|
463
463
|
}
|
|
464
|
+
|
|
465
|
+
// Agent Settings types
|
|
466
|
+
export interface AgentSettings {
|
|
467
|
+
id: string;
|
|
468
|
+
temperature: number;
|
|
469
|
+
topK: number;
|
|
470
|
+
topP: number;
|
|
471
|
+
repetitionPenalty: number;
|
|
472
|
+
createdAt: string;
|
|
473
|
+
updatedAt: string;
|
|
474
|
+
agentId: string;
|
|
475
|
+
organizationId: string;
|
|
476
|
+
|
|
477
|
+
// Relationships (populated by API)
|
|
478
|
+
agent?: Agent;
|
|
479
|
+
organization?: Organization;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Agent Settings DTOs
|
|
483
|
+
export interface CreateAgentSettingsDto {
|
|
484
|
+
agentId: string;
|
|
485
|
+
organizationId: string;
|
|
486
|
+
temperature?: number;
|
|
487
|
+
topK?: number;
|
|
488
|
+
topP?: number;
|
|
489
|
+
repetitionPenalty?: number;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export interface UpdateAgentSettingsDto {
|
|
493
|
+
temperature?: number;
|
|
494
|
+
topK?: number;
|
|
495
|
+
topP?: number;
|
|
496
|
+
repetitionPenalty?: number;
|
|
497
|
+
}
|