Skip to content

Commit 1d7f748

Browse files
authored
Refactor audio extraction logic in converter
1 parent bddda90 commit 1d7f748

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/agents-openai/src/openaiChatCompletionsConverter.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@ export function itemsToMessages(
159159
...providerData,
160160
};
161161

162-
const audio = content.find((c) => c.type === 'audio');
163-
if (audio) {
164-
assistant.audio = {
165-
id: '', // setting this to empty ID and expecting that the user sets providerData.id
166-
...audio.providerData,
167-
};
162+
if (Array.isArray(content)) {
163+
const audio = content.find((c) => c.type === 'audio');
164+
if (audio) {
165+
assistant.audio = {
166+
id: '', // setting this to empty ID and expecting that the user sets providerData.id
167+
...audio.providerData,
168+
};
169+
}
168170
}
169171

170172
result.push(assistant);

0 commit comments

Comments
 (0)