From 9842734ce7239ee6fdfb0d586b73a2aecb1bbaa8 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 5 Apr 2026 02:35:55 -0400 Subject: [PATCH] more cleanup of deprecated or orphaned code (#1305) --- .claude/rules/code-style.md | 2 +- CLAUDE.md | 1 + Cargo.lock | 37 ++- Cargo.toml | 1 - .../cli/devenv/dev-database-seed/Cargo.toml | 2 +- .../cli/devenv/dev-database-seed/src/main.rs | 8 +- .../devenv/dev-upload-media-file/Cargo.toml | 2 +- .../devenv/dev-upload-media-file/src/main.rs | 8 +- .../production/elasticsearch-cli/Cargo.toml | 2 +- .../production/elasticsearch-cli/src/main.rs | 2 +- .../production/kubectl-pod-cleanup/Cargo.toml | 2 +- .../kubectl-pod-cleanup/src/main.rs | 2 +- .../cli/production/migration-tool/Cargo.toml | 2 +- .../cli/production/migration-tool/src/main.rs | 2 +- crates/lib/deprecated/config/src/bad_urls.rs | 41 ++- .../lib/deprecated/config/src/common_env.rs | 17 -- crates/lib/deprecated/config/src/lib.rs | 2 - .../deprecated/config/src/shared_constants.rs | 23 -- .../prompt_engineering/Cargo.toml | 27 -- .../prompt_engineering/src/classify_prompt.rs | 100 ------- .../src/keywords/contains_children_keyword.rs | 16 -- .../contains_potential_minor_keyword.rs | 16 -- .../src/keywords/contains_racist_keyword.rs | 16 -- .../src/keywords/contains_sex_keyword.rs | 15 - .../prompt_engineering/src/keywords/mod.rs | 4 - .../prompt_engineering/src/lib.rs | 24 -- .../src/regexes/minor_regex.rs | 265 ------------------ .../prompt_engineering/src/regexes/mod.rs | 3 - .../src/regexes/nsfw_regex.rs | 40 --- .../src/regexes/potential_minor_regex.rs | 62 ---- .../tests/borderline_tests.rs | 41 --- .../tests/csam_prompt_tests.rs | 146 ---------- .../tests/nsfw_prompt_tests.rs | 188 ------------- .../tests/racist_prompt_tests.rs | 25 -- .../tests/sfw_prompt_tests.rs | 245 ---------------- .../tests/spicy_prompt_tests.rs | 38 --- .../config/shared_env_var_config/src/lib.rs | 3 + .../shared_env_var_config/src/logging.rs | 10 + .../config/shared_env_var_config/src/mysql.rs | 12 + .../config/shared_env_var_config/src/redis.rs | 20 ++ .../job/deprecated/analytics_job/Cargo.toml | 2 +- .../job/deprecated/analytics_job/src/main.rs | 9 +- .../job/deprecated/download_job/Cargo.toml | 2 + .../src/job_loop}/is_bad_download_url.rs | 7 +- .../download_job/src/job_loop/mod.rs | 1 + .../src/job_loop/process_single_job.rs | 2 +- .../job/deprecated/download_job/src/main.rs | 15 +- .../deprecated/email_sender_job/Cargo.toml | 1 + .../deprecated/email_sender_job/src/main.rs | 9 +- .../job/deprecated/es-update-job/Cargo.toml | 2 +- .../job/deprecated/es-update-job/src/main.rs | 9 +- .../job/deprecated/inference_job/Cargo.toml | 1 + .../job/deprecated/inference_job/src/main.rs | 9 +- .../deprecated/tts_download_job/Cargo.toml | 1 + .../deprecated/tts_download_job/src/main.rs | 15 +- .../deprecated/tts_inference_job/Cargo.toml | 1 + .../deprecated/tts_inference_job/src/main.rs | 9 +- .../deprecated/w2l_download_job/Cargo.toml | 1 + .../deprecated/w2l_download_job/src/main.rs | 15 +- .../deprecated/w2l_inference_job/Cargo.toml | 1 + .../deprecated/w2l_inference_job/src/main.rs | 15 +- .../service/job/seedance2_pro_job/Cargo.toml | 1 - .../service/job/seedance2_pro_job/src/main.rs | 9 +- .../job/video_thumbnail_job/Cargo.toml | 1 - .../job/video_thumbnail_job/src/main.rs | 9 +- crates/service/job/worldlabs_job/Cargo.toml | 2 +- crates/service/job/worldlabs_job/src/main.rs | 9 +- crates/service/web/storyteller_web/Cargo.toml | 1 - .../app_startup/redis_rate_limiters.rs | 22 +- .../src/configs/connect_to_database.rs | 7 +- .../image_gen/enqueue_image_generation.rs | 7 +- .../deprecated_endpoints/image_gen/mod.rs | 4 +- .../image_gen/prompt_enrichment.rs | 174 ------------ .../image_gen/replacement_prompts.rs | 14 - .../enqueue/progress_tracker_server.rs | 5 +- .../enqueue/progress_tracker_session.rs | 9 +- .../moderation/user_bans/list_banned_users.rs | 111 -------- .../endpoints/moderation/user_bans/mod.rs | 3 +- .../voice_designer/voices/create_voice.rs | 4 +- .../application_routes/moderation_routes.rs | 6 - .../service/web/storyteller_web/src/main.rs | 10 +- 81 files changed, 209 insertions(+), 1798 deletions(-) delete mode 100644 crates/lib/deprecated/config/src/shared_constants.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/Cargo.toml delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/classify_prompt.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_children_keyword.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_potential_minor_keyword.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_racist_keyword.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_sex_keyword.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/mod.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/lib.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/minor_regex.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/mod.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/nsfw_regex.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/potential_minor_regex.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/borderline_tests.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/csam_prompt_tests.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/nsfw_prompt_tests.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/racist_prompt_tests.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/sfw_prompt_tests.rs delete mode 100644 crates/lib/deprecated/machine_learning/prompt_engineering/tests/spicy_prompt_tests.rs create mode 100644 crates/schema/config/shared_env_var_config/src/logging.rs create mode 100644 crates/schema/config/shared_env_var_config/src/mysql.rs create mode 100644 crates/schema/config/shared_env_var_config/src/redis.rs rename crates/{lib/deprecated/config/src => service/job/deprecated/download_job/src/job_loop}/is_bad_download_url.rs (94%) delete mode 100644 crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/prompt_enrichment.rs delete mode 100644 crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/replacement_prompts.rs delete mode 100644 crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs diff --git a/.claude/rules/code-style.md b/.claude/rules/code-style.md index 9fe59a18bc..68a6baa054 100644 --- a/.claude/rules/code-style.md +++ b/.claude/rules/code-style.md @@ -5,7 +5,7 @@ - Two spaces for indentation (not four) - No minimum supported Rust version; use latest stable features freely - `#[macro_use] extern crate serde_derive;` is used in binary crates; library crates use `use serde_derive::{Serialize, Deserialize};` -- Prefer `log` crate macros (`info!`, `warn!`, `error!`) over `println!` +- Never use `println!` or `eprintln!` outside of tests; use `log` crate macros (`info!`, `warn!`, `error!`, `debug!`, `trace!`) instead - Use `anyhow::Result` / `AnyhowResult` for fallible functions in application code - Enum Display/Debug: use `impl_enum_display_and_debug_using_to_str!` macro, not `derive_more::Display` (CLion doesn't understand it) - Fields that are optional use the `maybe_` prefix: `maybe_creator_user_token`, `maybe_prompt_token` diff --git a/CLAUDE.md b/CLAUDE.md index 4a32af226e..0017d21b02 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,6 +60,7 @@ artcraft/ - Actix-web for HTTP services - SQLx for MySQL and SQLite - A mix of wreq and reqwest for Rust HTTP clients +- Never use `println!` or `eprintln!` outside of tests; use `log` crate macros instead - TypeScript with Nx, React, Vite, Zustand, and Three.js - Use two spaces for indentation diff --git a/Cargo.lock b/Cargo.lock index 3360c5f46e..da79764f55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -567,7 +567,6 @@ version = "0.0.1" dependencies = [ "anyhow", "chrono", - "config", "datetimes", "dotenv", "easyenv", @@ -582,6 +581,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "tokens", "tokio", @@ -3355,7 +3355,6 @@ dependencies = [ "bucket_paths", "clap 4.5.60", "cloud_storage", - "config", "easyenv", "elasticsearch", "enums", @@ -3366,6 +3365,7 @@ dependencies = [ "mimetypes", "mysql_queries", "rand 0.9.2", + "shared_env_var_config", "sqlx", "storyteller_root", "tokens", @@ -3381,7 +3381,6 @@ dependencies = [ "bucket_paths", "clap 4.5.60", "cloud_storage", - "config", "easyenv", "enums", "errors", @@ -3389,6 +3388,7 @@ dependencies = [ "log", "mimetypes", "mysql_queries", + "shared_env_var_config", "sqlx", "tokens", "tokio", @@ -3663,6 +3663,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "storyteller_root", "subprocess", @@ -3670,6 +3671,7 @@ dependencies = [ "tempdir", "tokens", "tokio", + "url", "workspace-build-acceleration", "zip 0.6.6", ] @@ -3835,7 +3837,6 @@ version = "0.0.1" dependencies = [ "bucket_paths", "clap 4.5.60", - "config", "easyenv", "elasticsearch", "elasticsearch_schema", @@ -3847,6 +3848,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "storyteller_root", "strum", @@ -3926,6 +3928,7 @@ dependencies = [ "serde_derive", "serde_json", "server_environment", + "shared_env_var_config", "sqlx", "workspace-build-acceleration", ] @@ -4136,7 +4139,6 @@ dependencies = [ "anyhow", "bootstrap", "chrono", - "config", "dotenv", "easyenv", "elasticsearch", @@ -4155,6 +4157,7 @@ dependencies = [ "serde_derive", "serde_json", "server_environment", + "shared_env_var_config", "sqlx", "storyteller_root", "tokens", @@ -5971,6 +5974,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "subprocess", "subprocess_common", @@ -6381,13 +6385,13 @@ dependencies = [ name = "kubectl-pod-cleanup" version = "0.0.1" dependencies = [ - "config", "easyenv", "errors", "log", "once_cell", "rand 0.8.5", "regex", + "shared_env_var_config", "workspace-build-acceleration", ] @@ -7086,7 +7090,6 @@ dependencies = [ "bucket_paths", "clap 4.5.60", "cloud_storage", - "config", "easyenv", "enums", "errors", @@ -7097,6 +7100,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "storyteller_root", "strum", @@ -8918,16 +8922,6 @@ dependencies = [ "syn 2.0.117", ] -[[package]] -name = "prompt_engineering" -version = "0.1.0" -dependencies = [ - "once_cell", - "regex", - "speculoos", - "workspace-build-acceleration", -] - [[package]] name = "prost" version = "0.12.6" @@ -10454,7 +10448,6 @@ dependencies = [ "bucket_paths", "cloud_storage", "concurrency", - "config", "easyenv", "enums", "errors", @@ -11547,7 +11540,6 @@ dependencies = [ "pager", "password", "primitives", - "prompt_engineering", "r2d2", "rand 0.9.2", "redis 1.2.0", @@ -13160,6 +13152,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "subprocess", "tempdir", @@ -13193,6 +13186,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "tempdir", "tokio", @@ -13659,7 +13653,6 @@ dependencies = [ "bucket_paths", "cloud_storage", "concurrency", - "config", "easyenv", "errors", "ffmpeg_utils", @@ -13741,6 +13734,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "subprocess", "tempdir", @@ -13771,6 +13765,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", + "shared_env_var_config", "sqlx", "subprocess", "tempdir", @@ -14916,7 +14911,6 @@ dependencies = [ "bucket_paths", "cloud_storage", "concurrency", - "config", "easyenv", "enums", "errors", @@ -14929,6 +14923,7 @@ dependencies = [ "serde_derive", "serde_json", "server_environment", + "shared_env_var_config", "sqlx", "tokens", "tokio", diff --git a/Cargo.toml b/Cargo.toml index 447a4a8954..460d5c0f3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,6 @@ members = [ "crates/lib/deprecated/http_server_common", # TODO(bt, 2023-03-20): Move useful pieces to actix_helpers "crates/lib/deprecated/image_algorithms", "crates/lib/deprecated/machine_learning/ml_weights_registry", - "crates/lib/deprecated/machine_learning/prompt_engineering", "crates/lib/deprecated/subprocess_common", "crates/lib/deprecated/tts_common", diff --git a/crates/cli/devenv/dev-database-seed/Cargo.toml b/crates/cli/devenv/dev-database-seed/Cargo.toml index 95d64e1777..baa2c4b962 100644 --- a/crates/cli/devenv/dev-database-seed/Cargo.toml +++ b/crates/cli/devenv/dev-database-seed/Cargo.toml @@ -22,7 +22,6 @@ workspace-build-acceleration = { workspace = true } # Internal bucket_paths.workspace = true cloud_storage.workspace = true -config = { path = "../../../lib/deprecated/config" } easyenv = { path = "../../../lib/easyenv" } enums.workspace = true errors.workspace = true @@ -31,6 +30,7 @@ hashing = { path = "../../../lib/files/hashing" } uuid_utils.workspace = true mimetypes.workspace = true mysql_queries = { path = "../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true storyteller_root = { path = "../../../lib/storyteller_root" } tokens.workspace = true diff --git a/crates/cli/devenv/dev-database-seed/src/main.rs b/crates/cli/devenv/dev-database-seed/src/main.rs index 98aa3812c0..ac724fe472 100644 --- a/crates/cli/devenv/dev-database-seed/src/main.rs +++ b/crates/cli/devenv/dev-database-seed/src/main.rs @@ -3,7 +3,8 @@ use log::info; use sqlx::{MySql, Pool}; use sqlx::mysql::MySqlPoolOptions; -use config::shared_constants::{DEFAULT_MYSQL_CONNECTION_STRING, DEFAULT_RUST_LOG}; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use errors::AnyhowResult; use crate::cli_args::parse_cli_args; @@ -25,10 +26,7 @@ pub async fn main() -> AnyhowResult<()> { // NB: Read secrets (eg. ACCESS_KEY) easyenv::from_filename(".env-secrets")?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); let pool = MySqlPoolOptions::new() .max_connections(easyenv::get_env_num("MYSQL_MAX_CONNECTIONS", 3)?) diff --git a/crates/cli/devenv/dev-upload-media-file/Cargo.toml b/crates/cli/devenv/dev-upload-media-file/Cargo.toml index 4a13592ec5..17ccab3ca4 100644 --- a/crates/cli/devenv/dev-upload-media-file/Cargo.toml +++ b/crates/cli/devenv/dev-upload-media-file/Cargo.toml @@ -22,13 +22,13 @@ workspace-build-acceleration = { workspace = true } # Internal bucket_paths.workspace = true cloud_storage.workspace = true -config = { path = "../../../lib/deprecated/config" } easyenv = { path = "../../../lib/easyenv" } enums.workspace = true errors.workspace = true filesys.workspace = true mimetypes.workspace = true mysql_queries = { path = "../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true tokens.workspace = true # External diff --git a/crates/cli/devenv/dev-upload-media-file/src/main.rs b/crates/cli/devenv/dev-upload-media-file/src/main.rs index 87b4626ed2..4a1394891a 100644 --- a/crates/cli/devenv/dev-upload-media-file/src/main.rs +++ b/crates/cli/devenv/dev-upload-media-file/src/main.rs @@ -5,7 +5,8 @@ use sqlx::mysql::MySqlPoolOptions; use bucket_paths::legacy::typified_paths::public::media_files::bucket_file_path::MediaFileBucketPath; use cloud_storage::bucket_client::BucketClient; -use config::shared_constants::{DEFAULT_MYSQL_CONNECTION_STRING, DEFAULT_RUST_LOG}; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use enums::by_table::media_files::media_file_type::MediaFileType; use enums::common::visibility::Visibility; use errors::{AnyhowResult, bail}; @@ -26,10 +27,7 @@ pub async fn main() -> AnyhowResult<()> { // NB: Read secrets (eg. ACCESS_KEY) easyenv::from_filename(".env-secrets")?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to MySQL..."); diff --git a/crates/cli/production/elasticsearch-cli/Cargo.toml b/crates/cli/production/elasticsearch-cli/Cargo.toml index d70c726999..f094bed99c 100644 --- a/crates/cli/production/elasticsearch-cli/Cargo.toml +++ b/crates/cli/production/elasticsearch-cli/Cargo.toml @@ -21,7 +21,7 @@ workspace-build-acceleration = { workspace = true } # Internal bucket_paths.workspace = true -config = { path = "../../../lib/deprecated/config" } +shared_env_var_config.workspace = true easyenv = { path = "../../../lib/easyenv" } elasticsearch_schema = { path = "../../../schema/database/elasticsearch_schema" } enums = { path = "../../../schema/public/enums" } diff --git a/crates/cli/production/elasticsearch-cli/src/main.rs b/crates/cli/production/elasticsearch-cli/src/main.rs index e77a8904fb..484733dedb 100644 --- a/crates/cli/production/elasticsearch-cli/src/main.rs +++ b/crates/cli/production/elasticsearch-cli/src/main.rs @@ -14,7 +14,7 @@ use sqlx::{MySql, Pool}; use std::collections::HashSet; use std::iter::FromIterator; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use elasticsearch_schema::searches::search_tts_models::search_tts_models; use errors::AnyhowResult; diff --git a/crates/cli/production/kubectl-pod-cleanup/Cargo.toml b/crates/cli/production/kubectl-pod-cleanup/Cargo.toml index fbafdfa5bd..c3c184015d 100644 --- a/crates/cli/production/kubectl-pod-cleanup/Cargo.toml +++ b/crates/cli/production/kubectl-pod-cleanup/Cargo.toml @@ -20,7 +20,7 @@ normal = ["workspace-build-acceleration"] workspace-build-acceleration = { workspace = true } # Internal -config = { path = "../../../lib/deprecated/config" } +shared_env_var_config.workspace = true easyenv = { path = "../../../lib/easyenv" } errors = { path = "../../../lib/errors" } diff --git a/crates/cli/production/kubectl-pod-cleanup/src/main.rs b/crates/cli/production/kubectl-pod-cleanup/src/main.rs index 0f2fb3cab9..a5d007a2e2 100644 --- a/crates/cli/production/kubectl-pod-cleanup/src/main.rs +++ b/crates/cli/production/kubectl-pod-cleanup/src/main.rs @@ -20,7 +20,7 @@ use std::time::Duration; use log::info; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use errors::AnyhowResult; use crate::delete_pods_threaded::delete_pods_threaded; diff --git a/crates/cli/production/migration-tool/Cargo.toml b/crates/cli/production/migration-tool/Cargo.toml index aaedd34a9a..41d4a7ece1 100644 --- a/crates/cli/production/migration-tool/Cargo.toml +++ b/crates/cli/production/migration-tool/Cargo.toml @@ -22,7 +22,7 @@ workspace-build-acceleration.workspace = true # Internal bucket_paths.workspace = true cloud_storage.workspace = true -config = { path = "../../../lib/deprecated/config" } +shared_env_var_config.workspace = true easyenv = { path = "../../../lib/easyenv" } enums.workspace = true errors.workspace = true diff --git a/crates/cli/production/migration-tool/src/main.rs b/crates/cli/production/migration-tool/src/main.rs index 70abe365d4..4d3d176eb5 100644 --- a/crates/cli/production/migration-tool/src/main.rs +++ b/crates/cli/production/migration-tool/src/main.rs @@ -10,7 +10,7 @@ use sqlx::{MySql, Pool}; use sqlx::mysql::MySqlPoolOptions; use cloud_storage::bucket_client::BucketClient; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use errors::AnyhowResult; use crate::cli_args::{Action, parse_cli_args}; diff --git a/crates/lib/deprecated/config/src/bad_urls.rs b/crates/lib/deprecated/config/src/bad_urls.rs index 280ed1d3bb..657b84817f 100644 --- a/crates/lib/deprecated/config/src/bad_urls.rs +++ b/crates/lib/deprecated/config/src/bad_urls.rs @@ -1,11 +1,7 @@ -//! Probably should be in its own "static_config" crate. - -use crate::is_bad_download_url::is_bad_download_url; +use url::{Host, Url}; /// Reports if the URL is inappropriate for downloading as a TTS model, vocoder, etc. -/// DEPRECATE: pub fn is_bad_tts_model_download_url(url: &str) -> anyhow::Result { - // TODO: Just use this. is_bad_download_url(url) } @@ -13,6 +9,41 @@ pub fn is_bad_model_weights_download_url(url: &str) -> anyhow::Result { is_bad_download_url(url) } +fn is_bad_download_url(url: &str) -> anyhow::Result { + if url.trim().is_empty() { + return Ok(true); + } + + let looks_malicious = url.contains("\"") + || url.contains("\'") + || url.contains("\\"); + + if looks_malicious { + return Ok(true); + } + + let url = Url::parse(url)?; + + match url.host() { + Some(Host::Domain(domain)) => { + let domain = domain.to_lowercase(); + + let bad_host = domain.contains("fb.watch") + || domain.contains("tiktok.com") + || domain.contains("vm.tiktok.com") + || domain.contains("youtu.be") + || domain.contains("youtube.com"); + + if bad_host { + return Ok(true) + } + } + _ => {}, + } + + Ok(false) +} + #[cfg(test)] mod tests { use crate::bad_urls::is_bad_tts_model_download_url; diff --git a/crates/lib/deprecated/config/src/common_env.rs b/crates/lib/deprecated/config/src/common_env.rs index 53ac666749..d62630a7e0 100644 --- a/crates/lib/deprecated/config/src/common_env.rs +++ b/crates/lib/deprecated/config/src/common_env.rs @@ -1,21 +1,8 @@ -use crate::shared_constants::DEFAULT_REDIS_DATABASE_0_CONNECTION_STRING; -use crate::shared_constants::DEFAULT_REDIS_DATABASE_1_CONNECTION_STRING; - -// TODO: Move more shared configs here. - /// Environment variables shared between one or more jobs or the main server. /// These do not have to have the same value for each instance, but they behave /// similarly across all usages. pub struct CommonEnv { - /// The Redis connection string. - /// This has FakeYou voice stats, rate limiters, etc. - pub redis_0_connection_string: String, - - /// The Redis connection string. - /// This has OBS/Twitch related functionality - pub redis_1_connection_string: String, - /// The amount of time to wait between job batches (not individual jobs). /// This prevents the outer loop of querying batches from flooding the DB. /// (In theory, there's work within jobs that prevents rapidly pegging the DB.) @@ -41,10 +28,6 @@ impl CommonEnv { pub fn read_from_env() -> anyhow::Result { Ok(Self { - redis_0_connection_string: easyenv::get_env_string_or_default("REDIS_0_URL", - DEFAULT_REDIS_DATABASE_0_CONNECTION_STRING), - redis_1_connection_string: easyenv::get_env_string_or_default("REDIS_1_URL", - DEFAULT_REDIS_DATABASE_1_CONNECTION_STRING), job_batch_wait_millis: easyenv::get_env_num("JOB_BATCH_WAIT_MILLIS", 100)?, job_max_attempts: easyenv::get_env_num("JOB_MAX_ATTEMPTS", 3)?, job_batch_size: easyenv::get_env_num("JOB_BATCH_SIZE", 10)?, diff --git a/crates/lib/deprecated/config/src/lib.rs b/crates/lib/deprecated/config/src/lib.rs index 7a590ff39f..452764e235 100644 --- a/crates/lib/deprecated/config/src/lib.rs +++ b/crates/lib/deprecated/config/src/lib.rs @@ -1,5 +1,3 @@ pub mod bad_urls; pub mod common_env; -pub mod is_bad_download_url; pub mod is_bad_video_download_url; -pub mod shared_constants; diff --git a/crates/lib/deprecated/config/src/shared_constants.rs b/crates/lib/deprecated/config/src/shared_constants.rs deleted file mode 100644 index 01b47f38f8..0000000000 --- a/crates/lib/deprecated/config/src/shared_constants.rs +++ /dev/null @@ -1,23 +0,0 @@ -//! Shared constants that all binaries use. -//! Or at least that deserve extremely high visibility. - -/// NB: `sqlx::query` is spammy and dumps all queries as "info"-level log lines. -/// NB: `hyper::proto::h1::io` is incredibly spammy and logs every chunk of bytes in very large files being downloaded. -pub const DEFAULT_RUST_LOG: &str = concat!( - "actix_web=info,", - "sqlx::query=warn,", - "hyper::proto::h1::io=warn,", - "storyteller_web::threads::db_health_checker_thread::db_health_checker_thread=warn,", - "http_server_common::request::get_request_ip=info,", // Debug spams Rust logs - "info", // Default level for everything else -); - -/// The default Redis connection string for use in development -pub const DEFAULT_REDIS_DATABASE_0_CONNECTION_STRING: &str = "redis://localhost/0"; - -/// The default Redis connection string for use in development -/// Database 1 -pub const DEFAULT_REDIS_DATABASE_1_CONNECTION_STRING: &str = "redis://localhost/1"; - -/// The default MySql connection string for use in development -pub const DEFAULT_MYSQL_CONNECTION_STRING: &str = "mysql://storyteller:password@localhost/storyteller"; diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/Cargo.toml b/crates/lib/deprecated/machine_learning/prompt_engineering/Cargo.toml deleted file mode 100644 index 6710e61d28..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "prompt_engineering" -version = "0.1.0" -edition = "2021" - - -[lib] -path = "src/lib.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[package.metadata.cargo-udeps.ignore] -normal = ["workspace-build-acceleration"] - -[dependencies] -# Hackari workspace hack (faster compile times) -workspace-build-acceleration = { workspace = true } - -# Internal -#errors = { path = "../errors" } - -# External -once_cell = "1.18.0" -regex = "1.5.4" - -[dev-dependencies] -speculoos.workspace = true diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/classify_prompt.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/classify_prompt.rs deleted file mode 100644 index 7f55578d95..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/classify_prompt.rs +++ /dev/null @@ -1,100 +0,0 @@ -use once_cell::sync::Lazy; -use regex::Regex; - -use crate::keywords::contains_children_keyword::contains_children_keyword; -use crate::keywords::contains_potential_minor_keyword::contains_potential_minor_keyword; -use crate::keywords::contains_racist_keyword::contains_racist_keyword; -use crate::keywords::contains_sex_keyword::contains_sex_keyword; -use crate::regexes::minor_regex::lowercase_mentions_underage; -use crate::regexes::nsfw_regex::nsfw_regex; -use crate::regexes::potential_minor_regex::potential_minor_regex; - -/// Classification of a text prompt -pub struct PromptClassification { - pub prompt_references_children: bool, - pub prompt_references_potential_minors: bool, - pub prompt_references_sex: bool, - pub prompt_references_racism: bool, - pub prompt_references_violence: bool, -} - -impl PromptClassification { - pub fn is_abusive(&self) -> bool { - self.prompt_references_racism || self.is_child_abuse() - - } - - pub fn is_child_abuse(&self) -> bool { - self.prompt_references_children && ( self.prompt_references_sex || self.prompt_references_violence ) - } -} - - -pub fn classify_prompt(text_prompt: &str) -> PromptClassification { - let text_prompt = text_prompt.to_lowercase(); - - let prompt_tokens_alpha = SPACES_REGEX.split(&text_prompt) - .map(|term| term.trim().to_string()) - .map(|term| term.chars().filter(|c| c.is_alphanumeric()).collect::()) - .collect::>(); - - let prompt_tokens_lower = SPACES_REGEX.split(&text_prompt) - .map(|term| term.trim().to_string()) - .collect::>(); - - let mut prompt_tokens= Vec::with_capacity(prompt_tokens_alpha.len() + prompt_tokens_lower.len()); - - prompt_tokens.extend(prompt_tokens_alpha); - prompt_tokens.extend(prompt_tokens_lower); - - let prompt_references_children = contains_children_keyword(&prompt_tokens) || lowercase_mentions_underage(&text_prompt); - let prompt_references_potential_minors = contains_potential_minor_keyword(&prompt_tokens) || potential_minor_regex(&text_prompt); - let prompt_references_sex = contains_sex_keyword(&prompt_tokens) || nsfw_regex(&text_prompt); - let prompt_references_racism = contains_racist_keyword(&prompt_tokens); - let prompt_references_violence = false; // TODO - - PromptClassification { - prompt_references_children, - prompt_references_potential_minors, - prompt_references_sex, - prompt_references_racism, - prompt_references_violence, - } -} - -static SPACES_REGEX : Lazy = Lazy::new(|| { - // NB: Includes non-ascii, such as ",". - Regex::new(r"[\s,;,]+").expect("regex should be valid") -}); - - -#[cfg(test)] -mod tests { - use speculoos::asserting; - - use crate::classify_prompt::SPACES_REGEX; - - fn regex_split(text: &str) -> Vec<&str> { - SPACES_REGEX.split(text).map(|s| s.trim()).collect() - } - - #[test] - fn test_regex() { - asserting("regex works") - .that(®ex_split("foo,bar,baz")) - .is_equal_to(vec!["foo", "bar", "baz"]); - - asserting("regex works") - .that(®ex_split("foo;bar;baz")) - .is_equal_to(vec!["foo", "bar", "baz"]); - - asserting("regex works") - .that(®ex_split("foo, bar, baz")) - .is_equal_to(vec!["foo", "bar", "baz"]); - - asserting("regex works") - .that(®ex_split("foo\n\nbar baz")) - .is_equal_to(vec!["foo", "bar", "baz"]); - } - -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_children_keyword.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_children_keyword.rs deleted file mode 100644 index 1d9169c7ad..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_children_keyword.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::collections::HashSet; - -use once_cell::sync::Lazy; - -const TERMS : &str = include_str!("../../../../../../../includes/binary_includes/safety/dictionary_children_terms.txt"); - -pub (crate) fn contains_children_keyword(prompt_tokens: &[String]) -> bool { - static TERM_DICTIONARY : Lazy> = Lazy::new(|| { - TERMS.lines() - .map(|line| line.trim().to_lowercase()) - .filter(|line| !line.is_empty() && !line.starts_with("#")) - .collect::>() - }); - - prompt_tokens.iter().any(|term| TERM_DICTIONARY.contains(term)) -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_potential_minor_keyword.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_potential_minor_keyword.rs deleted file mode 100644 index 462a80e1e2..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_potential_minor_keyword.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::collections::HashSet; - -use once_cell::sync::Lazy; - -const TERMS: &str = include_str!("../../../../../../../includes/binary_includes/safety/dictionary_potential_minor_terms.txt"); - -pub (crate) fn contains_potential_minor_keyword(prompt_tokens: &[String]) -> bool { - static TERM_DICTIONARY: Lazy> = Lazy::new(|| { - TERMS.lines() - .map(|line| line.trim().to_lowercase()) - .filter(|line| !line.is_empty() && !line.starts_with("#")) - .collect::>() - }); - - prompt_tokens.iter().any(|term| TERM_DICTIONARY.contains(term)) -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_racist_keyword.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_racist_keyword.rs deleted file mode 100644 index cd5f4d5ad9..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_racist_keyword.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::collections::HashSet; - -use once_cell::sync::Lazy; - -const TERMS : &str = include_str!("../../../../../../../includes/binary_includes/safety/dictionary_racist_terms.txt"); - -pub (crate) fn contains_racist_keyword(prompt_tokens: &[String]) -> bool { - static TERM_DICTIONARY : Lazy> = Lazy::new(|| { - TERMS.lines() - .map(|line| line.trim().to_lowercase()) - .filter(|line| !line.is_empty() && !line.starts_with("#")) - .collect::>() - }); - - prompt_tokens.iter().any(|term| TERM_DICTIONARY.contains(term)) -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_sex_keyword.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_sex_keyword.rs deleted file mode 100644 index 1eba7d66c7..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/contains_sex_keyword.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::collections::HashSet; - -use once_cell::sync::Lazy; - -const TERMS : &str = include_str!("../../../../../../../includes/binary_includes/safety/dictionary_sex_terms.txt"); -pub (crate) fn contains_sex_keyword(prompt_tokens: &[String]) -> bool { - static TERM_DICTIONARY : Lazy> = Lazy::new(|| { - TERMS.lines() - .map(|line| line.trim().to_lowercase()) - .filter(|line| !line.is_empty() && !line.starts_with("#")) - .collect::>() - }); - - prompt_tokens.iter().any(|term| TERM_DICTIONARY.contains(term)) -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/mod.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/mod.rs deleted file mode 100644 index a6d4629d2d..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/keywords/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub (crate) mod contains_children_keyword; -pub (crate) mod contains_potential_minor_keyword; -pub (crate) mod contains_racist_keyword; -pub (crate) mod contains_sex_keyword; \ No newline at end of file diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/lib.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/lib.rs deleted file mode 100644 index fe2fe32b30..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -//! classify_text -//! -//! Classify input text as abusive, sexual, etc. -//! - -// Never allow these -#![forbid(private_bounds)] -#![forbid(private_interfaces)] -#![forbid(unused_must_use)] // NB: It's unsafe to not close/check some things - -// Okay to toggle -#![forbid(unreachable_patterns)] -#![forbid(unused_imports)] -#![forbid(unused_mut)] -#![forbid(unused_variables)] - -// Always allow -#![allow(dead_code)] -#![allow(non_snake_case)] - -pub (crate) mod regexes; -pub (crate) mod keywords; - -pub mod classify_prompt; diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/minor_regex.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/minor_regex.rs deleted file mode 100644 index da4110e326..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/minor_regex.rs +++ /dev/null @@ -1,265 +0,0 @@ -use once_cell::sync::Lazy; -use regex::RegexSet; - -pub (crate) fn lowercase_mentions_underage(text: &str) -> bool { - let text = text.to_lowercase(); - - // NB: Unfortunately Rust Regex does not support look-around, so our age matching is awkward - // Matching digits "0" and "1" are tricky because they would match "19" and "0100". - static AGE_REGEX: Lazy = Lazy::new(|| { - let patterns = [ - // English - r"(age(ds)?)([^\d]){1,3}\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)\b", - r"(baby|little|small|young).{0,3}(boy|girl|kid|child|children)", - r"\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)([^\d]){1,3}(years?)", - r"\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)yos?", - r"\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)yrs?", - r"\b(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen)(.{0,3}|\w+)(years?)(.{0,3}|\w+)(old)", - - // English typos - r"\b(tweleve|fiveteen)(.{0,3}|\w+)(years?)(.{0,3}|\w+)(old)", - - // Spanish - r"\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)([^\d])+(años?)", - - // Italian - r"\b(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17)([^\d])+(anni)", - ]; - RegexSet::new(&patterns).expect("regex should be valid") - }); - - //println!("text: {:?}", text); - - AGE_REGEX.matches(&text).matched_any() -} - -#[cfg(test)] -mod tests { - use crate::regexes::minor_regex::lowercase_mentions_underage; - - mod english { - use super::*; - - mod non_match { - use super::*; - - #[test] - fn prefix_and_suffix_digits() { - assert!(!lowercase_mentions_underage("0100 years old")); - assert!(!lowercase_mentions_underage("I am 100 years old!")); - assert!(!lowercase_mentions_underage("99 years old")); - } - - #[test] - fn outside_range() { - assert!(!lowercase_mentions_underage("19 year old")); - assert!(!lowercase_mentions_underage("19 years old")); - assert!(!lowercase_mentions_underage("19-year old")); - assert!(!lowercase_mentions_underage("20 year old")); - assert!(!lowercase_mentions_underage("21 year old")); - assert!(!lowercase_mentions_underage("I am 18 years old")); - assert!(!lowercase_mentions_underage("I am 19 years old.")); - assert!(!lowercase_mentions_underage("I am 20 years old!")); - assert!(!lowercase_mentions_underage("age 18")); - assert!(!lowercase_mentions_underage("age 19,")); - assert!(!lowercase_mentions_underage("age 19-year")); - assert!(!lowercase_mentions_underage("age 20 ")); - assert!(!lowercase_mentions_underage("aged 18")); - assert!(!lowercase_mentions_underage("aged 20")); - assert!(!lowercase_mentions_underage("aged 21.")); - assert!(!lowercase_mentions_underage("ages 19")); - } - } - - mod positive_match { - use super::*; - - #[test] - fn spot_check_matches() { - assert!(lowercase_mentions_underage("age 17")); - assert!(lowercase_mentions_underage("aged 13")); - assert!(lowercase_mentions_underage("ages 16")); - assert!(lowercase_mentions_underage("17 year old")); - assert!(lowercase_mentions_underage("1-year old")); - assert!(lowercase_mentions_underage("7 year old girl")); - } - - #[test] - fn tough_digits() { - // Thanks to no Regex look-around, we have to be careful here. - assert!(lowercase_mentions_underage("1 year old")); - assert!(lowercase_mentions_underage("1 years old")); - assert!(lowercase_mentions_underage("1-year old")); - } - - #[test] - fn test_match() { - assert!(lowercase_mentions_underage("I am 17 years old")); - assert!(lowercase_mentions_underage("I am 17 years old.")); - assert!(lowercase_mentions_underage("I am 17 years old!")); - assert!(lowercase_mentions_underage("aged 17")); - assert!(lowercase_mentions_underage("age 17")); - assert!(lowercase_mentions_underage("small child")); - assert!(lowercase_mentions_underage("young girl")); - } - - #[test] - fn test_ranges() { - for i in 0..18 { - assert!(lowercase_mentions_underage(&format!("age {}", i).as_str())); - assert!(lowercase_mentions_underage(&format!("aged {}", i).as_str())); - assert!(lowercase_mentions_underage(&format!("ages {}", i).as_str())); - } - } - } - } - - mod spanish { - use super::*; - -//mod non_match { - // #[test] - // fn prefix_and_suffix_digits() { - // // TODO - // } - - // #[test] - // fn outside_range() { - // // TODO - // } - //} - - mod positive_match { - use super::*; - - #[test] - fn spot_check_matches() { - assert!(lowercase_mentions_underage("13 años")); - assert!(lowercase_mentions_underage("17 año")); - } - - //#[test] - //fn tough_digits() { - // // TODO - //} - - //#[test] - //fn test_match() { - // // TODO - //} - - #[test] - fn test_ranges() { - for i in 0..18 { - assert!(lowercase_mentions_underage(&format!("{} año", i).as_str())); - assert!(lowercase_mentions_underage(&format!("{} años", i).as_str())); - } - } - } - } - - - - mod italian { - use super::*; - - mod positive_match { - use super::*; - - #[test] - fn spot_check_matches() { - assert!(lowercase_mentions_underage("13 anni")); - assert!(lowercase_mentions_underage("17 anni")); - } - - #[test] - fn test_ranges() { - for i in 0..18 { - assert!(lowercase_mentions_underage(&format!("{} anni", i).as_str())); - } - } - } - } - - mod user_inputs { - use speculoos::asserting; - - use super::*; - - #[test] - fn test_bad_user_csam_inputs() { - let prompts = [ - // English - "12 year old girl with big tits with an innocent look", - "12yo teen topless, and friends. with short and dr. martens. Perfect face . At school . Details face. (Canon alpha7, perfect quality, HD, 8K", - "13yr naked girl", - "15 year old girl with big tits and innocent look", - "a beautiful blonde girl of 13 years old with blue eyes.she's naked ,showing her private parts ", - "a blonde girl of 13 years old with blue eyes.she's naked ,showing her private parts (no showing her face)", - "a blonde girl of 13 years old with blue eyes.she's naked ,showing her private parts. i'm fucking her now", - "a blonde girl of 13 years old with blue eyes.she's naked ,showing her tits and ass", - "a little boy have brown eyes and hair,nude body", - "Cute hot 15 year old girl, no bra, no shirt.", - "Fiveteen years old, naked, Brown hair, big ass, Brest d, open mouth, close eyes, seamen face", - "naked 8yo blonde girl", - "seven year old girl naked legs spread", - "Twelve years old girl , sucking thirty years old cock men", - "young loli butt, 13 years old", - - // Spanish - "niña de 13 años desnuda", - "una niiña de 13 años enseñando su vagina sin ropa", - - // Italian - "Ragazza nuda nudi tette 16yr bellissima corpo intero", - ]; - - for prompt in prompts { - asserting(&format!("prompt: {}", prompt)) - .that(&lowercase_mentions_underage(prompt)) - .is_equal_to(true); - } - } - - - #[test] - fn test_good_user_inputs() { - let prompts = [ - "(masterpiece), best quality, expressive eyes, perfect face, 1girl, anime, plump, solo, headphones, blonde hair, breasts, swimsuit, twintails, bikini, huge breasts, orange eyes, white bikini, short hair, blush, navel, smile, open mouth, looking at viewer, cleavage, barefoot, standing, render, full body, , massive belly, roundybelly, pregnant belly, , animated", - ", ", - "person waving", - "pichu witch pockimon", - "plum (plum landing) at comic con", - "President Putin riding on a Canguru", - "pride flag real flag", - "Princess Peach", - "Rat mixed with sharks", - "Red Dragon", - "red witch goat, purple eyes, round glasses, furry, young", - "REDHEAD", - "Richard Nixon holding a Super Mario lucky block", - "Ronald McDonald holding a taco ", - "Ronald Reagan standing in front of a Lamborghini Aventador, realistic, high quality, heaven", - "Ronald Reagan, looking at the camera, sitting on a duck floatie in a pool, realistic", - "Samurai and geisha riding on a horse", - "Scary, fear, horror, creepypasta, spooky", - "scrap company", - "Serbian musician star named Desingerica with wings and blade in his hands", - "Sexy latin girl in bikini, who's posing and take a pictures.", - "SheZow standing next to Christ the Redeemer, CGI render", - "Shigeru Miyamoto fighting through a crowd of nerds", - "skibidi toilet rizzed up ohio", - "Solid snake eating a hamburger", - "the wiggles dancing", - "Tifa and aerith. Bikini. Laughing. Squirting sunscreen on each other", - "touhou project, marisa kirisame, forest background", - ]; - - for prompt in prompts { - asserting(&format!("prompt: {}", prompt)) - .that(&lowercase_mentions_underage(prompt)) - .is_equal_to(false); - } - } - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/mod.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/mod.rs deleted file mode 100644 index 0fdb5b806e..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub (crate) mod minor_regex; -pub (crate) mod nsfw_regex; -pub (crate) mod potential_minor_regex; diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/nsfw_regex.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/nsfw_regex.rs deleted file mode 100644 index 91f2c309b1..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/nsfw_regex.rs +++ /dev/null @@ -1,40 +0,0 @@ -use once_cell::sync::Lazy; -use regex::RegexSet; - -pub (crate) fn nsfw_regex(text: &str) -> bool { - let text = text.to_lowercase(); - - // NB: Unfortunately Rust Regex does not support look-around, so our age matching is awkward - // Matching digits "0" and "1" are tricky because they would match "19" and "0100". - static AGE_REGEX: Lazy = Lazy::new(|| { - let patterns = [ - // English - r"\b(no|without|missing)\b(.{0,7})\b(clothes|clothing|bra|panties|panty|clothing)s?\b", - - ]; - RegexSet::new(&patterns).expect("regex should be valid") - }); - - //println!("text: {:?}", text); - - AGE_REGEX.matches(&text).matched_any() -} - -#[cfg(test)] -mod tests { - - mod english { - - mod positive_match { - use crate::regexes::nsfw_regex::nsfw_regex; - - #[test] - fn spot_check_matches() { - assert!(nsfw_regex("no panties")); - assert!(nsfw_regex("without panties")); - assert!(nsfw_regex("no clothing")); - assert!(nsfw_regex("missing clothing")); - } - } - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/potential_minor_regex.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/potential_minor_regex.rs deleted file mode 100644 index 2d4b5761ec..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/src/regexes/potential_minor_regex.rs +++ /dev/null @@ -1,62 +0,0 @@ -use once_cell::sync::Lazy; -use regex::RegexSet; - -pub (crate) fn potential_minor_regex(text: &str) -> bool { - let text = text.to_lowercase(); - - // NB: Unfortunately Rust Regex does not support look-around, so our age matching is awkward - // Matching digits "0" and "1" are tricky because they would match "19" and "0100". - static AGE_REGEX: Lazy = Lazy::new(|| { - let patterns = [ - // English - r"\b(teen(age(r)?)?s?)\b", - r"\b(young|tiny|small|petite)\b(.{0,7})\b(girl|boy)s?\b", - - ]; - RegexSet::new(&patterns).expect("regex should be valid") - }); - - //println!("text: {:?}", text); - - AGE_REGEX.matches(&text).matched_any() -} - -#[cfg(test)] -mod tests { - - mod english { - - mod positive_match { - use crate::regexes::potential_minor_regex::potential_minor_regex; - - #[test] - fn spot_check_matches() { - assert!(potential_minor_regex("teen")); - assert!(potential_minor_regex("teens")); - assert!(potential_minor_regex("teenage")); - assert!(potential_minor_regex("teenager")); - assert!(potential_minor_regex("teenagers")); - - assert!(potential_minor_regex("tiny girl")); - assert!(potential_minor_regex("tiny boy")); - assert!(potential_minor_regex("small boy")); - assert!(potential_minor_regex("small girl")); - - assert!(potential_minor_regex("tiny girls")); - assert!(potential_minor_regex("tiny boys")); - assert!(potential_minor_regex("small boys")); - assert!(potential_minor_regex("small girls")); - - assert!(potential_minor_regex("young girl")); - assert!(potential_minor_regex("young boy")); - assert!(potential_minor_regex("young boy")); - assert!(potential_minor_regex("young girl")); - - assert!(potential_minor_regex("petite girl")); - assert!(potential_minor_regex("petite boy")); - assert!(potential_minor_regex("petite boy")); - assert!(potential_minor_regex("petite girl")); - } - } - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/borderline_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/borderline_tests.rs deleted file mode 100644 index fe065ee080..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/borderline_tests.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Tests that could be close to CSAM, but appear to be completely SFW - -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn borderline_cases() { - // These are actual user prompts that use borderline language, but are safe - assert_prompts_are_sfw(&[ - "1 girl,pretty face,white stocking,swimmingsuit,duck sitting,school", - "4 year old girl, wearing a headset microphone", - "6 year old girl", - "a girl wearing a frost free puffer vest while sleeping with her mouth open", - "child's drawing of a fox", - "Create an Korean child playing with a polish child on play ground", - "Demon boy teen that is cute hot in a black suit and tie", - "girl in a strapless dress in a feald of flower", - "navel of a girl is eating banana", - "two girls kissing in bed", - ]); -} - -fn assert_prompts_are_sfw(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(false); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(false); - - asserting(&format!("references children or potential minors - prompt: {}", prompt)) - .that(&(classification.prompt_references_children || classification.prompt_references_potential_minors)) - - .is_equal_to(true); - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/csam_prompt_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/csam_prompt_tests.rs deleted file mode 100644 index 40cf010328..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/csam_prompt_tests.rs +++ /dev/null @@ -1,146 +0,0 @@ -//! These are illegal and abusive CSAM prompts from users that need to be blocked. -//! These queries were generated by actual users. - -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn sfw_prompts_including_children() { - assert_prompts_are_sfw_but_contain_children(&[ - "one little girl wearing pink ballerina style tank top with pink long-sleeved cardigan and pink skirt lying down on pink princess tent background and watching to viewers, who smiles, going prone", - ]); -} - -#[test] -fn prompts_that_generate_nsfw_possibly_ambiguous_but_could_accidentally_generate_csam() { - // "Teen" usually means 18+. - // We should swap these words for "adult" in prompt engineering. - assert_prompts_mention_potential_minors(&[ - "Red hair, Brest d, almost naked, teenage ", - "teen nude girl, full body", - "teen nude girl, full body, puffy pussy", - "tiny nude girl", - "tiny nude girl, full body", - "tiny nude girl, sexy", - "tiny tits turkish teen small ", - "turkish teen b cups freckles big nipples", - "turkish teen tiny tits big nipples freckles ", - ]); -} - -#[test] -fn test_english_bad_user_csam_prompts() { - assert_prompts_are_csam(&[ - "12 year old girl with big tits with an innocent look", - "12yo teen topless, and friends. with short and dr. martens. Perfect face . At school . Details face. (Canon alpha7, perfect quality, HD, 8K", - "13yr naked girl", - "15 year old girl with big tits and innocent look", - " yummy little jailbait teen girls naked", - "A beautiful blonde girl of 13 years old with blue eyes.She's naked ,showing her private parts ", - "A blonde girl of 13 years old with blue eyes.She's naked ,showing her private parts (no showing her face)", - "A blonde girl of 13 years old with blue eyes.She's naked ,showing her private parts. I'm fucking her now", - "A blonde girl of 13 years old with blue eyes.She's naked ,showing her tits and ass", - "A young girl how eats her classmates with her butt-hole", - "Beautiful young naked preteen girl hugging a young naked boy on a couch in front of a window. Boy Touch tits. Perfect teen’s breasts. Laneya Grace. superflat, a photorealistic 16k", - "Boy jerking off", - "Cute hot 15 year old girl, no bra, no shirt.", - "Fiveteen years old, naked, Brown hair, big ass, Brest d, open mouth, close eyes, seamen face", - "Little girl pussy cum dripping out", - "Twelve years old girl , sucking thirty years old cock men", - "Twelve years old girl, in bedroom pink , sucking thirty years old cock men", - "Young girls vore boys", - "a little boy have brown eyes and hair,nude body", // NB: That's not a comma! - "child porn", - "goth loli skirt, pink p@nties. butt", - "loli butt panties", - "loli n@ked", - "loli on knees, back side view, feet, butt, pink panties on", - "loli on knees, back side view, feet, butt, pink panties on.", - "loli p00ping in toilet", - "loli sitting on toilet", - "loli skirt cute upskirt pink panties", - "loli wearing black socks with whitish greyish stripes on the bottom of the socks. loli with legs and feet up showing off the dirty socks", - "loli", - "male kid in underwear, big butt", - "naked 8yo blonde girl", - "seven year old girl naked legs spread", - "sex 2 people. Full body 14yo teen topless, and naked boy friends. with short and dr. martens. Perfect innocent face . At school . Details face. tan lines. slutty. puffy’s areolas. masturbate(Canon alpha7, perfect quality, HD, 8K", - "underage sex", - "young boy in underwear, front view, bulge in underwear", - "young boy p3nis", - "young girl butt, pooping on bed", - "young loli butt, 13 years old", - "yummy little jailbait teen girls naked", - ]); -} - -#[test] -fn test_spanish_bad_user_csam_prompts() { - assert_prompts_are_csam(&[ - "12 year old girl with big tits with an innocent look desnude", - "Chica con semen rosado encima", // NB: Chica = teen girl - "Chica teniendo sexo", - "Hombre metiendo su pene en chica araña", - "niña de 13 años desnuda", - "niña de 13 años desnuda\n", - "Niño teniendo sexo y diciendo que rico", // NB: Nino = young child - "una niiña de 13 años enseñando su vagina sin ropa", - "una niña de 13 años desnuda", - "una niña desnuda enseñando su vagina sin ropa", - "una niña desnuda", - ]); -} - -#[test] -fn test_italian_bad_user_csam_prompts() { - assert_prompts_are_csam(&[ - "13yr preadolescente , Bella giovane ragazza nuda che abbraccia un giovane ragazzo nudo su un divano davanti a una finestra. Ragazzo Tocca le tette. Seni adolescenti perfetti. Laneya Grace. superflat, a photorealistic 16k", - "2 persone. Corpo intero 14 anni adolescente in topless e amici ragazzi nudi. con short e dr. martens. Faccia innocente perfetta. A scuola . Dettagli viso. linee di abbronzatura. troia. areole gonfie. masturbarsi(Canon alpha7, perfect quality, HD, 8K", - "Nuda preteen 16 anni adolescente nudo. Nudo a corpo intero. Perfetto piccolo seno giovane. Full body. preteen italo/brazilian. slutty con una bellissima tenera faccia innocente. festival punk all’aperto. Tette da adolescente perfette. Le areole da ragazzina. I capelli punk hippy . Jeans Short and black dr. Martens\n(Canon alpha7,photography)", - "Ragazza nuda nudi tette 16yr bellissima corpo intero", - "Vera adolescente di 12 anni nuda ", - ]); -} - -fn assert_prompts_are_sfw_but_contain_children(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(false); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(false); - - asserting(&format!("contains children - prompt: {}", prompt)) - .that(&classification.prompt_references_children) - .is_equal_to(true); - } -} - -fn assert_prompts_mention_potential_minors(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("contains children - prompt: {}", prompt)) - .that(&classification.prompt_references_potential_minors) - .is_equal_to(true); - } -} - -fn assert_prompts_are_csam(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(true); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(true); - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/nsfw_prompt_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/nsfw_prompt_tests.rs deleted file mode 100644 index 84b9f3d7f5..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/nsfw_prompt_tests.rs +++ /dev/null @@ -1,188 +0,0 @@ -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn english_nsfw_prompts_test() { - assert_prompts_are_nsfw(&[ - "((san from princess mononoke)), ((having sex)), (cowgirl position), ((penis in vagina)), ((short ginger hair)), (crop top),(lifting top), (showing tits), (nipples), ((small breast)), ((muscular)), hotelroom, ((drunk:1.2)), ((no panties)), (kneeling over a man), (((gaping pussy))), ((skirt)), horny, (in heat), (furrowed brow), (angry expression), ((sweat:1.2)), absurd resolution, masterpiece, ultra-detailed, vivid, intricate details, (((photorealistic))), visceral experience, (dynamic angle), (sharp focus), perfect face, looking down, perfect nipples, perfect feet", - "1girl, nude, large breasts", - "2B. white swimsuit, butt, black eyeliner, white droplets on ass, sunscreen bottle in hand", - "3 naked Latina women in a swimming pool", - "A beautiful, young, curvy woman with ginger hair, huge breasts twice the size of her head, wearing (red glasses) and a (((sexy white nurse costume with a front red zip))), playfully flirting with the viewer; ((pulling on the front zip, showing off her cleavage)), (no background; solid colour background). Mind-broken; sexual ecstasy, ahegao, happy, (Horny, naughty face), ((cock hungry, cock worship, penis awe)), 3/4 head shot; head, hair and arms in frame", - "a gay black guy with nipples and has undies on", - "A giant woman living in a city she loves putting people in her butthole", - "A girl who used her ass to eat vore", - "a poop dressed as a princess", - "A pornstar getting semen on her face stylized in 4k, realism, high resolution and NSFW.", - "A realistic photo of pokemon fully nude", - "A sexy anime girl with no clothes or bra and full body", - "A sexy anime girl with no clothes or bra", - "a woman having sex with a man", - "Adult film star Lisa Ann, naked, posing for viewer ", - "ahh daddy ahh fuck me", - "Anal vore", - "Anime Girl (NSFW)", - "anime girl getting fucked in the pussy", - "Anime girl moaning cum naked", - "anime girl naked moaning lots of cum", - "anime girl pussy getting fucked", - "Anime girls squiring from thier vaginas", - "anime pussy getting fucked by a dick", - "Anime woman jerking a man off", - "Anime woman showing her boobs", - "Anime woman with penis between her boobs and cum on her boobs", - "anthropomorphic poop princess in a castle bedroom", - "Belle Delphine's pussy squirting", - "Big boobs having sex ", - "Big boobs", - "Big breast", - "Big naked but girl with huge eyes on each cheek", - "Big nude boobs", - "Big perfect white boobs", - "Bikini girls tanning naked at the beach", - "black women, cum inflation, cute, sex, big boobs, big ass", - "Blowjob and cum", - "COCK COCK AND DICK BALLS HEELLPPPP", - "Creampie (NSFW)", - "Cute, is a latina, and naked", - "dick pic", - "Full body naked big boobs open pussy moaning anime girl", - "Full body, ultra giant boobs, ultra thicc, naked, facing viewer, in the sewers", - "Futanari holding her penis in one hand", - "Futanari", - "Generate a beautiful picture of a naked woman.", - "girl getting fucked in a pussy and another girl showing her ass in the image", - "girl in a tight thong. NSFW, k, realistic, photorealsitic.", - "Girl naked, masturbating, ahegao, squatting", - "Girl naked, masturbating, ahegao, squatting, ultra realistic", - "Girl nude, pink hair, pink pussy ", - "Girl with big ass in white pants shake her ass", - "Girl with big ass sits on chair on tight skirt", - "Girl with big boobs and small bro touch her boobs and make a lusty eye contact", - "girls gaping pussy and ass close up in the camera", - "guy shitting in the toilet", - "hentai", - "Hitomi Tanaka with nude big boobs and pussy open", - "hot and pretty faced naked girls", - "hot anime girl gaping pussy and ass legs wide open", - "hot cat girl pussy getting fucked by a dick", - "hot gaping pussy and ass close up", - "hot gaping pussy and ass legs wide open", - "hot girl gaping pussy and ass close up in the camera", - "hot girl with a tight vagina", - "Hot girl with big boobs in white dress", - "hot hentai fuck", - "Hot naked anime maids", - "hot naked girl full body", - "hot naked girl", - "hot wet gaping pussy close up", - "hot white girl gaping pussy and ass close up in the camera", - "Hottest anime girl spreading apart her vagina", - "Huge breasts naked anime girl", - "HUGEEEEEEEE BOOBS, HUGEEEEEEEEEEEE BUTT, a latina, has white hair, OVERLY CUTE, NAKED", - "huniepop 3", - "Huniepop fairy in pink lingerie", - "Huniepop", - "hyper boobs, boobjob, cum, smaller male, black girl, white man, paizuri, sex, black female, inflation, expansion, cum inflation, dialouge", - "hyper boobs, boobjob, cum, smaller male, black girl, white man, paizuri, sex,", - "inflation, water inflation, oral, hose in mouth, water, orgasm, english dialouge, solo female, belly expansion, expansion, cum, inflation, water inflation, water inflation, water inflation, water inflation, human girl, orgasm, human girl inflation", - "intercource between man and women", - "Iran blowjob girl", - "Iranian girl suck dick", - "juicy wet pussy close up", - "Kyu Sugardust from the game Huniepop", - "leaked sex tape", - "Lesbians in a park nude", - "LOOK AT MY MASSIVE DICK", - "Man and woman having sex", - "Man cumming on a woman’s ass", - "Mikasa Blowjob in car with big ass", - "Mikasa with big boobs", - "minecraft creeper having sex in the pussy with another minecraft creeper", - "moaning anime girl", - "monkey standing up with huge black penis hanging down", - "monkey with a huge black penis", - "naked anime girl", - "Naked Gardevoir", - "Naked girl showing her creampied vagina", - "Naked girl showing her cum covered vagina ", - "Naked girl showing her cum covered vagina", - "naked girl sitting in chair", - "Naked girl spreading her pussy", - "Naked woman giving birth", - "Naked woman", - "naked women fingring", - "naked", - "Naked, cute, hot, nice boobs", - "Nude woman big boobs", - "Nude woman sucking dick", - "Nude woman", - "nutsack", - "Penis", - "porno", - "pov your having sex with a naked anime girl", - "Purple haired, big breasted, naked, purple eyes, blushing", - "Purple haired, big breasted, naked, purple eyes, blushing, embarrassed, full body", - "Purple haired, naked, woman, naked, big breasts, blushing", - "pussy", - "raven team leader from fortnite getting fucked in the pussy", - "Santa jerking his penis in his workshop", - "Santa wanking his meat in his workshop", - "sex", - "Sexy milf with big ass sits on big dick anal", - "Sexy woman, ultra giant boobs, ultra thicc, facing viewer, standing, arms behind back, naked, in the mall", - "sexy,high heels,long brown hair,big breast,KTV,seducing", - "short blonde hair , side shaved. nude, legs spread, black eyeshadow, red lipstick, full body, sexy. realistic. 1970's", - "short blonde hair side shaved, black lingerie, black eyeliner, cum on face", - "The Love Fairy Kyu Sugardust from the game Huniepop", - "The wettest vagina ", - "The wettest vagina", - "titfuck, huge boobs", - "Vagina cuming", - "Vagina hole", - "Vagina squirting", - "vagina", - "Vegeta female version with big boobs from Dragonball", - "Wet vagina after cream pie", - "Wet vagina after cream pie\n", - "woman pleasuring herself stylized in photorealist, 4k, high-res, and NSFW (Nude)", - "woman sucking dick.", - "Woman with huge tits desnude", - "Woman with huge tits", - "Women with boobs too big for her own good", - "yuki tsukumo woman face feet five toes anime two feet normal sized feet tall body two legs 5,9 watery substance on feet feet in air sitting by bed blonde,long hair,grinning no clothes 35 year old big boobs long toes legs up in the air inviting to pussy two legs up in the air exposed nipples and breasts dripping wet pussy black tanktop blue jeans lipstick holding legs in the air moaning\n\nshowing her soles to the camera", - "Zayne and Nicky gay sex", - ]); -} - -#[test] -fn spanish_nsfw_prompts_test() { - assert_prompts_are_nsfw(&[ - "Girl desnude", - "Mujer rubia de ojos celestes y senos grandes en traje de baño rojo caminando por una playa del caribe", - "Mujer rubia desnuda tomando sol en la ppaya", - ]); -} - -fn assert_prompts_are_nsfw(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is nsfw - prompt: {}", prompt)) - .that(&classification.prompt_references_sex) - .is_equal_to(true); - - asserting(&format!("references children - prompt: {}", prompt)) - .that(&classification.prompt_references_children) - .is_equal_to(false); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(false); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(false); - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/racist_prompt_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/racist_prompt_tests.rs deleted file mode 100644 index d9344e103e..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/racist_prompt_tests.rs +++ /dev/null @@ -1,25 +0,0 @@ -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn test_bad_user_racist_prompts() { - assert_prompts_are_racism(&[ - "adolf hitler having tea with joe biden", - "niggers", - ]); -} - -fn assert_prompts_are_racism(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(true); - - asserting(&format!("is racism - prompt: {}", prompt)) - .that(&classification.prompt_references_racism) - .is_equal_to(true); - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/sfw_prompt_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/sfw_prompt_tests.rs deleted file mode 100644 index f1dfc731b0..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/sfw_prompt_tests.rs +++ /dev/null @@ -1,245 +0,0 @@ -//! These prompts should be fully innocent and allowed - -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn sfw_english_test() { - // These are actual user prompts that use borderline language, but are safe - // Eventually we'll want to classify prompts that are sufficiently engineered vs prompts that need enrichment. - assert_prompts_are_sfw(&[ - "(masterpiece, best quality), 1girl, blonde hair, red dress, pantyhose, cute face, blush", - "***botw style*** a lifeguard wearing a red one piece swimsuit", - "***charturnbetalora*** A lifeguard wearing a red one-piece swimsuit", - "1000 coins inside 50 large jars", - "1girl, blue hair, sitting on top of a table, smile", - "1girl, purple hair, school uniform, smug, looking at viewer, heterochromia", - "1girl, red hair, city streets", - "1girl, schoolgirl, blue hair, eating icecream", - "1girl, steampunk, holding a wrench", - "2 titans are looking at the sunset", - "2d hand drawn disney princess covered in chocolate, peanuts and corn", - "2Pac in today's world.", - "3 dancing people in a concert", - ", ", - "A 12 ft tall terrifying shadow analog horror demon", - "A badger in an explorer's hat and a fawn", - "A boy eating a ice cream at the palace", - "A boy, yellow short hair, blue eyes a star in it, hikaru kamiki", - "A crowd of 100 people looking at the camera", - "A cute pug with an owner", - "A cute small fox in the woods", - "A female inkling wearing a pink one-piece swimsuit", - "A giant bee and a small dog", - "A girl from Robotech universe, SDF1 mecha superdimensional fortess", - "A happy girl in a park", - "a kid crying for his ice cream in the floor, the seller is laughing in his car", - "a little Teddy throwing a blue ball", - "A little Unicorn playing in the Sand", - "A man is happy at the press conference", - "A man selling rotten milk in the park", - "a man that is also a car", - "A real life pikachu being walked like a dog.", - "A robotic girl with blue eyes.", - "A shark getting attacked by a vending machine.", - "A white cat, standing on its legs and holding a diamond sword.", - "A woman of KRON4", - "ai hoshino sleeping", - "Alastor from Hazbin Hotel, drinking out of a cup", - "Albert Einstein", - "Alex Jones wearing a Minecraft styled duck hat", - "An adorable chubby fawn laying on a patch of grass smiling", - "An eboost monkey", - "An extreme close-up of an gray-haired man with a beard in his 60s, he is deep in thought pondering the history of the universe as he sits at a cafe in Paris, his eyes focus on people offscreen as they walk as he sits mostly motionless, he is dressed in a wool coat suit coat with a button-down shirt , he wears a brown beret and glasses and has a very professorial appearance, and the end he offers a subtle closed-mouth smile as if he found the answer to the mystery of life, the lighting is very cinematic with the golden light and the Parisian streets and city in the background, depth of field, cinematic 35mm film.", - "an image of kojiro hiuga kicking tsubasa osora in the stomach", - "an island in the sun with surver and chamäleon", - "Animated character in the style of VivziePop", - "Anime girl with pink hair and blue eyes with green eyes with a kawaii outfit reading in her bedroom full of posters.", - "anime, hand-drawn and cel animation techniques, iron man from marvel, natural design, beautifully rendered and expressive rich colors, vibrant pastel colors, imaginative and fantastical landscapes, sharp attention to detail, realism and a strong sense of nostalgia and warmth, sharp attention to small details and textures, fantastical creatures, settings, depth and emotions emphasized and accentuated by lighting and shading, extremely high quality, incredibly high finite definition, high resolution, hand-drawn and cel animation techniques", - "Archaic warriors on horseback kidnap Sabine maidens", - "Baldi, showing his anger by slapping with his ruler.", - "Batman in iran", - "Beautiful Woman with blue hair and green eyes dressed kawaii dress smiling wearing cat ears and tail.", - "Big booty joe", - "Black and white image of a motor cycle in the year 1955", - "Blue apple", - "boy demon black hair wereind a shirt and shorts hands in pokets", - "Boy named axel davidson has a big belly and a girl called macey steward holds his belly in the sunset", - "boy with black and blue hair in a red shirt and jeans happy", - "cary entity floating menacingly, with many floating eyes and red flesh tentacles and spikes coming out of it, with many mouths with very spiky teeth.", - "Charlie Morningstar from Hazbin Hotel", - "Clark Gable smiling in a nineteen twenties nightclub.", - "Classic painting of 2 brown rabbits with white spots wearing overalls and a dress, carrying basket of carrots, outdoors, Monet", - "crab human man model realistic", - "Cute White Shepherd Dog, Standing, Blue Pants, Blue Shoes", - "Cute Wolf, Blue cap, Grey Fur, White Cream, Blue Tracksuit, Blue Pants, Wolf Tail, Red Shoes", - "Cute Wolf, Blue cap, Light grey fur, Blue Tracksuit, Blue pants, Red shoes, wolf tail", - "Cute, Muscular wolf, Male, Blue cap, Light grey fur, Blue Tracksuit, Red shoes, Blue pants, Wolf tail, Smiling", - "dead girl in a white dress with blood comeing frome her head in an abendend hospitel", - "demon girl with white hair light blue eyes with red horns and a tail in a castel", - "Dog with horns", - "Doki Doki Literature club", - "Donald Duck, riding on a yellow submarine", - "Donald Trump riding a t-rex while holding a gun with American flags in the background", - "Dragon ball", - "drone", - "Dwight D. Eisenhower, looking at the camera, realistic, high quality", - "Eazy-E wearing a Cuban Link, Rolex, and white Nike's with a AR-15 in his left hand.", - "Elsa Plush Doll!", - "Engineer Team Fortress 2", - "Eraser BFDI drunk", - "Eren Jaeger vs titans", - "Farmers with big Harvester machines", - "female, witch, holding flintlock pistol", - "Foxdog, Wolfdog", - "Foxy from five nights at Freddy’s eating a burger", - "freddy fazbear watching a movie", - "Friendly Monsters with long hair in front of mount fujii", - "Funny looking feff", - "Furry", - "Generate what would Eazy-E would look like today", - "Giant anime hamburger attacking Los Angeles", - "Giant girl baby destroying the city", - "Giantess acting like titan on attack on titan", - "girl hair pink , dance , japan", - "girl in a pink sweter and jeans with pink horns looking window with durtyblond hair saprized", - "girl in a prom dress crying in the rain", - "girl siting in a light blue dress", - "girl teen in a dress with horns and a tail in a feald of flowers", - "girl with bloned hair wering a light blue dress whell drawing with a boy with black hair wering a red shirt siting nex to her", - "girl with horns and a tail that has durdyblond hair wereing a pink sweter and riped jeans", - "girl with lightblue hair cute", - "girl with white hair and lifght blue eyes in a light blue dress with horns & a tail in a feld of flowers with a human boy", - "Glamorous white gold and pink themed room", - "Gogeta eating a chili dog", - "Grimreper human boy", - "Grover, Sesame Street", - "Guy Hamdon/SheZow (SheZow form) riding a motorcycle in a highway, anime style", - "Hank Hill in armor closeup", - "Has short yellow hair, blue eyes a star in it, Teenager", - "Hatsune Miku", - "Hexagon globe of the world", - "Hey what is up?", - "HopeScope Wedding Plush Doll", - "Horse running on a race track", - "I really tall old man. He is at least 13 feet tall, and with his familiy in a family photo. The next tallest member is 4 foot, so he is MASSIVE. He looks like a slitherman, but white old man", - "I’m a feff", - "James Dean smiling wearing a cowboy hat.", - "Joe Biden flying as Superman", - "Jolyne Cujoh flying on top of the apple tree", - "Kanye West and Jay-Z in Paris, France at the Eiffel Tower.", - "kawaii anime frog", - "kinda bug and kinda snack.", - "kirby fighting plankton", - "LGBTQ Appreciation", - "Lightning mcqueen from pixar cars but as an anime", - "Link", - "lovander palworld", - "magical animal", - "Maid with the prince standing next to her", - "Make Huggy Wuggy From Poppy Playtime: Chapter 1.", - "Man eating soup at a bagel shop on a sunny day", - "Man standing on the edge of a cliff", - "Man with slicked back black hair and blue eyes with a black puppy while smiling.", - "mank walking", - "Maroon 5 playing on the jimmy fallon stage", - "masterpiece, best quality, white dress, plump,", - "Me", - "monkey playing fortnite", - "morbidly obese blonde woman", - "Nahida from genshin impact", - "Nami from one peice on the beach angry", - "Overweight Taco Bell manager Female. Hair and a bun with braces, smiling. Black uniform with apron.", - "person waving", - "pichu witch pockimon", - "plum (plum landing) at comic con", - "President Putin riding on a Canguru", - "pride flag real flag", - "Princess Peach", - "Rat mixed with sharks", - "Red Dragon", - "red witch goat, purple eyes, round glasses, furry, young", - "REDHEAD", - "Richard Nixon holding a Super Mario lucky block", - "Ronald McDonald holding a taco ", - "Ronald Reagan standing in front of a Lamborghini Aventador, realistic, high quality, heaven", - "Ronald Reagan, looking at the camera, sitting on a duck floatie in a pool, realistic", - "Samurai and geisha riding on a horse", - "Scary, fear, horror, creepypasta, spooky", - "scrap company", - "Serbian musician star named Desingerica with wings and blade in his hands", - "Sexy latin girl in bikini, who's posing and take a pictures.", - "SheZow standing next to Christ the Redeemer, CGI render", - "Shigeru Miyamoto fighting through a crowd of nerds", - "skibidi toilet rizzed up ohio", - "Solid snake eating a hamburger", - "Sonic beats up Mario", - "Sonic meets the Powerpuff Girls", - "Sonic the hedgehog going fast", - "sunnyv2, man working in the office", - "sunnyv2, stunning close-up portrait of a swiss business woman with captivating eyes, background is a bright office", - "The biggest of biggest guys", - "The father in my dreams ! I love my father ! I hug him but... He does't hug me !", - "The healthiest hamburger in all the land", - "The Rock eating rocks.", - "The slimer hugging an eel", - "the wiggles dancing", - "Tifa and aerith. Bikini. Laughing. Squirting sunscreen on each other", - "touhou project, marisa kirisame, forest background", - "Transfur", - "tree people", - "trump riding and hanging out the window in a doge charger with an AR-15 pointed in the air shooting with American flags all over the place.", - "Ultra HD, very high resolution, photorealistic real life picture, very detailed face, wide shot photography of a huge, enormous, extremely muscular, supermassive, obese, good nature, shirtless, handsome 54 year old welsh wrestling-coach taking a selfie with his new iphone, welsh cocky alpha-male, superheavyweight-offseason-bodybuilder body shape, giant supermassive ultrabroad superflabby pointy pectorals, extremamente mamiludo , beer belly, immense massive muscular legs, mamilos enormes hiper-inchados protuberantes, sideburns, extremely high testosterone levels, very masculine face, side-parted tight hair", - "verey fansey dresses", - "Victorian era portrait of an thai woman", - "Wedding Dress", - "White and blue fox furry in a river", - "White German Shepherd, Back View, Tail up", - "white rabbit speaking into studio mic", - "White Shepherd Dog, Green Sport Coat, Blue Pants, Blue Shoes", - "will smith slapping Donald Trump at the Oscars. 4k, realistic", - "Woman with blue hair and green eyes dressed kawaii dress smiling wearing cat ears and tail.", - "Woman with pink and blue hair and green eyes dressed kawaii dress holding a kitten while smiling.", - "World's biggest Mountain Dew Baja Blast", - "XXXTENTACION", - "YOU ARE AWSOME", - "Young John F. Kennedy smoking a cigar in a nineteen forties club.", - "young wizard using magic with hands", - "Young woman with pink and blue hair and green eyes dressed kawaii Japanese singing into a microphone at a concert.", - "Yui and Hideki from Angel Beats holding hands while smiling.", - "Zelda", - "\"Stone Cold\" Steve Austin holding a Big Mac", - ]); -} - -#[test] -fn sfw_spanish_test() { - // These are actual user prompts that use borderline language, but are safe - // Eventually we'll want to classify prompts that are sufficiently engineered vs prompts that need enrichment. - assert_prompts_are_sfw(&[ - "como tan muchacho", // NB: "like such a boy" - "gata gata negra antropomorfica de ojos verdes y peinado bob color blanco peinado blanco vestida con un uniforme escolar japones estilo anime", - "perro volando en las nuves", // NB: Dog flying in the clouds - "rio con personas", // NB: "river with people" - "Uma mulher chorando", // NB: "A woman crying" - "Una mujer con piel de dragon, y cuernos", // NB: "A woman with dragon skin and horns" - "Una mujer japonesa embarazada pero más femenina con cabello blanco, ojos azules, un traje rojo de artes marciales de cuerpo completo, una cicatriz en la mejilla, con un efecto de nieve en el fondo de ciudad, en estilo de dibujo manga", - "Una persona con un brazo arancado caminando", // NB: A person with a torn arm walking - ]); -} - - -fn assert_prompts_are_sfw(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(false); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(false); - } -} diff --git a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/spicy_prompt_tests.rs b/crates/lib/deprecated/machine_learning/prompt_engineering/tests/spicy_prompt_tests.rs deleted file mode 100644 index 7190369ab3..0000000000 --- a/crates/lib/deprecated/machine_learning/prompt_engineering/tests/spicy_prompt_tests.rs +++ /dev/null @@ -1,38 +0,0 @@ -//! "Spicy" prompts are not necessarily NSFW -//! Currently these get the "NSFW" treatment, but we may wish to engineer the negative prompt -//! to steer the image generation away from NSFW territory. -//! -use speculoos::asserting; - -use prompt_engineering::classify_prompt::classify_prompt; - -#[test] -fn permissible_sexy_tests() { - // These classify as NSFW now, but should be in a category of their own - assert_prompts_are_spicy(&[ - "(masterpiece), best quality, expressive eyes, perfect face, 1girl, anime, plump, solo, headphones, blonde hair, breasts, swimsuit, twintails, bikini, huge breasts, orange eyes, white bikini, short hair, blush, navel, smile, open mouth, looking at viewer, cleavage, barefoot, standing, render, full body, , massive belly, roundybelly, pregnant belly, , animated", - "Beautiful woman, seductive pose, full body visible, leotard, heels", - "sexy,seducing,long hair,high heels,KTV,stockings", - "short blonde hair , side shaved. bunnygirl, corset, bunny ears, black eyeshadow, red lipstick, full body, sexy. realistic. ", - "short green and black hair , side shaved, black lingerie, black eyeshadow, dark lipstick, full body, smirk", - ]); -} - -fn assert_prompts_are_spicy(prompts: &[&str]) { - for prompt in prompts { - let classification = classify_prompt(prompt); - - asserting(&format!("is abusive - prompt: {}", prompt)) - .that(&classification.is_abusive()) - .is_equal_to(false); - - asserting(&format!("is child abuse - prompt: {}", prompt)) - .that(&classification.is_child_abuse()) - .is_equal_to(false); - - // TODO: This test should be made to report `false` - //asserting(&format!("is nsfw - prompt: {}", prompt)) - // .that(&classification.prompt_references_sex) - // .is_equal_to(true); - } -} diff --git a/crates/schema/config/shared_env_var_config/src/lib.rs b/crates/schema/config/shared_env_var_config/src/lib.rs index b7460ec27e..e271084ff1 100644 --- a/crates/schema/config/shared_env_var_config/src/lib.rs +++ b/crates/schema/config/shared_env_var_config/src/lib.rs @@ -1 +1,4 @@ +pub mod logging; +pub mod mysql; pub mod paging; +pub mod redis; diff --git a/crates/schema/config/shared_env_var_config/src/logging.rs b/crates/schema/config/shared_env_var_config/src/logging.rs new file mode 100644 index 0000000000..f11c3efbed --- /dev/null +++ b/crates/schema/config/shared_env_var_config/src/logging.rs @@ -0,0 +1,10 @@ +/// NB: `sqlx::query` is spammy and dumps all queries as "info"-level log lines. +/// NB: `hyper::proto::h1::io` is incredibly spammy and logs every chunk of bytes in very large files being downloaded. +pub const DEFAULT_RUST_LOG: &str = concat!( + "actix_web=info,", + "sqlx::query=warn,", + "hyper::proto::h1::io=warn,", + "storyteller_web::threads::db_health_checker_thread::db_health_checker_thread=warn,", + "http_server_common::request::get_request_ip=info,", // Debug spams Rust logs + "info", // Default level for everything else +); diff --git a/crates/schema/config/shared_env_var_config/src/mysql.rs b/crates/schema/config/shared_env_var_config/src/mysql.rs new file mode 100644 index 0000000000..cce39cd44d --- /dev/null +++ b/crates/schema/config/shared_env_var_config/src/mysql.rs @@ -0,0 +1,12 @@ +// ----- Constants ----- + +const ENV_MYSQL_URL: &str = "MYSQL_URL"; + +/// The default MySql connection string for use in development +const DEFAULT_MYSQL_CONNECTION_STRING: &str = "mysql://storyteller:password@localhost/storyteller"; + +// ----- Read Environment Variables ----- + +pub fn env_get_mysql_connection_string_or_default() -> String { + easyenv::get_env_string_or_default(ENV_MYSQL_URL, DEFAULT_MYSQL_CONNECTION_STRING) +} diff --git a/crates/schema/config/shared_env_var_config/src/redis.rs b/crates/schema/config/shared_env_var_config/src/redis.rs new file mode 100644 index 0000000000..29ceaee91c --- /dev/null +++ b/crates/schema/config/shared_env_var_config/src/redis.rs @@ -0,0 +1,20 @@ +// ----- Constants ----- + +const ENV_REDIS_0_URL: &str = "REDIS_0_URL"; +const ENV_REDIS_1_URL: &str = "REDIS_1_URL"; + +/// The default Redis connection string for use in development (database 0) +const DEFAULT_REDIS_DATABASE_0_CONNECTION_STRING: &str = "redis://localhost/0"; + +/// The default Redis connection string for use in development (database 1) +const DEFAULT_REDIS_DATABASE_1_CONNECTION_STRING: &str = "redis://localhost/1"; + +// ----- Read Environment Variables ----- + +pub fn env_get_redis_0_connection_string_or_default() -> String { + easyenv::get_env_string_or_default(ENV_REDIS_0_URL, DEFAULT_REDIS_DATABASE_0_CONNECTION_STRING) +} + +pub fn env_get_redis_1_connection_string_or_default() -> String { + easyenv::get_env_string_or_default(ENV_REDIS_1_URL, DEFAULT_REDIS_DATABASE_1_CONNECTION_STRING) +} diff --git a/crates/service/job/deprecated/analytics_job/Cargo.toml b/crates/service/job/deprecated/analytics_job/Cargo.toml index a673cba824..0f16a7f3bf 100644 --- a/crates/service/job/deprecated/analytics_job/Cargo.toml +++ b/crates/service/job/deprecated/analytics_job/Cargo.toml @@ -18,12 +18,12 @@ normal = ["workspace-build-acceleration"] [dependencies] # Internal -config = { path = "../../../../lib/deprecated/config" } datetimes = { path = "../../../../lib/data/datetimes" } easyenv = { path = "../../../../lib/easyenv" } enums = { workspace = true, default-features = false, features = [] } errors = { path = "../../../../lib/errors" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true reusable_types = { path = "../../../../schema/public/reusable_types" } tokens = { workspace = true, default-features = false, features = [] } diff --git a/crates/service/job/deprecated/analytics_job/src/main.rs b/crates/service/job/deprecated/analytics_job/src/main.rs index 31b17dd4e4..950d76c535 100644 --- a/crates/service/job/deprecated/analytics_job/src/main.rs +++ b/crates/service/job/deprecated/analytics_job/src/main.rs @@ -20,8 +20,8 @@ use log::info; use sqlx::{MySql, Pool}; use sqlx::mysql::MySqlPoolOptions; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use errors::AnyhowResult; use crate::job_state::{JobState, SleepConfigs}; @@ -82,10 +82,7 @@ async fn main() -> AnyhowResult<()> { async fn get_mysql_pool() -> AnyhowResult> { info!("Connecting to MySQL database..."); - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); let mysql_pool = MySqlPoolOptions::new() .max_connections(5) diff --git a/crates/service/job/deprecated/download_job/Cargo.toml b/crates/service/job/deprecated/download_job/Cargo.toml index 88e1daa904..754e07c59e 100644 --- a/crates/service/job/deprecated/download_job/Cargo.toml +++ b/crates/service/job/deprecated/download_job/Cargo.toml @@ -35,6 +35,7 @@ hashing = { path = "../../../../lib/files/hashing" } jobs_common = { path = "../../../../lib/jobs_common" } mimetypes.workspace = true mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true reusable_types = { path = "../../../../schema/public/reusable_types" } storyteller_root = { path = "../../../../lib/storyteller_root" } subprocess_common = { path = "../../../../lib/deprecated/subprocess_common" } @@ -42,6 +43,7 @@ tokens.workspace = true # External anyhow.workspace = true +url.workspace = true chrono.workspace = true dotenv.workspace = true hostname.workspace = true diff --git a/crates/lib/deprecated/config/src/is_bad_download_url.rs b/crates/service/job/deprecated/download_job/src/job_loop/is_bad_download_url.rs similarity index 94% rename from crates/lib/deprecated/config/src/is_bad_download_url.rs rename to crates/service/job/deprecated/download_job/src/job_loop/is_bad_download_url.rs index 907d68cbcf..11f47d9395 100644 --- a/crates/lib/deprecated/config/src/is_bad_download_url.rs +++ b/crates/service/job/deprecated/download_job/src/job_loop/is_bad_download_url.rs @@ -1,5 +1,4 @@ -//! Probably should be in its own "static_config" crate. - +use log::debug; use url::{Host, Url}; /// Reports if the URL is inappropriate for downloading as a TTS model, vocoder, etc. @@ -31,7 +30,7 @@ pub fn is_bad_download_url(url: &str) -> anyhow::Result { || domain.contains("youtu.be") || domain.contains("youtube.com"); - println!("domain: {:?}", domain); + debug!("domain: {:?}", domain); if bad_host { return Ok(true) @@ -45,7 +44,7 @@ pub fn is_bad_download_url(url: &str) -> anyhow::Result { #[cfg(test)] mod tests { - use crate::is_bad_download_url::is_bad_download_url; + use super::*; #[test] fn bad_download_url() { diff --git a/crates/service/job/deprecated/download_job/src/job_loop/mod.rs b/crates/service/job/deprecated/download_job/src/job_loop/mod.rs index bdf999f044..c98bcf6215 100644 --- a/crates/service/job/deprecated/download_job/src/job_loop/mod.rs +++ b/crates/service/job/deprecated/download_job/src/job_loop/mod.rs @@ -1,3 +1,4 @@ +mod is_bad_download_url; pub mod job_results; pub mod main_loop; pub mod process_single_job; diff --git a/crates/service/job/deprecated/download_job/src/job_loop/process_single_job.rs b/crates/service/job/deprecated/download_job/src/job_loop/process_single_job.rs index adce05827b..aa076cbda3 100644 --- a/crates/service/job/deprecated/download_job/src/job_loop/process_single_job.rs +++ b/crates/service/job/deprecated/download_job/src/job_loop/process_single_job.rs @@ -4,7 +4,7 @@ use anyhow::anyhow; use log::{info, warn}; use tempdir::TempDir; -use config::is_bad_download_url::is_bad_download_url; +use crate::job_loop::is_bad_download_url::is_bad_download_url; use errors::AnyhowResult; use filesys::file_deletion::safe_delete_directory::safe_delete_directory; use jobs_common::redis_job_status_logger::RedisJobStatusLogger; diff --git a/crates/service/job/deprecated/download_job/src/main.rs b/crates/service/job/deprecated/download_job/src/main.rs index 6d8c32e58e..9362a92fb1 100644 --- a/crates/service/job/deprecated/download_job/src/main.rs +++ b/crates/service/job/deprecated/download_job/src/main.rs @@ -18,7 +18,6 @@ #[macro_use] extern crate serde_derive; -use std::ops::Deref; use std::path::PathBuf; use std::time::Duration; @@ -32,8 +31,9 @@ use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use cloud_storage::bucket_client::BucketClient; use bucket_paths::legacy::old_bespoke_paths::bucket_path_unifier::BucketPathUnifier; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; use google_drive_downloader::google_drive_download_command::GoogleDriveDownloadCommand; @@ -312,10 +312,7 @@ async fn main() -> AnyhowResult<()> { check_directory_exists(&temp_directory)?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); @@ -328,8 +325,8 @@ async fn main() -> AnyhowResult<()> { info!("Connecting to redis..."); - let redis_manager = - RedisConnectionManager::new(common_env.redis_0_connection_string.deref())?; + let redis_connection_string = env_get_redis_0_connection_string_or_default(); + let redis_manager = RedisConnectionManager::new(redis_connection_string.as_str())?; let redis_pool = r2d2::Pool::builder() .build(redis_manager)?; diff --git a/crates/service/job/deprecated/email_sender_job/Cargo.toml b/crates/service/job/deprecated/email_sender_job/Cargo.toml index 0598738978..4d5510b2e3 100644 --- a/crates/service/job/deprecated/email_sender_job/Cargo.toml +++ b/crates/service/job/deprecated/email_sender_job/Cargo.toml @@ -31,6 +31,7 @@ errors = { workspace = true } filesys = { path = "../../../../lib/files/filesys" } jobs_common = { path = "../../../../lib/jobs_common" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true server_environment = { path = "../../../../lib/server_environment" } # External diff --git a/crates/service/job/deprecated/email_sender_job/src/main.rs b/crates/service/job/deprecated/email_sender_job/src/main.rs index 32c1838afd..4dbd376415 100644 --- a/crates/service/job/deprecated/email_sender_job/src/main.rs +++ b/crates/service/job/deprecated/email_sender_job/src/main.rs @@ -27,8 +27,8 @@ use sqlx::mysql::MySqlPoolOptions; use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use concurrency::relaxed_atomic_bool::RelaxedAtomicBool; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use email_sender::smtp_email_sender::SmtpEmailSender; use errors::AnyhowResult; use jobs_common::job_progress_reporter::job_progress_reporter::JobProgressReporterBuilder; @@ -63,10 +63,7 @@ async fn main() -> AnyhowResult<()> { let _k8s_node_name = easyenv::get_env_string_optional("K8S_NODE_NAME"); let _k8s_pod_name = easyenv::get_env_string_optional("K8S_POD_NAME"); - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); diff --git a/crates/service/job/deprecated/es-update-job/Cargo.toml b/crates/service/job/deprecated/es-update-job/Cargo.toml index c6a714d166..2b3ba3c0e6 100644 --- a/crates/service/job/deprecated/es-update-job/Cargo.toml +++ b/crates/service/job/deprecated/es-update-job/Cargo.toml @@ -19,12 +19,12 @@ normal = ["workspace-build-acceleration"] # Internal bootstrap = { path = "../../../../lib/bootstrap" } -config = { path = "../../../../lib/deprecated/config" } easyenv = { path = "../../../../lib/easyenv" } elasticsearch_schema = { path = "../../../../schema/database/elasticsearch_schema" } enums = { path = "../../../../schema/public/enums" } errors = { path = "../../../../lib/errors" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true primitives = { path = "../../../../lib/data/primitives" } reusable_types = { path = "../../../../schema/public/reusable_types" } server_environment = { path = "../../../../lib/server_environment" } diff --git a/crates/service/job/deprecated/es-update-job/src/main.rs b/crates/service/job/deprecated/es-update-job/src/main.rs index e6ba47fd54..9199c96e8e 100644 --- a/crates/service/job/deprecated/es-update-job/src/main.rs +++ b/crates/service/job/deprecated/es-update-job/src/main.rs @@ -25,8 +25,8 @@ use sqlx::{MySql, Pool}; use sqlx::mysql::MySqlPoolOptions; use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use errors::AnyhowResult; use crate::job_state::{JobState, SleepConfigs}; @@ -100,10 +100,7 @@ async fn main() -> AnyhowResult<()> { async fn get_mysql_pool() -> AnyhowResult> { info!("Connecting to MySQL database..."); - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); let mysql_pool = MySqlPoolOptions::new() .max_connections(5) diff --git a/crates/service/job/deprecated/inference_job/Cargo.toml b/crates/service/job/deprecated/inference_job/Cargo.toml index dfd6cc40b6..75321c4cdb 100644 --- a/crates/service/job/deprecated/inference_job/Cargo.toml +++ b/crates/service/job/deprecated/inference_job/Cargo.toml @@ -42,6 +42,7 @@ memory_caching = { path = "../../../../lib/caching/memory_caching" } migration = { path = "../../../../schema/database/migration" } mimetypes = { path = "../../../../lib/files/mimetypes" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true primitives.workspace = true redis_common = { path = "../../../../schema/database/redis_common" } redis_schema = { path = "../../../../schema/database/redis_schema" } diff --git a/crates/service/job/deprecated/inference_job/src/main.rs b/crates/service/job/deprecated/inference_job/src/main.rs index f9c89c5236..c60534d1e6 100644 --- a/crates/service/job/deprecated/inference_job/src/main.rs +++ b/crates/service/job/deprecated/inference_job/src/main.rs @@ -31,8 +31,8 @@ use bucket_paths::legacy::old_bespoke_paths::bucket_path_unifier::BucketPathUnif use cloud_storage::bucket_client::BucketClient; use concurrency::relaxed_atomic_bool::RelaxedAtomicBool; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; use filesys::create_dir_all_if_missing::create_dir_all_if_missing; @@ -153,10 +153,7 @@ async fn main() -> AnyhowResult<()> { easyenv::get_env_pathbuf_or_default("SEMI_PERSISTENT_DIR_ROOT", PathBuf::from("/tmp/persistent"))); - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to MySQL database..."); diff --git a/crates/service/job/deprecated/tts_download_job/Cargo.toml b/crates/service/job/deprecated/tts_download_job/Cargo.toml index 4925f0a62d..05a6f425b3 100644 --- a/crates/service/job/deprecated/tts_download_job/Cargo.toml +++ b/crates/service/job/deprecated/tts_download_job/Cargo.toml @@ -29,6 +29,7 @@ google_drive_downloader = { path = "../../../../api_clients/google_drive_downloa hashing = { path = "../../../../lib/files/hashing" } jobs_common = { path = "../../../../lib/jobs_common" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true # Workspace hack (faster compile times) workspace-build-acceleration = { version = "0.1", path = "../../../../workspace-build-acceleration" } diff --git a/crates/service/job/deprecated/tts_download_job/src/main.rs b/crates/service/job/deprecated/tts_download_job/src/main.rs index 765a36093a..e8e0b65b76 100644 --- a/crates/service/job/deprecated/tts_download_job/src/main.rs +++ b/crates/service/job/deprecated/tts_download_job/src/main.rs @@ -15,7 +15,6 @@ use std::fs; use std::fs::File; use std::io::{BufReader, Error, Read}; -use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::Command; use std::time::Duration; @@ -33,8 +32,9 @@ use cloud_storage::bucket_client::BucketClient; use bucket_paths::legacy::old_bespoke_paths::bucket_path_unifier::BucketPathUnifier; use config::bad_urls::is_bad_tts_model_download_url; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use enums::by_table::tts_models::tts_model_type::TtsModelType; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; @@ -153,10 +153,7 @@ async fn main() -> AnyhowResult<()> { check_directory_exists(&temp_directory)?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); @@ -169,8 +166,8 @@ async fn main() -> AnyhowResult<()> { info!("Connecting to redis..."); - let redis_manager = - RedisConnectionManager::new(common_env.redis_0_connection_string.deref())?; + let redis_connection_string = env_get_redis_0_connection_string_or_default(); + let redis_manager = RedisConnectionManager::new(redis_connection_string.as_str())?; let redis_pool = r2d2::Pool::builder() .build(redis_manager)?; diff --git a/crates/service/job/deprecated/tts_inference_job/Cargo.toml b/crates/service/job/deprecated/tts_inference_job/Cargo.toml index 00a8bb3cf0..4eb3c58328 100644 --- a/crates/service/job/deprecated/tts_inference_job/Cargo.toml +++ b/crates/service/job/deprecated/tts_inference_job/Cargo.toml @@ -31,6 +31,7 @@ hashing = { path = "../../../../lib/files/hashing" } jobs_common = { path = "../../../../lib/jobs_common" } memory_caching = { path = "../../../../lib/caching/memory_caching" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true tts_common = { path = "../../../../lib/deprecated/tts_common" } # External diff --git a/crates/service/job/deprecated/tts_inference_job/src/main.rs b/crates/service/job/deprecated/tts_inference_job/src/main.rs index 56d0022b7a..94f852092b 100644 --- a/crates/service/job/deprecated/tts_inference_job/src/main.rs +++ b/crates/service/job/deprecated/tts_inference_job/src/main.rs @@ -29,8 +29,8 @@ use cloud_storage::bucket_client::BucketClient; use bucket_paths::legacy::old_bespoke_paths::bucket_path_unifier::BucketPathUnifier; use collections::multiple_random_from_vec::multiple_random_from_vec; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; use jobs_common::job_progress_reporter::job_progress_reporter::JobProgressReporterBuilder; @@ -165,10 +165,7 @@ async fn main() -> AnyhowResult<()> { check_directory_exists(&temp_directory)?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); diff --git a/crates/service/job/deprecated/w2l_download_job/Cargo.toml b/crates/service/job/deprecated/w2l_download_job/Cargo.toml index 07310e0a02..c5ffc16fcd 100644 --- a/crates/service/job/deprecated/w2l_download_job/Cargo.toml +++ b/crates/service/job/deprecated/w2l_download_job/Cargo.toml @@ -30,6 +30,7 @@ google_drive_downloader = { path = "../../../../api_clients/google_drive_downloa hashing = { path = "../../../../lib/files/hashing" } jobs_common = { path = "../../../../lib/jobs_common" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true # External anyhow.workspace = true diff --git a/crates/service/job/deprecated/w2l_download_job/src/main.rs b/crates/service/job/deprecated/w2l_download_job/src/main.rs index 9b81e05322..13a6c0d0c8 100644 --- a/crates/service/job/deprecated/w2l_download_job/src/main.rs +++ b/crates/service/job/deprecated/w2l_download_job/src/main.rs @@ -14,7 +14,6 @@ use std::fs::{File, metadata}; use std::io::{BufReader, Read}; -use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::Command; use std::thread; @@ -32,8 +31,9 @@ use tempdir::TempDir; use cloud_storage::bucket_client::BucketClient; use config::common_env::CommonEnv; use config::is_bad_video_download_url::is_bad_video_download_url; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; use filesys::check_file_exists::check_file_exists; @@ -201,10 +201,7 @@ async fn main() -> AnyhowResult<()> { check_directory_exists(&temp_directory)?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); @@ -217,8 +214,8 @@ async fn main() -> AnyhowResult<()> { info!("Connecting to redis..."); - let redis_manager = - RedisConnectionManager::new(common_env.redis_0_connection_string.deref())?; + let redis_connection_string = env_get_redis_0_connection_string_or_default(); + let redis_manager = RedisConnectionManager::new(redis_connection_string.as_str())?; let redis_pool = r2d2::Pool::builder() .build(redis_manager)?; diff --git a/crates/service/job/deprecated/w2l_inference_job/Cargo.toml b/crates/service/job/deprecated/w2l_inference_job/Cargo.toml index 45058aeacd..10324033b4 100644 --- a/crates/service/job/deprecated/w2l_inference_job/Cargo.toml +++ b/crates/service/job/deprecated/w2l_inference_job/Cargo.toml @@ -30,6 +30,7 @@ filesys.workspace = true google_drive_downloader = { path = "../../../../api_clients/google_drive_downloader" } jobs_common = { path = "../../../../lib/jobs_common" } mysql_queries = { path = "../../../../schema/database/mysql_queries" } +shared_env_var_config.workspace = true # External anyhow.workspace = true diff --git a/crates/service/job/deprecated/w2l_inference_job/src/main.rs b/crates/service/job/deprecated/w2l_inference_job/src/main.rs index 0c1cf7256f..1635d54744 100644 --- a/crates/service/job/deprecated/w2l_inference_job/src/main.rs +++ b/crates/service/job/deprecated/w2l_inference_job/src/main.rs @@ -14,7 +14,6 @@ use std::fs::{File, metadata}; use std::io::{BufReader, Read}; -use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::Command; use std::thread; @@ -34,8 +33,9 @@ use tempdir::TempDir; use cloud_storage::bucket_client::BucketClient; use bucket_paths::legacy::old_bespoke_paths::bucket_path_unifier::BucketPathUnifier; use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use errors::AnyhowResult; use filesys::check_directory_exists::check_directory_exists; use filesys::check_file_exists::check_file_exists; @@ -195,10 +195,7 @@ async fn main() -> AnyhowResult<()> { check_directory_exists(&temp_directory)?; - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); @@ -211,8 +208,8 @@ async fn main() -> AnyhowResult<()> { info!("Connecting to redis..."); - let redis_manager = - RedisConnectionManager::new(common_env.redis_0_connection_string.deref())?; + let redis_connection_string = env_get_redis_0_connection_string_or_default(); + let redis_manager = RedisConnectionManager::new(redis_connection_string.as_str())?; let redis_pool = r2d2::Pool::builder() .build(redis_manager)?; diff --git a/crates/service/job/seedance2_pro_job/Cargo.toml b/crates/service/job/seedance2_pro_job/Cargo.toml index aeb77b0ba8..7f22c4e4b4 100644 --- a/crates/service/job/seedance2_pro_job/Cargo.toml +++ b/crates/service/job/seedance2_pro_job/Cargo.toml @@ -25,7 +25,6 @@ bootstrap.workspace = true bucket_paths.workspace = true cloud_storage.workspace = true concurrency.workspace = true -config = { path = "../../../lib/deprecated/config" } easyenv.workspace = true enums.workspace = true errors.workspace = true diff --git a/crates/service/job/seedance2_pro_job/src/main.rs b/crates/service/job/seedance2_pro_job/src/main.rs index 9c603ed7c2..457603930f 100644 --- a/crates/service/job/seedance2_pro_job/src/main.rs +++ b/crates/service/job/seedance2_pro_job/src/main.rs @@ -18,12 +18,12 @@ use sqlx::mysql::MySqlPoolOptions; use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use cloud_storage::bucket_client::BucketClient; use concurrency::relaxed_atomic_bool::RelaxedAtomicBool; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use errors::AnyhowResult; use jobs_common::job_stats::JobStats; use seedance2pro_client::creds::seedance2pro_session::Seedance2ProSession; use server_environment::ServerEnvironment; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use crate::http_server::run_http_server::{launch_http_server, CreateServerArgs}; use crate::jobs::character_polling_job::character_polling_main_loop::character_polling_main_loop; @@ -59,10 +59,7 @@ async fn main() -> AnyhowResult<()> { let _k8s_node_name = easyenv::get_env_string_optional("K8S_NODE_NAME"); let _k8s_pod_name = easyenv::get_env_string_optional("K8S_POD_NAME"); - let db_connection_string = easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING, - ); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); diff --git a/crates/service/job/video_thumbnail_job/Cargo.toml b/crates/service/job/video_thumbnail_job/Cargo.toml index c9215a15c6..4ddef52d19 100644 --- a/crates/service/job/video_thumbnail_job/Cargo.toml +++ b/crates/service/job/video_thumbnail_job/Cargo.toml @@ -26,7 +26,6 @@ bucket_paths.workspace = true cloud_storage.workspace = true ffmpeg_utils.workspace = true concurrency.workspace = true -config = { path = "../../../lib/deprecated/config" } easyenv.workspace = true errors.workspace = true jobs_common.workspace = true diff --git a/crates/service/job/video_thumbnail_job/src/main.rs b/crates/service/job/video_thumbnail_job/src/main.rs index 74c06d5ace..3ee0d9a9a0 100644 --- a/crates/service/job/video_thumbnail_job/src/main.rs +++ b/crates/service/job/video_thumbnail_job/src/main.rs @@ -19,11 +19,11 @@ use sqlx::mysql::MySqlPoolOptions; use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use cloud_storage::bucket_client::BucketClient; use concurrency::relaxed_atomic_bool::RelaxedAtomicBool; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use errors::AnyhowResult; use jobs_common::job_stats::JobStats; use server_environment::ServerEnvironment; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use crate::http_server::run_http_server::{launch_http_server, CreateServerArgs}; use crate::job::main_loop::main_loop; @@ -57,10 +57,7 @@ async fn main() -> AnyhowResult<()> { let _k8s_node_name = easyenv::get_env_string_optional("K8S_NODE_NAME"); let _k8s_pod_name = easyenv::get_env_string_optional("K8S_POD_NAME"); - let db_connection_string = easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING, - ); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); diff --git a/crates/service/job/worldlabs_job/Cargo.toml b/crates/service/job/worldlabs_job/Cargo.toml index 59e28475ff..2595378c65 100644 --- a/crates/service/job/worldlabs_job/Cargo.toml +++ b/crates/service/job/worldlabs_job/Cargo.toml @@ -25,7 +25,6 @@ bootstrap.workspace = true bucket_paths.workspace = true cloud_storage.workspace = true concurrency.workspace = true -config = { path = "../../../lib/deprecated/config" } easyenv.workspace = true enums.workspace = true errors.workspace = true @@ -34,6 +33,7 @@ jobs_common.workspace = true mysql_queries.workspace = true worldlabs_api_client.workspace = true server_environment = { path = "../../../lib/server_environment" } +shared_env_var_config.workspace = true tokens.workspace = true # External diff --git a/crates/service/job/worldlabs_job/src/main.rs b/crates/service/job/worldlabs_job/src/main.rs index 30005a1bac..bd52bc7a56 100644 --- a/crates/service/job/worldlabs_job/src/main.rs +++ b/crates/service/job/worldlabs_job/src/main.rs @@ -18,11 +18,11 @@ use sqlx::mysql::MySqlPoolOptions; use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use cloud_storage::bucket_client::BucketClient; use concurrency::relaxed_atomic_bool::RelaxedAtomicBool; -use config::shared_constants::DEFAULT_MYSQL_CONNECTION_STRING; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; use errors::AnyhowResult; use jobs_common::job_stats::JobStats; use server_environment::ServerEnvironment; +use shared_env_var_config::mysql::env_get_mysql_connection_string_or_default; use worldlabs_api_client::credentials::world_labs_api_creds::WorldLabsApiCreds; use crate::http_server::run_http_server::{launch_http_server, CreateServerArgs}; @@ -57,10 +57,7 @@ async fn main() -> AnyhowResult<()> { let _k8s_node_name = easyenv::get_env_string_optional("K8S_NODE_NAME"); let _k8s_pod_name = easyenv::get_env_string_optional("K8S_POD_NAME"); - let db_connection_string = easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING, - ); + let db_connection_string = env_get_mysql_connection_string_or_default(); info!("Connecting to database..."); diff --git a/crates/service/web/storyteller_web/Cargo.toml b/crates/service/web/storyteller_web/Cargo.toml index 0f6bec1caa..d9869bea40 100644 --- a/crates/service/web/storyteller_web/Cargo.toml +++ b/crates/service/web/storyteller_web/Cargo.toml @@ -70,7 +70,6 @@ rootly_client.workspace = true rootly_config.workspace = true shared_env_var_config.workspace = true primitives = { path = "../../../lib/data/primitives" } -prompt_engineering = { path = "../../../lib/deprecated/machine_learning/prompt_engineering" } redis_caching = { path = "../../../lib/caching/redis_caching" } redis_common = { path = "../../../schema/database/redis_common" } redis_schema = { path = "../../../schema/database/redis_schema" } diff --git a/crates/service/web/storyteller_web/src/configs/app_startup/redis_rate_limiters.rs b/crates/service/web/storyteller_web/src/configs/app_startup/redis_rate_limiters.rs index 3c4cbb16c4..21db936680 100644 --- a/crates/service/web/storyteller_web/src/configs/app_startup/redis_rate_limiters.rs +++ b/crates/service/web/storyteller_web/src/configs/app_startup/redis_rate_limiters.rs @@ -2,26 +2,26 @@ use std::time::Duration; use log::info; -use config::common_env::CommonEnv; use errors::AnyhowResult; use limitation::Limiter; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use crate::configs::app_startup::username_set::UsernameSet; use crate::http_server::web_utils::redis_rate_limiter::RedisRateLimiter; use crate::state::server_state::RedisRateLimiters; /// Build the various rate limiters -pub fn configure_redis_rate_limiters(common_env: &CommonEnv) -> AnyhowResult { - // TODO(bt,2023-12-13): Kill CommonEnv. - +pub fn configure_redis_rate_limiters() -> AnyhowResult { info!("Setting up Redis rate limiters..."); + let redis_connection_string = env_get_redis_0_connection_string_or_default(); + let logged_out_redis_rate_limiter = { let limiter_enabled = easyenv::get_env_bool_or_default("LIMITER_LOGGED_OUT_ENABLED", true); let limiter_max_requests = easyenv::get_env_num("LIMITER_LOGGED_OUT_MAX_REQUESTS", 3)?; let limiter_window_seconds = easyenv::get_env_num("LIMITER_LOGGED_OUT_WINDOW_SECONDS", 10)?; - let limiter = Limiter::build(&common_env.redis_0_connection_string) + let limiter = Limiter::build(&redis_connection_string) .limit(limiter_max_requests) .period(Duration::from_secs(limiter_window_seconds)) .finish()?; @@ -34,7 +34,7 @@ pub fn configure_redis_rate_limiters(common_env: &CommonEnv) -> AnyhowResult AnyhowResult AnyhowResult AnyhowResult AnyhowResult AnyhowResult AnyhowResult{ - let db_connection_string = - easyenv::get_env_string_or_default( - "MYSQL_URL", - DEFAULT_MYSQL_CONNECTION_STRING); + let db_connection_string = env_get_mysql_connection_string_or_default(); let pool_options = MySqlPoolOptions::new() .max_connections(easyenv::get_env_num("MYSQL_MAX_CONNECTIONS", 5)?); diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/enqueue_image_generation.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/enqueue_image_generation.rs index 14bc0967d0..b71f7b6cf7 100644 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/enqueue_image_generation.rs +++ b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/enqueue_image_generation.rs @@ -37,7 +37,6 @@ use tokens::tokens::model_weights::ModelWeightToken; use tokens::tokens::users::UserToken; use crate::configs::plans::get_correct_plan_for_session::get_correct_plan_for_session; -use crate::http_server::deprecated_endpoints::image_gen::prompt_enrichment::enrich_prompt; use crate::http_server::validations::validate_idempotency_token_format::validate_idempotency_token_format; use crate::http_server::web_utils::response_error_helpers::to_simple_json_error; use crate::state::server_state::ServerState; @@ -382,13 +381,11 @@ pub async fn enqueue_image_generation_request( version = s; } - let maybe_enriched_prompts = enrich_prompt(&request); - let inference_args = StableDiffusionArgs { maybe_sd_model_token: Some(sd_weight_token), maybe_lora_model_token: Some(lora_token), - maybe_prompt: maybe_enriched_prompts.as_ref().map(|p| p.positive_prompt.clone()), - maybe_n_prompt: maybe_enriched_prompts.as_ref().and_then(|p| p.maybe_negative_prompt.clone()), + maybe_prompt: request.maybe_prompt.clone(), + maybe_n_prompt: request.maybe_n_prompt.clone(), maybe_seed: Some(seed), maybe_upload_path: maybe_sd_upload_url, maybe_lora_upload_path: maybe_lora_upload_url, diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/mod.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/mod.rs index e0af7fc8c0..460b32b57c 100644 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/mod.rs +++ b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/mod.rs @@ -1,4 +1,2 @@ pub mod enqueue_image_generation; -pub mod enqueue_generation_type; -mod replacement_prompts; -mod prompt_enrichment; \ No newline at end of file +pub mod enqueue_generation_type; \ No newline at end of file diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/prompt_enrichment.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/prompt_enrichment.rs deleted file mode 100644 index 03a02de94d..0000000000 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/prompt_enrichment.rs +++ /dev/null @@ -1,174 +0,0 @@ -use prompt_engineering::classify_prompt::classify_prompt; - -use crate::http_server::deprecated_endpoints::image_gen::enqueue_image_generation::EnqueueImageGenRequest; -use crate::http_server::deprecated_endpoints::image_gen::replacement_prompts::get_replacement_prompt; - -pub struct EnrichedPrompts { - pub positive_prompt: String, - pub maybe_negative_prompt: Option, -} - -const DEFAULT_NEGATIVE_PROMPT : &str = "nudity, nsfw, naked, sex"; - -const ADD_TO_NSFW_POSITIVE_PROMPT: &str = "legal adult, legal age"; -const ADD_TO_NSFW_NEGATIVE_PROMPT: &str = "underage, child, minor, kid, children, young, youngling, younglings"; - -/// Enrich the user-provided prompts. -/// In the future, we can add prompt engineering to these. -pub fn enrich_prompt(request: &EnqueueImageGenRequest) -> Option { - let mut positive_prompt = match request.maybe_prompt.as_deref() { - None => return None, // NB: Some callers aren't running prompts. - Some(prompt) => prompt.to_string(), - }; - - let mut maybe_negative_prompt = request.maybe_n_prompt - .as_ref() - .map(|prompt| prompt.to_string()); - - let classification = classify_prompt(&positive_prompt); - - if !classification.prompt_references_sex { - // If the prompt doesn't have sex terms in it, try to make sure it doesn't get generated. - match maybe_negative_prompt.as_deref() { - None => { - maybe_negative_prompt = Some(DEFAULT_NEGATIVE_PROMPT.to_string()); - } - Some(negative_prompt) => { - let new_negative_prompt = format!("{}, {}", negative_prompt, DEFAULT_NEGATIVE_PROMPT); - maybe_negative_prompt = Some(new_negative_prompt); - } - } - } - - if classification.prompt_references_sex { - if !classification.is_abusive() { - // Abusive cases get handled below - positive_prompt = format!("{}, {}", positive_prompt, ADD_TO_NSFW_POSITIVE_PROMPT); - } - - match maybe_negative_prompt.as_deref() { - None => { - maybe_negative_prompt = Some(ADD_TO_NSFW_NEGATIVE_PROMPT.to_string()); - } - Some(negative_prompt) => { - let new_negative_prompt = format!("{}, {}", negative_prompt, ADD_TO_NSFW_NEGATIVE_PROMPT); - maybe_negative_prompt = Some(new_negative_prompt); - } - } - } - - // These prompts get treated harshly. - if classification.is_abusive() { - // NB: Save the original prompt as the negative prompt so that we can study it. - maybe_negative_prompt = Some(positive_prompt.clone()); - positive_prompt = get_replacement_prompt().to_string(); - } - - Some(EnrichedPrompts { - positive_prompt, - maybe_negative_prompt, - }) -} - -#[cfg(test)] -mod tests { - use crate::http_server::deprecated_endpoints::image_gen::enqueue_image_generation::EnqueueImageGenRequest; - use crate::http_server::deprecated_endpoints::image_gen::prompt_enrichment::enrich_prompt; - - struct Prompt { - pub positive: &'static str, - pub maybe_negative: Option<&'static str>, - } - - impl Prompt { - fn positive(positive: &'static str) -> Self { - Self { - positive, - maybe_negative: None, - } - } - - fn positive_negative(positive: &'static str, negative: &'static str) -> Self { - Self { - positive, - maybe_negative: Some(negative), - } - } - - fn to_request(&self) -> EnqueueImageGenRequest { - EnqueueImageGenRequest { - maybe_prompt: Some(self.positive.to_string()), - maybe_n_prompt: self.maybe_negative.as_deref().map(|s| s.to_string()), - ..Default::default() - } - } - } - - mod sfw { - use super::*; - - #[test] - fn sfw_prompt_no_negative_prompt() { - let result = enrich_prompt(&Prompt::positive("hello").to_request()).unwrap(); - - assert_eq!(result.positive_prompt, "hello".to_string()); - assert_eq!(result.maybe_negative_prompt, Some("nudity, nsfw, naked, sex".to_string())); - } - - #[test] - fn sfw_prompt_with_negative_prompt() { - let result = enrich_prompt(&Prompt::positive_negative("hello", "goodbye").to_request()).unwrap(); - - assert_eq!(result.positive_prompt, "hello".to_string()); - assert_eq!(result.maybe_negative_prompt, Some("goodbye, nudity, nsfw, naked, sex".to_string())); - } - } - - mod nsfw { - use super::*; - - #[test] - fn legal_nsfw_prompt_no_negative_prompt() { - let result = enrich_prompt(&Prompt::positive("sex").to_request()).unwrap(); - - assert_eq!(result.positive_prompt, "sex, legal adult, legal age".to_string()); - assert_eq!(result.maybe_negative_prompt, Some("underage, child, minor, kid, children, young, youngling, younglings".to_string())); - } - - #[test] - fn legal_nsfw_prompt_with_negative_prompt() { - let result = enrich_prompt(&Prompt::positive_negative("sex", "goodbye").to_request()).unwrap(); - - assert_eq!(result.positive_prompt, "sex, legal adult, legal age".to_string()); - assert_eq!(result.maybe_negative_prompt, Some("goodbye, underage, child, minor, kid, children, young, youngling, younglings".to_string())); - } - } - - mod illegal { - use super::*; - - #[test] - fn csam_prompt_no_negative_prompt() { - let result = enrich_prompt(&Prompt::positive("underage sex").to_request()).unwrap(); - - // Scrubbed from prompt - assert!(!result.positive_prompt.contains("underage")); - assert!(!result.positive_prompt.contains("sex")); - - // Bad prompt is preserved as the negative prompt - assert_eq!(result.maybe_negative_prompt, Some("underage sex".to_string())); - } - - #[test] - fn csam_prompt_with_negative_prompt() { - let result = enrich_prompt(&Prompt::positive_negative("underage sex", "goodbye").to_request()).unwrap(); - - // Scrubbed from prompt - assert!(!result.positive_prompt.contains("underage")); - assert!(!result.positive_prompt.contains("sex")); - - // Bad prompt is preserved as the negative prompt - assert_eq!(result.maybe_negative_prompt, Some("underage sex".to_string())); - } - } -} diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/replacement_prompts.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/replacement_prompts.rs deleted file mode 100644 index 67532a1fb6..0000000000 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/image_gen/replacement_prompts.rs +++ /dev/null @@ -1,14 +0,0 @@ -use collections::random_from_array::random_from_array; - -const REPLACEMENT_PROMPTS : [&str; 4] = [ - "angry president bush, disappointed George Bush, single person, pointing in accusation, disappointed at the viewer, trying to teach the user a lesson, furrowed brow, sad, angry, disappointed, high quality, good art, best quality, amazing detail, masterpiece", - "angry president obama, disappointed Barack Obama, single person, pointing in accusation, disappointed at the viewer, trying to teach the user a lesson, furrowed brow, sad, angry, disappointed, high quality, good art, best quality, amazing detail, masterpiece", - "angry elvis, disappointed Elvis Presley, single person, pointing in accusation, disappointed at the viewer, trying to teach the user a lesson, furrowed brow, sad, angry, disappointed, high quality, good art, best quality, amazing detail, masterpiece", - "angry Queen Elizabeth, disappointed Queen Elizabeth II, single person, pointing in accusation, disappointed at the viewer, trying to teach the user a lesson, furrowed brow, sad, angry, disappointed, high quality, good art, best quality, amazing detail, masterpiece", -]; - -/// If the user inputs a abusive, controversial, or bad prompt, replace the prompt with one of these. -pub fn get_replacement_prompt() -> &'static str { - random_from_array(&REPLACEMENT_PROMPTS) - .unwrap_or(&REPLACEMENT_PROMPTS[0]) -} diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_server.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_server.rs index a5109c9241..6edd6f535c 100644 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_server.rs +++ b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_server.rs @@ -11,6 +11,7 @@ use std::{ }; use actix::prelude::*; +use log::info; use rand::{rngs::ThreadRng, Rng}; /// Chat server sends this messages to session @@ -119,7 +120,7 @@ impl Handler for ChatServer { type Result = usize; fn handle(&mut self, msg: Connect, _: &mut Context) -> Self::Result { - println!("Someone joined"); + info!("Someone joined"); // notify all users in same room self.send_message("main", "Someone joined", 0); @@ -144,7 +145,7 @@ impl Handler for ChatServer { type Result = (); fn handle(&mut self, msg: Disconnect, _: &mut Context) { - println!("Someone disconnected"); + info!("Someone disconnected"); let mut rooms: Vec = Vec::new(); diff --git a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_session.rs b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_session.rs index d050faa44b..f7a055a6c1 100644 --- a/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_session.rs +++ b/crates/service/web/storyteller_web/src/http_server/deprecated_endpoints/workflows/enqueue/progress_tracker_session.rs @@ -2,6 +2,7 @@ use std::time::{Duration, Instant}; use actix::prelude::*; use actix_web_actors::ws; +use log::{debug, info, warn}; use crate::http_server::deprecated_endpoints::workflows::enqueue::progress_tracker_server; use crate::http_server::deprecated_endpoints::workflows::enqueue::progress_tracker_server::ChatServer; @@ -40,7 +41,7 @@ impl WsChatSession { // check client heartbeats if Instant::now().duration_since(act.hb) > CLIENT_TIMEOUT { // heartbeat timed out - println!("Websocket Client heartbeat failed, disconnecting!"); + warn!("Websocket Client heartbeat failed, disconnecting!"); // notify chat server act.addr.do_send(progress_tracker_server::Disconnect { id: act.id }); @@ -134,7 +135,7 @@ impl StreamHandler> for WsChatSession { "/list" => { // Send ListRooms message to chat server and wait for // response - println!("List rooms"); + debug!("List rooms"); self.addr .send(progress_tracker_server::ListRooms) .into_actor(self) @@ -145,7 +146,7 @@ impl StreamHandler> for WsChatSession { ctx.text(room); } } - _ => println!("Something is wrong"), + _ => warn!("Something is wrong"), } fut::ready(()) }) @@ -190,7 +191,7 @@ impl StreamHandler> for WsChatSession { }) } } - ws::Message::Binary(_) => println!("Unexpected binary"), + ws::Message::Binary(_) => warn!("Unexpected binary"), ws::Message::Close(reason) => { ctx.close(reason); ctx.stop(); diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs deleted file mode 100644 index bba0d7ad31..0000000000 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/list_banned_users.rs +++ /dev/null @@ -1,111 +0,0 @@ -use std::fmt; -use std::sync::Arc; - -use actix_web::error::ResponseError; -use actix_web::http::StatusCode; -use actix_web::{web, HttpRequest, HttpResponse}; -use log::warn; - -use crate::http_server::web_utils::serialize_as_json_error::serialize_as_json_error; -use crate::state::server_state::ServerState; - -// TODO: Implement the endpoint -#[derive(Deserialize)] -pub struct ListBannedUsersRequest; - -// TODO: Implement the endpoint -#[derive(Serialize)] -pub struct ListBannedUsersResponse; - -#[derive(Serialize, Debug)] -pub struct ListBannedUsersErrorResponse { - pub success: bool, - pub error_type: ListBannedUsersErrorType, - pub error_message: String, -} - -#[derive(Copy, Clone, Debug, Serialize)] -pub enum ListBannedUsersErrorType { - BadInput, - ServerError, - Unauthorized, - UserNotFound, -} - -impl ListBannedUsersErrorResponse { - fn unauthorized() -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::Unauthorized, - error_message: "unauthorized".to_string() - } - } - fn server_error() -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::ServerError, - error_message: "server error".to_string() - } - } - fn bad_request(error_message: &str) -> Self { - Self { - success: false, - error_type: ListBannedUsersErrorType::BadInput, - error_message: error_message.to_string() - } - } -} - -impl ResponseError for ListBannedUsersErrorResponse { - fn status_code(&self) -> StatusCode { - match self.error_type { - ListBannedUsersErrorType::BadInput => StatusCode::BAD_REQUEST, - ListBannedUsersErrorType::ServerError => StatusCode::INTERNAL_SERVER_ERROR, - ListBannedUsersErrorType::Unauthorized => StatusCode::UNAUTHORIZED, - ListBannedUsersErrorType::UserNotFound => StatusCode::NOT_FOUND, - } - } - - fn error_response(&self) -> HttpResponse { - serialize_as_json_error(self) - } -} - -// NB: Not using DeriveMore since Clion doesn't understand it. -impl fmt::Display for ListBannedUsersErrorResponse { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self.error_type) - } -} - -pub async fn list_banned_users_handler( - http_request: HttpRequest, - request: web::Json, - server_state: web::Data> -) -> Result { - - let maybe_user_session = server_state - .session_checker - .maybe_get_user_session(&http_request, &server_state.mysql_pool) - .await - .map_err(|e| { - warn!("Session checker error: {:?}", e); - ListBannedUsersErrorResponse::server_error() - })?; - - let user_session = match maybe_user_session { - Some(session) => session, - None => { - warn!("not logged in"); - return Err(ListBannedUsersErrorResponse::unauthorized()); - } - }; - - if !user_session.can_ban_users { - warn!("user is not allowed to add bans: {:?}", user_session.user_token.as_str()); - return Err(ListBannedUsersErrorResponse::unauthorized()); - } - - // TODO: Implement the endpoint - unimplemented!() -} diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs index eec5556ade..513f013b35 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/moderation/user_bans/mod.rs @@ -1,2 +1 @@ -pub mod ban_user; -pub mod list_banned_users; \ No newline at end of file +pub mod ban_user; \ No newline at end of file diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/voice_designer/voices/create_voice.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/voice_designer/voices/create_voice.rs index 5e4dd5aa55..35fb233a0e 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/voice_designer/voices/create_voice.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/voice_designer/voices/create_voice.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use actix_web::error::ResponseError; use actix_web::http::StatusCode; use actix_web::{web, HttpRequest, HttpResponse}; -use log::warn; +use log::{info, warn}; use serde::Deserialize; use serde::Serialize; @@ -159,7 +159,7 @@ pub async fn create_voice_handler( return Err(EnqueueCreateVoiceRequestError::RateLimited); } - println!("Received payload for voice creation."); + info!("Received payload for voice creation."); // Get up IP address let ip_address = get_request_ip(&http_request); diff --git a/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs b/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs index 9617cabe44..ae9202618d 100644 --- a/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs +++ b/crates/service/web/storyteller_web/src/http_server/routes/application_routes/moderation_routes.rs @@ -30,7 +30,6 @@ use crate::http_server::endpoints::moderation::jobs::get_tts_inference_queue_cou use crate::http_server::endpoints::moderation::jobs::get_w2l_inference_queue_count::get_w2l_inference_queue_count_handler; use crate::http_server::endpoints::moderation::jobs::kill_tts_inference_jobs::kill_tts_inference_jobs_handler; use crate::http_server::endpoints::moderation::user_bans::ban_user::ban_user_handler; -use crate::http_server::endpoints::moderation::user_bans::list_banned_users::list_banned_users_handler; use crate::http_server::endpoints::moderation::user::moderator_list_subscribing_users_by_signup_date::moderator_list_subscribing_users_by_signup_date_handler; use crate::http_server::endpoints::moderation::user::moderator_list_users_by_signup_date::moderator_list_users_by_signup_date_handler; use crate::http_server::endpoints::moderation::user::moderator_user_lookup_by_stripe_customer_id_handler::moderator_user_lookup_by_stripe_customer_id_handler; @@ -158,11 +157,6 @@ pub fn add_moderator_routes (app: App) -> App ) .service( web::scope("/user_bans") - .service( - web::resource("/list") - .route(web::get().to(list_banned_users_handler)) - .route(web::head().to(|| HttpResponse::Ok())) - ) .service( web::resource("/manage_ban") .route(web::post().to(ban_user_handler)) diff --git a/crates/service/web/storyteller_web/src/main.rs b/crates/service/web/storyteller_web/src/main.rs index c5713bcd4a..3195f655ec 100644 --- a/crates/service/web/storyteller_web/src/main.rs +++ b/crates/service/web/storyteller_web/src/main.rs @@ -46,8 +46,8 @@ use bootstrap::bootstrap::{bootstrap, BootstrapArgs}; use chrono::Utc; use cloud_storage::bucket_client::BucketClient; use component_traits::traits::internal_user_lookup::InternalUserLookup; -use config::common_env::CommonEnv; -use config::shared_constants::DEFAULT_RUST_LOG; +use shared_env_var_config::logging::DEFAULT_RUST_LOG; +use shared_env_var_config::redis::env_get_redis_0_connection_string_or_default; use elasticsearch::http::transport::Transport; use elasticsearch::Elasticsearch; use errors::AnyhowResult; @@ -140,7 +140,7 @@ async fn main() -> AnyhowResult<()> { ignore_legacy_dot_env_file: true, })?; - let common_env = CommonEnv::read_from_env()?; + info!("Obtaining hostname..."); @@ -169,7 +169,7 @@ async fn main() -> AnyhowResult<()> { info!("Connected to redis..."); let redis_manager = Client::open( - common_env.redis_0_connection_string.clone())?; + env_get_redis_0_connection_string_or_default())?; let redis_pool = r2d2::Pool::builder() .build(redis_manager)?; @@ -460,7 +460,7 @@ async fn main() -> AnyhowResult<()> { elasticsearch, redis_pool, redis_ttl_cache, - redis_rate_limiters: configure_redis_rate_limiters(&common_env)?, + redis_rate_limiters: configure_redis_rate_limiters()?, firehose_publisher, badge_granter, avt_cookie_manager,