diff --git a/package.json b/package.json index aedd160..bc13eae 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@anthropic-ai/sdk": "^0.39.0", "@aws-sdk/client-bedrock": "^3.787.0", "@aws-sdk/client-bedrock-runtime": "^3.785.0", - "@google/genai": "^0.9.0", + "@google/genai": "^0.13.0", "@modelcontextprotocol/sdk": "^1.7.0", "@types/react": "^19.0.12", "@types/react-dom": "^19.0.4", diff --git a/src/main/llm/geminiLLM.ts b/src/main/llm/geminiLLM.ts index dddef51..b4ac2fc 100644 --- a/src/main/llm/geminiLLM.ts +++ b/src/main/llm/geminiLLM.ts @@ -135,9 +135,7 @@ export class GeminiLLM implements ILLM { } } - async getModels(): Promise { - // Currently no support for listModels in the Node SDK - may be coming: https://github.com/google-gemini/generative-ai-js/issues/54 - // For now we're going to make a hardcoded list of current models. + async getModelsStatic(): Promise { // This seems like the best source for models and description: https://ai.google.dev/gemini-api/docs/ const models: ILLMModel[] = [ { @@ -201,6 +199,27 @@ export class GeminiLLM implements ILLM { return models; } + async getModels(): Promise { + const returnModels: ILLMModel[] = [] + const models = await this.genAI.models.list(); + + // You might want to filter or sort this list in some way. There's some + // models that may not make sense, and you might want the "good" ones first. + + for await (const model of models) { + const newModel: ILLMModel = { + provider: LLMType.Gemini, + // May not need to remove the models/ prefix here in case you like it + id: model.name ? model.name.replace(/^models\//, '') : '', + name: model.displayName ?? '', + description: model.description || '', + modelSource: 'Google' + }; + returnModels.push(newModel); + } + return returnModels; + } + async generateResponse(session: ChatSession, messages: ChatMessage[]): Promise { const modelReply: ModelReply = { timestamp: Date.now(),