Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/plugins/compat-oai/src/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,16 @@ export function defineCompatOpenAITranscriptionModel<
requestBuilder?: TranscriptionRequestBuilder;
}): ModelAction {
const {
name: modelName,
name,
pluginOptions,
client: defaultClient,
modelRef,
requestBuilder,
} = params;

const modelName = toModelName(name, pluginOptions?.name);
const actionName =
modelRef?.name ?? `${pluginOptions?.name ?? 'compat-oai'}/${modelName}`;

return model(
{
name: actionName,
Expand Down
Binary file added js/testapps/compat-oai/jfk.flac
Binary file not shown.
19 changes: 19 additions & 0 deletions js/testapps/compat-oai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,25 @@ async function toWav(
});
}

// STT sample
ai.defineFlow('transcribe', async () => {
const audioFile = fs.readFileSync('jfk.flac');

const { text } = await ai.generate({
model: openAI.model('whisper-1'),
prompt: [
{
media: {
contentType: 'audio/flac',
url: `data:audio/flac;base64,${audioFile.toString('base64')}`,
},
},
],
});

return text;
});

// PDF file input example
ai.defineFlow(
{
Expand Down