[FEAT] Add support for gemini-1.5-flash-latest model (#1502)

* add support for gemini-1.5-flash-latest

* update comment in gemini LLM provider
This commit is contained in:
Sean Hatfield 2024-05-23 09:42:30 -07:00 committed by GitHub
parent 961630f7d5
commit cc7e7fb3ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 6 deletions

View File

@ -30,7 +30,11 @@ export default function GeminiLLMOptions({ settings }) {
required={true} required={true}
className="bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" className="bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
> >
{["gemini-pro", "gemini-1.5-pro-latest"].map((model) => { {[
"gemini-pro",
"gemini-1.5-pro-latest",
"gemini-1.5-flash-latest",
].map((model) => {
return ( return (
<option key={model} value={model}> <option key={model} value={model}>
{model} {model}

View File

@ -10,7 +10,7 @@ export const DISABLED_PROVIDERS = [
]; ];
const PROVIDER_DEFAULT_MODELS = { const PROVIDER_DEFAULT_MODELS = {
openai: [], openai: [],
gemini: ["gemini-pro", "gemini-1.5-pro-latest"], gemini: ["gemini-pro", "gemini-1.5-pro-latest", "gemini-1.5-flash-latest"],
anthropic: [ anthropic: [
"claude-instant-1.2", "claude-instant-1.2",
"claude-2.0", "claude-2.0",

View File

@ -17,8 +17,12 @@ class GeminiLLM {
this.gemini = genAI.getGenerativeModel( this.gemini = genAI.getGenerativeModel(
{ model: this.model }, { model: this.model },
{ {
// Gemini-1.5-pro is only available on the v1beta API. // Gemini-1.5-pro and Gemini-1.5-flash are only available on the v1beta API.
apiVersion: this.model === "gemini-1.5-pro-latest" ? "v1beta" : "v1", apiVersion:
this.model === "gemini-1.5-pro-latest" ||
this.model === "gemini-1.5-flash-latest"
? "v1beta"
: "v1",
} }
); );
this.limits = { this.limits = {
@ -95,7 +99,11 @@ class GeminiLLM {
} }
isValidChatCompletionModel(modelName = "") { isValidChatCompletionModel(modelName = "") {
const validModels = ["gemini-pro", "gemini-1.5-pro-latest"]; const validModels = [
"gemini-pro",
"gemini-1.5-pro-latest",
"gemini-1.5-flash-latest",
];
return validModels.includes(modelName); return validModels.includes(modelName);
} }

View File

@ -526,7 +526,11 @@ function supportedTranscriptionProvider(input = "") {
} }
function validGeminiModel(input = "") { function validGeminiModel(input = "") {
const validModels = ["gemini-pro", "gemini-1.5-pro-latest"]; const validModels = [
"gemini-pro",
"gemini-1.5-pro-latest",
"gemini-1.5-flash-latest",
];
return validModels.includes(input) return validModels.includes(input)
? null ? null
: `Invalid Model type. Must be one of ${validModels.join(", ")}.`; : `Invalid Model type. Must be one of ${validModels.join(", ")}.`;