pi-nvidia-nim 1.1.3 → 1.1.4
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/index.ts +8 -6
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -48,8 +48,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
48
48
|
// =============================================================================
|
|
49
49
|
|
|
50
50
|
const NVIDIA_NIM_BASE_URL = "https://integrate.api.nvidia.com/v1";
|
|
51
|
-
const
|
|
52
|
-
const NVIDIA_NIM_API_KEY_ENV = "$NVIDIA_NIM_API_KEY"; // $ prefix for pi's apiKey resolution
|
|
51
|
+
const NVIDIA_NIM_API_KEY_ENV = "NVIDIA_NIM_API_KEY";
|
|
53
52
|
const PROVIDER_NAME = "nvidia-nim";
|
|
54
53
|
|
|
55
54
|
// =============================================================================
|
|
@@ -532,6 +531,7 @@ interface NimModelEntry {
|
|
|
532
531
|
maxTokens: number;
|
|
533
532
|
cost: { input: number; output: number; cacheRead: number; cacheWrite: number };
|
|
534
533
|
compat?: Record<string, unknown>;
|
|
534
|
+
headers?: Record<string, string>;
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
function makeDisplayName(modelId: string): string {
|
|
@@ -551,6 +551,9 @@ function buildModelEntry(modelId: string): NimModelEntry | null {
|
|
|
551
551
|
const contextWindow = CONTEXT_WINDOWS[modelId] ?? 4096;
|
|
552
552
|
const maxTokens = MAX_TOKENS[modelId] ?? Math.min(2048, contextWindow);
|
|
553
553
|
|
|
554
|
+
// Get API key for Authorization header
|
|
555
|
+
const apiKey = process.env[NVIDIA_NIM_API_KEY_ENV];
|
|
556
|
+
|
|
554
557
|
const entry: NimModelEntry = {
|
|
555
558
|
id: modelId,
|
|
556
559
|
name: makeDisplayName(modelId),
|
|
@@ -559,6 +562,7 @@ function buildModelEntry(modelId: string): NimModelEntry | null {
|
|
|
559
562
|
contextWindow,
|
|
560
563
|
maxTokens,
|
|
561
564
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
565
|
+
headers: apiKey ? { Authorization: `Bearer ${apiKey}` } : undefined,
|
|
562
566
|
};
|
|
563
567
|
|
|
564
568
|
// Default compat for all NIM models:
|
|
@@ -632,17 +636,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
632
636
|
baseUrl: NVIDIA_NIM_BASE_URL,
|
|
633
637
|
apiKey: NVIDIA_NIM_API_KEY_ENV,
|
|
634
638
|
api: "openai-completions",
|
|
635
|
-
authHeader: true,
|
|
636
639
|
models: curatedModels,
|
|
637
640
|
streamSimple: nimStreamSimple,
|
|
638
641
|
});
|
|
639
642
|
|
|
640
643
|
// On session start, discover additional models from the API
|
|
641
644
|
pi.on("session_start", async (_event, ctx) => {
|
|
642
|
-
const apiKey = process.env[
|
|
645
|
+
const apiKey = process.env[NVIDIA_NIM_API_KEY_ENV];
|
|
643
646
|
if (!apiKey) {
|
|
644
647
|
ctx.ui.notify(
|
|
645
|
-
`NVIDIA NIM: Set ${
|
|
648
|
+
`NVIDIA NIM: Set ${NVIDIA_NIM_API_KEY_ENV} env var to enable models. Get a key at https://build.nvidia.com`,
|
|
646
649
|
"warning",
|
|
647
650
|
);
|
|
648
651
|
return;
|
|
@@ -672,7 +675,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
672
675
|
baseUrl: NVIDIA_NIM_BASE_URL,
|
|
673
676
|
apiKey: NVIDIA_NIM_API_KEY_ENV,
|
|
674
677
|
api: "openai-completions",
|
|
675
|
-
authHeader: true,
|
|
676
678
|
models: allModels,
|
|
677
679
|
streamSimple: nimStreamSimple,
|
|
678
680
|
});
|