Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Groq Cloud support #794

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@kangc/v-md-editor": "^2.3.16",
"@langchain/anthropic": "^0.1.9",
"@langchain/google-genai": "^0.0.7",
"@langchain/groq": "^0.0.6",
"@langchain/openai": "^0.0.12",
"@mdi/font": "^7.4.47",
"@vueuse/rxjs": "^10.7.1",
Expand Down
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
Loading