From a411746df368a0ec83b93ddc6fb9e9abcf01431b Mon Sep 17 00:00:00 2001 From: Ben Browning Date: Tue, 15 Apr 2025 20:54:16 -0400 Subject: [PATCH] fix: OpenAI spec cleanup for assistant requests Some of our multi-turn verification tests were failing because I had accidentally marked content as a required field in the OpenAI chat completion request assistant messages, but it's actually optional. It is required for messages from other roles, but assistant is explicitly allowed to be optional. Similarly, the assistant message tool_calls field should default to None instead of an empty list. These two changes get the openai-llama-stack verification test back to 100% passing, just like it passes 100% when not behind Llama Stack. Signed-off-by: Ben Browning --- docs/_static/llama-stack-spec.html | 3 +-- docs/_static/llama-stack-spec.yaml | 1 - llama_stack/apis/inference/inference.py | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/_static/llama-stack-spec.html b/docs/_static/llama-stack-spec.html index 54d888441..24fde9054 100644 --- a/docs/_static/llama-stack-spec.html +++ b/docs/_static/llama-stack-spec.html @@ -8891,8 +8891,7 @@ }, "additionalProperties": false, "required": [ - "role", - "content" + "role" ], "title": "OpenAIAssistantMessageParam", "description": "A message containing the model's (assistant) response in an OpenAI-compatible chat completion request." diff --git a/docs/_static/llama-stack-spec.yaml b/docs/_static/llama-stack-spec.yaml index cf657bff9..27712ee74 100644 --- a/docs/_static/llama-stack-spec.yaml +++ b/docs/_static/llama-stack-spec.yaml @@ -6097,7 +6097,6 @@ components: additionalProperties: false required: - role - - content title: OpenAIAssistantMessageParam description: >- A message containing the model's (assistant) response in an OpenAI-compatible diff --git a/llama_stack/apis/inference/inference.py b/llama_stack/apis/inference/inference.py index 596efb136..309171f20 100644 --- a/llama_stack/apis/inference/inference.py +++ b/llama_stack/apis/inference/inference.py @@ -526,9 +526,9 @@ class OpenAIAssistantMessageParam(BaseModel): """ role: Literal["assistant"] = "assistant" - content: OpenAIChatCompletionMessageContent + content: Optional[OpenAIChatCompletionMessageContent] = None name: Optional[str] = None - tool_calls: Optional[List[OpenAIChatCompletionToolCall]] = Field(default_factory=list) + tool_calls: Optional[List[OpenAIChatCompletionToolCall]] = None @json_schema_type