@crewdle/mist-connector-openai 1.0.19 → 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.
|
@@ -72,7 +72,7 @@ export class OpenAIGenerativeAIWorkerConnector {
|
|
|
72
72
|
console.log('OpenAIGenerativeAIWorkerConnector.processJob audio transcription response');
|
|
73
73
|
return {
|
|
74
74
|
type: "prompt" /* GenerativeAIJobType.Prompt */,
|
|
75
|
-
output: response.text,
|
|
75
|
+
output: (!parameters.responseFormat || parameters.responseFormat !== 'json') ? response.text : JSON.stringify(response),
|
|
76
76
|
inputTokens: response.usage?.type === 'tokens' ? response.usage.input_tokens : 0,
|
|
77
77
|
outputTokens: response.usage?.type === 'tokens' ? response.usage.output_tokens : 0,
|
|
78
78
|
};
|
|
@@ -203,21 +203,37 @@ export class OpenAIGenerativeAIWorkerConnector {
|
|
|
203
203
|
throw new Error('No file found');
|
|
204
204
|
}
|
|
205
205
|
console.log('OpenAIGenerativeAIWorkerConnector.processJobStream audio transcription');
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
+
});
|
|
216
232
|
yield {
|
|
217
233
|
type: "prompt" /* GenerativeAIJobType.Prompt */,
|
|
218
|
-
output:
|
|
219
|
-
inputTokens:
|
|
220
|
-
outputTokens:
|
|
234
|
+
output: JSON.stringify(response),
|
|
235
|
+
inputTokens: 0,
|
|
236
|
+
outputTokens: 0,
|
|
221
237
|
};
|
|
222
238
|
}
|
|
223
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
|
},
|