Skip to content

Commit b4ccc24

Browse files
committed
llm-lib.html demo reuses existing localStorage keys
https://gistpreview.github.io/?f88ffd3a551f42421494a78b98c5e41a
1 parent 993aa7a commit b4ccc24

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

llm-lib.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@ <h2>Usage</h2>
353353
}
354354
}
355355

356+
// Standard localStorage keys (shared with other tools)
357+
const providerStorageKeys = {
358+
openai: 'openai_api_key',
359+
anthropic: 'ANTHROPIC_API_KEY',
360+
gemini: 'GEMINI_API_KEY'
361+
};
362+
356363
// Update model dropdown when provider changes
357364
providerSelect.addEventListener('change', () => {
358365
const provider = providerSelect.value;
@@ -367,7 +374,7 @@ <h2>Usage</h2>
367374
}
368375

369376
// Load saved API key for this provider
370-
const savedKey = localStorage.getItem(`llm-lib-${provider}-key`);
377+
const savedKey = localStorage.getItem(providerStorageKeys[provider]);
371378
apiKeyInput.value = savedKey || '';
372379
});
373380

@@ -378,7 +385,7 @@ <h2>Usage</h2>
378385
if (provider && provider !== providerSelect.value) {
379386
providerSelect.value = provider;
380387
// Load saved API key for new provider
381-
const savedKey = localStorage.getItem(`llm-lib-${provider}-key`);
388+
const savedKey = localStorage.getItem(providerStorageKeys[provider]);
382389
apiKeyInput.value = savedKey || '';
383390
}
384391
});
@@ -387,12 +394,12 @@ <h2>Usage</h2>
387394
apiKeyInput.addEventListener('change', () => {
388395
const provider = providerSelect.value;
389396
if (apiKeyInput.value) {
390-
localStorage.setItem(`llm-lib-${provider}-key`, apiKeyInput.value);
397+
localStorage.setItem(providerStorageKeys[provider], apiKeyInput.value);
391398
}
392399
});
393400

394401
// Load initial API key
395-
const initialKey = localStorage.getItem(`llm-lib-${providerSelect.value}-key`);
402+
const initialKey = localStorage.getItem(providerStorageKeys[providerSelect.value]);
396403
if (initialKey) apiKeyInput.value = initialKey;
397404

398405
function setStatus(state, text) {

0 commit comments

Comments
 (0)