Skip to content

Commit 2aa4f37

Browse files
qcgm1978sunner
andauthored
Support tags in bots menu (#475)
* Feat: bots tag filter system * multiple select * The tags have set relationships with one another. * feat: redefine tags * style: improve coding style * feat: improve tags css * style: improve readability * style: add tailing newline * feat: improve tags css * move buttons to bottom * change button style * style --------- Co-authored-by: Sunner Sun <[email protected]>
1 parent b585754 commit 2aa4f37

File tree

4 files changed

+128
-17
lines changed

4 files changed

+128
-17
lines changed

src/bots/index.js

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import SkyWorkBot from "./SkyWorkBot";
2929
import ChatGPT4MobileBot from "./openai/ChatGPT4MobileBot";
3030
import OpenAIAPI3516KBot from "./openai/OpenAIAPI3516KBot";
3131
import AzureOpenAIAPIBot from "./microsoft/AzureOpenAIAPIBot";
32-
import WinxinQianfanTurboBot from "./baidu/WenxinQianfanTurboBot";
32+
import WenxinQianfanTurboBot from "./baidu/WenxinQianfanTurboBot";
3333
import YouChatBot from "./YouChatBot";
3434
import PiBot from "./PiBot";
3535
import Qihoo360AIBrainBot from "./Qihoo360AIBrainBot";
@@ -74,7 +74,7 @@ const all = [
7474
SparkBot.getInstance(),
7575
VicunaBot.getInstance(),
7676
WenxinQianfanBot.getInstance(),
77-
WinxinQianfanTurboBot.getInstance(),
77+
WenxinQianfanTurboBot.getInstance(),
7878
YouChatBot.getInstance(),
7979
];
8080

@@ -99,4 +99,67 @@ const bots = {
9999
},
100100
};
101101

102+
export const botTags = {
103+
free: [
104+
bots.getBotByClassName("BardBot"),
105+
bots.getBotByClassName("BingChatBalancedBot"),
106+
bots.getBotByClassName("BingChatCreativeBot"),
107+
bots.getBotByClassName("BingChatPreciseBot"),
108+
bots.getBotByClassName("ChatGLMBot"),
109+
bots.getBotByClassName("ChatGPT35Bot"),
110+
bots.getBotByClassName("ChatGPT35PoeBot"),
111+
bots.getBotByClassName("ClaudeBot"),
112+
bots.getBotByClassName("ClaudeInstantPoeBot"),
113+
bots.getBotByClassName("HuggingChatBot"),
114+
bots.getBotByClassName("Llama2HC70bBot"),
115+
bots.getBotByClassName("MOSSBot"),
116+
bots.getBotByClassName("OpenAssistantBot"),
117+
bots.getBotByClassName("Qihoo360AIBrainBot"),
118+
bots.getBotByClassName("QianWenBot"),
119+
bots.getBotByClassName("SkyWorkBot"),
120+
bots.getBotByClassName("SparkBot"),
121+
bots.getBotByClassName("YouChatBot"),
122+
bots.getBotByClassName("GradioAppBot"),
123+
bots.getBotByClassName("AlpacaBot"),
124+
bots.getBotByClassName("VicunaBot"),
125+
bots.getBotByClassName("CharacterAIBot"),
126+
bots.getBotByClassName("ClaudeAIBot"),
127+
bots.getBotByClassName("PiBot"),
128+
bots.getBotByClassName("SageBot"),
129+
],
130+
paid: [
131+
bots.getBotByClassName("ChatGPT4Bot"),
132+
bots.getBotByClassName("ChatGPT4MobileBot"),
133+
bots.getBotByClassName("ChatGPT4PoeBot"),
134+
bots.getBotByClassName("ChatGPTBrowsingBot"),
135+
bots.getBotByClassName("ClaudeInstant100kPoeBot"),
136+
bots.getBotByClassName("ClaudePlusPoeBot"),
137+
],
138+
openSource: [
139+
bots.getBotByClassName("AlpacaBot"),
140+
bots.getBotByClassName("ChatGLMBot"),
141+
bots.getBotByClassName("HuggingChatBot"),
142+
bots.getBotByClassName("Llama2HC70bBot"),
143+
bots.getBotByClassName("MOSSBot"),
144+
bots.getBotByClassName("OpenAssistantBot"),
145+
bots.getBotByClassName("VicunaBot"),
146+
],
147+
api: [
148+
bots.getBotByClassName("AzureOpenAIAPIBot"),
149+
bots.getBotByClassName("OpenAIAPI35Bot"),
150+
bots.getBotByClassName("OpenAIAPI3516KBot"),
151+
bots.getBotByClassName("OpenAIAPI4Bot"),
152+
bots.getBotByClassName("WenxinQianfanBot"),
153+
bots.getBotByClassName("WenxinQianfanTurboBot"),
154+
],
155+
madeInChina: [
156+
bots.getBotByClassName("Qihoo360AIBrainBot"),
157+
bots.getBotByClassName("QianWenBot"),
158+
bots.getBotByClassName("SkyWorkBot"),
159+
bots.getBotByClassName("SparkBot"),
160+
bots.getBotByClassName("WenxinQianfanBot"),
161+
bots.getBotByClassName("WenxinQianfanTurboBot"),
162+
bots.getBotByClassName("MOSSBot"),
163+
],
164+
};
102165
export default bots;

src/components/Footer/BotsMenu.vue

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@
1919
</template>
2020

2121
<v-card>
22-
<v-list>
23-
<v-list-item>
24-
<v-list-item-title class="font-weight-black">
25-
{{ $t("footer.chooseFavorite") }}
26-
</v-list-item-title>
27-
</v-list-item>
28-
</v-list>
29-
30-
<v-divider></v-divider>
31-
3222
<v-list
3323
class="bots-list"
3424
density="compact"
@@ -37,7 +27,7 @@
3727
nav
3828
>
3929
<v-list-item
40-
v-for="(bot, index) in bots.all"
30+
v-for="(bot, index) in shownBots"
4131
:key="index"
4232
:value="bot.getClassname()"
4333
color="primary"
@@ -57,6 +47,32 @@
5747
</v-list-item-title>
5848
</v-list-item>
5949
</v-list>
50+
51+
<v-divider></v-divider>
52+
53+
<v-list>
54+
<v-list-item>
55+
<v-list-item-title class="font-weight-black">
56+
{{ $t("footer.chooseFavorite") }}
57+
</v-list-item-title>
58+
<template v-slot:append>
59+
<v-btn-toggle
60+
v-model="selectedTags"
61+
divided
62+
color="primary"
63+
group
64+
multiple
65+
variant="outlined"
66+
rounded="xl"
67+
@update:model-value="filterBots($event)"
68+
>
69+
<v-btn v-for="(tag, index) in tags" :key="index" :value="tag">
70+
{{ $t(`footer.${tag}`) }}
71+
</v-btn>
72+
</v-btn-toggle>
73+
</template>
74+
</v-list-item>
75+
</v-list>
6076
</v-card>
6177
</v-menu>
6278
</div>
@@ -66,16 +82,21 @@
6682
import { computed, ref } from "vue";
6783
6884
import bots from "@/bots";
85+
import { botTags } from "@/bots";
6986
import BotLogo from "./BotLogo.vue";
7087
import store from "@/store";
7188
72-
const props = defineProps(["favBots"]);
73-
7489
let menu = ref(false);
90+
91+
const props = defineProps(["favBots"]);
7592
const favorited = computed(() => {
7693
return props.favBots.map((bot) => bot.classname);
7794
});
7895
96+
const tags = Object.keys(botTags);
97+
const selectedTags = ref([]);
98+
const shownBots = ref(bots.all);
99+
79100
const toggleFavorite = (bot) => {
80101
const classname = bot.getClassname();
81102
if (favorited.value.includes(classname)) {
@@ -89,6 +110,18 @@ function toggleMenu() {
89110
menu.value = !menu.value;
90111
}
91112
113+
function filterBots(selectedTags) {
114+
let filteredIn = bots.all;
115+
116+
if (selectedTags.length) {
117+
const tagBots = selectedTags.map((tag) => botTags[tag]);
118+
filteredIn = filteredIn.filter((bot) => {
119+
return tagBots.every((tagBot) => tagBot.includes(bot));
120+
});
121+
}
122+
shownBots.value = filteredIn;
123+
}
124+
92125
defineExpose({
93126
toggleMenu,
94127
});
@@ -98,4 +131,9 @@ defineExpose({
98131
.bots-list {
99132
column-count: 3;
100133
}
134+
135+
/* Keep the orignal case of tab names */
136+
.v-btn {
137+
text-transform: none !important;
138+
}
101139
</style>

src/i18n/locales/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
"footer": {
2828
"chooseFavorite": "Choose your favorite AI bots",
2929
"sendPrompt": "Send to:",
30-
"promptPlaceholder": "Type a message. (Shift+Enter to add a new line)"
30+
"promptPlaceholder": "Type a message. (Shift+Enter to add a new line)",
31+
"madeInChina": "Made in China",
32+
"openSource": "Open Source",
33+
"free": "Free",
34+
"paid": "Paid",
35+
"api": "API"
3136
},
3237
"error": {
3338
"error": "Error",

src/i18n/locales/zh.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
"footer": {
2828
"chooseFavorite": "选择你喜欢的 AI",
2929
"sendPrompt": "发送到:",
30-
"promptPlaceholder": "输入消息。(Shift+Enter 换行)"
30+
"promptPlaceholder": "输入消息。(Shift+Enter 换行)",
31+
"madeInChina": "中国制造",
32+
"openSource": "开源",
33+
"free": "免费",
34+
"paid": "付费",
35+
"api": "API"
3136
},
3237
"error": {
3338
"error": "错误",

0 commit comments

Comments
 (0)