Spaces:
Sleeping
Sleeping
Fix 404 by updating model name to gemma-3-taide-12b-chat
Browse filesThe API server hosts gemma-3-taide-12b-chat, not gemma-3-4b-it.
Also add better error logging for API failures.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -5,13 +5,15 @@ import gradio as gr
|
|
| 5 |
|
| 6 |
BASE_URL = os.environ["BASE_URL"]
|
| 7 |
API_KEY = os.environ["API_KEY"]
|
| 8 |
-
MODEL = "gemma-3-
|
| 9 |
|
| 10 |
# Startup connectivity test
|
| 11 |
print(f"Testing connection to {BASE_URL}...")
|
| 12 |
try:
|
| 13 |
r = requests.get(f"{BASE_URL}/models", headers={"Authorization": f"Bearer {API_KEY}"}, timeout=30)
|
| 14 |
print(f"Connection OK: {r.status_code}")
|
|
|
|
|
|
|
| 15 |
except Exception as e:
|
| 16 |
print(f"Connection FAILED: {e}")
|
| 17 |
|
|
@@ -27,7 +29,9 @@ def chat(message, history):
|
|
| 27 |
json={"model": MODEL, "messages": messages, "stream": True, "max_tokens": 1024, "temperature": 0.7},
|
| 28 |
stream=True, timeout=60,
|
| 29 |
)
|
| 30 |
-
resp.
|
|
|
|
|
|
|
| 31 |
|
| 32 |
partial = ""
|
| 33 |
for line in resp.iter_lines():
|
|
@@ -43,4 +47,4 @@ def chat(message, history):
|
|
| 43 |
partial += chunk["choices"][0]["delta"]["content"]
|
| 44 |
yield partial
|
| 45 |
|
| 46 |
-
gr.ChatInterface(chat, type="messages", title="Gemma-3-
|
|
|
|
| 5 |
|
| 6 |
BASE_URL = os.environ["BASE_URL"]
|
| 7 |
API_KEY = os.environ["API_KEY"]
|
| 8 |
+
MODEL = "gemma-3-taide-12b-chat"
|
| 9 |
|
| 10 |
# Startup connectivity test
|
| 11 |
print(f"Testing connection to {BASE_URL}...")
|
| 12 |
try:
|
| 13 |
r = requests.get(f"{BASE_URL}/models", headers={"Authorization": f"Bearer {API_KEY}"}, timeout=30)
|
| 14 |
print(f"Connection OK: {r.status_code}")
|
| 15 |
+
if r.status_code == 200:
|
| 16 |
+
print(f"Available models: {r.json()}")
|
| 17 |
except Exception as e:
|
| 18 |
print(f"Connection FAILED: {e}")
|
| 19 |
|
|
|
|
| 29 |
json={"model": MODEL, "messages": messages, "stream": True, "max_tokens": 1024, "temperature": 0.7},
|
| 30 |
stream=True, timeout=60,
|
| 31 |
)
|
| 32 |
+
if resp.status_code != 200:
|
| 33 |
+
print(f"API error {resp.status_code}: {resp.text}")
|
| 34 |
+
resp.raise_for_status()
|
| 35 |
|
| 36 |
partial = ""
|
| 37 |
for line in resp.iter_lines():
|
|
|
|
| 47 |
partial += chunk["choices"][0]["delta"]["content"]
|
| 48 |
yield partial
|
| 49 |
|
| 50 |
+
gr.ChatInterface(chat, type="messages", title="Gemma-3-TAIDE-12B-Chat (RTX 3090)").launch(ssr_mode=False)
|