Skip to content

Commit

Permalink
Update workflow to fail on missing api key
Browse files Browse the repository at this point in the history
  • Loading branch information
jhcoll committed Oct 25, 2023
1 parent 9b9bb58 commit 05572be
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/generate-related/compute-embeddings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ const { markdownToTxt } = require("markdown-to-txt");
if (!fs.existsSync(filename)) {
await summarisePost(formatContent(path)).then((embedding) => {
fs.writeFileSync(filename, JSON.stringify(embedding, null, 2));
}).catch((err) => {
console.log("failed to embed: ", filename);
console.log(err);
});
}
}
Expand Down Expand Up @@ -57,9 +54,11 @@ const summarisePost = async (data) => {
})
.then((res) => {
if(res.status !== 200) {
throw new Error(res.statusText);
if(res.status === 401) {
throw Error(res.statusText + " - check your OpenAI API key");
}
throw Error(res.statusText);
}
return res.json()
})
.then((json) => {
if (json.data) {
Expand Down

0 comments on commit 05572be

Please sign in to comment.