wuhp commited on
Commit
cd8e82e
·
verified ·
1 Parent(s): 7482458

Update src/components/AIChat.tsx

Browse files
Files changed (1) hide show
  1. src/components/AIChat.tsx +2 -1
src/components/AIChat.tsx CHANGED
@@ -34,7 +34,8 @@ export function AIChat({
34
  const [keyInput, setKeyInput] = useState('');
35
 
36
  const ai = useMemo(() => {
37
- const key = geminiApiKey || process.env.GEMINI_API_KEY;
 
38
  if (!key) return null;
39
  return new GoogleGenAI({ apiKey: key });
40
  }, [geminiApiKey]);
 
34
  const [keyInput, setKeyInput] = useState('');
35
 
36
  const ai = useMemo(() => {
37
+ // Priority: 1. User provided key, 2. Vite environment variable
38
+ const key = geminiApiKey || (import.meta as any).env?.VITE_GEMINI_API_KEY;
39
  if (!key) return null;
40
  return new GoogleGenAI({ apiKey: key });
41
  }, [geminiApiKey]);