Skip to content

Commit c16e04c

Browse files
committed
feat: show DEFAULT_MODEL in OpenAPI schema
Update model field description to tell LLMs: - The parameter is optional - Which model the server uses by default - Not to send the parameter unless a specific model is needed
1 parent 2620222 commit c16e04c

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

app/main.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,23 @@ def custom_openapi():
114114
routes=app.routes,
115115
)
116116

117-
# Get available models and add to schema description
118-
available_models = model_registry.get_models()
119-
if available_models:
120-
image_models = [m.id for m in available_models if "image" in m.id.lower() or "dall" in m.id.lower()]
121-
if not image_models:
122-
image_models = [m.id for m in available_models[:10]] # First 10 as fallback
123-
124-
models_list = ", ".join(f"'{m}'" for m in image_models)
125-
126-
# Update the model field description in ImageRequest schema
127-
if (
128-
"components" in openapi_schema
129-
and "schemas" in openapi_schema["components"]
130-
and "ImageRequest" in openapi_schema["components"]["schemas"]
131-
):
132-
props = openapi_schema["components"]["schemas"]["ImageRequest"].get("properties", {})
133-
if "model" in props:
117+
# Update model field description with default model info
118+
if (
119+
"components" in openapi_schema
120+
and "schemas" in openapi_schema["components"]
121+
and "ImageRequest" in openapi_schema["components"]["schemas"]
122+
):
123+
props = openapi_schema["components"]["schemas"]["ImageRequest"].get("properties", {})
124+
if "model" in props:
125+
if settings.DEFAULT_MODEL:
134126
props["model"]["description"] = (
135-
f"Model ID for image generation. Available models: {models_list}. "
136-
"Use 'openai/dall-e-3' for high quality, 'openai/gpt-image-1' for fast generation."
127+
f"Optional. Server uses '{settings.DEFAULT_MODEL}' if not specified. "
128+
"Do not send this parameter unless you need a different model."
129+
)
130+
else:
131+
props["model"]["description"] = (
132+
"Optional. Server selects the best available model if not specified. "
133+
"Do not send this parameter unless you need a specific model."
137134
)
138135

139136
app.openapi_schema = openapi_schema

0 commit comments

Comments
 (0)