feat: refine language controls and add per-tier ChatGPT Fast mode
This commit is contained in:
@@ -170,6 +170,41 @@ test("case-insensitive Authorization overrides including null are refused before
|
||||
assert.equal(requests.length, before);
|
||||
});
|
||||
|
||||
test("Fast opt-in pins priority on the actual OAuth request without altering reasoning or accepting caller tier overrides", async () => {
|
||||
for (const fastMode of [undefined, false, true]) {
|
||||
requests = []; responseEvents = [complete()];
|
||||
const engine = piEngineForSpec({ provider: "chatgpt", id: model.id, thinkingLevel: "high", fastMode }, false);
|
||||
const result = await engine.streamFn(engine.model, context(), {
|
||||
samplingParams: { service_tier: "flex" },
|
||||
onPayload: (raw) => ({ ...raw as object, service_tier: "default" }),
|
||||
}).result();
|
||||
assert.equal(result.stopReason, "stop"); assert.equal(requests.length, 1);
|
||||
assert.equal(requests[0]!.body.service_tier, fastMode ? "priority" : undefined);
|
||||
assert.equal(requests[0]!.body.reasoning.effort, "high");
|
||||
assert.equal(requests[0]!.authorization, "Bearer scratch-oauth-only");
|
||||
}
|
||||
});
|
||||
|
||||
test("the Fast preference never injects priority into an API-key provider request", async () => {
|
||||
requests = []; responseEvents = [complete()];
|
||||
const engine = piEngineForSpec({ provider: "openai", id: model.id, fastMode: true }, false);
|
||||
const result = await engine.streamFn(engine.model, context(), { apiKey: "sk-offline-api-key-fixture" }).result();
|
||||
assert.equal(result.stopReason, "stop"); assert.equal(requests.length, 1);
|
||||
assert.equal(requests[0]!.body.service_tier, undefined);
|
||||
assert.equal(requests[0]!.authorization, "Bearer sk-offline-api-key-fixture");
|
||||
});
|
||||
|
||||
test("an unsupported priority tier gives actionable feedback without retrying or using an API key", async () => {
|
||||
requests = [];
|
||||
responseEvents = [{ type: "error", code: "unsupported_parameter", param: "service_tier", message: "private provider diagnostic" }];
|
||||
const engine = piEngineForSpec({ provider: "chatgpt", id: model.id, fastMode: true }, false);
|
||||
const result = await engine.streamFn(engine.model, context()).result();
|
||||
assert.equal(result.stopReason, "error"); assert.equal(requests.length, 1);
|
||||
assert(result.errorMessage?.includes("Turn off Fast mode"));
|
||||
assert(!result.errorMessage?.includes("private provider diagnostic"));
|
||||
assert.equal(requests[0]!.authorization, "Bearer scratch-oauth-only");
|
||||
});
|
||||
|
||||
test("full credential-storage invalidation aborts foreground and background controllers and clears capabilities", () => {
|
||||
const foreground = chatGPTAbortController(false), background = chatGPTAbortController(true);
|
||||
ipc({ channel: "lh:chatgpt", kind: "state", stamp: { epoch: 2, authorityRevision: 2, revision: 3 }, status: { ...status, available: false }, invalidate: "all" });
|
||||
|
||||
Reference in New Issue
Block a user