Skip to content

Commit 3dfc332

Browse files
committed
Expose API metadata and reuse in translators
1 parent 2b3daca commit 3dfc332

File tree

6 files changed

+36
-15
lines changed

6 files changed

+36
-15
lines changed

src/lib/services/integrations/ai/anthropic.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
const apiEndpoint = 'https://api.anthropic.com/v1/messages';
1111

12+
export const apiLabel = 'Anthropic API';
13+
export const developerURL = 'https://docs.claude.com/en/api/overview';
14+
export const apiKeyURL = 'https://platform.claude.com/settings/keys';
15+
export const apiKeyPattern = /sk-ant-api03-[a-zA-Z0-9-_]{80,}/;
16+
1217
/**
1318
* Send a message to the Anthropic Messages API and return the response text.
1419
* @param {AiCompletionOptions} options Options.

src/lib/services/integrations/ai/google.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
* @import { AiCompletionOptions } from '$lib/types/private';
88
*/
99

10+
export const apiLabel = 'Google AI Studio API';
11+
export const developerURL = 'https://ai.google.dev/gemini-api/docs';
12+
export const apiKeyURL = 'https://aistudio.google.com/api-keys';
13+
export const apiKeyPattern = /AIza[a-zA-Z0-9_-]{35}/;
14+
1015
/**
1116
* Send a message to the Google Gemini API and return the response text.
1217
* @param {AiCompletionOptions & { responseFormat?: string }} options Options. Pass

src/lib/services/integrations/ai/openai.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
const apiEndpoint = 'https://api.openai.com/v1/chat/completions';
1111

12+
export const apiLabel = 'OpenAI API';
13+
export const developerURL = 'https://platform.openai.com/docs/overview';
14+
export const apiKeyURL = 'https://platform.openai.com/api-keys';
15+
export const apiKeyPattern = /sk-[a-zA-Z0-9-_]{40,}/;
16+
1217
/**
1318
* Send a message to the OpenAI Chat Completions API and return the response text.
1419
* @param {AiCompletionOptions} options Options.

src/lib/services/integrations/translators/anthropic.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { complete } from '$lib/services/integrations/ai/anthropic';
1+
import {
2+
apiKeyPattern,
3+
apiKeyURL,
4+
apiLabel,
5+
complete,
6+
developerURL,
7+
} from '$lib/services/integrations/ai/anthropic';
28

39
import {
410
createTranslationSystemPrompt,
@@ -13,10 +19,6 @@ import {
1319

1420
const serviceId = 'anthropic';
1521
const serviceLabel = 'Anthropic Claude';
16-
const apiLabel = 'Anthropic API';
17-
const developerURL = 'https://docs.claude.com/en/api/overview';
18-
const apiKeyURL = 'https://platform.claude.com/settings/keys';
19-
const apiKeyPattern = /sk-ant-api03-[a-zA-Z0-9-_]{80,}/;
2022
const model = 'claude-haiku-4-5';
2123

2224
/**

src/lib/services/integrations/translators/google-ai.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { complete } from '$lib/services/integrations/ai/google';
1+
import {
2+
apiKeyPattern,
3+
apiKeyURL,
4+
apiLabel,
5+
complete,
6+
developerURL,
7+
} from '$lib/services/integrations/ai/google';
28

39
import {
410
createTranslationSystemPrompt,
@@ -13,10 +19,6 @@ import {
1319

1420
const serviceId = 'google-ai';
1521
const serviceLabel = 'Google Gemini';
16-
const apiLabel = 'Google AI Studio API';
17-
const developerURL = 'https://ai.google.dev/gemini-api/docs';
18-
const apiKeyURL = 'https://aistudio.google.com/api-keys';
19-
const apiKeyPattern = /AIza[a-zA-Z0-9_-]{35}/;
2022
const model = 'gemini-2.5-flash-lite';
2123

2224
/**

src/lib/services/integrations/translators/openai.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { complete } from '$lib/services/integrations/ai/openai';
1+
import {
2+
apiKeyPattern,
3+
apiKeyURL,
4+
apiLabel,
5+
complete,
6+
developerURL,
7+
} from '$lib/services/integrations/ai/openai';
28

39
import {
410
createTranslationSystemPrompt,
@@ -13,10 +19,6 @@ import {
1319

1420
const serviceId = 'openai';
1521
const serviceLabel = 'OpenAI GPT';
16-
const apiLabel = 'OpenAI API';
17-
const developerURL = 'https://platform.openai.com/docs/overview';
18-
const apiKeyURL = 'https://platform.openai.com/api-keys';
19-
const apiKeyPattern = /sk-[a-zA-Z0-9-_]{40,}/;
2022
const model = 'gpt-4o-mini';
2123

2224
/**

0 commit comments

Comments
 (0)