Skip to content

Commit 1f11200

Browse files
committed
chore: remove skipAuth repetition
1 parent b68982a commit 1f11200

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

packages/cli/src/cli/localizer/explicit.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,14 @@ export default function createExplicitLocalizer(
3434
);
3535
}
3636

37-
const skipAuth = provider.id === "ollama";
3837
try {
3938
const model = createProviderClient(provider.id as ProviderId, provider.model, {
4039
baseUrl: provider.baseUrl,
41-
skipAuth,
4240
});
4341
return createLocalizerFromModel({
4442
model,
4543
id: provider.id,
4644
prompt: provider.prompt,
47-
skipAuth,
4845
});
4946
} catch (error: unknown) {
5047
if (error instanceof ProviderKeyMissingError) {
@@ -80,7 +77,6 @@ function createLocalizerFromModel(params: {
8077
model: LanguageModel;
8178
id: NonNullable<I18nConfig["provider"]>["id"];
8279
prompt: string;
83-
skipAuth?: boolean;
8480
}): ILocalizer {
8581
const { model } = params;
8682

packages/cli/src/cli/processor/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ function getPureModelProvider(provider: I18nConfig["provider"]) {
7474
throw new Error(createUnsupportedProviderErrorMessage(provider?.id));
7575
}
7676

77-
const skipAuth = provider?.id === "ollama";
7877
try {
7978
return createProviderClient(provider!.id as ProviderId, provider!.model, {
8079
baseUrl: provider!.baseUrl,
81-
skipAuth,
8280
});
8381
} catch (error: unknown) {
8482
if (error instanceof ProviderKeyMissingError) {

packages/providers/src/factory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { LanguageModel } from "ai";
22
import { ProviderId } from "./constants";
33
import { resolveProviderApiKey } from "./keys";
4+
import { PROVIDER_METADATA } from "./metadata";
45
import { UnsupportedProviderError } from "./errors";
56
import { createOpenAI } from "@ai-sdk/openai";
67
import { createAnthropic } from "@ai-sdk/anthropic";
@@ -21,7 +22,8 @@ export function createProviderClient(
2122
modelId: string,
2223
options?: ClientOptions,
2324
): LanguageModel {
24-
const skipAuth = options?.skipAuth === true || providerId === "ollama";
25+
const skipAuth =
26+
options?.skipAuth === true || !PROVIDER_METADATA[providerId]?.apiKeyEnvVar;
2527
const apiKey = options?.apiKey ?? resolveProviderApiKey(providerId, { required: !skipAuth });
2628

2729
switch (providerId) {

0 commit comments

Comments
 (0)