Update app.py
Browse files
app.py
CHANGED
|
@@ -413,6 +413,50 @@ PyPDF2>=3.0.0
|
|
| 413 |
markdown>=3.4.1
|
| 414 |
"""
|
| 415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
# Main application
|
| 417 |
def create_app():
|
| 418 |
with gr.Blocks(css="""
|
|
@@ -688,49 +732,7 @@ def create_app():
|
|
| 688 |
Built with ❤️ using Gradio and OpenRouter API | Context sizes shown next to model names
|
| 689 |
""")
|
| 690 |
|
| 691 |
-
# Helper function to filter models
|
| 692 |
-
def filter_models(search_term):
|
| 693 |
-
if not search_term:
|
| 694 |
-
return [model[0] for model in ALL_MODELS], ALL_MODELS[0][0]
|
| 695 |
-
|
| 696 |
-
filtered_models = [model[0] for model in ALL_MODELS if search_term.lower() in model[0].lower()]
|
| 697 |
-
|
| 698 |
-
if filtered_models:
|
| 699 |
-
return filtered_models, filtered_models[0]
|
| 700 |
-
else:
|
| 701 |
-
return [model[0] for model in ALL_MODELS], ALL_MODELS[0][0]
|
| 702 |
-
|
| 703 |
-
# Helper function for context display
|
| 704 |
-
def update_context_display(model_name):
|
| 705 |
-
for model in ALL_MODELS:
|
| 706 |
-
if model[0] == model_name:
|
| 707 |
-
_, _, context_size = model
|
| 708 |
-
context_formatted = f"{context_size:,}"
|
| 709 |
-
return f"{context_formatted} tokens"
|
| 710 |
-
return "Unknown"
|
| 711 |
-
|
| 712 |
-
# Helper function for model info display
|
| 713 |
-
def update_model_info(model_name):
|
| 714 |
-
for model in ALL_MODELS:
|
| 715 |
-
if model[0] == model_name:
|
| 716 |
-
name, model_id, context_size = model
|
| 717 |
-
return f"""
|
| 718 |
-
<div class="model-info">
|
| 719 |
-
<h3>{name}</h3>
|
| 720 |
-
<p><strong>Model ID:</strong> {model_id}</p>
|
| 721 |
-
<p><strong>Context Size:</strong> {context_size:,} tokens</p>
|
| 722 |
-
<p><strong>Provider:</strong> {model_id.split('/')[0]}</p>
|
| 723 |
-
</div>
|
| 724 |
-
"""
|
| 725 |
-
return "<p>Model information not available</p>"
|
| 726 |
|
| 727 |
-
# Helper function to update category models
|
| 728 |
-
def update_category_models(category):
|
| 729 |
-
for cat in MODELS:
|
| 730 |
-
if cat["category"] == category:
|
| 731 |
-
model_names = [model[0] for model in cat["models"]]
|
| 732 |
-
return model_names, model_names[0]
|
| 733 |
-
return [], ""
|
| 734 |
|
| 735 |
# Connect model search to dropdown filter
|
| 736 |
model_search.change(
|
|
|
|
| 413 |
markdown>=3.4.1
|
| 414 |
"""
|
| 415 |
|
| 416 |
+
# Helper function to filter models
|
| 417 |
+
def filter_models(search_term):
|
| 418 |
+
if not search_term:
|
| 419 |
+
return [model[0] for model in ALL_MODELS], ALL_MODELS[0][0]
|
| 420 |
+
|
| 421 |
+
filtered_models = [model[0] for model in ALL_MODELS if search_term.lower() in model[0].lower()]
|
| 422 |
+
|
| 423 |
+
if filtered_models:
|
| 424 |
+
return filtered_models, filtered_models[0]
|
| 425 |
+
else:
|
| 426 |
+
return [model[0] for model in ALL_MODELS], ALL_MODELS[0][0]
|
| 427 |
+
|
| 428 |
+
# Helper function for context display
|
| 429 |
+
def update_context_display(model_name):
|
| 430 |
+
for model in ALL_MODELS:
|
| 431 |
+
if model[0] == model_name:
|
| 432 |
+
_, _, context_size = model
|
| 433 |
+
context_formatted = f"{context_size:,}"
|
| 434 |
+
return f"{context_formatted} tokens"
|
| 435 |
+
return "Unknown"
|
| 436 |
+
|
| 437 |
+
# Helper function for model info display
|
| 438 |
+
def update_model_info(model_name):
|
| 439 |
+
for model in ALL_MODELS:
|
| 440 |
+
if model[0] == model_name:
|
| 441 |
+
name, model_id, context_size = model
|
| 442 |
+
return f"""
|
| 443 |
+
<div class="model-info">
|
| 444 |
+
<h3>{name}</h3>
|
| 445 |
+
<p><strong>Model ID:</strong> {model_id}</p>
|
| 446 |
+
<p><strong>Context Size:</strong> {context_size:,} tokens</p>
|
| 447 |
+
<p><strong>Provider:</strong> {model_id.split('/')[0]}</p>
|
| 448 |
+
</div>
|
| 449 |
+
"""
|
| 450 |
+
return "<p>Model information not available</p>"
|
| 451 |
+
|
| 452 |
+
# Helper function to update category models
|
| 453 |
+
def update_category_models(category):
|
| 454 |
+
for cat in MODELS:
|
| 455 |
+
if cat["category"] == category:
|
| 456 |
+
model_names = [model[0] for model in cat["models"]]
|
| 457 |
+
return model_names, model_names[0]
|
| 458 |
+
return [], ""
|
| 459 |
+
|
| 460 |
# Main application
|
| 461 |
def create_app():
|
| 462 |
with gr.Blocks(css="""
|
|
|
|
| 732 |
Built with ❤️ using Gradio and OpenRouter API | Context sizes shown next to model names
|
| 733 |
""")
|
| 734 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 735 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 736 |
|
| 737 |
# Connect model search to dropdown filter
|
| 738 |
model_search.change(
|