Skip to content

Commit

Permalink
Add Groq Cloud support, close ai-shifu#716
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Apr 18, 2024
1 parent e519453 commit 544cea9
Show file tree
Hide file tree
Showing 22 changed files with 210 additions and 0 deletions.
Binary file added public/bots/gemma-7b-it-groq-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bots/llama-2-70b-groq-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/bots/mistral-8x7b-groq-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/bots/groq/Gemma7bGroqAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import GroqAPIBot from "./GroqAPIBot";

export default class Gemma7bGroqAPIBot extends GroqAPIBot {
static _className = "Gemma7bGroqAPIBot";
static _logoFilename = "gemma-7b-it-groq-logo.png";
static _model = "gemma-7b-it";
constructor() {
super();
}
}
38 changes: 38 additions & 0 deletions src/bots/groq/GroqAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import LangChainBot from "../LangChainBot";
import store from "@/store";
import { ChatGroq } from "@langchain/groq";

export default class GroqAPIBot extends LangChainBot {
static _brandId = "groqApi";
static _className = "GroqAPIBot";

constructor() {
super();
}

async _checkAvailability() {
let available = false;

if (store.state.groqApi.apiKey) {
this.setupModel();
available = true;
}
return available;
}

_setupModel() {
const chatModel = new ChatGroq({
apiKey: store.state.groqApi.apiKey,
modelName: this.constructor._model ? this.constructor._model : "",
streaming: true,
temperature: store.state.groqApi.temperature,
maxTokens: store.state.groqApi.maxTokens,
});

return chatModel;
}

getPastRounds() {
return store.state.groqApi.pastRounds ? store.state.groqApi.pastRounds : 1;
}
}
10 changes: 10 additions & 0 deletions src/bots/groq/Llama270bGroqAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import GroqAPIBot from "./GroqAPIBot";

export default class Llama270bGroqAPIBot extends GroqAPIBot {
static _className = "Llama270bGroqAPIBot";
static _logoFilename = "llama-2-70b-groq-logo.png";
static _model = "llama2-70b-4096";
constructor() {
super();
}
}
10 changes: 10 additions & 0 deletions src/bots/groq/Mixtral8x7bGroqAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import GroqAPIBot from "./GroqAPIBot";

export default class Mixtral8x7bGroqAPIBot extends GroqAPIBot {
static _className = "Mixtral8x7bGroqAPIBot";
static _logoFilename = "mistral-8x7b-groq-logo.png";
static _model = "mixtral-8x7b-32768";
constructor() {
super();
}
}
9 changes: 9 additions & 0 deletions src/bots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import AlpacaBot from "@/bots/lmsys/AlpacaBot";
import ClaudeBot from "@/bots/lmsys/ClaudeBot";
import DevBot from "@/bots/DevBot";
import GradioAppBot from "@/bots/huggingface/GradioAppBot";
import Gemma7bGroqAPIBot from "@/bots/groq/Gemma7bGroqAPIBot";
import Llama270bGroqAPIBot from "@/bots/groq/Llama270bGroqAPIBot";
import Mixtral8x7bGroqAPIBot from "@/bots/groq/Mixtral8x7bGroqAPIBot";
import HuggingChatBot from "@/bots/huggingface/HuggingChatBot";
import QianWenBot from "./QianWenBot";
import ChatGPT35PoeBot from "./poe/ChatGPT35PoeBot";
Expand Down Expand Up @@ -123,6 +126,9 @@ const all = [
OpenAIAPI4128KBot.getInstance(),
ChatGPT432kPoeBot.getInstance(),
GradioAppBot.getInstance(),
Gemma7bGroqAPIBot.getInstance(),
Llama270bGroqAPIBot.getInstance(),
Mixtral8x7bGroqAPIBot.getInstance(),
KimiBot.getInstance(),
Llama27bBot.getInstance(),
Llama213bBot.getInstance(),
Expand Down Expand Up @@ -280,6 +286,9 @@ export const botTags = {
bots.getBotByClassName("ClaudeAPIInstant12Bot"),
bots.getBotByClassName("ClaudeAPIOpusBot"),
bots.getBotByClassName("ClaudeAPISonnetBot"),
bots.getBotByClassName("Gemma7bGroqAPIBot"),
bots.getBotByClassName("Llama270bGroqAPIBot"),
bots.getBotByClassName("Mixtral8x7bGroqAPIBot"),
],
madeInChina: [
bots.getBotByClassName("Qihoo360AIBrainBot"),
Expand Down
56 changes: 56 additions & 0 deletions src/components/BotSettings/GroqAPIBotSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<CommonBotSettings
:settings="settings"
:brand-id="brandId"
mutation-type="setGroqApi"
:watcher="watcher"
></CommonBotSettings>
</template>

<script>
import _bots from "@/bots";
import Bot from "@/bots/groq/GroqAPIBot";
import CommonBotSettings from "@/components/BotSettings/CommonBotSettings.vue";
import { Type } from "./settings.const";
const settings = [
{
type: Type.Text,
name: "apiKey",
title: "groqApi.apiKey",
description: "settings.secretPrompt",
placeholder: "gsk_...",
},
{
type: Type.Slider,
name: "temperature",
title: "openaiApi.temperature",
description: "openaiApi.temperaturePrompt",
min: 0,
max: 1,
step: 0.1,
ticks: {
0: "openaiApi.temperature0",
1: "openaiApi.temperature2",
},
},
];
export default {
components: {
CommonBotSettings,
},
data() {
return {
settings: settings,
brandId: Bot._brandId,
};
},
methods: {
watcher() {
_bots.all
.filter((bot) => bot instanceof Bot)
.map((bot) => bot.setupModel());
},
},
};
</script>
2 changes: 2 additions & 0 deletions src/components/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import KimiBotSettings from "./BotSettings/KimiBotSettings.vue";
import { resolveTheme, applyTheme, Mode } from "../theme";
import ClaudeAPIBotSettings from "./BotSettings/ClaudeAPIBotSettings.vue";
import GroqAPIBotSettings from "./BotSettings/GroqAPIBotSettings.vue";
const { ipcRenderer } = window.require("electron");
const { t: $t, locale } = useI18n();
Expand Down Expand Up @@ -167,6 +168,7 @@ const botSettings = [
{ brand: "wenxinQianfan", component: WenxinQianfanBotSettings },
{ brand: "youChat", component: YouChatBotSettings },
{ brand: "claudeApi", component: ClaudeAPIBotSettings },
{ brand: "groqApi", component: GroqAPIBotSettings },
];
const proxy = ProxySettings;
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,11 @@
},
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
}
}
6 changes: 6 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "Update Available!",
"currentVersion": "Your Version",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@
"dev": {
"name": "Bot de desarrollo"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "¡Actualización disponible!",
"currentVersion": "Su versión",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@
},
"dev": {
"name": "Bot Dev"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
}
}
6 changes: 6 additions & 0 deletions src/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,11 @@
},
"dev": {
"name": "Bot Dev"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
}
}
6 changes: 6 additions & 0 deletions src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "アップデート利用可能!",
"currentVersion": "現バージョン",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "업데이트 가능!",
"currentVersion": "사용자 버전",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@
},
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
}
}
6 changes: 6 additions & 0 deletions src/i18n/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
"dev": {
"name": "Dev Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "Cập nhập mới đã có!",
"currentVersion": "Phiên bản của bạn",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
"dev": {
"name": "开发专用 Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "有更新!",
"currentVersion": "您当前的版本",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/locales/zhtw.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@
"dev": {
"name": "開發專用 Bot"
},
"groqApi": {
"name": "Groq API",
"llama2-70b-4096": "LLaMA2 70b",
"mixtral-8x7b-32768": "Mixtral 8x7b",
"gemma-7b-it": "Gemma 7b"
},
"updates": {
"updateAvailable": "有新版可使用!",
"currentVersion": "您目前的版本",
Expand Down
9 changes: 9 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ export default createStore({
mistral: {
model: "mistral-large",
},
groqApi: {
apiKey: "",
temperature: 0,
maxTokens: 1000,
pastRounds: 1,
},
moss: {
token: "",
},
Expand Down Expand Up @@ -230,6 +236,9 @@ export default createStore({
setGradio(state, values) {
state.gradio = { ...state.gradio, ...values };
},
setGroq(state, values) {
state.groq = { ...state.groq, ...values };
},
setCharacterAI(state, values) {
state.characterAI = { ...state.characterAI, ...values };
},
Expand Down

0 comments on commit 544cea9

Please sign in to comment.