diff --git a/components/openai/actions/chat/chat.mjs b/components/openai/actions/chat/chat.mjs index c91d7a0461a8d..5d25c284cce1c 100644 --- a/components/openai/actions/chat/chat.mjs +++ b/components/openai/actions/chat/chat.mjs @@ -6,7 +6,7 @@ import { ConfigurationError } from "@pipedream/platform"; export default { ...common, name: "Chat", - version: "0.2.8", + version: "0.2.9", key: "openai-chat", description: "The Chat API, using the `gpt-3.5-turbo` or `gpt-4` model. [See the documentation](https://platform.openai.com/docs/api-reference/chat)", type: "action", @@ -159,6 +159,16 @@ export default { }, }); + if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + for (const choice of response.choices) { + try { + choice.message.content = JSON.parse(choice.message.content); + } catch { + console.log(`Unable to parse JSON: ${choice.message.content}`); + } + } + } + if (response) { $.export("$summary", `Successfully sent chat with id ${response.id}`); } diff --git a/components/openai/package.json b/components/openai/package.json index ae27551143732..b172f0a4627a6 100644 --- a/components/openai/package.json +++ b/components/openai/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/openai", - "version": "0.10.0", + "version": "0.10.1", "description": "Pipedream OpenAI Components", "main": "openai.app.mjs", "keywords": [