Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,7 +41,15 @@ def run_sql(sql):
|
|
| 41 |
|
| 42 |
# 3. AGENTIC LOGIC
|
| 43 |
def sql_agent(user_prompt):
|
| 44 |
-
model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
schema = get_schema()
|
| 46 |
|
| 47 |
# ATTEMPT 1
|
|
|
|
| 41 |
|
| 42 |
# 3. AGENTIC LOGIC
|
| 43 |
def sql_agent(user_prompt):
|
| 44 |
+
# Force the model to use the most stable string
|
| 45 |
+
# Try 'gemini-1.5-flash' first, but if it fails, 'gemini-pro' is the universal fallback
|
| 46 |
+
try:
|
| 47 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
| 48 |
+
# Test a small call to see if it's alive
|
| 49 |
+
model.generate_content("test")
|
| 50 |
+
except:
|
| 51 |
+
# Fallback to the older, most stable naming convention
|
| 52 |
+
model = genai.GenerativeModel('gemini-pro')
|
| 53 |
schema = get_schema()
|
| 54 |
|
| 55 |
# ATTEMPT 1
|