Skip to content

Commit

Permalink
fix: styles shouldn't override n
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Nov 7, 2024
1 parent aa57dd3 commit 0737c27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ SPDX-License-Identifier: AGPL-3.0-or-later

# Changelog

# 4.44.2

* Allow trusted users to also create styles
* Fix styles always returning 1 image

# 4.44.1

* Various fixes around styles
Expand Down
6 changes: 4 additions & 2 deletions horde/apis/v2/kobold.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def apply_style(self):
# We need to use defaultdict to avoid getting keyerrors in case the style author added
# Erroneous keys in the string
self.prompt = self.existing_style.prompt.format_map(defaultdict(str, p=self.args.prompt))
requested_n = self.params.get("n", 1)
self.params = self.existing_style.params
self.params["n"] = requested_n
self.nsfw = self.existing_style.nsfw
self.existing_style.use_count += 1
self.existing_style.user.record_style(2, "text")
Expand Down Expand Up @@ -541,9 +543,9 @@ def post(self):
self.user = database.find_user_by_api_key(self.args["apikey"])
if not self.user:
raise e.InvalidAPIKey("TextStyle POST")
if not self.user.customizer:
if not self.user.customizer and not self.user.trusted:
raise e.Forbidden(
"Only customizers can create new styles. You can request this role in our channels.",
"Only customizers and trusted users can create new styles. You can request the customizer role in our channels.",
rc="StylesRequiresCustomizer",
)
if self.user.is_anon():
Expand Down
6 changes: 4 additions & 2 deletions horde/apis/v2/stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ def apply_style(self):
# We need to use defaultdict to avoid getting keyerrors in case the style author added
# Erroneous keys in the string
self.prompt = self.existing_style.prompt.format_map(defaultdict(str, p=self.args.prompt, np=self.negprompt))
requested_n = self.params.get("n", 1)
self.params = self.existing_style.params
self.params["n"] = requested_n
self.nsfw = self.existing_style.nsfw
self.existing_style.use_count += 1
self.existing_style.user.record_style(2, "image")
Expand Down Expand Up @@ -1417,9 +1419,9 @@ def post(self):
self.user = database.find_user_by_api_key(self.args["apikey"])
if not self.user:
raise e.InvalidAPIKey("ImageStyle POST")
if not self.user.customizer:
if not self.user.customizer and not self.user.trusted:
raise e.Forbidden(
"Only customizers can create new styles. You can request this role in our channels.",
"Only customizers and trusted users can create new styles. You can request the customizer role in our channels.",
rc="StylesRequiresCustomizer",
)
if self.user.is_anon():
Expand Down
2 changes: 1 addition & 1 deletion horde/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: AGPL-3.0-or-later

HORDE_VERSION = "4.44.1"
HORDE_VERSION = "4.44.2"
HORDE_API_VERSION = "2.5"

WHITELISTED_SERVICE_IPS = {
Expand Down

0 comments on commit 0737c27

Please sign in to comment.