Skip to content

Commit

Permalink
fix: handle openai key errors
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammed-shihebi committed Mar 26, 2024
1 parent 35cd7f5 commit 1bc749e
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions frontend/src/views/PromptingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ export default {
streaming: true,
});
}
else if (this.openAIChatModels.includes(this.chatConfig.selectedModel)) {
else if (this.openAIChatModels.includes(this.chatConfig.selectedModel) && this.openAIApiKey !== "") {
chat = new ChatOpenAI({
openAIApiKey: this.openAIApiKey,
modelName: this.chatConfig.selectedModel,
Expand Down Expand Up @@ -1187,18 +1187,22 @@ export default {
async fetchModels() {
if (this.openAIApiKey !== "") {
let response = await getOpenAIModels(this.openAIApiKey);
this.openAIChatModels = response.data.data.filter(
(model) =>{
if (this.chatConfig.chatMode !== "sensitivity"){
return model.id.startsWith("gpt") &&
!model.id.includes("curie")
} else {
return (model.id.startsWith("gpt") || model.id.startsWith("text") || model.id.startsWith("davinci")) &&
!model.id.includes("curie")
try {
let response = await getOpenAIModels(this.openAIApiKey);
this.openAIChatModels = response.data.data.filter(
(model) =>{
if (this.chatConfig.chatMode !== "sensitivity"){
return model.id.startsWith("gpt") &&
!model.id.includes("curie")
} else {
return (model.id.startsWith("gpt") || model.id.startsWith("text") || model.id.startsWith("davinci")) &&
!model.id.includes("curie")
}
}
}
).map((model) => model.id);
).map((model) => model.id);
} catch (e){
console.error(e)
}
}
let response = await getLocalLLMs();
Expand Down Expand Up @@ -1358,11 +1362,10 @@ export default {
/* eslint-disable no-unused-vars */
async handler(newKey, oldKey) {
localStorage.setItem("openAIApiKey", newKey);
if (newKey !== "") {
await this.fetchModels();
await this.initChatModel();
this.initGenerativeModel();
}
await this.fetchModels();
await this.initChatModel();
this.resetConv();
this.initGenerativeModel();
}
},
Expand Down

0 comments on commit 1bc749e

Please sign in to comment.