mirror of
https://github.com/cosmicoptima/loom.git
synced 2026-07-22 07:40:25 +00:00
display openai errs
This commit is contained in:
parent
7efdeb3900
commit
df7e12287e
2 changed files with 12 additions and 1 deletions
11
main.ts
11
main.ts
|
|
@ -369,6 +369,7 @@ export default class LoomPlugin extends Plugin {
|
|||
const trailingSpace = prompt.match(/\s+$/);
|
||||
prompt = prompt.replace(/\s+$/, "");
|
||||
|
||||
try {
|
||||
let completions = (
|
||||
await this.openai.createCompletion({
|
||||
model,
|
||||
|
|
@ -378,6 +379,16 @@ export default class LoomPlugin extends Plugin {
|
|||
temperature: 1,
|
||||
})
|
||||
).data.choices.map((choice) => choice.text);
|
||||
} catch (e) {
|
||||
if (e.response.status === 401)
|
||||
new Notice("OpenAI API key is invalid. Please provide a valid key in the settings.");
|
||||
else if (e.response.status === 429)
|
||||
new Notice("OpenAI API rate limit exceeded.");
|
||||
else
|
||||
new Notice("Unknown OpenAI API error: " + e.response.data.error.message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let ids = [];
|
||||
for (const completion of completions) {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,6 @@
|
|||
|
||||
.loom-icon {
|
||||
display: inline-flex !important;
|
||||
margin-left: 0.2em;
|
||||
margin-left: 0.25em;
|
||||
--icon-size: 1rem;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue