style: apply oxfmt to minimax provider and tests
This commit is contained in:
parent
e46931f300
commit
b9335e6b06
@ -4,10 +4,7 @@ import {
|
||||
DEFAULT_COPILOT_API_BASE_URL,
|
||||
resolveCopilotApiToken,
|
||||
} from "../providers/github-copilot-token.js";
|
||||
import {
|
||||
ensureAuthProfileStore,
|
||||
listProfilesForProvider,
|
||||
} from "./auth-profiles.js";
|
||||
import { ensureAuthProfileStore, listProfilesForProvider } from "./auth-profiles.js";
|
||||
import { resolveAwsSdkEnvVarName, resolveEnvApiKey } from "./model-auth.js";
|
||||
import { discoverBedrockModels } from "./bedrock-discovery.js";
|
||||
import {
|
||||
@ -114,8 +111,7 @@ async function discoverOllamaModels(): Promise<ModelDefinitionConfig[]> {
|
||||
return data.models.map((model) => {
|
||||
const modelId = model.name;
|
||||
const isReasoning =
|
||||
modelId.toLowerCase().includes("r1") ||
|
||||
modelId.toLowerCase().includes("reasoning");
|
||||
modelId.toLowerCase().includes("r1") || modelId.toLowerCase().includes("reasoning");
|
||||
return {
|
||||
id: modelId,
|
||||
name: modelId,
|
||||
@ -199,8 +195,7 @@ export function normalizeProviders(params: {
|
||||
// Fix common misconfig: apiKey set to "${ENV_VAR}" instead of "ENV_VAR".
|
||||
if (
|
||||
normalizedProvider.apiKey &&
|
||||
normalizeApiKeyConfig(normalizedProvider.apiKey) !==
|
||||
normalizedProvider.apiKey
|
||||
normalizeApiKeyConfig(normalizedProvider.apiKey) !== normalizedProvider.apiKey
|
||||
) {
|
||||
mutated = true;
|
||||
normalizedProvider = {
|
||||
@ -212,12 +207,10 @@ export function normalizeProviders(params: {
|
||||
// If a provider defines models, pi's ModelRegistry requires apiKey to be set.
|
||||
// Fill it from the environment or auth profiles when possible.
|
||||
const hasModels =
|
||||
Array.isArray(normalizedProvider.models) &&
|
||||
normalizedProvider.models.length > 0;
|
||||
Array.isArray(normalizedProvider.models) && normalizedProvider.models.length > 0;
|
||||
if (hasModels && !normalizedProvider.apiKey?.trim()) {
|
||||
const authMode =
|
||||
normalizedProvider.auth ??
|
||||
(normalizedKey === "amazon-bedrock" ? "aws-sdk" : undefined);
|
||||
normalizedProvider.auth ?? (normalizedKey === "amazon-bedrock" ? "aws-sdk" : undefined);
|
||||
if (authMode === "aws-sdk") {
|
||||
const apiKey = resolveAwsSdkApiKeyVarName();
|
||||
mutated = true;
|
||||
@ -439,8 +432,7 @@ export async function resolveImplicitCopilotProvider(params: {
|
||||
const authStore = ensureAuthProfileStore(params.agentDir, {
|
||||
allowKeychainPrompt: false,
|
||||
});
|
||||
const hasProfile =
|
||||
listProfilesForProvider(authStore, "github-copilot").length > 0;
|
||||
const hasProfile = listProfilesForProvider(authStore, "github-copilot").length > 0;
|
||||
const envToken = env.COPILOT_GITHUB_TOKEN ?? env.GH_TOKEN ?? env.GITHUB_TOKEN;
|
||||
const githubToken = (envToken ?? "").trim();
|
||||
|
||||
@ -503,11 +495,7 @@ export async function resolveImplicitBedrockProvider(params: {
|
||||
if (enabled === false) return null;
|
||||
if (enabled !== true && !hasAwsCreds) return null;
|
||||
|
||||
const region =
|
||||
discoveryConfig?.region ??
|
||||
env.AWS_REGION ??
|
||||
env.AWS_DEFAULT_REGION ??
|
||||
"us-east-1";
|
||||
const region = discoveryConfig?.region ?? env.AWS_REGION ?? env.AWS_DEFAULT_REGION ?? "us-east-1";
|
||||
const models = await discoverBedrockModels({
|
||||
region,
|
||||
config: discoveryConfig,
|
||||
|
||||
@ -74,9 +74,7 @@ describe("models-config", () => {
|
||||
agentDir,
|
||||
);
|
||||
|
||||
await expect(
|
||||
fs.stat(path.join(agentDir, "models.json")),
|
||||
).rejects.toThrow();
|
||||
await expect(fs.stat(path.join(agentDir, "models.json"))).rejects.toThrow();
|
||||
expect(result.wrote).toBe(false);
|
||||
} finally {
|
||||
if (previous === undefined) delete process.env.COPILOT_GITHUB_TOKEN;
|
||||
@ -91,8 +89,7 @@ describe("models-config", () => {
|
||||
else process.env.MINIMAX_API_KEY = previousMinimax;
|
||||
if (previousMoonshot === undefined) delete process.env.MOONSHOT_API_KEY;
|
||||
else process.env.MOONSHOT_API_KEY = previousMoonshot;
|
||||
if (previousSynthetic === undefined)
|
||||
delete process.env.SYNTHETIC_API_KEY;
|
||||
if (previousSynthetic === undefined) delete process.env.SYNTHETIC_API_KEY;
|
||||
else process.env.SYNTHETIC_API_KEY = previousSynthetic;
|
||||
if (previousVenice === undefined) delete process.env.VENICE_API_KEY;
|
||||
else process.env.VENICE_API_KEY = previousVenice;
|
||||
@ -113,9 +110,7 @@ describe("models-config", () => {
|
||||
providers: Record<string, { baseUrl?: string }>;
|
||||
};
|
||||
|
||||
expect(parsed.providers["custom-proxy"]?.baseUrl).toBe(
|
||||
"http://localhost:4000/v1",
|
||||
);
|
||||
expect(parsed.providers["custom-proxy"]?.baseUrl).toBe("http://localhost:4000/v1");
|
||||
});
|
||||
});
|
||||
it("adds minimax provider when MINIMAX_API_KEY is set", async () => {
|
||||
@ -141,9 +136,7 @@ describe("models-config", () => {
|
||||
}
|
||||
>;
|
||||
};
|
||||
expect(parsed.providers.minimax?.baseUrl).toBe(
|
||||
"https://api.minimax.io/v1",
|
||||
);
|
||||
expect(parsed.providers.minimax?.baseUrl).toBe("https://api.minimax.io/v1");
|
||||
expect(parsed.providers.minimax?.apiKey).toBe("MINIMAX_API_KEY");
|
||||
const ids = parsed.providers.minimax?.models?.map((model) => model.id);
|
||||
expect(ids).toContain("MiniMax-M2.1");
|
||||
@ -177,13 +170,9 @@ describe("models-config", () => {
|
||||
}
|
||||
>;
|
||||
};
|
||||
expect(parsed.providers.synthetic?.baseUrl).toBe(
|
||||
"https://api.synthetic.new/anthropic",
|
||||
);
|
||||
expect(parsed.providers.synthetic?.baseUrl).toBe("https://api.synthetic.new/anthropic");
|
||||
expect(parsed.providers.synthetic?.apiKey).toBe("SYNTHETIC_API_KEY");
|
||||
const ids = parsed.providers.synthetic?.models?.map(
|
||||
(model) => model.id,
|
||||
);
|
||||
const ids = parsed.providers.synthetic?.models?.map((model) => model.id);
|
||||
expect(ids).toContain("hf:MiniMaxAI/MiniMax-M2.1");
|
||||
} finally {
|
||||
if (prevKey === undefined) delete process.env.SYNTHETIC_API_KEY;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user