forked from ai-shifu/ChatALL
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Gemini-pro model for chat (ai-shifu#678)
* Add langchain/google-genai package and update langchain to 0.0.207 for Gemini * Gemini up and running * Update gemini-logo.png --------- Co-authored-by: Sunner Sun <[email protected]>
- Loading branch information
Showing
19 changed files
with
328 additions
and
7 deletions.
There are no files selected for viewing
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.
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 "@/bots/LangChainBot"; | ||
import store from "@/store"; | ||
import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; | ||
|
||
export default class GeminiBot extends LangChainBot { | ||
static _brandId = "gemini"; | ||
static _className = "GeminiBot"; | ||
static _logoFilename = "gemini-logo.png"; // Place it in public/bots/ | ||
static _model = "gemini-pro"; | ||
|
||
constructor() { | ||
super(); | ||
} | ||
|
||
async _checkAvailability() { | ||
let available = false; | ||
|
||
if (store.state.gemini.apiKey) { | ||
const chatModel = new ChatGoogleGenerativeAI({ | ||
apiKey: store.state.gemini.apiKey, | ||
modelName: this.constructor._model ? this.constructor._model : "", | ||
temperature: store.state.gemini.temperature, | ||
streaming: true, | ||
topK: store.state.gemini.topK, | ||
topP: store.state.gemini.topP, | ||
}); | ||
this.constructor._chatModel = chatModel; | ||
available = true; | ||
} | ||
return available; | ||
} | ||
|
||
getPastRounds() { | ||
return store.state.gemini.pastRounds; | ||
} | ||
} |
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,75 @@ | ||
<template> | ||
<CommonBotSettings | ||
:settings="settings" | ||
:brand-id="brandId" | ||
mutation-type="setGemini" | ||
></CommonBotSettings> | ||
</template> | ||
|
||
<script> | ||
import Bot from "@/bots/GeminiBot"; | ||
import CommonBotSettings from "@/components/BotSettings/CommonBotSettings.vue"; | ||
import i18n from "@/i18n"; | ||
import { Type } from "./settings.const"; | ||
const settings = [ | ||
{ | ||
type: Type.Text, | ||
name: "apiKey", | ||
title: i18n.global.t("openaiApi.apiKey"), | ||
description: i18n.global.t("settings.secretPrompt"), | ||
placeholder: "...", | ||
}, | ||
{ | ||
type: Type.Slider, | ||
name: "temperature", | ||
title: i18n.global.t("openaiApi.temperature"), | ||
description: i18n.global.t("openaiApi.temperaturePrompt"), | ||
min: 0, | ||
max: 1, | ||
step: 0.1, | ||
ticks: { | ||
0: i18n.global.t("openaiApi.temperature0"), | ||
2: i18n.global.t("openaiApi.temperature2"), | ||
}, | ||
}, | ||
{ | ||
type: Type.Slider, | ||
name: "topK", | ||
title: i18n.global.t("gemini.topK"), | ||
description: i18n.global.t("gemini.topKPrompt"), | ||
min: 1, | ||
max: 100, | ||
step: 1, | ||
}, | ||
{ | ||
type: Type.Slider, | ||
name: "topP", | ||
title: i18n.global.t("gemini.topP"), | ||
description: i18n.global.t("gemini.topPPrompt"), | ||
min: 0.1, | ||
max: 1, | ||
step: 0.01, | ||
}, | ||
{ | ||
type: Type.Slider, | ||
name: "pastRounds", | ||
title: i18n.global.t("bot.pastRounds"), | ||
description: i18n.global.t("bot.pastRoundsPrompt"), | ||
min: 0, | ||
max: 10, | ||
step: 1, | ||
}, | ||
]; | ||
export default { | ||
components: { | ||
CommonBotSettings, | ||
}, | ||
data() { | ||
return { | ||
settings: settings, | ||
brandId: Bot._brandId, | ||
}; | ||
}, | ||
}; | ||
</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.