forked from phoenix-oss/llama-stack-mirror
Ensure that deprecations for fields follow through to OpenAPI
This commit is contained in:
parent
31a5ba5268
commit
034ece0011
3 changed files with 22 additions and 3 deletions
6
docs/_static/llama-stack-spec.html
vendored
6
docs/_static/llama-stack-spec.html
vendored
|
@ -2702,7 +2702,8 @@
|
||||||
"none"
|
"none"
|
||||||
],
|
],
|
||||||
"title": "ToolChoice",
|
"title": "ToolChoice",
|
||||||
"description": "Whether tool use is required or automatic. This is a hint to the model which may not be followed. It depends on the Instruction Following capabilities of the model."
|
"description": "Whether tool use is required or automatic. This is a hint to the model which may not be followed. It depends on the Instruction Following capabilities of the model.",
|
||||||
|
"deprecated": true
|
||||||
},
|
},
|
||||||
"tool_prompt_format": {
|
"tool_prompt_format": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -2712,7 +2713,8 @@
|
||||||
"python_list"
|
"python_list"
|
||||||
],
|
],
|
||||||
"title": "ToolPromptFormat",
|
"title": "ToolPromptFormat",
|
||||||
"description": "Prompt format for calling custom / zero shot tools."
|
"description": "Prompt format for calling custom / zero shot tools.",
|
||||||
|
"deprecated": true
|
||||||
},
|
},
|
||||||
"tool_config": {
|
"tool_config": {
|
||||||
"$ref": "#/components/schemas/ToolConfig"
|
"$ref": "#/components/schemas/ToolConfig"
|
||||||
|
|
2
docs/_static/llama-stack-spec.yaml
vendored
2
docs/_static/llama-stack-spec.yaml
vendored
|
@ -1644,6 +1644,7 @@ components:
|
||||||
Whether tool use is required or automatic. This is a hint to the model
|
Whether tool use is required or automatic. This is a hint to the model
|
||||||
which may not be followed. It depends on the Instruction Following capabilities
|
which may not be followed. It depends on the Instruction Following capabilities
|
||||||
of the model.
|
of the model.
|
||||||
|
deprecated: true
|
||||||
tool_prompt_format:
|
tool_prompt_format:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
|
@ -1653,6 +1654,7 @@ components:
|
||||||
title: ToolPromptFormat
|
title: ToolPromptFormat
|
||||||
description: >-
|
description: >-
|
||||||
Prompt format for calling custom / zero shot tools.
|
Prompt format for calling custom / zero shot tools.
|
||||||
|
deprecated: true
|
||||||
tool_config:
|
tool_config:
|
||||||
$ref: '#/components/schemas/ToolConfig'
|
$ref: '#/components/schemas/ToolConfig'
|
||||||
max_infer_iters:
|
max_infer_iters:
|
||||||
|
|
|
@ -313,6 +313,17 @@ class JsonSchemaGenerator:
|
||||||
data_type: TypeLike,
|
data_type: TypeLike,
|
||||||
force_expand: bool = False,
|
force_expand: bool = False,
|
||||||
json_schema_extra: Optional[dict] = None,
|
json_schema_extra: Optional[dict] = None,
|
||||||
|
) -> Schema:
|
||||||
|
common_info = {}
|
||||||
|
if json_schema_extra and "deprecated" in json_schema_extra:
|
||||||
|
common_info["deprecated"] = json_schema_extra["deprecated"]
|
||||||
|
return self._type_to_schema(data_type, force_expand, json_schema_extra) | common_info
|
||||||
|
|
||||||
|
def _type_to_schema(
|
||||||
|
self,
|
||||||
|
data_type: TypeLike,
|
||||||
|
force_expand: bool = False,
|
||||||
|
json_schema_extra: Optional[dict] = None,
|
||||||
) -> Schema:
|
) -> Schema:
|
||||||
"""
|
"""
|
||||||
Returns the JSON schema associated with a type.
|
Returns the JSON schema associated with a type.
|
||||||
|
@ -489,7 +500,11 @@ class JsonSchemaGenerator:
|
||||||
if "model_fields" in members:
|
if "model_fields" in members:
|
||||||
f = members["model_fields"]
|
f = members["model_fields"]
|
||||||
defaults = {k: finfo.default for k, finfo in f.items()}
|
defaults = {k: finfo.default for k, finfo in f.items()}
|
||||||
json_schema_extra = f.get(output_name, None).json_schema_extra
|
if output_name in f:
|
||||||
|
finfo = f[output_name]
|
||||||
|
json_schema_extra = finfo.json_schema_extra or {}
|
||||||
|
if finfo.deprecated:
|
||||||
|
json_schema_extra["deprecated"] = True
|
||||||
|
|
||||||
if is_type_optional(property_type):
|
if is_type_optional(property_type):
|
||||||
optional_type: type = unwrap_optional_type(property_type)
|
optional_type: type = unwrap_optional_type(property_type)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue