Skip to content

Commit

Permalink
Fix broken availability dialog in release-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
sunner committed May 1, 2023
1 parent 8b6cf2e commit c7a0bec
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="bot-logos margin-bottom">
<img
v-for="(bot, index) in bots"
:class="{ 'selected': activeBots[bot.constructor.name] }"
:class="{ 'selected': activeBots[bot.constructor._className] }"
:key="index"
:src="bot.getLogo()"
:alt="bot.getFullname()"
Expand Down Expand Up @@ -138,7 +138,7 @@ export default {
// Send the prompt to all the bots and update the message with the response
for (const bot of this.bots) {
if (!this.activeBots[bot.constructor.name])
if (!this.activeBots[bot.constructor._className])
continue;
var message = {
Expand All @@ -161,22 +161,22 @@ export default {
...mapMutations(["changeColumns"]),
...mapMutations(["SET_BOT_SELECTED"]),
toggleSelected(bot) {
const botId = bot.constructor.name;
const botId = bot.constructor._className;
var selected = false;
if (!bot.isAvailable()) {
this.clickedBot = bot;
// Open the bot's settings dialog
this.$refs.makeAvailableModal.open();
selected = true;
} else {
selected = !this.selectedBots[bot.constructor.name];
selected = !this.selectedBots[bot.constructor._className];
}
this.SET_BOT_SELECTED({ botId, selected});
this.updateActiveBots();
},
updateActiveBots() {
for (const bot of this.bots) {
this.activeBots[bot.constructor.name] = bot.isAvailable() && this.selectedBots[bot.constructor.name];
this.activeBots[bot.constructor._className] = bot.isAvailable() && this.selectedBots[bot.constructor._className];
}
},
async checkAllBotsAvailability(specifiedBot) {
Expand Down
1 change: 1 addition & 0 deletions src/bots/BardBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function parseBartResponse(resp) {

export default class BardBot extends Bot {
static _brandId = "bard";
static _className = "BardBot"; // Class name of the bot
static _logoFilename = "bard-logo.svg"; // Place it in assets/bots/
static _loginUrl = "https://bard.google.com/";

Expand Down
1 change: 1 addition & 0 deletions src/bots/BingChatBalancedBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AsyncLock from "async-lock";
import BingChatBot from "./BingChatBot";

export default class BingChatBalancedBot extends BingChatBot {
static _className = "BingChatBalancedBot"; // Class name of the bot
static _logoFilename = "bing-balanced-logo.png"; // Place it in assets/bots/
static _model = "harmonyv3"; // Bing styles: h3imaginative, harmonyv3, h3precise
static _lock = new AsyncLock(); // Must process requests in queue
Expand Down
1 change: 1 addition & 0 deletions src/bots/BingChatBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function randomIP() {
}
export default class BingChatBot extends Bot {
static _brandId = "bingChat";
static _className = "BingChatBot"; // Class name of the bot
static _model = "h3precise"; // Bing styles: h3imaginative, harmonyv3, h3precise
static _logoFilename = "bing-logo.svg"; // Place it in assets/bots/
static _loginUrl = "https://www.bing.com/new";
Expand Down
1 change: 1 addition & 0 deletions src/bots/BingChatCreativeBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AsyncLock from "async-lock";
import BingChatBot from "./BingChatBot";

export default class BingChatCreativeBot extends BingChatBot {
static _className = "BingChatCreativeBot"; // Class name of the bot
static _logoFilename = "bing-creative-logo.png"; // Place it in assets/bots/
static _model = "h3imaginative"; // Bing styles: h3imaginative, harmonyv3, h3precise
static _lock = new AsyncLock(); // Must process requests in queue
Expand Down
1 change: 1 addition & 0 deletions src/bots/BingChatPreciseBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AsyncLock from "async-lock";
import BingChatBot from "./BingChatBot";

export default class BingChatPreciseBot extends BingChatBot {
static _className = "BingChatPreciseBot"; // Class name of the bot
static _logoFilename = "bing-precise-logo.png"; // Place it in assets/bots/
static _model = "h3precise"; // Bing styles: h3imaginative, harmonyv3, h3precise
static _lock = new AsyncLock(); // Must process requests in queue
Expand Down
5 changes: 3 additions & 2 deletions src/bots/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class Bot {
static _isAvailable = false;

static _brandId = "bot"; // Brand id of the bot, should be unique. Used in i18n.
static _className = "Bot"; // Class name of the bot
static _model = ""; // Model of the bot (eg. "text-davinci-002-render-sha")
static _logoFilename = "default-logo.svg"; // Place it in assets/bots/
static _loginUrl = "undefined";
Expand Down Expand Up @@ -82,11 +83,11 @@ export default class Bot {
} else {
let currentClass = this.constructor;
let parentClass = Object.getPrototypeOf(currentClass);
while (parentClass && parentClass.name !== "Bot") {
while (parentClass && parentClass._className !== "Bot") {
currentClass = parentClass;
parentClass = Object.getPrototypeOf(currentClass);
}
const componentName = currentClass.name + "Settings";
const componentName = currentClass._className + "Settings";
component = await import(`@/components/BotSettings/${componentName}.vue`);
}

Expand Down
1 change: 1 addition & 0 deletions src/bots/ChatGPT35Bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ChatGPTBot from "./ChatGPTBot";

export default class ChatGPT35Bot extends ChatGPTBot {
static _className = "ChatGPT35Bot"; // Class name of the bot
static _logoFilename = "chatgpt-35-logo.png"; // Place it in assets/bots/
static _model = "text-davinci-002-render-sha";

Expand Down
1 change: 1 addition & 0 deletions src/bots/ChatGPT4Bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ChatGPTBot from "./ChatGPTBot";

export default class ChatGPT4Bot extends ChatGPTBot {
static _className = "ChatGPT4Bot"; // Class name of the bot
static _logoFilename = "chatgpt-4-logo.png"; // Place it in assets/bots/
static _model = "gpt-4";

Expand Down
1 change: 1 addition & 0 deletions src/bots/ChatGPTBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const REFRESH_SESSION_URL =

export default class ChatGPTBot extends Bot {
static _brandId = "chatGpt";
static _className = "ChatGPTBot"; // Class name of the bot
static _logoFilename = "chatgpt-logo.svg"; // Place it in assets/bots/
static _loginUrl = "https://chat.openai.com/";
static _model = "";
Expand Down
1 change: 1 addition & 0 deletions src/bots/ERNIEBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from "axios";

export default class ERNIEBot extends Bot {
static _brandId = "ernie"; // ID of the bot, should be unique
static _className = "ERNIEBot"; // Class name of the bot
static _logoFilename = "ernie-logo.png"; // Place it in assets/bots/
static _loginUrl = "https://yiyan.baidu.com/";

Expand Down
1 change: 1 addition & 0 deletions src/bots/OpenAIAPI35Bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import OpenAIAPIBot from "./OpenAIAPIBot";

export default class OpenAIAPI35Bot extends OpenAIAPIBot {
static _className = "OpenAIAPI35Bot"; // Class name of the bot
static _logoFilename = "openai-35-logo.png"; // Place it in assets/bots/
static _model = "gpt-3.5-turbo";

Expand Down
1 change: 1 addition & 0 deletions src/bots/OpenAIAPI4Bot.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import OpenAIAPIBot from "./OpenAIAPIBot";

export default class OpenAIAPI4Bot extends OpenAIAPIBot {
static _className = "OpenAIAPI4Bot"; // Class name of the bot
static _logoFilename = "openai-4-logo.png"; // Place it in assets/bots/
static _model = "gpt-4";

Expand Down
1 change: 1 addition & 0 deletions src/bots/OpenAIAPIBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import store from "@/store";

export default class OpenAIAPIBot extends Bot {
static _brandId = "openaiApi";
static _className = "OpenAIAPIBot";
static _logoFilename = "";
static _loginUrl = ""; // URL for the login button on the bots page
static _apiUrl = "https://api.openai.com/v1/chat/completions";
Expand Down
1 change: 1 addition & 0 deletions src/bots/SparkBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Bot from "./Bot";

export default class SparkBot extends Bot {
static _brandId = "spark";
static _className = "SparkBot"; // Class name of the bot
static _logoFilename = "spark-logo.png"; // Place it in assets/bots/
static _loginUrl = "https://xinghuo.xfyun.cn/";
static _lock = new AsyncLock(); // All Spark bots share the same lock
Expand Down

0 comments on commit c7a0bec

Please sign in to comment.