mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-09 15:59:30 +00:00
fix(openai): keep missing-auth hint on default model (#100579)
This commit is contained in:
parent
bfdd60bd30
commit
cecb6cf600
2 changed files with 33 additions and 1 deletions
32
extensions/openai/openai-provider-missing-auth.test.ts
Normal file
32
extensions/openai/openai-provider-missing-auth.test.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const FUTURE_DEFAULT_MODEL = "openai/gpt-next-default";
|
||||
|
||||
describe("OpenAI missing auth message", () => {
|
||||
afterEach(() => {
|
||||
vi.doUnmock("./default-models.js");
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("uses the shared OpenAI default model in the ChatGPT/Codex OAuth hint", async () => {
|
||||
vi.resetModules();
|
||||
vi.doMock("./default-models.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./default-models.js")>();
|
||||
return {
|
||||
...actual,
|
||||
OPENAI_DEFAULT_MODEL: FUTURE_DEFAULT_MODEL,
|
||||
OPENAI_CODEX_DEFAULT_MODEL: FUTURE_DEFAULT_MODEL,
|
||||
};
|
||||
});
|
||||
|
||||
const { buildOpenAIProvider } = await import("./openai-provider.js");
|
||||
const provider = buildOpenAIProvider();
|
||||
|
||||
const message = provider.buildMissingAuthMessage?.({
|
||||
provider: "openai",
|
||||
listProfileIds: (providerId: string) => (providerId === "openai" ? ["openai:codex"] : []),
|
||||
} as never);
|
||||
|
||||
expect(message).toContain(`Use ${FUTURE_DEFAULT_MODEL} with the ChatGPT/Codex OAuth profile`);
|
||||
});
|
||||
});
|
||||
|
|
@ -871,7 +871,7 @@ export function buildOpenAIProvider(): ProviderPlugin {
|
|||
if (ctx.listProfileIds(PROVIDER_ID).length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return 'No API key found for provider "openai". You are authenticated with OpenAI ChatGPT/Codex OAuth. Use openai/gpt-5.5 with the ChatGPT/Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API access.';
|
||||
return `No API key found for provider "openai". You are authenticated with OpenAI ChatGPT/Codex OAuth. Use ${OPENAI_DEFAULT_MODEL} with the ChatGPT/Codex OAuth profile, or set OPENAI_API_KEY for direct OpenAI API access.`;
|
||||
},
|
||||
matchesContextOverflowError: ({ errorMessage }) =>
|
||||
/content_filter.*(?:prompt|input).*(?:too long|exceed)/i.test(errorMessage),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue