Skip to content

Commit a74e4cf

Browse files
committed
update
1 parent 9b75f86 commit a74e4cf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/openai/actions/chat/chat.mjs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ export default {
161161

162162
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
163163
for (const choice of response.choices) {
164-
choice.message.content = JSON.parse(choice.message.content);
164+
try {
165+
choice.message.content = JSON.parse(choice.message.content);
166+
} catch {
167+
console.log(`Unable to parse JSON: ${choice.message.content}`);
168+
}
165169
}
166170
}
167171

0 commit comments

Comments
 (0)