pi-bob 0.2.4 → 0.2.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.
- package/extensions/bob.ts +9 -3
- package/package.json +1 -1
package/extensions/bob.ts
CHANGED
|
@@ -164,8 +164,13 @@ function configuredApiKey(): { envName: "IBM_BOB_API_KEY" | "IBM_BOB_KEY"; value
|
|
|
164
164
|
return alias ? { envName: "IBM_BOB_KEY", value: alias } : undefined;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function providerApiKeyReference(): string {
|
|
168
|
-
|
|
167
|
+
function providerApiKeyReference(): string | undefined {
|
|
168
|
+
const apiKey = configuredApiKey();
|
|
169
|
+
// Only advertise when resolvable at launch: an unresolvable $VAR reference makes
|
|
170
|
+
// pi's /model catalog refresh throw for a logged-out provider ("Could not refresh
|
|
171
|
+
// ibm-bob; showing cached models"). Process env is fixed after launch, so this
|
|
172
|
+
// loses nothing.
|
|
173
|
+
return apiKey ? `$${apiKey.envName}` : undefined;
|
|
169
174
|
}
|
|
170
175
|
|
|
171
176
|
function apiKeyAuthScheme(): string {
|
|
@@ -921,6 +926,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
921
926
|
const headers = buildHeaders(settings);
|
|
922
927
|
let catalog: BobDiscoveredModel[] | undefined;
|
|
923
928
|
const apiKey = configuredApiKey();
|
|
929
|
+
const apiKeyRef = providerApiKeyReference();
|
|
924
930
|
if (apiKey && envBool("IBM_BOB_DISCOVER_MODELS", true)) {
|
|
925
931
|
try {
|
|
926
932
|
catalog = await fetchBobModelCatalog(apiKey.value, apiKeyAuthScheme(), settings);
|
|
@@ -934,7 +940,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
934
940
|
pi.registerProvider(PROVIDER_ID, {
|
|
935
941
|
name: "IBM Bob",
|
|
936
942
|
baseUrl: providerRequestBaseUrl(api),
|
|
937
|
-
apiKey:
|
|
943
|
+
...(apiKeyRef ? { apiKey: apiKeyRef } : {}),
|
|
938
944
|
api: BOB_API,
|
|
939
945
|
...(headers ? { headers } : {}),
|
|
940
946
|
models: buildModels(api, catalog),
|