Skip to content

Commit

Permalink
feat: adds active_generations key (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 authored Jul 7, 2024
1 parent 95bb4ab commit f15f608
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

# 4.30.0

* Adds the `active_generations` privileged key on user info providing a list of all non-expired gens the user has active.

# 4.39.1

* Added news about transparent images
Expand Down
25 changes: 25 additions & 0 deletions horde/apis/models/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,30 @@ def __init__(self, api):
},
)

self.response_model_user_active_generations = api.model(
"UserActiveGenerations",
{
"text": fields.List(
fields.String(
description="(Privileged) The list of active text generation IDs requested by this user.",
example="00000000-0000-0000-0000-000000000000",
),
),
"image": fields.List(
fields.String(
description="(Privileged) The list of active image generation IDs requested by this user.",
example="00000000-0000-0000-0000-000000000000",
),
),
"alchemy": fields.List(
fields.String(
description="(Privileged) The list of active alchemy generation IDs requested by this user.",
example="00000000-0000-0000-0000-000000000000",
),
),
},
)

self.response_model_user_details = api.model(
"UserDetails",
{
Expand Down Expand Up @@ -919,6 +943,7 @@ def __init__(self, api):
example="00000000-0000-0000-0000-000000000000",
),
),
"active_generations": fields.Nested(self.response_model_user_active_generations, skip_none=True),
"monthly_kudos": fields.Nested(self.response_model_monthly_kudos, skip_none=True),
"trusted": fields.Boolean(
example=False,
Expand Down
5 changes: 5 additions & 0 deletions horde/classes/base/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ def get_details(self, details_privilege=0):
for worker in self.workers:
workers_array.append(str(worker.id))
ret_dict["worker_ids"] = workers_array
ret_dict["active_generations"] = {}
for wp in self.waiting_prompts:
if wp.wp_type not in ret_dict["active_generations"]:
ret_dict["active_generations"][wp.wp_type] = []
ret_dict["active_generations"][wp.wp_type].append(str(wp.id))
if details_privilege >= 1:
sharedkeys_array = []
for sk in self.sharedkeys:
Expand Down
2 changes: 1 addition & 1 deletion horde/consts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HORDE_VERSION = "4.39.1"
HORDE_VERSION = "4.40.0"

WHITELISTED_SERVICE_IPS = {
"212.227.227.178", # Turing Bot
Expand Down

0 comments on commit f15f608

Please sign in to comment.