Spaces:
Sleeping
Sleeping
Anurag Prasad
commited on
Commit
·
f7527e8
1
Parent(s):
d65ad43
removed duplicates
Browse files
app.py
CHANGED
|
@@ -197,17 +197,6 @@ def save_model_to_db(model_name: str, system_prompt: str):
|
|
| 197 |
print(f"Error saving model: {e}")
|
| 198 |
return f"Error saving model: {e}"
|
| 199 |
|
| 200 |
-
def calculate_drift_via_mcp(model_name: str):
|
| 201 |
-
"""Calculate drift for model via MCP"""
|
| 202 |
-
try:
|
| 203 |
-
result = run_async(mcp_client.call_tool("calculate_drift", {"model_name": model_name}))
|
| 204 |
-
return result
|
| 205 |
-
except Exception as e:
|
| 206 |
-
print(f"Error calculating drift: {e}")
|
| 207 |
-
import random
|
| 208 |
-
drift_score = round(random.uniform(0.05, 0.25), 3)
|
| 209 |
-
return {"drift_score": drift_score, "message": f"Drift calculated and saved for {model_name}"}
|
| 210 |
-
|
| 211 |
def get_drift_history_from_db(model_name: str):
|
| 212 |
"""Get drift history from database via MCP"""
|
| 213 |
try:
|
|
@@ -277,10 +266,6 @@ def on_model_select(dropdown_value):
|
|
| 277 |
actual_model_name = extract_model_name_from_dropdown(dropdown_value, current_model_mapping)
|
| 278 |
return actual_model_name, actual_model_name
|
| 279 |
|
| 280 |
-
def toggle_create_new():
|
| 281 |
-
"""Toggle create new model section visibility"""
|
| 282 |
-
return gr.update(visible=True)
|
| 283 |
-
|
| 284 |
def cancel_create_new():
|
| 285 |
"""Cancel create new model"""
|
| 286 |
return [
|
|
@@ -375,9 +360,10 @@ def calculate_drift(dropdown_value):
|
|
| 375 |
return "\n".join(msg.text for msg in result)
|
| 376 |
except Exception as e:
|
| 377 |
print(f"Error calculating drift: {e}")
|
|
|
|
| 378 |
|
| 379 |
# Fallback to the simpler drift calculation if needed
|
| 380 |
-
result = calculate_drift_handler({"model_name": model_name})
|
| 381 |
return f"Drift Score: {result.get('drift_score', 0.0):.3f}\n{result.get('message', '')}"
|
| 382 |
|
| 383 |
def refresh_drift_history(dropdown_value):
|
|
|
|
| 197 |
print(f"Error saving model: {e}")
|
| 198 |
return f"Error saving model: {e}"
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
def get_drift_history_from_db(model_name: str):
|
| 201 |
"""Get drift history from database via MCP"""
|
| 202 |
try:
|
|
|
|
| 266 |
actual_model_name = extract_model_name_from_dropdown(dropdown_value, current_model_mapping)
|
| 267 |
return actual_model_name, actual_model_name
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
def cancel_create_new():
|
| 270 |
"""Cancel create new model"""
|
| 271 |
return [
|
|
|
|
| 360 |
return "\n".join(msg.text for msg in result)
|
| 361 |
except Exception as e:
|
| 362 |
print(f"Error calculating drift: {e}")
|
| 363 |
+
return f"Error calculating drift from server side: {e}"
|
| 364 |
|
| 365 |
# Fallback to the simpler drift calculation if needed
|
| 366 |
+
# result = calculate_drift_handler({"model_name": model_name})
|
| 367 |
return f"Drift Score: {result.get('drift_score', 0.0):.3f}\n{result.get('message', '')}"
|
| 368 |
|
| 369 |
def refresh_drift_history(dropdown_value):
|