-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add xAI Grok Beta & Grok-2 bot via API
Reference: - https://docs.x.ai/ - https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-xai/ Logo file source: - https://commons.wikimedia.org/wiki/File:Grok_logo_without_text.svg
- Loading branch information
1 parent
5004e5d
commit f251e75
Showing
32 changed files
with
290 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.