Refactor provider around fixed regions and friendly model ids
Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
This commit is contained in:
co-authored by
Simon Shi
parent
63c517002e
commit
9d88e995ee
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { getCachedModels, updateQoderModelsCache } from "../models.js";
|
||||
import { getCachedModelConfig, getCachedModels, updateQoderModelsCache } from "../catalog.js";
|
||||
import { loadLiveFixture, responseFromFixture } from "./live-fixture.js";
|
||||
|
||||
const CACHE_PATHS = {
|
||||
@@ -44,11 +44,37 @@ describe("Qoder model cache", () => {
|
||||
const catalog = interaction.response.body as { chat: Array<{ key: string; display_name: string }> };
|
||||
for (const entry of catalog.chat) {
|
||||
const friendlyId = entry.display_name.replace(/\s+/g, "");
|
||||
expect(cache.configs[entry.key]?.key).toBe(entry.key);
|
||||
expect(cache.configs[friendlyId]?.key).toBe(entry.key);
|
||||
expect(cache.configs[entry.key]).toBeUndefined();
|
||||
expect(getCachedModelConfig(friendlyId, region)?.key).toBe(entry.key);
|
||||
expect(getCachedModelConfig(entry.key, region)).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it("does not register raw live-catalog keys as public model ids", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({
|
||||
chat: [
|
||||
{ key: "lite", enable: true, display_name: "Lite" },
|
||||
{ key: "qfmodel", enable: true, display_name: "Qwen3.8-Flash" },
|
||||
],
|
||||
}),
|
||||
}),
|
||||
);
|
||||
|
||||
await updateQoderModelsCache("access-token", "user-id", "Test User", "test@example.com", "global");
|
||||
|
||||
expect(getCachedModels("global").map((model) => model.id)).toEqual(["Lite", "Qwen3.8-Flash"]);
|
||||
expect(getCachedModelConfig("Lite", "global")?.key).toBe("lite");
|
||||
expect(getCachedModelConfig("Qwen3.8-Flash", "global")?.key).toBe("qfmodel");
|
||||
expect(getCachedModelConfig("lite", "global")).toBeNull();
|
||||
expect(getCachedModelConfig("qfmodel", "global")).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps only enabled service models without adding auto as a fallback", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
@@ -99,7 +125,7 @@ describe("Qoder model cache", () => {
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(getCachedModels("global").map((model) => model.id)).toEqual(["ultimate"]);
|
||||
expect(getCachedModels("global").map((model) => model.id)).toEqual(["Ultimate"]);
|
||||
});
|
||||
|
||||
it("records a 1M context window when the catalog omits context_config", async () => {
|
||||
@@ -5,8 +5,9 @@ import {
|
||||
getCachedModelConfig,
|
||||
staticCnModels,
|
||||
staticModels,
|
||||
toQoderModelId,
|
||||
ZERO_COST,
|
||||
} from "../models.js";
|
||||
} from "../catalog.js";
|
||||
|
||||
// ── staticModels ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -56,10 +57,11 @@ describe("staticModels", () => {
|
||||
expect(staticModels.find((m) => m.upstreamKey === "kmodel")?.contextWindow).toBe(256000);
|
||||
});
|
||||
|
||||
it("maps friendly ids and legacy keys to the same static upstream key", () => {
|
||||
it("maps friendly ids to static upstream keys without raw-key aliases", () => {
|
||||
expect(getCachedModelConfig("Lite", "global")?.key).toBe("lite");
|
||||
expect(getCachedModelConfig("lite", "global")?.key).toBe("lite");
|
||||
expect(getCachedModelConfig("Qwen3.8-Max", "global")?.key).toBe("qmodel_preview");
|
||||
expect(getCachedModelConfig("lite", "global")).toBeNull();
|
||||
expect(getCachedModelConfig("qmodel_preview", "global")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,6 +98,13 @@ describe("staticCnModels", () => {
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
});
|
||||
|
||||
it("uses friendly IDs only in both static region catalogs", () => {
|
||||
for (const model of [...staticModels, ...staticCnModels]) {
|
||||
expect(model.id).toBe(toQoderModelId(model.name));
|
||||
expect(model.id).not.toBe(model.upstreamKey);
|
||||
}
|
||||
});
|
||||
|
||||
it("every CN model has a description", () => {
|
||||
for (const m of staticCnModels) {
|
||||
expect(m.description).toBeTruthy();
|
||||
@@ -135,6 +144,19 @@ describe("contextWindowFromCatalog", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("toQoderModelId", () => {
|
||||
it("strips whitespace from catalog display names", () => {
|
||||
expect(toQoderModelId("Qwen3.8-Flash")).toBe("Qwen3.8-Flash");
|
||||
expect(toQoderModelId("Qwen 3.8 Max")).toBe("Qwen3.8Max");
|
||||
expect(toQoderModelId("DeepSeek V4 Pro")).toBe("DeepSeekV4Pro");
|
||||
});
|
||||
|
||||
it("uses a stable fallback when the display name is absent", () => {
|
||||
expect(toQoderModelId()).toBe("QoderModel");
|
||||
expect(toQoderModelId("")).toBe("QoderModel");
|
||||
});
|
||||
});
|
||||
|
||||
// ── ZERO_COST ─────────────────────────────────────────────────────────────
|
||||
|
||||
describe("ZERO_COST", () => {
|
||||
+1
-180
@@ -1,184 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildAuthHeaders,
|
||||
getQoderBaseUrl,
|
||||
getQoderCenterUrl,
|
||||
getQoderChatURL,
|
||||
getQoderExchangeURL,
|
||||
getQoderManageUrl,
|
||||
getQoderMode,
|
||||
getQoderModelListURL,
|
||||
getQoderOpenApiUrl,
|
||||
getQoderRefreshURL,
|
||||
getQoderUsageURL,
|
||||
getQoderUserEmailFallback,
|
||||
getQoderUserInfoURL,
|
||||
isQoderCNMode,
|
||||
toQoderModelId,
|
||||
} from "../cosy.js";
|
||||
|
||||
// ── getQoderMode ──────────────────────────────────────────────────────────
|
||||
|
||||
describe("getQoderMode", () => {
|
||||
it('returns "cn" for explicit CN variants', () => {
|
||||
expect(getQoderMode("cn")).toBe("cn");
|
||||
expect(getQoderMode("china")).toBe("cn");
|
||||
expect(getQoderMode("qodercn")).toBe("cn");
|
||||
expect(getQoderMode("qoder-cn")).toBe("cn");
|
||||
expect(getQoderMode("CN")).toBe("cn");
|
||||
expect(getQoderMode("China")).toBe("cn");
|
||||
});
|
||||
|
||||
it('returns "global" for explicit global variants', () => {
|
||||
expect(getQoderMode("global")).toBe("global");
|
||||
expect(getQoderMode("intl")).toBe("global");
|
||||
expect(getQoderMode("international")).toBe("global");
|
||||
expect(getQoderMode("qoder")).toBe("global");
|
||||
});
|
||||
|
||||
it("falls back to global for unknown strings", () => {
|
||||
expect(getQoderMode("unknown")).toBe("global");
|
||||
expect(getQoderMode("")).toBe("global");
|
||||
});
|
||||
});
|
||||
|
||||
// ── isQoderCNMode ─────────────────────────────────────────────────────────
|
||||
|
||||
describe("isQoderCNMode", () => {
|
||||
it("returns true for CN modes", () => {
|
||||
expect(isQoderCNMode("cn")).toBe(true);
|
||||
expect(isQoderCNMode("china")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for global modes", () => {
|
||||
expect(isQoderCNMode("global")).toBe(false);
|
||||
expect(isQoderCNMode("intl")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
// ── URL builders ──────────────────────────────────────────────────────────
|
||||
|
||||
describe("getQoderBaseUrl", () => {
|
||||
it("returns CN URL for cn mode", () => {
|
||||
expect(getQoderBaseUrl("cn")).toBe("https://gateway.qoder.com.cn/");
|
||||
});
|
||||
|
||||
it("returns global URL for global mode", () => {
|
||||
expect(getQoderBaseUrl("global")).toBe("https://api3.qoder.sh/");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderOpenApiUrl", () => {
|
||||
it("returns CN URL for cn mode", () => {
|
||||
expect(getQoderOpenApiUrl("cn")).toBe("https://openapi.qoder.com.cn");
|
||||
});
|
||||
|
||||
it("returns global URL for global mode", () => {
|
||||
expect(getQoderOpenApiUrl("global")).toBe("https://openapi.qoder.sh");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderCenterUrl", () => {
|
||||
it("returns CN URL for cn mode", () => {
|
||||
expect(getQoderCenterUrl("cn")).toBe("https://gateway.qoder.com.cn");
|
||||
});
|
||||
|
||||
it("returns global URL for global mode", () => {
|
||||
expect(getQoderCenterUrl("global")).toBe("https://center.qoder.sh");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderModelListURL", () => {
|
||||
it("constructs correct CN URL", () => {
|
||||
expect(getQoderModelListURL("cn")).toBe("https://gateway.qoder.com.cn/algo/api/v2/model/list?Encode=1");
|
||||
});
|
||||
|
||||
it("constructs correct global URL", () => {
|
||||
expect(getQoderModelListURL("global")).toBe("https://api3.qoder.sh/algo/api/v2/model/list?Encode=1");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderChatURL", () => {
|
||||
it("contains base URL and chat path", () => {
|
||||
const url = getQoderChatURL("global");
|
||||
expect(url).toContain("https://api3.qoder.sh/");
|
||||
expect(url).toContain("algo/api/v2/service/pro/sse/agent_chat_generation");
|
||||
expect(url).toContain("Encode=1");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderExchangeURL", () => {
|
||||
it("constructs correct CN URL", () => {
|
||||
expect(getQoderExchangeURL("cn")).toBe("https://openapi.qoder.com.cn/api/v1/jobToken/exchange");
|
||||
});
|
||||
|
||||
it("constructs correct global URL", () => {
|
||||
expect(getQoderExchangeURL("global")).toBe("https://openapi.qoder.sh/api/v1/jobToken/exchange");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderUserInfoURL", () => {
|
||||
it("constructs correct URL", () => {
|
||||
expect(getQoderUserInfoURL("global")).toBe("https://openapi.qoder.sh/api/v1/userinfo");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderUsageURL", () => {
|
||||
it("constructs correct URL", () => {
|
||||
expect(getQoderUsageURL("global")).toBe("https://openapi.qoder.sh/api/v2/quota/usage");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderRefreshURL", () => {
|
||||
it("constructs correct CN URL", () => {
|
||||
expect(getQoderRefreshURL("cn")).toBe("https://gateway.qoder.com.cn/algo/api/v3/user/refresh_token");
|
||||
});
|
||||
|
||||
it("constructs correct global URL", () => {
|
||||
expect(getQoderRefreshURL("global")).toBe("https://center.qoder.sh/algo/api/v3/user/refresh_token");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderManageUrl", () => {
|
||||
it("returns CN URL", () => {
|
||||
expect(getQoderManageUrl("cn")).toBe("https://qoder.com.cn");
|
||||
});
|
||||
|
||||
it("returns global URL", () => {
|
||||
expect(getQoderManageUrl("global")).toBe("https://qoder.com");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getQoderUserEmailFallback", () => {
|
||||
it("returns CN email", () => {
|
||||
expect(getQoderUserEmailFallback("cn")).toBe("user@qoder.com.cn");
|
||||
});
|
||||
|
||||
it("returns global email", () => {
|
||||
expect(getQoderUserEmailFallback("global")).toBe("user@qoder.com");
|
||||
});
|
||||
});
|
||||
|
||||
// ── toQoderModelId ────────────────────────────────────────────────────────
|
||||
|
||||
describe("toQoderModelId", () => {
|
||||
it("strips whitespace from the upstream display_name", () => {
|
||||
// The display name is used directly as the pi-visible model id, with
|
||||
// whitespace removed so it stays a clean token for persistence keys and
|
||||
// search. "Qwen3.8-Flash" has no spaces already.
|
||||
expect(toQoderModelId("Qwen3.8-Flash")).toBe("Qwen3.8-Flash");
|
||||
});
|
||||
|
||||
it("collapses internal spaces", () => {
|
||||
expect(toQoderModelId("Qwen 3.8 Max")).toBe("Qwen3.8Max");
|
||||
expect(toQoderModelId("DeepSeek V4 Pro")).toBe("DeepSeekV4Pro");
|
||||
});
|
||||
|
||||
it("falls back to a default when no display name is given", () => {
|
||||
expect(toQoderModelId()).toBe("QoderModel");
|
||||
expect(toQoderModelId("")).toBe("QoderModel");
|
||||
});
|
||||
});
|
||||
import { buildAuthHeaders } from "../cosy.js";
|
||||
|
||||
describe("COSY client identity", () => {
|
||||
it("sends Cosy-Version and cosyVersion as current qodercli 1.1.38", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { qoderEncodeBody } from "../qoder-encoding.js";
|
||||
import { qoderEncodeBody } from "../protocol/encoding.js";
|
||||
|
||||
describe("qoderEncodeBody", () => {
|
||||
it("encodes a simple string", () => {
|
||||
@@ -2,14 +2,14 @@ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { updateQoderModelsCache } from "../models.js";
|
||||
import { autoLoginQoderFromEnvironment, getCachedCredentials, getQoderPatForMode } from "../oauth.js";
|
||||
import { credentialsFromPat } from "../pat.js";
|
||||
import { updateQoderModelsCache } from "../catalog.js";
|
||||
import { autoLoginQoderFromEnvironment, getCachedCredentials, getQoderPatForMode } from "../auth/oauth.js";
|
||||
import { credentialsFromPat } from "../auth/pat.js";
|
||||
import { loadLiveFixture } from "./live-fixture.js";
|
||||
|
||||
const AUTH_FILE = join(homedir(), ".pi", "agent", "auth.json");
|
||||
|
||||
vi.mock("../pat.js", () => ({
|
||||
vi.mock("../auth/pat.js", () => ({
|
||||
credentialsFromPat: vi.fn().mockResolvedValue({
|
||||
access: "mock-access-token",
|
||||
refresh: "mock-refresh-token",
|
||||
@@ -24,7 +24,7 @@ vi.mock("../pat.js", () => ({
|
||||
decodePatRefresh: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../models.js", () => ({
|
||||
vi.mock("../catalog.js", () => ({
|
||||
updateQoderModelsCache: vi.fn().mockResolvedValue(undefined),
|
||||
getCachedModels: vi.fn().mockReturnValue([]),
|
||||
isCacheStale: vi.fn().mockReturnValue(true),
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
fetchUserInfo,
|
||||
isPatRefresh,
|
||||
PAT_REFRESH_PREFIX,
|
||||
} from "../pat.js";
|
||||
} from "../auth/pat.js";
|
||||
import { loadLiveFixture, responseFromFixture } from "./live-fixture.js";
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { OAuthCredentials } from "@earendil-works/pi-ai";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const originalRegion = process.env.QODER_REGION;
|
||||
const patEnvNames = [
|
||||
"QODER_API_KEY",
|
||||
"QODER_PERSONAL_ACCESS_TOKEN",
|
||||
@@ -13,8 +12,6 @@ const patEnvNames = [
|
||||
const originalPats = Object.fromEntries(patEnvNames.map((name) => [name, process.env[name]]));
|
||||
|
||||
afterEach(() => {
|
||||
if (originalRegion === undefined) delete process.env.QODER_REGION;
|
||||
else process.env.QODER_REGION = originalRegion;
|
||||
for (const name of patEnvNames) {
|
||||
const value = originalPats[name];
|
||||
if (value === undefined) delete process.env[name];
|
||||
@@ -25,8 +22,7 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe("provider region binding", () => {
|
||||
it("keeps qoder global and qoder-cn in CN when QODER_REGION=cn", async () => {
|
||||
process.env.QODER_REGION = "cn";
|
||||
it("binds qoder to global and qoder-cn to CN", async () => {
|
||||
for (const name of patEnvNames) delete process.env[name];
|
||||
const providers = new Map<string, Record<string, unknown>>();
|
||||
const pi = {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
getQoderBaseUrl,
|
||||
getQoderChatURL,
|
||||
getQoderExchangeURL,
|
||||
getQoderModelListURL,
|
||||
getQoderRefreshURL,
|
||||
getQoderRegionConfig,
|
||||
getQoderUsageURL,
|
||||
getQoderUserInfoURL,
|
||||
QODER_MODES,
|
||||
} from "../region.js";
|
||||
|
||||
describe("Qoder regions", () => {
|
||||
it("defines only the fixed global and CN provider bindings", () => {
|
||||
expect(QODER_MODES).toEqual(["global", "cn"]);
|
||||
expect(getQoderRegionConfig("global").providerID).toBe("qoder");
|
||||
expect(getQoderRegionConfig("cn").providerID).toBe("qoder-cn");
|
||||
});
|
||||
|
||||
it("builds global endpoints", () => {
|
||||
expect(getQoderBaseUrl("global")).toBe("https://api3.qoder.sh/");
|
||||
expect(getQoderModelListURL("global")).toBe("https://api3.qoder.sh/algo/api/v2/model/list?Encode=1");
|
||||
expect(getQoderChatURL("global")).toContain("api3.qoder.sh/algo/api/v2/service/pro/sse/agent_chat_generation");
|
||||
expect(getQoderExchangeURL("global")).toBe("https://openapi.qoder.sh/api/v1/jobToken/exchange");
|
||||
expect(getQoderUserInfoURL("global")).toBe("https://openapi.qoder.sh/api/v1/userinfo");
|
||||
expect(getQoderUsageURL("global")).toBe("https://openapi.qoder.sh/api/v2/quota/usage");
|
||||
expect(getQoderRefreshURL("global")).toBe("https://center.qoder.sh/algo/api/v3/user/refresh_token");
|
||||
});
|
||||
|
||||
it("builds CN endpoints", () => {
|
||||
expect(getQoderBaseUrl("cn")).toBe("https://gateway.qoder.com.cn/");
|
||||
expect(getQoderModelListURL("cn")).toBe("https://gateway.qoder.com.cn/algo/api/v2/model/list?Encode=1");
|
||||
expect(getQoderChatURL("cn")).toContain("gateway.qoder.com.cn/algo/api/v2/service/pro/sse/agent_chat_generation");
|
||||
expect(getQoderExchangeURL("cn")).toBe("https://openapi.qoder.com.cn/api/v1/jobToken/exchange");
|
||||
expect(getQoderUserInfoURL("cn")).toBe("https://openapi.qoder.com.cn/api/v1/userinfo");
|
||||
expect(getQoderUsageURL("cn")).toBe("https://openapi.qoder.com.cn/api/v2/quota/usage");
|
||||
expect(getQoderRefreshURL("cn")).toBe("https://gateway.qoder.com.cn/algo/api/v3/user/refresh_token");
|
||||
});
|
||||
});
|
||||
@@ -8,13 +8,13 @@ import type {
|
||||
ToolCall,
|
||||
} from "@earendil-works/pi-ai";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { streamQoder } from "../stream.js";
|
||||
import { streamQoder } from "../protocol/stream.js";
|
||||
import { loadLiveFixture } from "./live-fixture.js";
|
||||
|
||||
// Pin the identity so the mocked fetch below only ever serves the chat request.
|
||||
// Without a resolved identity, streamQoder fetches /userinfo first and consumes
|
||||
// the mock response, leaving the chat read to fail on a locked stream.
|
||||
vi.mock("../oauth.js", () => ({
|
||||
vi.mock("../auth/oauth.js", () => ({
|
||||
resolveQoderIdentity: vi.fn().mockResolvedValue({
|
||||
access: "fake",
|
||||
userID: "test-user",
|
||||
@@ -93,8 +93,8 @@ function mockFetch(body: string): typeof fetch {
|
||||
return vi.fn(async () => response) as unknown as typeof fetch;
|
||||
}
|
||||
|
||||
function makeModel(provider = "qoder"): Model<Api> {
|
||||
return { id: "ultimate", api: "qoder-api" as Api, provider } as Model<Api>;
|
||||
function makeModel(provider = "qoder", id = "Lite"): Model<Api> {
|
||||
return { id, api: "qoder-api" as Api, provider } as Model<Api>;
|
||||
}
|
||||
|
||||
function makeContext(): Context {
|
||||
@@ -137,6 +137,32 @@ describe("streamQoder", () => {
|
||||
expect(text && "text" in text ? text.text : "").toBe("OK");
|
||||
});
|
||||
|
||||
it("sends the internal upstream key for a friendly model id", async () => {
|
||||
globalThis.fetch = mockFetch(SUCCESS_SSE);
|
||||
await consume(streamQoder(makeModel("qoder", "Lite"), makeContext(), { apiKey: "fake" }));
|
||||
|
||||
const init = vi.mocked(globalThis.fetch).mock.calls[0][1];
|
||||
expect(init?.headers).toEqual(expect.objectContaining({ "X-Model-Key": "lite" }));
|
||||
|
||||
const custom = "_doRTgHZBKcGVjlvpC,@aFSx#DPuNJme&i*MzLOEn)sUrthbf%Y^w.(kIQyXqWA!";
|
||||
const standard = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
const encoded = Buffer.from(init?.body as Uint8Array).toString("utf8");
|
||||
const rearranged = [...encoded]
|
||||
.map((character) => (character === "$" ? "=" : standard[custom.indexOf(character)] || character))
|
||||
.join("");
|
||||
const third = Math.floor(rearranged.length / 3);
|
||||
const base64 =
|
||||
rearranged.slice(rearranged.length - third) +
|
||||
rearranged.slice(third, rearranged.length - third) +
|
||||
rearranged.slice(0, third);
|
||||
const body = JSON.parse(Buffer.from(base64, "base64").toString("utf8")) as {
|
||||
chat_context: { extra: { modelConfig: { key: string } } };
|
||||
model_config: { key: string };
|
||||
};
|
||||
expect(body.chat_context.extra.modelConfig.key).toBe("lite");
|
||||
expect(body.model_config.key).toBe("lite");
|
||||
});
|
||||
|
||||
it("binds chat hosts to provider ids even when only a CN PAT is set", async () => {
|
||||
process.env.QODERCN_PERSONAL_ACCESS_TOKEN = "pt-cn-only";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Api, AssistantMessage, AssistantMessageEvent, AssistantMessageEventStream } from "@earendil-works/pi-ai";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { stripThinkingTags, ThinkingTagParser } from "../thinking-parser.js";
|
||||
import { stripThinkingTags, ThinkingTagParser } from "../protocol/thinking.js";
|
||||
|
||||
function createMockStream() {
|
||||
const events: AssistantMessageEvent[] = [];
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Message, Tool } from "@earendil-works/pi-ai";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getContentText, transformMessagesForQoder, transformTools } from "../transform.js";
|
||||
import { getContentText, transformMessagesForQoder, transformTools } from "../protocol/transform.js";
|
||||
|
||||
// ── getContentText ────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user