Spaces:
Running on Zero
Running on Zero
Enhanced get_model_architecture_list MCP Tools.
Browse files
mcp_tools/get_model_architecture_list.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
"""
|
| 2 |
MCP Tool: get_model_architecture_list
|
| 3 |
-
Get all supported model architectures
|
| 4 |
"""
|
| 5 |
|
| 6 |
from .common import _load_yaml, _MODEL_ARCHITECTURES_PATH, _CONSTANTS_PATH
|
| 7 |
|
| 8 |
|
| 9 |
def handle_get_model_architecture_list() -> list:
|
| 10 |
-
"""Dynamically load all supported model architectures from model_architectures.yaml."""
|
| 11 |
arch_config = _load_yaml(_MODEL_ARCHITECTURES_PATH)
|
| 12 |
constants = _load_yaml(_CONSTANTS_PATH)
|
| 13 |
resolution_map = constants.get("RESOLUTION_MAP", {})
|
|
@@ -22,15 +22,21 @@ def handle_get_model_architecture_list() -> list:
|
|
| 22 |
model_type = arch_data.get("model_type", arch_name.lower())
|
| 23 |
|
| 24 |
default_res = [1024, 1024]
|
|
|
|
| 25 |
if model_type in resolution_map:
|
| 26 |
-
|
| 27 |
-
if
|
| 28 |
-
first_key = next(iter(
|
| 29 |
-
default_res =
|
| 30 |
|
| 31 |
-
|
| 32 |
"model_architecture": arch_name,
|
| 33 |
"default_resolution": default_res,
|
| 34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
return result
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
MCP Tool: get_model_architecture_list
|
| 3 |
+
Get all supported model architectures, their corresponding default resolutions, and available aspect ratios.
|
| 4 |
"""
|
| 5 |
|
| 6 |
from .common import _load_yaml, _MODEL_ARCHITECTURES_PATH, _CONSTANTS_PATH
|
| 7 |
|
| 8 |
|
| 9 |
def handle_get_model_architecture_list() -> list:
|
| 10 |
+
"""Dynamically load all supported model architectures from model_architectures.yaml along with available aspect ratios and resolutions."""
|
| 11 |
arch_config = _load_yaml(_MODEL_ARCHITECTURES_PATH)
|
| 12 |
constants = _load_yaml(_CONSTANTS_PATH)
|
| 13 |
resolution_map = constants.get("RESOLUTION_MAP", {})
|
|
|
|
| 22 |
model_type = arch_data.get("model_type", arch_name.lower())
|
| 23 |
|
| 24 |
default_res = [1024, 1024]
|
| 25 |
+
resolutions_dict = {}
|
| 26 |
if model_type in resolution_map:
|
| 27 |
+
resolutions_dict = resolution_map[model_type]
|
| 28 |
+
if resolutions_dict:
|
| 29 |
+
first_key = next(iter(resolutions_dict))
|
| 30 |
+
default_res = resolutions_dict[first_key]
|
| 31 |
|
| 32 |
+
entry = {
|
| 33 |
"model_architecture": arch_name,
|
| 34 |
"default_resolution": default_res,
|
| 35 |
+
}
|
| 36 |
+
if resolutions_dict:
|
| 37 |
+
entry["available_resolutions"] = resolutions_dict
|
| 38 |
+
|
| 39 |
+
result.append(entry)
|
| 40 |
|
| 41 |
return result
|
| 42 |
+
|
mcp_tools/mcp_gradio_integration.py
CHANGED
|
@@ -81,7 +81,7 @@ def register_high_level_mcp_apis(demo):
|
|
| 81 |
return sanitize_keys(handle_get_task_list())
|
| 82 |
|
| 83 |
def get_model_architecture_list() -> list:
|
| 84 |
-
"""[Recommended Discovery Flow Step 2] Get a list of all supported model architectures (e.g., SD1.5, SDXL, FLUX, etc.) along with their default resolutions. It is recommended to call this tool before get_model_list to obtain valid model_architecture parameters for precise model filtering."""
|
| 85 |
return sanitize_keys(handle_get_model_architecture_list())
|
| 86 |
|
| 87 |
def get_model_list(model_architecture: str = "") -> list | dict:
|
|
|
|
| 81 |
return sanitize_keys(handle_get_task_list())
|
| 82 |
|
| 83 |
def get_model_architecture_list() -> list:
|
| 84 |
+
"""[Recommended Discovery Flow Step 2] Get a list of all supported model architectures (e.g., SD1.5, SDXL, FLUX, etc.) along with their default resolutions and available aspect ratios (with corresponding width & height). It is recommended to call this tool before get_model_list to obtain valid model_architecture parameters for precise model filtering."""
|
| 85 |
return sanitize_keys(handle_get_model_architecture_list())
|
| 86 |
|
| 87 |
def get_model_list(model_architecture: str = "") -> list | dict:
|