pi-free 2.0.7 → 2.0.9
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/CHANGELOG.md +96 -10
- package/README.md +572 -495
- package/config.ts +58 -11
- package/constants.ts +12 -0
- package/index.ts +67 -3
- package/lib/built-in-toggle.ts +2 -2
- package/lib/model-detection.ts +2 -1
- package/lib/model-enhancer.ts +1 -1
- package/lib/open-browser.ts +1 -1
- package/lib/provider-compat.ts +1 -1
- package/lib/quota-monitor.ts +123 -0
- package/lib/registry.ts +1 -1
- package/lib/types.ts +101 -101
- package/lib/util.ts +460 -351
- package/package.json +4 -4
- package/provider-failover/benchmark-lookup.ts +743 -702
- package/provider-failover/benchmarks-chunk-0.ts +48 -48
- package/provider-failover/benchmarks-chunk-1.ts +44 -44
- package/provider-failover/benchmarks-chunk-2.ts +39 -39
- package/provider-failover/benchmarks-chunk-3.ts +41 -41
- package/provider-failover/benchmarks-chunk-4.ts +33 -33
- package/provider-helper.ts +1 -1
- package/providers/cline/cline-auth.ts +473 -473
- package/providers/cline/cline-models.ts +2 -2
- package/providers/cline/cline.ts +3 -3
- package/providers/codestral/codestral.ts +139 -0
- package/providers/crofai/crofai.ts +14 -85
- package/providers/deepinfra/deepinfra.ts +109 -0
- package/providers/dynamic-built-in/index.ts +1 -1
- package/providers/kilo/kilo-auth.ts +155 -155
- package/providers/kilo/kilo.ts +3 -3
- package/providers/llm7/llm7.ts +156 -0
- package/providers/model-fetcher.ts +2 -2
- package/providers/nvidia/nvidia.ts +5 -5
- package/providers/ollama/ollama.ts +2 -2
- package/providers/opencode-session.ts +1 -1
- package/providers/qwen/qwen-auth.ts +1 -1
- package/providers/qwen/qwen-models.ts +1 -1
- package/providers/qwen/qwen.ts +3 -3
- package/providers/sambanova/sambanova.ts +109 -0
- package/providers/zenmux/zenmux.ts +6 -3
- package/scripts/check-extensions.mjs +6 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SambaNova Provider Extension
|
|
3
|
+
*
|
|
4
|
+
* SambaNova Cloud offers fast inference on custom RDU hardware with an
|
|
5
|
+
* OpenAI-compatible API. Known for running Llama 3.3 70B faster than
|
|
6
|
+
* competitors.
|
|
7
|
+
*
|
|
8
|
+
* Free tier (no credit card, no payment method):
|
|
9
|
+
* - Production models: 20-480 RPM, 400-9600 RPD
|
|
10
|
+
* - Preview models: 10-150 RPM, 200-3000 RPD
|
|
11
|
+
* - Forever free, no token pricing
|
|
12
|
+
*
|
|
13
|
+
* Developer tier (add payment method):
|
|
14
|
+
* - Higher rate limits, same models
|
|
15
|
+
*
|
|
16
|
+
* Endpoint:
|
|
17
|
+
* Chat: https://api.sambanova.ai/v1/chat/completions
|
|
18
|
+
*
|
|
19
|
+
* Setup:
|
|
20
|
+
* 1. Sign up at https://cloud.sambanova.ai/
|
|
21
|
+
* 2. Get API key from https://cloud.sambanova.ai/apis
|
|
22
|
+
* 3. Set SAMBANOVA_API_KEY env var (or add to ~/.pi/free.json)
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* pi install git:github.com/apmantza/pi-free
|
|
26
|
+
* # Set SAMBANOVA_API_KEY env var
|
|
27
|
+
* # Models appear in /model selector as "sambanova/Meta-Llama-3.3-70B-Instruct"
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
31
|
+
import { getSambanovaApiKey, getSambanovaShowPaid } from "../../config.ts";
|
|
32
|
+
import { BASE_URL_SAMBANOVA, PROVIDER_SAMBANOVA } from "../../constants.ts";
|
|
33
|
+
import { createLogger } from "../../lib/logger.ts";
|
|
34
|
+
import { registerWithGlobalToggle } from "../../lib/registry.ts";
|
|
35
|
+
import { fetchOpenAICompatibleModels } from "../../lib/util.ts";
|
|
36
|
+
import { createReRegister, setupProvider } from "../../provider-helper.ts";
|
|
37
|
+
|
|
38
|
+
const _logger = createLogger("sambanova");
|
|
39
|
+
|
|
40
|
+
// =============================================================================
|
|
41
|
+
// Extension Entry Point
|
|
42
|
+
// =============================================================================
|
|
43
|
+
|
|
44
|
+
export default async function sambanovaProvider(pi: ExtensionAPI) {
|
|
45
|
+
const apiKey = getSambanovaApiKey();
|
|
46
|
+
|
|
47
|
+
if (!apiKey) {
|
|
48
|
+
_logger.info(
|
|
49
|
+
"[sambanova] Skipping — SAMBANOVA_API_KEY not set. Sign up at https://cloud.sambanova.ai/",
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Fetch models via shared OpenAI-compatible helper
|
|
55
|
+
const allModels = await fetchOpenAICompatibleModels(
|
|
56
|
+
"sambanova",
|
|
57
|
+
BASE_URL_SAMBANOVA,
|
|
58
|
+
apiKey,
|
|
59
|
+
{ maxTokens: 8_192 },
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (allModels.length === 0) {
|
|
63
|
+
_logger.warn("[sambanova] No models available");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// All SambaNova models are free-tier (no payment method required).
|
|
68
|
+
// Rate limits are lower on free tier but all models are accessible.
|
|
69
|
+
const freeModels = allModels;
|
|
70
|
+
const stored = { free: freeModels, all: allModels };
|
|
71
|
+
|
|
72
|
+
_logger.info(
|
|
73
|
+
`[sambanova] Registered ${allModels.length} models (all free tier)`,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// Create re-register function
|
|
77
|
+
const reRegister = createReRegister(pi, {
|
|
78
|
+
providerId: PROVIDER_SAMBANOVA,
|
|
79
|
+
baseUrl: BASE_URL_SAMBANOVA,
|
|
80
|
+
apiKey,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Register with global toggle
|
|
84
|
+
registerWithGlobalToggle(PROVIDER_SAMBANOVA, stored, reRegister, true);
|
|
85
|
+
|
|
86
|
+
// Setup provider with toggle command
|
|
87
|
+
setupProvider(
|
|
88
|
+
pi,
|
|
89
|
+
{
|
|
90
|
+
providerId: PROVIDER_SAMBANOVA,
|
|
91
|
+
initialShowPaid: getSambanovaShowPaid(),
|
|
92
|
+
tosUrl: "https://sambanova.ai/terms",
|
|
93
|
+
reRegister: (models, _stored) => {
|
|
94
|
+
if (_stored) {
|
|
95
|
+
stored.free = _stored.free;
|
|
96
|
+
stored.all = _stored.all;
|
|
97
|
+
}
|
|
98
|
+
reRegister(models);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
stored,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
// Initial registration — respect persisted toggle state
|
|
105
|
+
const showPaid = getSambanovaShowPaid();
|
|
106
|
+
const initialModels =
|
|
107
|
+
showPaid && stored.all.length > 0 ? stored.all : freeModels;
|
|
108
|
+
reRegister(initialModels);
|
|
109
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import type {
|
|
20
20
|
ExtensionAPI,
|
|
21
21
|
ProviderModelConfig,
|
|
22
|
-
} from "@
|
|
22
|
+
} from "@earendil-works/pi-coding-agent";
|
|
23
23
|
import { getZenmuxApiKey, getZenmuxShowPaid } from "../../config.ts";
|
|
24
24
|
import {
|
|
25
25
|
BASE_URL_ZENMUX,
|
|
@@ -171,6 +171,9 @@ export default async function zenmuxProvider(pi: ExtensionAPI) {
|
|
|
171
171
|
stored,
|
|
172
172
|
);
|
|
173
173
|
|
|
174
|
-
// Initial registration
|
|
175
|
-
|
|
174
|
+
// Initial registration — respect persisted toggle state
|
|
175
|
+
const showPaid = getZenmuxShowPaid();
|
|
176
|
+
const initialModels =
|
|
177
|
+
showPaid && stored.all.length > 0 ? stored.all : freeModels;
|
|
178
|
+
reRegister(initialModels);
|
|
176
179
|
}
|
|
@@ -19,7 +19,9 @@ function resolveNpm() {
|
|
|
19
19
|
for (const p of [
|
|
20
20
|
"/usr/bin/npm",
|
|
21
21
|
"/usr/local/bin/npm",
|
|
22
|
-
process.platform === "win32"
|
|
22
|
+
process.platform === "win32"
|
|
23
|
+
? String.raw`C:\Program Files\nodejs\npm.cmd`
|
|
24
|
+
: "",
|
|
23
25
|
]) {
|
|
24
26
|
if (p && existsSync(p)) return p;
|
|
25
27
|
}
|
|
@@ -77,11 +79,11 @@ const seen = new Set();
|
|
|
77
79
|
|
|
78
80
|
for (const file of files) {
|
|
79
81
|
const src = readFileSync(file, "utf8");
|
|
80
|
-
const relFile = file.slice(installDir.length + 1).
|
|
82
|
+
const relFile = file.slice(installDir.length + 1).replaceAll("\\", "/");
|
|
81
83
|
// Strip comments before matching imports
|
|
82
84
|
const stripped = src
|
|
83
|
-
.
|
|
84
|
-
.
|
|
85
|
+
.replaceAll(/\/\/[^\n]*/g, "")
|
|
86
|
+
.replaceAll(/\/\*[\s\S]*?\*\//g, "");
|
|
85
87
|
const importRe = /from\s+['"](\.[^'"]+)['"]/g;
|
|
86
88
|
let match;
|
|
87
89
|
while ((match = importRe.exec(stripped)) !== null) {
|