Spaces:
Running
Running
Fix: Move update_reasoning_visibility to module level - was accidentally defined inside load_model function
Browse files
app.py
CHANGED
|
@@ -284,33 +284,35 @@ def load_model(model_key: str = None) -> Tuple[Llama, str]:
|
|
| 284 |
raise
|
| 285 |
|
| 286 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
-
def update_reasoning_visibility(model_key):
|
| 289 |
-
"""Show or hide reasoning checkbox based on model capabilities."""
|
| 290 |
-
model = AVAILABLE_MODELS[model_key]
|
| 291 |
-
supports_toggle = model.get("supports_toggle", False)
|
| 292 |
-
return gr.update(visible=supports_toggle)
|
| 293 |
|
| 294 |
-
def download_summary_json(summary, thinking, model_key, language):
|
| 295 |
-
"""Generate JSON file with summary and metadata."""
|
| 296 |
-
import json
|
| 297 |
-
from datetime import datetime
|
| 298 |
-
|
| 299 |
-
data = {
|
| 300 |
-
"metadata": {
|
| 301 |
-
"generated_at": datetime.now().isoformat(),
|
| 302 |
-
"model": AVAILABLE_MODELS[model_key]["name"],
|
| 303 |
-
"model_id": model_key,
|
| 304 |
-
"language": language
|
| 305 |
-
},
|
| 306 |
-
"thinking_process": thinking,
|
| 307 |
-
"summary": summary
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
filename = f"summary_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 311 |
-
with open(filename, 'w', encoding='utf-8') as f:
|
| 312 |
-
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 313 |
-
return filename
|
| 314 |
def estimate_tokens(text: str) -> int:
|
| 315 |
"""
|
| 316 |
Estimate token count for mixed CJK/English text.
|
|
|
|
| 284 |
raise
|
| 285 |
|
| 286 |
|
| 287 |
+
def update_reasoning_visibility(model_key):
|
| 288 |
+
"""Show or hide reasoning checkbox based on model capabilities."""
|
| 289 |
+
model = AVAILABLE_MODELS[model_key]
|
| 290 |
+
supports_toggle = model.get("supports_toggle", False)
|
| 291 |
+
return gr.update(visible=supports_toggle)
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def download_summary_json(summary, thinking, model_key, language):
|
| 295 |
+
"""Generate JSON file with summary and metadata."""
|
| 296 |
+
import json
|
| 297 |
+
from datetime import datetime
|
| 298 |
+
|
| 299 |
+
data = {
|
| 300 |
+
"metadata": {
|
| 301 |
+
"generated_at": datetime.now().isoformat(),
|
| 302 |
+
"model": AVAILABLE_MODELS[model_key]["name"],
|
| 303 |
+
"model_id": model_key,
|
| 304 |
+
"language": language
|
| 305 |
+
},
|
| 306 |
+
"thinking_process": thinking,
|
| 307 |
+
"summary": summary
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
filename = f"summary_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 311 |
+
with open(filename, 'w', encoding='utf-8') as f:
|
| 312 |
+
json.dump(data, f, ensure_ascii=False, indent=2)
|
| 313 |
+
return filename
|
| 314 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
def estimate_tokens(text: str) -> int:
|
| 317 |
"""
|
| 318 |
Estimate token count for mixed CJK/English text.
|