Skip to content

Commit

Permalink
fix: correctly detect blank str in model meta results
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Sep 15, 2023
1 parent 295e8df commit 60056c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions horde_sdk/ai_horde_worker/model_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def resolve_top_n_model_names(
"""
models_in_timeframe = response.get_timeframe(timeframe)

# Remove the `None` values from the dict
models_in_timeframe = {k: v for k, v in models_in_timeframe.items() if v is not None}
# Remove the blank or null values from the dict
models_in_timeframe = {k: v for k, v in models_in_timeframe.items() if k and v is not None}

# Sort by value (number of uses) ascending (highest first)
sorted_models = sorted(models_in_timeframe.items(), key=lambda x: x[1], reverse=True)
Expand All @@ -140,7 +140,7 @@ def resolve_top_n_model_names(
top_n_models = sorted_models[:number_of_top_models]

# Get just the model names as a list
return [model[0] for model in top_n_models if model]
return [model[0] for model in top_n_models]

@staticmethod
def resolve_bottom_n_model_names(
Expand All @@ -160,11 +160,14 @@ def resolve_bottom_n_model_names(
"""
models_in_timeframe = response.get_timeframe(timeframe)

# Remove the blank or null values from the dict
models_in_timeframe = {k: v for k, v in models_in_timeframe.items() if k and v is not None}

# Sort by value (number of uses) ascending (lowest first)
sorted_models = sorted(models_in_timeframe.items(), key=lambda x: x[1])

# Get the bottom n models
bottom_n_models = sorted_models[:number_of_bottom_models]

# Get just the model names as a list
return [model[0] for model in bottom_n_models if model]
return [model[0] for model in bottom_n_models]

0 comments on commit 60056c9

Please sign in to comment.