Skip to content

Commit

Permalink
feat: civitai token
Browse files Browse the repository at this point in the history
  • Loading branch information
tazlin committed Jan 25, 2024
1 parent fb583cf commit 345825b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ repos:
- horde_safety
- torch
- ruamel.yaml
- hordelib==2.4.0
- horde_sdk==0.7.33
- hordelib==2.4.2
- horde_sdk==0.7.34
8 changes: 8 additions & 0 deletions bridgeData_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ safety_on_gpu: false
# Users in priority_usernames and trusted users will bypass this restriction
require_upfront_kudos: false

# If set, this worker will use this civitai API token when downloading any resources from civitai.
# This is required in order to provide LoRas/TIs (or other resources)
# which are marked as requiring a civitai token to download.
#
# You can get your civitai API Key from https://civitai.com/user/account (look for 'Add API Key')
#
# Remove the # from the line below and add your civitai API token to enable this feature.
# civitai_api_token:

#######################################
## Dreamer (Stable Diffusion Worker) ##
Expand Down
5 changes: 5 additions & 0 deletions horde_worker_regen/bridge_data/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class reGenBridgeData(CombinedHordeBridgeData):
default=False,
)

CIVIT_API_TOKEN: str | None = Field(
default=None,
alias="civitai_api_token",
)

def load_env_vars(self) -> None:
"""Load the environment variables into the config model."""
if self.models_folder_parent and os.getenv("AIWORKER_CACHE_HOME") is None:
Expand Down
2 changes: 1 addition & 1 deletion horde_worker_regen/process_management/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,7 @@ async def api_job_pop(self) -> None:
job_pop_request = ImageGenerateJobPopRequest(
apikey=self.bridge_data.api_key,
name=self.bridge_data.dreamer_worker_name,
bridge_agent="AI Horde Worker reGen:4.1.0:https://github.com/Haidra-Org/horde-worker-reGen",
bridge_agent="AI Horde Worker reGen:4.1.1:https://github.com/Haidra-Org/horde-worker-reGen",
models=self.bridge_data.image_models_to_load,
nsfw=self.bridge_data.nsfw,
threads=self.max_concurrent_inference_processes,
Expand Down
8 changes: 8 additions & 0 deletions load_env_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ def load_env_vars() -> None: # FIXME: there is a dynamic way to do this
"AIWORKER_LORA_CACHE_SIZE environment variable already set. "
"This will override the value for `max_lora_cache_size` in the config file.",
)
if "civitai_api_token" in config:
if os.getenv("CIVIT_API_TOKEN") is None:
os.environ["CIVIT_API_TOKEN"] = config["civitai_api_token"]
else:
print(
"CIVIT_API_TOKEN environment variable already set. "
"This will override the value for `civitai_api_token` in the config file.",
)
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
--extra-index-url https://download.pytorch.org/whl/cu121
torch>=2.1.2

horde_sdk~=0.7.33
horde_sdk~=0.7.36
horde_safety~=0.2.3
hordelib~=2.4.0
hordelib~=2.4.2
horde_model_reference

python-dotenv
ruamel.yaml
semver

python-Levenshtein

Expand Down

0 comments on commit 345825b

Please sign in to comment.