Skip to content

Commit

Permalink
Add xAI Grok Beta & Grok-2 bot via API
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Dec 30, 2024
1 parent 5004e5d commit f251e75
Show file tree
Hide file tree
Showing 32 changed files with 290 additions and 3 deletions.
1 change: 1 addition & 0 deletions README_DE-DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Auf großen Sprachmodellen (LLMs) basierende KI-Bots sind erstaunlich. Ihr Verha
| [Tongyi Qianwen](http://tongyi.aliyun.com/) | Ja | Demnächst | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) | Ja | Nein | Kein Login erforderlich |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) | Ja | Nein | |
| [xAI Grok](https://x.ai) | Nein | Ja | |
| [YouChat](https://you.com/) | Ja | Nein | |
| [You](https://you.com/) | Ja | Nein | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) | Ja | Nein | |
Expand Down
1 change: 1 addition & 0 deletions README_ES-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Los usuarios típicos de ChatALL son:
| [Tongyi Qianwen](http://tongyi.aliyun.com/) || Prossimamente | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) || No | Nessun accesso richiesto |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) || No | |
| [xAI Grok](https://x.ai) | No || |
| [YouChat](https://you.com/) || No | |
| [You](https://you.com/) || No | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) || No | |
Expand Down
1 change: 1 addition & 0 deletions README_FR-FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Les robots d'intelligence artificielle basés sur les grands modèles de langage
| [Tongyi Qianwen](http://tongyi.aliyun.com/) | Oui | Prochainement | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) | Oui | Non | Pas besoin de compte ou de clé API |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) | Oui | Non | |
| [xAI Grok](https://x.ai) | Non | Oui | |
| [YouChat](https://you.com/) | Oui | Non | |
| [You](https://you.com/) | Oui | Non | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) | Oui | Non | |
Expand Down
1 change: 1 addition & 0 deletions README_IT-IT.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Gli utenti tipici di ChatALL sono:
| [Tongyi Qianwen](http://tongyi.aliyun.com/) || Prossimamente | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) || No | Nessun accesso richiesto |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) || No | |
| [xAI Grok](https://x.ai) | No || |
| [YouChat](https://you.com/) || No | |
| [You](https://you.com/) || No | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) || No | |
Expand Down
1 change: 1 addition & 0 deletions README_JA-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ ChatALLのユーザーはこんな感じ:
| [Tongyi Qianwen](http://tongyi.aliyun.com/) | はい | 近日登場 | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) | はい | なし | ログイン不要 |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) | はい | なし | |
| [xAI Grok](https://x.ai) | いいえ | あり | |
| [YouChat](https://you.com/) | はい | なし | |
| [You](https://you.com/) | はい | なし | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) | はい | なし | |
Expand Down
1 change: 1 addition & 0 deletions README_KO-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ChatALL의 일반적인 사용자는 다음과 같습니다:
| [Tongyi Qianwen](http://tongyi.aliyun.com/) || 근일 개봉 | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) || 없음 | 로그인 필요 없음 |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) || 없음 | |
| [xAI Grok](https://x.ai) | 아니오 || |
| [YouChat](https://you.com/) || 없음 | |
| [You](https://you.com/) || 없음 | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) || 없음 | |
Expand Down
1 change: 1 addition & 0 deletions README_RU-RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
| [Tongyi Qianwen](http://tongyi.aliyun.com/) | Да | Скоро будет | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) | Да | Нет API | Вход в ученую запись не требуется |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) | Да | Нет | |
| [xAI Grok](https://x.ai) | Нет | Да | |
| [YouChat](https://you.com/) | Да | Нет | |
| [You](https://you.com/) | Да | Нет | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) | Да | Нет | |
Expand Down
1 change: 1 addition & 0 deletions README_VI-VN.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Các Chat bots AI dựa trên Mô hình ngôn ngữ lớn (Large Language Models
| [Tongyi Qianwen](http://tongyi.aliyun.com/) || Sắp ra mắt | |
| [Vicuna 13B & 33B](https://lmsys.org/blog/2023-03-30-vicuna/) || Không có API | Không yêu cầu tài khoản |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) || Không có | |
| [xAI Grok](https://x.ai) | Không || |
| [YouChat](https://you.com/) || Không có | |
| [You](https://you.com/) || Không có | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) || Không có | |
Expand Down
1 change: 1 addition & 0 deletions README_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ChatALL 的典型用户是:
| [通义千问](http://tongyi.aliyun.com/) | 支持 | 即将推出 | |
| [Vicuna 13B 和 33B](https://lmsys.org/blog/2023-03-30-vicuna/) | 支持 | 无 API | 不需要帐号 |
| [WizardLM 70B](https://github.com/nlpxucan/WizardLM) | 支持 | 无 API | |
| [xAI Grok](https://x.ai) || 支持 | |
| [YouChat](https://you.com/) | 支持 || |
| [You](https://you.com/) | 支持 | 无 API | |
| [Zephyr](https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat) | 支持 || |
Expand Down
40 changes: 37 additions & 3 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 @@ -35,6 +35,7 @@
"@langchain/google-genai": "^0.0.21",
"@langchain/groq": "^0.1.2",
"@langchain/openai": "^0.2.1",
"@langchain/xai": "^0.0.1",
"@mdi/font": "^7.4.47",
"@vueuse/rxjs": "^11.1.0",
"async-lock": "^1.4.1",
Expand Down
Binary file added public/bots/grok-2-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/grok-beta-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/bots/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ import ClaudeAPI20Bot from "./anthropic/ClaudeAPI20Bot";
import ClaudeAPI21Bot from "./anthropic/ClaudeAPI21Bot";
import ClaudeAPISonnetBot from "./anthropic/ClaudeAPISonnetBot";
import ClaudeAPIHaikuBot from "./anthropic/ClaudeAPIHaikuBot";
import GrokBetaAPIBot from "./xai/GrokBetaAPIBot";
import Grok2APIBot from "./xai/Grok2APIBot";

const all = [
Qihoo360AIBrainBot.getInstance(),
Expand Down Expand Up @@ -162,6 +164,8 @@ const all = [
Wizardlm70bBot.getInstance(),
Zephyr7bBot.getInstance(),
YouChatBot.getInstance(),
GrokBetaAPIBot.getInstance(),
Grok2APIBot.getInstance(),
];

const disabled = [
Expand Down Expand Up @@ -303,6 +307,8 @@ export const botTags = {
bots.getBotByClassName("Llama38bGroqAPIBot"),
bots.getBotByClassName("Llama370bGroqAPIBot"),
bots.getBotByClassName("Mixtral8x7bGroqAPIBot"),
bots.getBotByClassName("GrokBetaAPIBot"),
bots.getBotByClassName("Grok2APIBot"),
],
madeInChina: [
bots.getBotByClassName("Qihoo360AIBrainBot"),
Expand Down
10 changes: 10 additions & 0 deletions src/bots/xai/Grok2APIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import xAIAPIBot from "./xAIAPIBot";

export default class Grok2APIBot extends xAIAPIBot {
static _className = "Grok2APIBot";
static _logoFilename = "grok-2-logo.png";
static _model = "grok-2-latest";
constructor() {
super();
}
}
10 changes: 10 additions & 0 deletions src/bots/xai/GrokBetaAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import xAIAPIBot from "./xAIAPIBot";

export default class GrokBetaAPIBot extends xAIAPIBot {
static _className = "GrokBetaAPIBot";
static _logoFilename = "grok-beta-logo.png";
static _model = "grok-beta";
constructor() {
super();
}
}
36 changes: 36 additions & 0 deletions src/bots/xai/xAIAPIBot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import LangChainBot from "../LangChainBot";
import store from "@/store";
import { ChatXAI } from "@langchain/xai";

export default class xAIAPIBot extends LangChainBot {
static _brandId = "xaiApi";
static _className = "xAIAPIBot";

constructor() {
super();
}

async _checkAvailability() {
let available = false;

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

_setupModel() {
const chatModel = new ChatXAI({
apiKey: store.state.xaiApi.apiKey,
model: this.constructor._model ? this.constructor._model : "",
streaming: true,
});

return chatModel;
}

getPastRounds() {
return store.state.xaiApi.pastRounds ? store.state.xaiApi.pastRounds : 5;
}
}
65 changes: 65 additions & 0 deletions src/bots/xai/xAIAPIBotSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<CommonBotSettings
:settings="settings"
:brand-id="brandId"
mutation-type="setXaiApi"
:watcher="watcher"
></CommonBotSettings>
</template>

<script>
import _bots from "@/bots";
import Bot from "@/bots/xai/xAIAPIBot";
import CommonBotSettings from "@/components/BotSettings/CommonBotSettings.vue";
import { Type } from "./settings.const";
const settings = [
{
type: Type.Text,
name: "apiKey",
title: "common.apiKey",
description: "settings.secretPrompt",
placeholder: "xai_...",
},
{
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",
},
},
{
type: Type.Slider,
name: "pastRounds",
title: "bot.pastRounds",
description: "bot.pastRoundsPrompt",
min: 0,
max: 10,
step: 1,
},
];
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>
52 changes: 52 additions & 0 deletions src/components/BotSettings/xAIAPIBotSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<CommonBotSettings
:settings="settings"
:brand-id="brandId"
mutation-type="setxAIApi"
:watcher="watcher"
></CommonBotSettings>
</template>

<script>
import _bots from "@/bots";
import Bot from "@/bots/xai/xAIAPIBot";
import CommonBotSettings from "@/components/BotSettings/CommonBotSettings.vue";
import { Type } from "./settings.const";
const settings = [
{
type: Type.Text,
name: "apiKey",
title: "common.apiKey",
description: "settings.secretPrompt",
placeholder: "xai-...",
},
{
type: Type.Slider,
name: "pastRounds",
title: "bot.pastRounds",
description: "bot.pastRoundsPrompt",
min: 0,
max: 10,
step: 1,
},
];
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 @@ -130,6 +130,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";
import xAIAPIBotSettings from "./BotSettings/xAIAPIBotSettings.vue";
const { ipcRenderer } = window.require("electron");
const { t: $t, locale } = useI18n();
Expand Down Expand Up @@ -170,6 +171,7 @@ const botSettings = [
{ brand: "skyWork", component: SkyWorkBotSettings },
{ brand: "spark", component: SparkBotSettings },
{ brand: "wenxinQianfan", component: WenxinQianfanBotSettings },
{ brand: "xaiApi", component: xAIAPIBotSettings },
{ brand: "youChat", component: YouChatBotSettings },
];
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@
"gemma-7b-it": "Gemma 7b",
"gemma2-9b-it": "Gemma2 9b"
},
"xaiApi": {
"name": "xAI API",
"grok-beta": "Grok Beta",
"grok-2-latest": "Grok-2"
},
"updates": {
"updateAvailable": "Update verfügbar!",
"currentVersion": "Ihre Version",
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@
"gemma-7b-it": "Gemma 7b",
"gemma2-9b-it": "Gemma2 9b"
},
"xaiApi": {
"name": "xAI API",
"grok-beta": "Grok Beta",
"grok-2-latest": "Grok-2"
},
"updates": {
"updateAvailable": "Update Available!",
"currentVersion": "Your Version",
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@
"gemma-7b-it": "Gemma 7b",
"gemma2-9b-it": "Gemma2 9b"
},
"xaiApi": {
"name": "xAI API",
"grok-beta": "Grok Beta",
"grok-2-latest": "Grok-2"
},
"updates": {
"updateAvailable": "¡Hay una actualización disponible!",
"currentVersion": "Su versión",
Expand Down
Loading

0 comments on commit f251e75

Please sign in to comment.