pi-provider-litellm 1.2.0 → 1.2.1
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.
- package/README.md +11 -13
- package/dist/cache.js +3 -2
- package/dist/discover.js +10 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-provider-litellm
|
|
2
2
|
|
|
3
|
-
LiteLLM proxy provider extension for [
|
|
3
|
+
LiteLLM proxy provider extension for [Pi](https://pi.dev).
|
|
4
4
|
|
|
5
5
|
Discovers models from a self-hosted LiteLLM proxy and registers them under the `litellm` provider. Supports `/login litellm` and `/litellm-refresh`. Tries `/model/info` first (admin endpoint with rich metadata), falls back to `/v1/models` (OpenAI-compatible) on 401/403/404.
|
|
6
6
|
|
|
@@ -32,14 +32,7 @@ npm run build
|
|
|
32
32
|
|
|
33
33
|
## Configure
|
|
34
34
|
|
|
35
|
-
### Option A —
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
export LITELLM_BASE_URL="https://litellm.your-domain.com"
|
|
39
|
-
export LITELLM_API_KEY="sk-..."
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Option B — interactive login
|
|
35
|
+
### Option A — interactive login
|
|
43
36
|
|
|
44
37
|
Inside pi:
|
|
45
38
|
|
|
@@ -49,16 +42,21 @@ Inside pi:
|
|
|
49
42
|
|
|
50
43
|
You'll be prompted for the base URL and API key. Credentials are persisted to `~/.pi/agent/auth.json`.
|
|
51
44
|
|
|
45
|
+
### Option B — environment variables
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export LITELLM_BASE_URL="https://litellm.your-domain.com"
|
|
49
|
+
export LITELLM_API_KEY="sk-..."
|
|
50
|
+
```
|
|
51
|
+
|
|
52
52
|
Stored pi credentials for `litellm` take precedence over `LITELLM_API_KEY`; the environment key is used when no saved credential exists. `LITELLM_BASE_URL` is used when no saved login base URL exists.
|
|
53
53
|
|
|
54
54
|
## Use
|
|
55
55
|
|
|
56
56
|
```
|
|
57
|
-
/model
|
|
57
|
+
/model
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
(Whatever model IDs your proxy exposes — see the discovered list at startup.)
|
|
61
|
-
|
|
62
60
|
## Optional environment variables
|
|
63
61
|
|
|
64
62
|
| Variable | Default | Effect |
|
|
@@ -74,7 +72,7 @@ Stored pi credentials for `litellm` take precedence over `LITELLM_API_KEY`; the
|
|
|
74
72
|
|
|
75
73
|
## Cache
|
|
76
74
|
|
|
77
|
-
The model list is cached at `~/.pi/agent/litellm-models.json` with a
|
|
75
|
+
The model list is cached at `~/.pi/agent/litellm-models.json` with a keyed fingerprint of the base URL + API key. Changing either invalidates the cache automatically.
|
|
78
76
|
|
|
79
77
|
## Troubleshooting
|
|
80
78
|
|
package/dist/cache.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { scryptSync } from "node:crypto";
|
|
2
2
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
3
3
|
import { dirname } from "node:path";
|
|
4
|
+
const FINGERPRINT_SALT = "pi-provider-litellm-cache-fingerprint-v1";
|
|
4
5
|
export function fingerprint(apiKey) {
|
|
5
|
-
return
|
|
6
|
+
return scryptSync(apiKey, FINGERPRINT_SALT, 32).toString("hex");
|
|
6
7
|
}
|
|
7
8
|
export function isCacheValid(cache, baseUrl, apiKey) {
|
|
8
9
|
if (!cache)
|
package/dist/discover.js
CHANGED
|
@@ -10,7 +10,17 @@ export function normalizeBaseUrl(input) {
|
|
|
10
10
|
// `cacheControlFormat: "anthropic"` flag, pi never relays cache_control markers
|
|
11
11
|
// through the proxy, so prompt caching silently no-ops on Claude models.
|
|
12
12
|
const ANTHROPIC_MODEL_PATTERN = /^(anthropic\/|claude|opus|sonnet|haiku)/i;
|
|
13
|
+
const MOONSHOT_MODEL_PATTERN = /^(moonshotai\/|moonshot\/|kimi[-/])/i;
|
|
13
14
|
export function buildCompat(modelId) {
|
|
15
|
+
if (MOONSHOT_MODEL_PATTERN.test(modelId)) {
|
|
16
|
+
return {
|
|
17
|
+
supportsStore: false,
|
|
18
|
+
supportsDeveloperRole: false,
|
|
19
|
+
supportsReasoningEffort: false,
|
|
20
|
+
supportsStrictMode: false,
|
|
21
|
+
maxTokensField: "max_tokens",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
14
24
|
if (ANTHROPIC_MODEL_PATTERN.test(modelId)) {
|
|
15
25
|
return { supportsStore: false, cacheControlFormat: "anthropic" };
|
|
16
26
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-provider-litellm",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "LiteLLM proxy provider extension for
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"description": "LiteLLM proxy provider extension for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Dávid Balatoni <balcsida@gmail.com>",
|
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
"@earendil-works/pi-ai": "^0.74.0",
|
|
58
58
|
"@earendil-works/pi-coding-agent": "^0.74.0"
|
|
59
59
|
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"basic-ftp": "6.0.1",
|
|
62
|
+
"fast-xml-builder": "1.2.0",
|
|
63
|
+
"protobufjs": "8.2.1"
|
|
64
|
+
},
|
|
60
65
|
"devDependencies": {
|
|
61
66
|
"@earendil-works/pi-ai": "^0.74.0",
|
|
62
67
|
"@earendil-works/pi-coding-agent": "^0.74.0",
|