pi integration

This commit is contained in:
redshift
2026-08-24 20:07:04 +01:00
parent 836f50a27b
commit c25273cbb0
+17 -1
View File
@@ -8,6 +8,8 @@ import { callDaemon, getDaemonBaseUrl } from "../utils/daemon-client";
type PiModelEntry = {
id: string;
contextWindow?: number;
// Preserve arbitrary manual fields (reasoning, thinkingLevelMap, compat, cost, maxTokens, etc.)
[key: string]: unknown;
};
type PiProviderConfig = {
@@ -61,15 +63,29 @@ export async function installPiIntegration(
return;
}
// Preserve any manually-added per-model fields (reasoning, thinkingLevelMap,
// compat, cost, maxTokens, etc.) across refreshes. Only `id` and `contextWindow`
// are managed by routstrd.
const existingModels = new Map<string, PiModelEntry>(
(piConfig.providers["routstr"]?.models ?? []).map((m) => [m.id, m]),
);
const providerModels: PiModelEntry[] = models.map((model) => {
const entry: PiModelEntry = { id: model.id };
const previous = existingModels.get(model.id);
const entry: PiModelEntry = previous ? { ...previous } : { id: model.id };
entry.id = model.id;
if (model.context_length !== undefined && model.context_length > 0) {
entry.contextWindow = model.context_length;
}
return entry;
});
// Preserve provider-level manual fields (compat, headers, name, etc.); only update
// the routstrd-managed fields below.
piConfig.providers["routstr"] = {
...(piConfig.providers["routstr"] ?? {}),
baseUrl,
api: "openai-completions",
apiKey,