fix(coreweave): drop blank project header overrides
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
COREWEAVE_PROJECT_HEADER,
|
||||
coreWeaveProjectHeaders,
|
||||
hasCoreWeaveProjectHeader,
|
||||
removeBlankCoreWeaveProjectHeaders,
|
||||
} from "@oh-my-pi/pi-catalog/wire/coreweave";
|
||||
import { parseGitHubCopilotApiKey } from "@oh-my-pi/pi-catalog/wire/github-copilot";
|
||||
import {
|
||||
@@ -160,6 +161,7 @@ function resolveSakanaRequestBaseUrl(): string | undefined {
|
||||
}
|
||||
|
||||
function applyCoreWeaveProjectHeader(headers: Record<string, string>): void {
|
||||
removeBlankCoreWeaveProjectHeaders(headers);
|
||||
if (hasCoreWeaveProjectHeader(headers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,9 +96,10 @@ describe("CoreWeave Serverless Inference project header", () => {
|
||||
});
|
||||
|
||||
expect(setup.headers["OpenAI-Project"]).toBe("team/project");
|
||||
expect(setup.headers["openai-project"]).toBeUndefined();
|
||||
});
|
||||
|
||||
test("sends OpenAI-Project on chat-completions requests", async () => {
|
||||
test("sends one OpenAI-Project header on chat-completions requests when a blank override is present", async () => {
|
||||
Bun.env.COREWEAVE_PROJECT = "team/project";
|
||||
const requestHeaders: Headers[] = [];
|
||||
const fetchMock: FetchImpl = vi.fn(async (_input: string | URL | Request, init?: RequestInit) => {
|
||||
@@ -109,6 +110,7 @@ describe("CoreWeave Serverless Inference project header", () => {
|
||||
await completeSimple(getBundledModel("coreweave", "zai-org/GLM-5.2"), context, {
|
||||
apiKey: "coreweave-key",
|
||||
fetch: fetchMock,
|
||||
headers: { "openai-project": " " },
|
||||
});
|
||||
|
||||
expect(requestHeaders[0]?.get("OpenAI-Project")).toBe("team/project");
|
||||
|
||||
@@ -40,3 +40,12 @@ export function hasCoreWeaveProjectHeader(headers: Record<string, string>): bool
|
||||
const normalized = COREWEAVE_PROJECT_HEADER.toLowerCase();
|
||||
return Object.entries(headers).some(([header, value]) => header.toLowerCase() === normalized && value.trim() !== "");
|
||||
}
|
||||
|
||||
export function removeBlankCoreWeaveProjectHeaders(headers: Record<string, string>): void {
|
||||
const normalized = COREWEAVE_PROJECT_HEADER.toLowerCase();
|
||||
for (const [header, value] of Object.entries(headers)) {
|
||||
if (header.toLowerCase() === normalized && value.trim() === "") {
|
||||
delete headers[header];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user