Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cline-models.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import {
getClinePromptCacheCompat,
type ClinePromptCacheCompat,
} from "./cline-cache.ts";
import type { OpenAICompletionsCompat } from "@earendil-works/pi-ai";
import { getClinePromptCacheCompat } from "./cline-cache.ts";

const API_BASE_URL = "https://api.cline.bot";
const MODELS_DEV_CACHE_TTL_MS = 3 * 60 * 60 * 1000;
Expand All @@ -29,7 +27,7 @@ export type PiModel = {
};
contextWindow: number;
maxTokens: number;
compat?: ClinePromptCacheCompat;
compat?: OpenAICompletionsCompat;
};

type ClineModelEntry = {
Expand Down Expand Up @@ -95,6 +93,10 @@ const CLINE_PASS_MODELS = ([
cost: { input: 0.9086, output: 2.8556, cacheRead: 0.16874, cacheWrite: 0 },
contextWindow: 1_048_576,
maxTokens: 131_072,
// The GLM upstream rejects the `developer` role (400: "developer is
// not one of ['system', 'assistant', 'user', 'tool', 'function']"),
// so the system prompt must be sent as a `system` message.
compat: { supportsDeveloperRole: false },
},
{
id: "cline-pass/kimi-k2.7-code",
Expand Down Expand Up @@ -180,8 +182,9 @@ const CLINE_PASS_MODELS = ([
] satisfies PiModel[]).map(withClinePromptCacheCompat);

function withClinePromptCacheCompat(model: PiModel): PiModel {
const compat = getClinePromptCacheCompat(model.id, model.cost);
return compat ? { ...model, compat } : model;
const cacheCompat = getClinePromptCacheCompat(model.id, model.cost);
if (!cacheCompat) return model;
return { ...model, compat: { ...model.compat, ...cacheCompat } };
}

function userCacheDir(): string {
Expand Down