[PR #3616] [MERGED] Refactor Gemini to use OpenAI interface API #4338

Closed
opened 2026-02-22 18:35:37 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/3616
Author: @timothycarambat
Created: 4/7/2025
Status: Merged
Merged: 4/7/2025
Merged by: @timothycarambat

Base: masterHead: 3614-gemini-refactor


📝 Commits (5)

  • 6fc52f0 Refactor Gemini to use OpenAI interface API
  • 8fbed63 add TODO
  • a69a897 Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into 3614-gemini-refactor
  • 98639fd handle errors better (gemini)
  • 33dcedf remove unused code

📊 Changes

13 files changed (+290 additions, -257 deletions)

View changed files

📝 docker/.env.example (+1 -1)
📝 frontend/src/components/LLMSelection/GeminiLLMOptions/index.jsx (+6 -1)
📝 frontend/src/hooks/useGetProvidersModels.js (+1 -15)
📝 frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/index.jsx (+1 -1)
📝 server/.env.example (+1 -1)
📝 server/models/systemSettings.js (+2 -1)
📝 server/utils/AiProviders/gemini/index.js (+103 -228)
📝 server/utils/EmbeddingEngines/gemini/index.js (+2 -0)
📝 server/utils/agents/aibitat/index.js (+3 -3)
📝 server/utils/agents/aibitat/providers/ai-provider.js (+8 -0)
server/utils/agents/aibitat/providers/gemini.js (+154 -0)
📝 server/utils/agents/aibitat/providers/index.js (+2 -0)
📝 server/utils/agents/index.js (+6 -6)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #3614
resolves #1297

What is in this change?

  • Removes @google/generative-ai dependency in LLM provider in favor of OpenAI SDK layer
  • Enables AI Agents (all types) via Untooled through this change
  • Replaces default model for gemini to gemini-2.0-flash-lite
  • Streaming enabled for all models

Additional Information

  • TODO: remove embedding dependency for @google/generative-ai in favor of OpenAI in #3618
  • Tested with all stable and experimental models - all of which work under the /v1beta/openai endpoint (???)
  • Compensate for non-system prompt enabled models for both LLM & Agentic inference
  • This change removes Safety settings for Gemini - not available in API.
  • Token counting is estimated and will not be accurate.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/3616 **Author:** [@timothycarambat](https://github.com/timothycarambat) **Created:** 4/7/2025 **Status:** ✅ Merged **Merged:** 4/7/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `3614-gemini-refactor` --- ### 📝 Commits (5) - [`6fc52f0`](https://github.com/Mintplex-Labs/anything-llm/commit/6fc52f02ad1480b0581b4927ead8671608c2b4b2) Refactor Gemini to use OpenAI interface API - [`8fbed63`](https://github.com/Mintplex-Labs/anything-llm/commit/8fbed63f8f357998fad9de26b6949c2b6bbe306d) add TODO - [`a69a897`](https://github.com/Mintplex-Labs/anything-llm/commit/a69a89744870e8fabed2aa88fc8e592c74cff80e) Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into 3614-gemini-refactor - [`98639fd`](https://github.com/Mintplex-Labs/anything-llm/commit/98639fd49ee9a646669517fdd72976d5dfa6c3dd) handle errors better (gemini) - [`33dcedf`](https://github.com/Mintplex-Labs/anything-llm/commit/33dcedf65db72b1024c607749fa4e6f66643d17a) remove unused code ### 📊 Changes **13 files changed** (+290 additions, -257 deletions) <details> <summary>View changed files</summary> 📝 `docker/.env.example` (+1 -1) 📝 `frontend/src/components/LLMSelection/GeminiLLMOptions/index.jsx` (+6 -1) 📝 `frontend/src/hooks/useGetProvidersModels.js` (+1 -15) 📝 `frontend/src/pages/WorkspaceSettings/AgentConfig/AgentLLMSelection/index.jsx` (+1 -1) 📝 `server/.env.example` (+1 -1) 📝 `server/models/systemSettings.js` (+2 -1) 📝 `server/utils/AiProviders/gemini/index.js` (+103 -228) 📝 `server/utils/EmbeddingEngines/gemini/index.js` (+2 -0) 📝 `server/utils/agents/aibitat/index.js` (+3 -3) 📝 `server/utils/agents/aibitat/providers/ai-provider.js` (+8 -0) ➕ `server/utils/agents/aibitat/providers/gemini.js` (+154 -0) 📝 `server/utils/agents/aibitat/providers/index.js` (+2 -0) 📝 `server/utils/agents/index.js` (+6 -6) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [x] ✨ feat - [ ] 🐛 fix - [x] ♻️ refactor - [ ] 💄 style - [x] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #3614 resolves #1297 ### What is in this change? - Removes `@google/generative-ai` dependency in LLM provider in favor of `OpenAI` SDK layer - Enables AI Agents (all types) via `Untooled` through this change - Replaces default model for `gemini to gemini-2.0-flash-lite` - Streaming enabled for all models <!-- Describe the changes in this PR that are impactful to the repo. --> ### Additional Information - TODO: remove embedding dependency for `@google/generative-ai` in favor of OpenAI in #3618 - Tested with all stable and experimental models - all of which work under the `/v1beta/openai` endpoint (???) - Compensate for non-system prompt enabled models for both LLM & Agentic inference - This change _removes_ Safety settings for Gemini - not available in API. - Token counting is estimated and will not be accurate. <!-- Add any other context about the Pull Request here that was not captured above. --> ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:35:37 -05:00
yindo closed this issue 2026-02-22 18:35:37 -05:00
yindo changed title from [PR #3616] Refactor Gemini to use OpenAI interface API to [PR #3616] [MERGED] Refactor Gemini to use OpenAI interface API 2026-06-05 15:18:04 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4338