feat: Store API key locally in browser instead of build-time
- Add apiKeyService for localStorage-based API key management - Add ApiKeyModal component for entering/updating API key - Update geminiService to use dynamic API key - Remove .env.example as API key is now user-provided - Update to gemini-2.0-flash model The API key is now stored only in the user's browser localStorage, making the app more secure and easier to deploy. https://claude.ai/code/session_01DBAyjuKW8Qtzixc64qn9KP
This commit is contained in:
parent
1a758f9f8c
commit
b23daec6e5
5 changed files with 155 additions and 11 deletions
|
|
@ -1,8 +1,15 @@
|
|||
import { GoogleGenAI, Type, Schema } from "@google/genai";
|
||||
import { FileData, FormResponse } from "../types";
|
||||
import { PdfFieldInfo } from "./pdfService";
|
||||
import { getApiKey } from "./apiKeyService";
|
||||
|
||||
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY });
|
||||
const getAI = () => {
|
||||
const apiKey = getApiKey();
|
||||
if (!apiKey) {
|
||||
throw new Error("Kein API Key gesetzt. Bitte gib deinen Gemini API Key ein.");
|
||||
}
|
||||
return new GoogleGenAI({ apiKey });
|
||||
};
|
||||
|
||||
const responseSchema: Schema = {
|
||||
type: Type.OBJECT,
|
||||
|
|
@ -130,7 +137,8 @@ export const processDocuments = async (
|
|||
`;
|
||||
|
||||
try {
|
||||
const modelId = "gemini-3-flash-preview";
|
||||
const ai = getAI();
|
||||
const modelId = "gemini-2.0-flash";
|
||||
|
||||
const response = await ai.models.generateContent({
|
||||
model: modelId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue