Tag search limit
This commit is contained in:
@@ -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"` |
|
| `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"` |
|
| `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_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)
|
### 🧠 Model & Token Tuning (Optimized for Gemma 4)
|
||||||
| Parameter | Description | Default |
|
| Parameter | Description | Default |
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ SD_URL = "http://127.0.0.1:7860"
|
|||||||
MODEL_PRESETS_PATH = str(ROOT_DIR / "model_presets.toml")
|
MODEL_PRESETS_PATH = str(ROOT_DIR / "model_presets.toml")
|
||||||
RES_PRESETS_PATH = str(ROOT_DIR / "resolution_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_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) ---
|
# --- Model Specific Token Tuning (Tuned for Gemma 4) ---
|
||||||
# Patch size is typically (clip.vision.patch_size * n_merge)
|
# Patch size is typically (clip.vision.patch_size * n_merge)
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ async def handle(args: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|||||||
# Sort by count descending
|
# Sort by count descending
|
||||||
matches.sort(key=lambda x: x["count"], reverse=True)
|
matches.sort(key=lambda x: x["count"], reverse=True)
|
||||||
|
|
||||||
# Format top 20 results
|
# Format top results
|
||||||
results = []
|
results = []
|
||||||
for m in matches[:20]:
|
for m in matches[:config.TAG_SEARCH_LIMIT]:
|
||||||
count_fmt = format_count(str(m["count"]))
|
count_fmt = format_count(str(m["count"]))
|
||||||
type_sfx = get_type_suffix(m["type"])
|
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:
|
if not results:
|
||||||
# Attempt to find similar tags using difflib
|
# Attempt to find similar tags using difflib
|
||||||
all_names_lower = [t["name_lower"] for t in _TAG_CACHE]
|
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:
|
if not suggestions_lower:
|
||||||
return [{"type": "text", "text": f"No tags found matching '{query}'."}]
|
return [{"type": "text", "text": f"No tags found matching '{query}'."}]
|
||||||
|
|||||||
Reference in New Issue
Block a user