Skip to content

Commit

Permalink
Gemini Integrated Successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
aakash-a-dev committed Nov 21, 2024
1 parent c6d3ac8 commit 44ac9b0
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
"@changesets/cli": "^2.27.8",
"@srcbook/configs": "workspace:^",
"@types/node": "^20.14.2",
"eslint": "^8.57.0",
"prettier": "^3.3.3",
"typescript": "5.6.2",
"eslint": "^8.57.0"
"typescript": "5.6.2"
},
"dependencies": {
"@ai-sdk/google": "^1.0.1",
"turbo": "^2.1.1"
},
"packageManager": "[email protected]",
Expand Down
10 changes: 3 additions & 7 deletions packages/api/ai/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createAnthropic } from '@ai-sdk/anthropic';
import { getConfig } from '../config.mjs';
import type { LanguageModel } from 'ai';
import { getDefaultModel, type AiProviderType } from '@srcbook/shared';
import { createGoogleGenerativeAI } from '@ai-sdk/google';

/**
* Get the correct client and model configuration.
Expand Down Expand Up @@ -34,13 +35,8 @@ export async function getModel(): Promise<LanguageModel> {
if (!config.geminiKey) {
throw new Error('Gemini API key is not set');
}
const gemini = createOpenAI({
compatibility: 'compatible',
baseURL:
'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=',
apiKey: config.geminiKey,
});
return gemini(model);
const google = createGoogleGenerativeAI({apiKey: config.geminiKey})
return google(model);

case 'Xai':
if (!config.xaiKey) {
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@ai-sdk/anthropic": "catalog:",
"@ai-sdk/google": "^1.0.1",
"@ai-sdk/openai": "catalog:",
"@srcbook/shared": "workspace:^",
"ai": "^3.3.33",
Expand Down
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"prepublishOnly": "npm run build"
},
"dependencies": {
"@ai-sdk/google": "1.0.1",
"@scure/base": "^1.1.8",
"zod": "catalog:"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/ai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const defaultModels: Record<AiProviderType, string> = {
[AiProvider.Anthropic]: 'claude-3-5-sonnet-latest',
[AiProvider.Custom]: 'mistral-nemo',
[AiProvider.XAI]: 'grok-beta',
[AiProvider.Gemini]: 'google-developer-ai',
[AiProvider.Gemini]: 'gemini-1.5-pro-latest',
} as const;

export function isValidProvider(provider: string): provider is AiProviderType {
Expand Down
53 changes: 53 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 44ac9b0

Please sign in to comment.