fix: api-key manager cleanup and log error on llm call (#1077)
* fix: api-key manager cleanup and log error on llm call * log improved
This commit is contained in:
@@ -2,7 +2,6 @@ import React, { useState, useEffect, useCallback } from 'react';
|
||||
import { IconButton } from '~/components/ui/IconButton';
|
||||
import type { ProviderInfo } from '~/types/model';
|
||||
import Cookies from 'js-cookie';
|
||||
import { providerBaseUrlEnvKeys } from '~/utils/constants';
|
||||
|
||||
interface APIKeyManagerProps {
|
||||
provider: ProviderInfo;
|
||||
@@ -93,18 +92,16 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
||||
<span className="text-sm font-medium text-bolt-elements-textSecondary">{provider?.name} API Key:</span>
|
||||
{!isEditing && (
|
||||
<div className="flex items-center gap-2">
|
||||
{isEnvKeySet ? (
|
||||
<>
|
||||
<div className="i-ph:check-circle-fill text-green-500 w-4 h-4" />
|
||||
<span className="text-xs text-green-500">
|
||||
Set via {providerBaseUrlEnvKeys[provider.name].apiTokenKey} environment variable
|
||||
</span>
|
||||
</>
|
||||
) : apiKey ? (
|
||||
{apiKey ? (
|
||||
<>
|
||||
<div className="i-ph:check-circle-fill text-green-500 w-4 h-4" />
|
||||
<span className="text-xs text-green-500">Set via UI</span>
|
||||
</>
|
||||
) : isEnvKeySet ? (
|
||||
<>
|
||||
<div className="i-ph:check-circle-fill text-green-500 w-4 h-4" />
|
||||
<span className="text-xs text-green-500">Set via environment variable</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="i-ph:x-circle-fill text-red-500 w-4 h-4" />
|
||||
@@ -117,7 +114,7 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 shrink-0">
|
||||
{isEditing && !isEnvKeySet ? (
|
||||
{isEditing ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="password"
|
||||
@@ -145,7 +142,7 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{!isEnvKeySet && (
|
||||
{
|
||||
<IconButton
|
||||
onClick={() => setIsEditing(true)}
|
||||
title="Edit API Key"
|
||||
@@ -153,8 +150,8 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
||||
>
|
||||
<div className="i-ph:pencil-simple w-4 h-4" />
|
||||
</IconButton>
|
||||
)}
|
||||
{provider?.getApiKeyLink && !isEnvKeySet && (
|
||||
}
|
||||
{provider?.getApiKeyLink && !apiKey && (
|
||||
<IconButton
|
||||
onClick={() => window.open(provider?.getApiKeyLink)}
|
||||
title="Get API Key"
|
||||
|
||||
Reference in New Issue
Block a user