Skip to content

Commit

Permalink
Merge pull request #387 from Haidra-Org/mr
Browse files Browse the repository at this point in the history
fix: Show shared key names
  • Loading branch information
db0 authored Mar 9, 2024
2 parents 2260bd0 + b7d1776 commit 56edbe4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .env_template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ HORDE_LOGO="https://raw.githubusercontent.com/db0/Stable-Horde/main/img_stable/0
HORDE_HTML_TERMS="terms_of_service.html"
HORDE_HTML_PRIVACY="privacy_policy.html"
HORDE_MARKDOWN_INDEX="index_stable.md"
HORDE_IMAGE_COMPVIS_REFERENCE="https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/stable_diffusion.json"
HORDE_IMAGE_DIFFUSERS_REFERENCE="https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/diffusers.json"
HORDE_IMAGE_LLM_REFERENCE="https://raw.githubusercontent.com/db0/AI-Horde-text-model-reference/main/db.json"
# Google Oauth2
GOOGLE_CLIENT_ID=""
GLOOGLE_CLIENT_SECRET=""
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

# 4.32.3

* Shared Keys details now include their name
* Allow customizing horde model reference locations

# 4.32.2

* Adds support for customizing the Horde (name/icons/frontpage etc)
Expand Down
6 changes: 3 additions & 3 deletions horde/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
def after_request(response):
response.headers["Access-Control-Allow-Origin"] = "*"
response.headers["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS, PUT, DELETE, PATCH"
response.headers[
"Access-Control-Allow-Headers"
] = "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, apikey, Client-Agent, X-Fields"
response.headers["Access-Control-Allow-Headers"] = (
"Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, apikey, Client-Agent, X-Fields"
)
response.headers["Horde-Node"] = f"{socket.gethostname()}:{args.port}:{HORDE_VERSION}"
return response

Expand Down
1 change: 1 addition & 0 deletions horde/apis/models/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@ def __init__(self, api):
"username": fields.String(
description="The owning user's unique Username. It is a combination of their chosen alias plus their ID.",
),
"name": fields.String(description="The Shared Key Name."),
"kudos": fields.Integer(description="The Kudos limit assigned to this key."),
"expiry": fields.DateTime(
dt_format="rfc822",
Expand Down
6 changes: 2 additions & 4 deletions horde/apis/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ def post(self):
# self.priority_users = [self.user]
## Start prioritize by bridge request ##
pre_priority_user_ids = [x.split("#")[-1] for x in self.priority_usernames]
if any(
(u == '' or not u.isdigit) for u in pre_priority_user_ids
):
if any((u == "" or not u.isdigit) for u in pre_priority_user_ids):
raise e.BadRequest(
message="Priority usernames need to be provided in the form of 'alias#number'. Example: 'db0#1'",
rc="InvalidPriorityUsername",
Expand Down Expand Up @@ -2731,7 +2729,7 @@ class SharedKeySingle(Resource):
@api.response(401, "Invalid API Key", models.response_model_error)
@api.response(404, "Shared Key Not Found", models.response_model_error)
def get(self, sharedkey_id=""):
"""Get details about an existing Shared Key for this user"""
"""Get details about an existing Shared Key"""
self.args = self.get_parser.parse_args()
sharedkey = database.find_sharedkey(sharedkey_id)
if not sharedkey:
Expand Down
1 change: 1 addition & 0 deletions horde/classes/base/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def get_details(self):
ret_dict = {
"username": self.user.get_unique_alias(),
"id": self.id,
"name": self.name,
"kudos": self.kudos,
"expiry": self.expiry,
"utilized": self.utilized,
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.32.2"
HORDE_VERSION = "4.32.3"

WHITELISTED_SERVICE_IPS = {
"212.227.227.178", # Turing Bot
Expand Down
17 changes: 14 additions & 3 deletions horde/model_reference.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import requests

from horde.logger import logger
Expand Down Expand Up @@ -31,11 +33,17 @@ def call_function(self):
for _riter in range(10):
try:
self.reference = requests.get(
"https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/stable_diffusion.json",
os.getenv(
"HORDE_IMAGE_COMPVIS_REFERENCE",
"https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/stable_diffusion.json",
),
timeout=2,
).json()
diffusers = requests.get(
"https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/diffusers.json",
os.getenv(
"HORDE_IMAGE_DIFFUSERS_REFERENCE",
"https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/diffusers.json",
),
timeout=2,
).json()
self.reference.update(diffusers)
Expand All @@ -60,7 +68,10 @@ def call_function(self):
for _riter in range(10):
try:
self.text_reference = requests.get(
"https://raw.githubusercontent.com/db0/AI-Horde-text-model-reference/main/db.json",
os.getenv(
"HORDE_IMAGE_LLM_REFERENCE",
"https://raw.githubusercontent.com/db0/AI-Horde-text-model-reference/main/db.json",
),
timeout=2,
).json()
# logger.debug(self.reference)
Expand Down
2 changes: 1 addition & 1 deletion prune_stale_images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import os
import time
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta, timezone

Expand Down

0 comments on commit 56edbe4

Please sign in to comment.