Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix: 429 on gemini
Browse files Browse the repository at this point in the history
  • Loading branch information
MrlolDev committed Dec 16, 2023
1 parent 8767c1b commit c8475c1
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/models/text/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ import {
VertexAI,
} from "@google-cloud/vertexai";
import delay from "delay";
const vertexAI = new VertexAI({
project: process.env.GOOGLE_PROJECT_ID,
location: "us-central1",
});
const regions = [
"us-central1",
"northamerica-northeast1",
"us-east4",
"us-west1",
"us-west4",
/*
"europe-west4",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west9",*/
"asia-northeast1",
"asia-northeast3",
"asia-southeast1",
]


export default {
data: {
Expand Down Expand Up @@ -81,6 +94,11 @@ export default {
record: null,
id: id || randomUUID(),
};
const region = regions[Math.floor(Math.random() * regions.length)]
const vertexAI = new VertexAI({
project: process.env.GOOGLE_PROJECT_ID,
location: region,
});
// get message that is message.role == "system"
let message = messages.find((message) => message.role == "system");
messages = messages.map((message) => {
Expand Down Expand Up @@ -136,7 +154,7 @@ export default {
}),
};
let promptLength = 0;
await delay(250);
await delay(500);
generativeModel
.generateContentStream(request)
.then(async (streamingResp) => {
Expand Down

0 comments on commit c8475c1

Please sign in to comment.