Skip to content

Commit

Permalink
🚀 feat: Add Gemini 2.0 Support, Update Packages and Deprecations (dan…
Browse files Browse the repository at this point in the history
…ny-avila#4951)

* chore: Comment out deprecated MongoDB connection options in connectDb.js

* replaced deprecrated MongoDB count() function with countDocuments()

* npm audit fix (package-lock cleanup)

* chore: Specify .env file in launch configuration

* feat: gemini-2.0

* chore: bump express to 4.21.2 to address CVE-2024-52798

* chore: remove redundant comment for .env file specification in launch configuration

---------

Co-authored-by: neturmel <[email protected]>
  • Loading branch information
2 people authored and Tsounguinzo committed Dec 14, 2024
1 parent 5018cfe commit c951b02
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ GOOGLE_KEY=user_provided
# GOOGLE_REVERSE_PROXY=

# Gemini API (AI Studio)
# GOOGLE_MODELS=gemini-exp-1121,gemini-exp-1114,gemini-1.5-flash-latest,gemini-1.0-pro,gemini-1.0-pro-001,gemini-1.0-pro-latest,gemini-1.0-pro-vision-latest,gemini-1.5-pro-latest,gemini-pro,gemini-pro-vision
# GOOGLE_MODELS=gemini-2.0-flash-exp,gemini-exp-1121,gemini-exp-1114,gemini-1.5-flash-latest,gemini-1.0-pro,gemini-1.0-pro-001,gemini-1.0-pro-latest,gemini-1.0-pro-vision-latest,gemini-1.5-pro-latest,gemini-pro,gemini-pro-vision

# Vertex AI
# GOOGLE_MODELS=gemini-1.5-flash-preview-0514,gemini-1.5-pro-preview-0514,gemini-1.0-pro-vision-001,gemini-1.0-pro-002,gemini-1.0-pro-001,gemini-pro-vision,gemini-1.0-pro
Expand Down
3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"env": {
"NODE_ENV": "production"
},
"console": "integratedTerminal"
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env"
}
]
}
4 changes: 2 additions & 2 deletions api/lib/db/connectDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async function connectDb() {
const disconnected = cached.conn && cached.conn?._readyState !== 1;
if (!cached.promise || disconnected) {
const opts = {
useNewUrlParser: true,
useUnifiedTopology: true,
bufferCommands: false,
// useNewUrlParser: true,
// useUnifiedTopology: true,
// bufferMaxEntries: 0,
// useFindAndModify: true,
// useCreateIndex: true
Expand Down
1 change: 1 addition & 0 deletions api/models/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const tokenValues = Object.assign(
/* cohere doesn't have rates for the older command models,
so this was from https://artificialanalysis.ai/models/command-light/providers */
command: { prompt: 0.38, completion: 0.38 },
'gemini-2.0': { prompt: 0, completion: 0 }, // https://ai.google.dev/pricing
'gemini-1.5': { prompt: 7, completion: 21 }, // May 2nd, 2024 pricing
gemini: { prompt: 0.5, completion: 1.5 }, // May 2nd, 2024 pricing
},
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"cors": "^2.8.5",
"dedent": "^1.5.3",
"dotenv": "^16.0.3",
"express": "^4.21.1",
"express": "^4.21.2",
"express-mongo-sanitize": "^2.2.0",
"express-rate-limit": "^7.4.1",
"express-session": "^1.18.1",
Expand Down
3 changes: 2 additions & 1 deletion api/utils/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const googleModels = {
gemini: 30720, // -2048 from max
'gemini-pro-vision': 12288, // -4096 from max
'gemini-exp': 8000,
'gemini-1.5': 1048576, // -8192 from max
'gemini-2.0': 1048576,
'gemini-1.5': 1048576,
'text-bison-32k': 32758, // -10 from max
'chat-bison-32k': 32758, // -10 from max
'code-bison-32k': 32758, // -10 from max
Expand Down
4 changes: 2 additions & 2 deletions config/user-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const connect = require('./connect');
let users = await User.find({});
let userData = [];
for (const user of users) {
let conversationsCount = (await Conversation.count({ user: user._id })) ?? 0;
let messagesCount = (await Message.count({ user: user._id })) ?? 0;
let conversationsCount = (await Conversation.countDocuments({ user: user._id })) ?? 0;
let messagesCount = (await Message.countDocuments({ user: user._id })) ?? 0;

userData.push({
User: user.name,
Expand Down
52 changes: 16 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/data-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "librechat-data-provider",
"version": "0.7.58",
"version": "0.7.59",
"description": "data services for librechat apps",
"main": "dist/index.js",
"module": "dist/index.es.js",
Expand Down
1 change: 1 addition & 0 deletions packages/data-provider/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ export const visionModels = [
'llava-13b',
'gemini-pro-vision',
'claude-3',
'gemini-2.0',
'gemini-1.5',
'gemini-exp',
'moondream',
Expand Down

0 comments on commit c951b02

Please sign in to comment.