@pipedream/openai 0.10.0 → 0.10.1
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.
- package/actions/chat/chat.mjs +11 -1
- package/package.json +1 -1
package/actions/chat/chat.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { ConfigurationError } from "@pipedream/platform";
|
|
|
6
6
|
export default {
|
|
7
7
|
...common,
|
|
8
8
|
name: "Chat",
|
|
9
|
-
version: "0.2.
|
|
9
|
+
version: "0.2.9",
|
|
10
10
|
key: "openai-chat",
|
|
11
11
|
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)",
|
|
12
12
|
type: "action",
|
|
@@ -159,6 +159,16 @@ export default {
|
|
|
159
159
|
},
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
|
|
163
|
+
for (const choice of response.choices) {
|
|
164
|
+
try {
|
|
165
|
+
choice.message.content = JSON.parse(choice.message.content);
|
|
166
|
+
} catch {
|
|
167
|
+
console.log(`Unable to parse JSON: ${choice.message.content}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
162
172
|
if (response) {
|
|
163
173
|
$.export("$summary", `Successfully sent chat with id ${response.id}`);
|
|
164
174
|
}
|