Accept empty content array - transform it to null#4359
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
contentarrays in OpenAI chat parsing and defer normalization to a newEmptyContentNormalizationProcessor. - Adjust
TextContentNormalizationProcessorto 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") { |
dkalinowski
reviewed
Jul 8, 2026
dkalinowski
approved these changes
Jul 8, 2026
michalkulakowski
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.