Skip to content

image gen format fixes#91

Merged
adambalogh merged 3 commits into
mainfrom
ani/test-tee-image-gen
Jun 3, 2026
Merged

image gen format fixes#91
adambalogh merged 3 commits into
mainfrom
ani/test-tee-image-gen

Conversation

@dixitaniket
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 the gateway’s chat-message handling to better support multimodal (vision-style) OpenAI content blocks by preserving list-of-parts user content instead of flattening it into a single string, and aligns request hashing + tests with that behavior.

Changes:

  • Preserve user content provided as a list of parts (e.g., text + image_url) when converting OpenAI-format messages to LangChain messages.
  • Stop stringifying non-string user content in _chat_request_to_dict, enabling canonical JSON hashing for list-of-parts requests.
  • Update/extend unit tests to assert list-of-parts preservation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tee_gateway/llm_backend.py Preserves multimodal user content lists via normalization rather than concatenating into a string.
tee_gateway/controllers/chat_controller.py Keeps user message content as-is when building the canonical hash dictionary.
tee_gateway/test/test_tee_core.py Updates convert_messages tests to validate list-of-parts preservation for user content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 571 to +575
def test_user_content_as_list_of_parts(self):
"""Multimodal content parts should be concatenated into a single string."""
"""Multimodal content parts should be preserved for vision-capable models."""
content = [
{"type": "text", "text": "Hello world"},
{
Comment on lines 911 to 915
messages.append(
{
"role": "user",
"content": msg.content
if isinstance(msg.content, str)
else str(msg.content),
"content": msg.content,
}
Comment on lines 361 to 364
elif role == "user":
# content may be a string or a list of content parts; handle both
if isinstance(content, list):
content = "".join(
part.get("text", "") if isinstance(part, dict) else str(part)
for part in content
)
content = _normalize_user_content_parts(content)
langchain_messages.append(HumanMessage(content=content))
adambalogh
adambalogh previously approved these changes Jun 3, 2026
@adambalogh adambalogh merged commit afa7966 into main Jun 3, 2026
7 checks passed
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.

3 participants