Skip to content

Commit

Permalink
⚡ perf: Update gemini deployment restrictions (lobehub#3167)
Browse files Browse the repository at this point in the history
  • Loading branch information
RubuJam authored Jul 9, 2024
1 parent a5be879 commit 1f05959
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/app/api/chat/google/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ describe('Configuration tests', () => {
});

it('should contain specific regions in preferredRegion', () => {
expect(preferredRegion).not.contain(['hk1']);
expect(preferredRegion).not.contain(['hkg1']);
expect(preferredRegion).not.contain(['dub1']);
expect(preferredRegion).not.contain(['cdg1']);
expect(preferredRegion).not.contain(['fra1']);
expect(preferredRegion).not.contain(['lhr1']);
expect(preferredRegion).not.contain(['arn1']);
});
});

Expand Down
21 changes: 18 additions & 3 deletions src/app/api/chat/google/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ import { POST as UniverseRoute } from '../[provider]/route';
// so if you want to use with proxy, you need comment the code below
export const runtime = 'edge';

// due to Gemini-1.5-pro is not available in Hong Kong and Ireland, we need to set the preferred region to exclude "Hong Kong" or "Ireland".
// refs: https://github.com/lobehub/lobe-chat/pull/2149
export const preferredRegion = ['cle1', 'iad1', 'pdx1', 'sfo1'];
// due to Gemini-1.5-pro is not available in Hong Kong, we need to set the preferred region to exclude "Hong Kong (hkg1)".
// the paid service of the Gemini API is required in the following regions until 8 July 2024. The free service is not available. Therefore, the regions is temporarily disabled.
// regions include Dublin (dub1, Ireland), Paris (cdg1, France), Frankfurt (fra1, Germany), London (lhr1, UK), and Stockholm (arn1, Sweden).
// refs: https://ai.google.dev/gemini-api/docs/available-regions
export const preferredRegion = [
'icn1',
'sin1',
'hnd1',
'kix1',
'bom1',
'cpt1',
'pdx1',
'cle1',
'syd1',
'iad1',
'sfo1',
'gru1',
];

export const POST = async (req: Request) => UniverseRoute(req, { params: { provider: 'google' } });

0 comments on commit 1f05959

Please sign in to comment.