pi-provider-litellm 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,11 @@
1
+ import type { Api, Model } from "@earendil-works/pi-ai";
1
2
  import type { DiscoveredModel, DiscoveryOptions, DiscoveryResult } from "./types.js";
2
3
  export declare function normalizeBaseUrl(input: string): string;
3
4
  export declare function isMoonshotModel(modelId: string): boolean;
4
5
  export declare function isGpt55Model(modelId: string): boolean;
5
6
  export declare function shouldSuppressReasoningContent(modelId: string): boolean;
6
7
  export declare function buildCompat(modelId: string): DiscoveredModel["compat"];
8
+ export declare function enrichCachedModel(model: Model<Api>): Model<Api>;
7
9
  export declare function discoverModels(baseUrl: string, apiKey: string, options?: DiscoveryOptions & {
8
10
  onProgress?: (message: string) => void;
9
11
  silent?: boolean;
package/dist/discover.js CHANGED
@@ -77,6 +77,36 @@ function findCatalogModel(id, ownedBy) {
77
77
  }
78
78
  return undefined;
79
79
  }
80
+ export function enrichCachedModel(model) {
81
+ // ponytail: legacy cache lacks field provenance; add per-field cache provenance if strict preservation becomes necessary.
82
+ if (!model.name.endsWith(" (no metadata)") ||
83
+ model.reasoning ||
84
+ model.thinkingLevelMap !== undefined ||
85
+ model.input.length !== 1 ||
86
+ model.input[0] !== "text" ||
87
+ model.cost.input !== 0 ||
88
+ model.cost.output !== 0 ||
89
+ model.cost.cacheRead !== 0 ||
90
+ model.cost.cacheWrite !== 0 ||
91
+ model.cost.tiers !== undefined ||
92
+ model.contextWindow !== DEFAULT_CONTEXT_WINDOW ||
93
+ model.maxTokens !== DEFAULT_MAX_TOKENS) {
94
+ return model;
95
+ }
96
+ const catalogModel = findCatalogModel(model.id);
97
+ if (!catalogModel)
98
+ return model;
99
+ return {
100
+ ...model,
101
+ name: catalogModel.name,
102
+ reasoning: catalogModel.reasoning,
103
+ thinkingLevelMap: catalogModel.thinkingLevelMap,
104
+ input: catalogModel.input,
105
+ cost: catalogModel.cost,
106
+ contextWindow: catalogModel.contextWindow,
107
+ maxTokens: catalogModel.maxTokens,
108
+ };
109
+ }
80
110
  function catalogLookupIds(id) {
81
111
  const lookupIds = new Set([id]);
82
112
  const unprefixed = id.includes("/") ? id.slice(id.indexOf("/") + 1) : id;
package/dist/provider.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createProvider } from "@earendil-works/pi-ai";
2
2
  import { openAICompletionsApi, openAIResponsesApi } from "@earendil-works/pi-ai/compat";
3
+ import { enrichCachedModel } from "./discover.js";
3
4
  export function toNativeModels(provider, baseUrl, models) {
4
5
  return models.map((model) => ({
5
6
  ...model,
@@ -9,7 +10,7 @@ export function toNativeModels(provider, baseUrl, models) {
9
10
  }));
10
11
  }
11
12
  export function createLiteLLMProvider(options) {
12
- return createProvider({
13
+ const provider = createProvider({
13
14
  id: options.id,
14
15
  name: options.name,
15
16
  baseUrl: options.baseUrl,
@@ -26,4 +27,21 @@ export function createLiteLLMProvider(options) {
26
27
  "openai-responses": openAIResponsesApi(),
27
28
  },
28
29
  });
30
+ const refreshModels = provider.refreshModels;
31
+ if (!refreshModels)
32
+ return provider;
33
+ return {
34
+ ...provider,
35
+ refreshModels: (context) => refreshModels({
36
+ ...context,
37
+ store: {
38
+ async read() {
39
+ const entry = await context.store.read();
40
+ return entry && { ...entry, models: entry.models.map(enrichCachedModel) };
41
+ },
42
+ write: (entry) => context.store.write(entry),
43
+ delete: () => context.store.delete(),
44
+ },
45
+ }),
46
+ };
29
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-provider-litellm",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "LiteLLM proxy provider extension for Pi",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -58,10 +58,18 @@
58
58
  "@earendil-works/pi-ai": ">=0.81.0",
59
59
  "@earendil-works/pi-coding-agent": ">=0.81.0"
60
60
  },
61
+ "peerDependenciesMeta": {
62
+ "@earendil-works/pi-ai": {
63
+ "optional": true
64
+ },
65
+ "@earendil-works/pi-coding-agent": {
66
+ "optional": true
67
+ }
68
+ },
61
69
  "overrides": {
62
70
  "basic-ftp": "6.0.1",
63
- "fast-xml-builder": "1.2.0",
64
- "protobufjs": "8.7.1"
71
+ "protobufjs": "8.7.1",
72
+ "undici": "8.9.0"
65
73
  },
66
74
  "devDependencies": {
67
75
  "@biomejs/biome": "^2.4.15",