mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-12 13:57:57 +00:00
test
# What does this PR do? ## Test Plan
This commit is contained in:
parent
f50ce11a3b
commit
9f5fdce86e
32 changed files with 652 additions and 892 deletions
|
@ -769,24 +769,30 @@ class Generator:
|
|||
first = next(iter(op.request_params))
|
||||
request_name, request_type = first
|
||||
|
||||
op_name = "".join(word.capitalize() for word in op.name.split("_"))
|
||||
request_name = f"{op_name}Request"
|
||||
fields = [
|
||||
(
|
||||
name,
|
||||
type_,
|
||||
)
|
||||
for name, type_ in op.request_params
|
||||
]
|
||||
request_type = make_dataclass(
|
||||
request_name,
|
||||
fields,
|
||||
namespace={
|
||||
"__doc__": create_docstring_for_request(
|
||||
request_name, fields, doc_params
|
||||
# Special case: if there's a single parameter named "params" that's already a BaseModel,
|
||||
# unwrap it to show the flat structure in the OpenAPI spec (matches FastAPI's embed=False behavior)
|
||||
if len(op.request_params) == 1 and request_name == "params" and inspect.isclass(request_type) and issubclass(request_type, BaseModel):
|
||||
# Use the actual model type directly (unwrapped)
|
||||
pass # request_type is already set correctly
|
||||
else:
|
||||
op_name = "".join(word.capitalize() for word in op.name.split("_"))
|
||||
request_name = f"{op_name}Request"
|
||||
fields = [
|
||||
(
|
||||
name,
|
||||
type_,
|
||||
)
|
||||
},
|
||||
)
|
||||
for name, type_ in op.request_params
|
||||
]
|
||||
request_type = make_dataclass(
|
||||
request_name,
|
||||
fields,
|
||||
namespace={
|
||||
"__doc__": create_docstring_for_request(
|
||||
request_name, fields, doc_params
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
requestBody = RequestBody(
|
||||
content={
|
||||
|
|
|
@ -11,6 +11,7 @@ from pathlib import Path
|
|||
from typing import TextIO
|
||||
from typing import Any, List, Optional, Union, get_type_hints, get_origin, get_args
|
||||
|
||||
from pydantic import BaseModel
|
||||
from llama_stack.strong_typing.schema import object_to_json, StrictJsonType
|
||||
from llama_stack.core.resolver import api_protocol_map
|
||||
|
||||
|
@ -205,6 +206,14 @@ def _validate_has_return_in_docstring(method) -> str | None:
|
|||
def _validate_has_params_in_docstring(method) -> str | None:
|
||||
source = inspect.getsource(method)
|
||||
sig = inspect.signature(method)
|
||||
|
||||
params_list = [p for p in sig.parameters.values() if p.name != "self"]
|
||||
if len(params_list) == 1:
|
||||
param = params_list[0]
|
||||
param_type = param.annotation
|
||||
if issubclass(param_type, BaseModel):
|
||||
return
|
||||
|
||||
# Only check if the method has more than one parameter
|
||||
if len(sig.parameters) > 1 and ":param" not in source:
|
||||
return "does not have a ':param' in its docstring"
|
||||
|
|
16
docs/static/deprecated-llama-stack-spec.html
vendored
16
docs/static/deprecated-llama-stack-spec.html
vendored
|
@ -1617,7 +1617,7 @@
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OpenaiCompletionRequest"
|
||||
"$ref": "#/components/schemas/OpenAICompletionRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -7716,7 +7716,8 @@
|
|||
"model",
|
||||
"messages"
|
||||
],
|
||||
"title": "OpenaiChatCompletionRequest"
|
||||
"title": "OpenaiChatCompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible chat completion endpoint."
|
||||
},
|
||||
"OpenAIChatCompletion": {
|
||||
"type": "object",
|
||||
|
@ -7900,7 +7901,7 @@
|
|||
],
|
||||
"title": "OpenAICompletionWithInputMessages"
|
||||
},
|
||||
"OpenaiCompletionRequest": {
|
||||
"OpenAICompletionRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"model": {
|
||||
|
@ -8035,10 +8036,12 @@
|
|||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "(Optional) vLLM-specific parameter for guided generation with a list of choices."
|
||||
},
|
||||
"prompt_logprobs": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"description": "(Optional) vLLM-specific parameter for number of log probabilities to return for prompt tokens."
|
||||
},
|
||||
"suffix": {
|
||||
"type": "string",
|
||||
|
@ -8050,7 +8053,8 @@
|
|||
"model",
|
||||
"prompt"
|
||||
],
|
||||
"title": "OpenaiCompletionRequest"
|
||||
"title": "OpenAICompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible completion endpoint."
|
||||
},
|
||||
"OpenAICompletion": {
|
||||
"type": "object",
|
||||
|
|
16
docs/static/deprecated-llama-stack-spec.yaml
vendored
16
docs/static/deprecated-llama-stack-spec.yaml
vendored
|
@ -1167,7 +1167,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OpenaiCompletionRequest'
|
||||
$ref: '#/components/schemas/OpenAICompletionRequest'
|
||||
required: true
|
||||
deprecated: true
|
||||
/v1/openai/v1/embeddings:
|
||||
|
@ -5671,6 +5671,8 @@ components:
|
|||
- model
|
||||
- messages
|
||||
title: OpenaiChatCompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible chat completion endpoint.
|
||||
OpenAIChatCompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -5824,7 +5826,7 @@ components:
|
|||
- model
|
||||
- input_messages
|
||||
title: OpenAICompletionWithInputMessages
|
||||
OpenaiCompletionRequest:
|
||||
OpenAICompletionRequest:
|
||||
type: object
|
||||
properties:
|
||||
model:
|
||||
|
@ -5916,8 +5918,14 @@ components:
|
|||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for guided generation with a list of
|
||||
choices.
|
||||
prompt_logprobs:
|
||||
type: integer
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for number of log probabilities to
|
||||
return for prompt tokens.
|
||||
suffix:
|
||||
type: string
|
||||
description: >-
|
||||
|
@ -5926,7 +5934,9 @@ components:
|
|||
required:
|
||||
- model
|
||||
- prompt
|
||||
title: OpenaiCompletionRequest
|
||||
title: OpenAICompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible completion endpoint.
|
||||
OpenAICompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
|
16
docs/static/llama-stack-spec.html
vendored
16
docs/static/llama-stack-spec.html
vendored
|
@ -243,7 +243,7 @@
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OpenaiCompletionRequest"
|
||||
"$ref": "#/components/schemas/OpenAICompletionRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -5212,7 +5212,8 @@
|
|||
"model",
|
||||
"messages"
|
||||
],
|
||||
"title": "OpenaiChatCompletionRequest"
|
||||
"title": "OpenaiChatCompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible chat completion endpoint."
|
||||
},
|
||||
"OpenAIChatCompletion": {
|
||||
"type": "object",
|
||||
|
@ -5396,7 +5397,7 @@
|
|||
],
|
||||
"title": "OpenAICompletionWithInputMessages"
|
||||
},
|
||||
"OpenaiCompletionRequest": {
|
||||
"OpenAICompletionRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"model": {
|
||||
|
@ -5531,10 +5532,12 @@
|
|||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "(Optional) vLLM-specific parameter for guided generation with a list of choices."
|
||||
},
|
||||
"prompt_logprobs": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"description": "(Optional) vLLM-specific parameter for number of log probabilities to return for prompt tokens."
|
||||
},
|
||||
"suffix": {
|
||||
"type": "string",
|
||||
|
@ -5546,7 +5549,8 @@
|
|||
"model",
|
||||
"prompt"
|
||||
],
|
||||
"title": "OpenaiCompletionRequest"
|
||||
"title": "OpenAICompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible completion endpoint."
|
||||
},
|
||||
"OpenAICompletion": {
|
||||
"type": "object",
|
||||
|
|
16
docs/static/llama-stack-spec.yaml
vendored
16
docs/static/llama-stack-spec.yaml
vendored
|
@ -167,7 +167,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OpenaiCompletionRequest'
|
||||
$ref: '#/components/schemas/OpenAICompletionRequest'
|
||||
required: true
|
||||
deprecated: false
|
||||
/v1/conversations:
|
||||
|
@ -3920,6 +3920,8 @@ components:
|
|||
- model
|
||||
- messages
|
||||
title: OpenaiChatCompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible chat completion endpoint.
|
||||
OpenAIChatCompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -4073,7 +4075,7 @@ components:
|
|||
- model
|
||||
- input_messages
|
||||
title: OpenAICompletionWithInputMessages
|
||||
OpenaiCompletionRequest:
|
||||
OpenAICompletionRequest:
|
||||
type: object
|
||||
properties:
|
||||
model:
|
||||
|
@ -4165,8 +4167,14 @@ components:
|
|||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for guided generation with a list of
|
||||
choices.
|
||||
prompt_logprobs:
|
||||
type: integer
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for number of log probabilities to
|
||||
return for prompt tokens.
|
||||
suffix:
|
||||
type: string
|
||||
description: >-
|
||||
|
@ -4175,7 +4183,9 @@ components:
|
|||
required:
|
||||
- model
|
||||
- prompt
|
||||
title: OpenaiCompletionRequest
|
||||
title: OpenAICompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible completion endpoint.
|
||||
OpenAICompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
|
16
docs/static/stainless-llama-stack-spec.html
vendored
16
docs/static/stainless-llama-stack-spec.html
vendored
|
@ -243,7 +243,7 @@
|
|||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/OpenaiCompletionRequest"
|
||||
"$ref": "#/components/schemas/OpenAICompletionRequest"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -7221,7 +7221,8 @@
|
|||
"model",
|
||||
"messages"
|
||||
],
|
||||
"title": "OpenaiChatCompletionRequest"
|
||||
"title": "OpenaiChatCompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible chat completion endpoint."
|
||||
},
|
||||
"OpenAIChatCompletion": {
|
||||
"type": "object",
|
||||
|
@ -7405,7 +7406,7 @@
|
|||
],
|
||||
"title": "OpenAICompletionWithInputMessages"
|
||||
},
|
||||
"OpenaiCompletionRequest": {
|
||||
"OpenAICompletionRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"model": {
|
||||
|
@ -7540,10 +7541,12 @@
|
|||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"description": "(Optional) vLLM-specific parameter for guided generation with a list of choices."
|
||||
},
|
||||
"prompt_logprobs": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"description": "(Optional) vLLM-specific parameter for number of log probabilities to return for prompt tokens."
|
||||
},
|
||||
"suffix": {
|
||||
"type": "string",
|
||||
|
@ -7555,7 +7558,8 @@
|
|||
"model",
|
||||
"prompt"
|
||||
],
|
||||
"title": "OpenaiCompletionRequest"
|
||||
"title": "OpenAICompletionRequest",
|
||||
"description": "Request parameters for OpenAI-compatible completion endpoint."
|
||||
},
|
||||
"OpenAICompletion": {
|
||||
"type": "object",
|
||||
|
|
16
docs/static/stainless-llama-stack-spec.yaml
vendored
16
docs/static/stainless-llama-stack-spec.yaml
vendored
|
@ -170,7 +170,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OpenaiCompletionRequest'
|
||||
$ref: '#/components/schemas/OpenAICompletionRequest'
|
||||
required: true
|
||||
deprecated: false
|
||||
/v1/conversations:
|
||||
|
@ -5365,6 +5365,8 @@ components:
|
|||
- model
|
||||
- messages
|
||||
title: OpenaiChatCompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible chat completion endpoint.
|
||||
OpenAIChatCompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -5518,7 +5520,7 @@ components:
|
|||
- model
|
||||
- input_messages
|
||||
title: OpenAICompletionWithInputMessages
|
||||
OpenaiCompletionRequest:
|
||||
OpenAICompletionRequest:
|
||||
type: object
|
||||
properties:
|
||||
model:
|
||||
|
@ -5610,8 +5612,14 @@ components:
|
|||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for guided generation with a list of
|
||||
choices.
|
||||
prompt_logprobs:
|
||||
type: integer
|
||||
description: >-
|
||||
(Optional) vLLM-specific parameter for number of log probabilities to
|
||||
return for prompt tokens.
|
||||
suffix:
|
||||
type: string
|
||||
description: >-
|
||||
|
@ -5620,7 +5628,9 @@ components:
|
|||
required:
|
||||
- model
|
||||
- prompt
|
||||
title: OpenaiCompletionRequest
|
||||
title: OpenAICompletionRequest
|
||||
description: >-
|
||||
Request parameters for OpenAI-compatible completion endpoint.
|
||||
OpenAICompletion:
|
||||
type: object
|
||||
properties:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue