Skip to content

Commit 8797788

Browse files
committed
fix: handle previous value as an array
1 parent 6f16c12 commit 8797788

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/client.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ async function send(conversation) {
8787
let content = data.chat.choices[0].message.content;
8888
content = content.replace(/```json\n|\n```/g, '');
8989
content = JSON.parse(content)
90+
91+
// TODO: check if careers exist else create
9092
let responseElement = document.querySelector('[openai="response"]')
9193
if (responseElement) {
9294
let preValue = responseElement.getValue()
@@ -221,12 +223,7 @@ async function openaiAction(form) {
221223
continue
222224

223225
if (element.getAttribute('key') === 'careers') {
224-
let Content = []
225-
if (typeof content === 'string')
226-
content = JSON.parse(content)
227-
for (let contentItem of content)
228-
Content.push(contentItem.name)
229-
content = { previousCareers: Content }
226+
content = JSON.stringify({ previousCareers: content })
230227
}
231228

232229
if (typeof content === 'string')

0 commit comments

Comments
 (0)