Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,8 +14,9 @@ def get_recent_models(min_likes, days_ago, filter_string, search_string):
|
|
14 |
# Initialize an empty list to store the filtered models
|
15 |
recent_models = []
|
16 |
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
# Use a generator to fetch models in batches, sorted by likes in descending order
|
21 |
for model in api.list_models(sort="likes", direction=-1):
|
@@ -23,9 +24,9 @@ def get_recent_models(min_likes, days_ago, filter_string, search_string):
|
|
23 |
if hasattr(model, "created_at") and model.created_at:
|
24 |
# Ensure created_at is offset-naive
|
25 |
created_at_date = model.created_at.replace(tzinfo=None)
|
26 |
-
if search_substrings
|
27 |
if any(term in model.modelId.lower() for term in search_substrings):
|
28 |
-
if filter_substrings
|
29 |
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
30 |
if created_at_date >= start_date:
|
31 |
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
@@ -45,7 +46,7 @@ def get_recent_models(min_likes, days_ago, filter_string, search_string):
|
|
45 |
"Task": task
|
46 |
})
|
47 |
else:
|
48 |
-
if filter_substrings
|
49 |
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
50 |
if created_at_date >= start_date:
|
51 |
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
|
|
14 |
# Initialize an empty list to store the filtered models
|
15 |
recent_models = []
|
16 |
|
17 |
+
# Split filter and search strings into lists of substrings
|
18 |
+
filter_substrings = filter_string.lower().split(';') if filter_string else []
|
19 |
+
search_substrings = search_string.lower().split(';') if search_string else []
|
20 |
|
21 |
# Use a generator to fetch models in batches, sorted by likes in descending order
|
22 |
for model in api.list_models(sort="likes", direction=-1):
|
|
|
24 |
if hasattr(model, "created_at") and model.created_at:
|
25 |
# Ensure created_at is offset-naive
|
26 |
created_at_date = model.created_at.replace(tzinfo=None)
|
27 |
+
if search_substrings:
|
28 |
if any(term in model.modelId.lower() for term in search_substrings):
|
29 |
+
if filter_substrings:
|
30 |
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
31 |
if created_at_date >= start_date:
|
32 |
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|
|
|
46 |
"Task": task
|
47 |
})
|
48 |
else:
|
49 |
+
if filter_substrings:
|
50 |
if not any(sub in model.modelId.lower() for sub in filter_substrings):
|
51 |
if created_at_date >= start_date:
|
52 |
task = model.pipeline_tag if hasattr(model, "pipeline_tag") else "N/A"
|