Update web-app/src/lib/completion.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Louis 2025-10-08 20:59:36 +07:00 committed by GitHub
parent 38bdfd51ba
commit ce9c8fe1cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -187,9 +187,10 @@ export const sendCompletion = async (
if (!secretKey) { if (!secretKey) {
throw new Error('Encryption key unavailable: cannot decrypt API key.') throw new Error('Encryption key unavailable: cannot decrypt API key.')
} }
const apiKey = provider.api_key if (!provider.api_key) {
? decryptApiKey(provider.api_key, secretKey) throw new Error('API key is missing for the selected provider.');
: (secretKey ?? '') }
const apiKey = decryptApiKey(provider.api_key, secretKey);
const tokenJS = new TokenJS({ const tokenJS = new TokenJS({
apiKey, apiKey,