Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions config/gemini-pricing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"models": {
"gemini-1.5-flash-latest": {
"prompt": 0.0005,
"completion": 0.0015
},
"gemini-1.5-pro-latest": {
"prompt": 0.0025,
"completion": 0.0075
},
"gemini-pro": {
"prompt": 0.0005,
"completion": 0.0015
}
},
"fallback": {
"prompt": 0.0005,
"completion": 0.0015
}
}
14 changes: 12 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
},
"scripts": {
"translate": "./potomatic",
"translate:gemini": "./potomatic --provider gemini",
"ab-prompt-test": "node tools/ab-prompt-test",
"test": "vitest run",
"test:watch": "vitest",
Expand All @@ -45,6 +46,7 @@
"node": ">=18"
},
"dependencies": {
"@google/generative-ai": "^0.24.1",
"chalk": "^5.3.0",
"commander": "^12.0.0",
"dotenv": "^16.5.0",
Expand Down
3 changes: 2 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ export function parseCliArguments() {
.option('--locale-format <format>', 'Format to use for locale codes in file names: `wp_locale` (ru_RU), `iso_639_1` (ru), `iso_639_2` (rus), or `target_lang` (default)', DEFAULTS.LOCALE_FORMAT)

// === Translation Options ==.=
.option('-k, --api-key <key>', 'OpenAI API key (overrides API_KEY env var)')
.option('--provider <provider>', 'AI provider to use (e.g., "openai", "gemini")', DEFAULTS.PROVIDER)
.option('-k, --api-key <key>', 'Provider API key (overrides API_KEY env var)')
.option('-m, --model <model>', 'AI model name (e.g., "gpt-4o-mini")', DEFAULTS.MODEL)
.option('--temperature <number>', 'Creativity level (0.0-2.0); lower = more deterministic, higher = more creative', (val) => Math.max(0, Math.min(2, parseFloat(val))), DEFAULTS.TEMPERATURE)
.option('-F, --force-translate', 'Re-translate all strings, ignoring any existing translations', DEFAULTS.FORCE_TRANSLATE)
Expand Down
17 changes: 16 additions & 1 deletion src/providers/ProviderFactory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAIProvider } from './openai/OpenAIProvider.js';
import { GeminiProvider } from './gemini/GeminiProvider.js';

/**
* Creates and configures AI translation providers based on configuration.
Expand Down Expand Up @@ -26,6 +27,8 @@ export class ProviderFactory {
switch (providerName.toLowerCase()) {
case 'openai':
return new OpenAIProvider(config, logger);
case 'gemini':
return new GeminiProvider(config, logger);
default:
throw new Error(`Unsupported provider: ${providerName}. ` + `Supported providers: ${ProviderFactory.getSupportedProviders().join(', ')}`);
}
Expand All @@ -39,7 +42,7 @@ export class ProviderFactory {
* @return {Array<string>} Array of supported provider names.
*/
static getSupportedProviders() {
return ['openai'];
return ['openai', 'gemini'];
}

/**
Expand Down Expand Up @@ -76,6 +79,18 @@ export class ProviderFactory {
model: 'gpt-3.5-turbo',
},
},
{
name: 'gemini',
displayName: 'Google Gemini',
description: 'Google Gemini models',
status: 'implemented',
models: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Model names inconsistency across files

The models listed here (gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite) don't match the models in config/gemini-pricing.json (gemini-1.5-flash-latest, gemini-1.5-pro-latest, gemini-pro). This will cause issues when users try to use the models shown in provider info.

Please ensure consistency between:

  • The pricing configuration models
  • The provider info models
  • The actual supported models in GeminiProvider

Consider updating either the pricing config or this provider info to match.

🤖 Prompt for AI Agents
In src/providers/ProviderFactory.js at line 87, the model names listed are
inconsistent with those in config/gemini-pricing.json and the actual supported
models in GeminiProvider. To fix this, update the models array here to exactly
match the model names used in the pricing configuration and supported by
GeminiProvider, ensuring all three sources use the same model identifiers for
consistency.

configExample: {
provider: 'gemini',
apiKey: 'your-gemini-api-key',
model: 'gemini-2.5-flash',
},
},
];
}

Expand Down
Loading