Skip to content

Accept empty content array - transform it to null#4359

Merged
mzegla merged 2 commits into
mainfrom
accept_empty_content_array
Jul 8, 2026
Merged

Accept empty content array - transform it to null#4359
mzegla merged 2 commits into
mainfrom
accept_empty_content_array

Conversation

@mzegla

@mzegla mzegla commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 8, 2026 11:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates OVMS LLM chat input handling to accept OpenAI-style content: [] message payloads by preserving them during request parsing and normalizing them downstream to null, avoiding upfront request rejection and keeping the processing pipeline consistent across LM/VLM chat paths.

Changes:

  • Accept empty content arrays in OpenAI chat parsing and defer normalization to a new EmptyContentNormalizationProcessor.
  • Adjust TextContentNormalizationProcessor to flatten only text-only content arrays (leave mixed-modality arrays intact for image decoding) and run it for both LM and VLM chat paths.
  • Update and extend unit/integration tests to reflect the new parsing + normalization behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/test/llm/input_processing/text_content_normalization_processor_test.cpp Updates expectations: mixed-modality content arrays are no longer flattened.
src/test/llm/input_processing/input_processing_integration_test.cpp Verifies text-only array flattening on both LM and VLM paths.
src/test/llm/input_processing/empty_content_normalization_processor_test.cpp Adds unit tests for empty-array-to-null normalization behavior.
src/test/http_openai_handler_test.cpp Updates parsing test: empty content arrays are now accepted and preserved.
src/llm/io_processing/input_processors/text_content_normalization_processor.hpp Updates processor documentation to match new behavior and scope.
src/llm/io_processing/input_processors/text_content_normalization_processor.cpp Ensures only text-only arrays are flattened; mixed arrays are left for downstream image handling.
src/llm/io_processing/input_processors/empty_content_normalization_processor.hpp Introduces new processor to normalize empty content arrays to null.
src/llm/io_processing/input_processors/empty_content_normalization_processor.cpp Implements empty-array-to-null normalization for ChatHistory inputs.
src/llm/io_processing/input_processor.cpp Inserts new processor into the chat input processing chain and adjusts processor ordering.
src/llm/BUILD Adds the new processor sources/headers to the LLM input processors Bazel target.
src/llm/apis/openai_completions.cpp Stops rejecting empty content arrays during OpenAI chat message parsing.

Comment on lines +35 to +39
// Only flatten arrays that contain exclusively text parts. Arrays with
// images (or other modalities) are left untouched for ImageDecodingProcessor.
bool allText = true;
for (size_t j = 0; j < content.size(); j++) {
if (content[j]["type"].as_string().value_or("") != "text") {
Comment thread src/llm/io_processing/input_processors/empty_content_normalization_processor.cpp Outdated
@mzegla mzegla merged commit a3feb14 into main Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants