Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,20 @@ from google.api_core import exceptions
|
|
| 19 |
# This specifically fixes the 'INVALID_ARGUMENT' error you received
|
| 20 |
|
| 21 |
# Initialize the client with explicit API version 'v1'
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
# --- Data Preparation ---
|
| 28 |
df_credit = pd.DataFrame({'ID': [1111, 2222, 3333, 4444, 5555], 'Credit_Score': [455, 685, 825, 840, 350]})
|
|
|
|
| 19 |
# This specifically fixes the 'INVALID_ARGUMENT' error you received
|
| 20 |
|
| 21 |
# Initialize the client with explicit API version 'v1'
|
| 22 |
+
import os
|
| 23 |
+
import time
|
| 24 |
+
import pandas as pd
|
| 25 |
+
import gradio as gr
|
| 26 |
+
from google import genai
|
| 27 |
+
from google.genai import types
|
| 28 |
+
from google.api_core import exceptions
|
| 29 |
+
|
| 30 |
+
# SECURE FIX: Use os.environ for Hugging Face Spaces
|
| 31 |
+
# The SDK will automatically use 'GOOGLE_API_KEY' if it exists in environment
|
| 32 |
+
client = genai.Client(api_key=os.environ.get('GOOGLE_API_KEY'))
|
| 33 |
+
|
| 34 |
+
# Use gemini-1.5-flash for the best free-tier stability
|
| 35 |
+
FREE_STABLE_MODEL = "gemini-flash-latest"
|
| 36 |
|
| 37 |
# --- Data Preparation ---
|
| 38 |
df_credit = pd.DataFrame({'ID': [1111, 2222, 3333, 4444, 5555], 'Credit_Score': [455, 685, 825, 840, 350]})
|