@crewdle/mist-connector-openai 1.0.18 → 1.0.20
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.
|
@@ -65,12 +65,14 @@ export class OpenAIGenerativeAIWorkerConnector {
|
|
|
65
65
|
const response = await this.client.audio.transcriptions.create({
|
|
66
66
|
model: options.model.id,
|
|
67
67
|
file,
|
|
68
|
-
response_format: 'json',
|
|
68
|
+
response_format: parameters.responseFormat || 'json',
|
|
69
|
+
language: parameters.language,
|
|
70
|
+
timestamp_granularities: parameters.timestampGranularities ? [parameters.timestampGranularities] : undefined,
|
|
69
71
|
});
|
|
70
72
|
console.log('OpenAIGenerativeAIWorkerConnector.processJob audio transcription response');
|
|
71
73
|
return {
|
|
72
74
|
type: "prompt" /* GenerativeAIJobType.Prompt */,
|
|
73
|
-
output: response.text,
|
|
75
|
+
output: (!parameters.responseFormat || parameters.responseFormat !== 'json') ? response.text : JSON.stringify(response),
|
|
74
76
|
inputTokens: response.usage?.type === 'tokens' ? response.usage.input_tokens : 0,
|
|
75
77
|
outputTokens: response.usage?.type === 'tokens' ? response.usage.output_tokens : 0,
|
|
76
78
|
};
|
|
@@ -201,19 +203,37 @@ export class OpenAIGenerativeAIWorkerConnector {
|
|
|
201
203
|
throw new Error('No file found');
|
|
202
204
|
}
|
|
203
205
|
console.log('OpenAIGenerativeAIWorkerConnector.processJobStream audio transcription');
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
if (!parameters.responseFormat || parameters.responseFormat === 'json') {
|
|
207
|
+
const stream = await this.client.audio.transcriptions.create({
|
|
208
|
+
model: options.model.id,
|
|
209
|
+
file,
|
|
210
|
+
response_format: 'json',
|
|
211
|
+
language: parameters.language,
|
|
212
|
+
stream: true,
|
|
213
|
+
});
|
|
214
|
+
console.log('OpenAIGenerativeAIWorkerConnector.processJobStream audio transcription response');
|
|
215
|
+
for await (const chunk of stream) {
|
|
216
|
+
yield {
|
|
217
|
+
type: "prompt" /* GenerativeAIJobType.Prompt */,
|
|
218
|
+
output: chunk.type === 'transcript.text.delta' ? chunk.delta : '',
|
|
219
|
+
inputTokens: chunk.type === 'transcript.text.done' ? chunk.usage?.input_tokens ?? 0 : 0,
|
|
220
|
+
outputTokens: chunk.type === 'transcript.text.done' ? chunk.usage?.output_tokens ?? 0 : 0,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const response = await this.client.audio.transcriptions.create({
|
|
226
|
+
model: options.model.id,
|
|
227
|
+
file,
|
|
228
|
+
response_format: parameters.responseFormat ? parameters.responseFormat : 'json',
|
|
229
|
+
language: parameters.language,
|
|
230
|
+
timestamp_granularities: parameters.timestampGranularities ? [parameters.timestampGranularities] : undefined,
|
|
231
|
+
});
|
|
212
232
|
yield {
|
|
213
233
|
type: "prompt" /* GenerativeAIJobType.Prompt */,
|
|
214
|
-
output:
|
|
215
|
-
inputTokens:
|
|
216
|
-
outputTokens:
|
|
234
|
+
output: JSON.stringify(response),
|
|
235
|
+
inputTokens: 0,
|
|
236
|
+
outputTokens: 0,
|
|
217
237
|
};
|
|
218
238
|
}
|
|
219
239
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewdle/mist-connector-openai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist/"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@crewdle/web-sdk-types": "^1.0.
|
|
18
|
+
"@crewdle/web-sdk-types": "^1.0.53",
|
|
19
19
|
"@types/node": "^22.13.9",
|
|
20
20
|
"typescript": "^5.8.2"
|
|
21
21
|
},
|