Upload 26 files
Browse files
app/components/chat/ApiKeyWarning.tsx
CHANGED
@@ -1,28 +1,23 @@
|
|
1 |
-
import React from 'react';
|
2 |
-
import type { ProviderInfo } from '~/types/model';
|
3 |
-
|
4 |
-
interface ApiKeyWarningProps {
|
5 |
-
provider: ProviderInfo;
|
6 |
-
apiKeys: Record<string, string>;
|
7 |
-
}
|
8 |
-
|
9 |
export const ApiKeyWarning: React.FC<ApiKeyWarningProps> = ({ provider, apiKeys }) => {
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
<div className="
|
17 |
-
<div className="flex
|
18 |
-
<div className="
|
19 |
-
|
20 |
-
|
21 |
-
<
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
</div>
|
25 |
</div>
|
26 |
-
|
27 |
-
|
28 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
export const ApiKeyWarning: React.FC<ApiKeyWarningProps> = ({ provider, apiKeys }) => {
|
2 |
+
// Add a null check for provider before accessing its name
|
3 |
+
const isApiKeyMissing = !provider || !apiKeys[provider.name];
|
4 |
+
|
5 |
+
if (!isApiKeyMissing) return null;
|
6 |
+
|
7 |
+
return (
|
8 |
+
<div className="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-4">
|
9 |
+
<div className="flex">
|
10 |
+
<div className="flex-shrink-0">
|
11 |
+
<div className="i-ph:warning-circle text-yellow-400 text-2xl" />
|
12 |
+
</div>
|
13 |
+
<div className="ml-3">
|
14 |
+
<p className="text-sm text-yellow-700">
|
15 |
+
{provider
|
16 |
+
? `API key is missing for ${provider.name}. Please add an API key in the settings to send messages.`
|
17 |
+
: 'No provider selected. Please select a provider and add an API key.'}
|
18 |
+
</p>
|
19 |
+
</div>
|
20 |
</div>
|
21 |
</div>
|
22 |
+
);
|
23 |
+
};
|
|