Tag search limit

This commit is contained in:
2026-07-27 01:45:52 -07:00
parent f0e5267828
commit c0c3a4c405
3 changed files with 5 additions and 3 deletions
+1
View File
@@ -97,6 +97,7 @@ Tuning the server's behavior is done via `config.py`.
| `MODEL_PRESETS_PATH` | Path to the `model_presets.toml` file. | `ROOT_DIR / "model_presets.toml"` |
| `RES_PRESETS_PATH` | Path to the `resolution_presets.toml` file. | `ROOT_DIR / "resolution_presets.toml"` |
| `TAG_DATABASE_PATH` | Path to the Danbooru `tags.csv` file. | (Path to extension folder) |
| `TAG_SEARCH_LIMIT` | Number of results returned by `search_tags` (direct or similar). | `20` |
### 🧠 Model & Token Tuning (Optimized for Gemma 4)
| Parameter | Description | Default |
+1
View File
@@ -17,6 +17,7 @@ SD_URL = "http://127.0.0.1:7860"
MODEL_PRESETS_PATH = str(ROOT_DIR / "model_presets.toml")
RES_PRESETS_PATH = str(ROOT_DIR / "resolution_presets.toml")
TAG_DATABASE_PATH = "/home/matt/stable-diffusion-webui/extensions/a1111-sd-webui-tagcomplete/tags/danbooru.csv"
TAG_SEARCH_LIMIT = 20
# --- Model Specific Token Tuning (Tuned for Gemma 4) ---
# Patch size is typically (clip.vision.patch_size * n_merge)
+3 -3
View File
@@ -74,9 +74,9 @@ async def handle(args: Dict[str, Any]) -> List[Dict[str, Any]]:
# Sort by count descending
matches.sort(key=lambda x: x["count"], reverse=True)
# Format top 20 results
# Format top results
results = []
for m in matches[:20]:
for m in matches[:config.TAG_SEARCH_LIMIT]:
count_fmt = format_count(str(m["count"]))
type_sfx = get_type_suffix(m["type"])
@@ -90,7 +90,7 @@ async def handle(args: Dict[str, Any]) -> List[Dict[str, Any]]:
if not results:
# Attempt to find similar tags using difflib
all_names_lower = [t["name_lower"] for t in _TAG_CACHE]
suggestions_lower = difflib.get_close_matches(query, all_names_lower, n=10, cutoff=0.5)
suggestions_lower = difflib.get_close_matches(query, all_names_lower, n=config.TAG_SEARCH_LIMIT, cutoff=0.5)
if not suggestions_lower:
return [{"type": "text", "text": f"No tags found matching '{query}'."}]