Skip to content

Commit

Permalink
Catch empty respons from OpenAI API
Browse files Browse the repository at this point in the history
  • Loading branch information
lucksus committed Nov 8, 2023
1 parent d13b2c2 commit 23c709a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/routes/EveChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,18 @@ Done.`
const completion = await chat_with_gpt_3_5(promptMessages);
console.log(completion);
const writeSplit = split(completion, "WRITE-SDNA:")
if(writeSplit.code) {
dispatch("sdnacreated", writeSplit.code)
if(completion) {
console.log(completion);
const writeSplit = split(completion, "WRITE-SDNA:")
if(writeSplit.code) {
dispatch("sdnacreated", writeSplit.code)
}
promptMessages = [...promptMessages, {role: "assistant", content: completion}]
} else {
promptMessages = [...promptMessages, {role: "assistant", content: "<OpenAI API error - empty response>"}]
}
promptMessages = [...promptMessages, {role: "assistant", content: completion}]
}
function code(content) {
Expand Down

0 comments on commit 23c709a

Please sign in to comment.