Skip to content

refactor: simplify ChatMessage serialization/OpenAI conversion - #13275

Merged
anakin87 merged 7 commits into
mainfrom
chatmessage-refactor-conversion
Oct 16, 2026
Merged

anakin87 merged 7 commits into
mainfrom
chatmessage-refactor-conversion

Conversation

@anakin87

@anakin87 anakin87 commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Related Issues

I noticed that ChatMessage serialization and conversion from/to OpenAI became complex and a bit hard to follow

Proposed Changes:

  • reduce duplication in ChatMessage/ToolCallResult serialization
  • simplify deserialization
  • split to_openai_dict_format into helpers
  • reorder tests

How did you test it?

CI. Added 2-3 tests.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
haystack-docs Ready Ready Preview Oct 15, 2026 1:39pm UTC

Request Review

@github-actions github-actions Bot added topic:tests type:documentation Improvements on the docs labels Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/dataclasses
  chat_message.py
Project Total  

This report was generated by python-coverage-comment-action

@@ -35,7 +35,31 @@ def test_function_role_removed(self):
ChatRole.from_str("function")


Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

in this file, I just reordered the existing tests into focused classes and added 2-3 tests for uncovered paths

@anakin87 anakin87 changed the title Chatmessage refactor conversion refactor: simplify ChatMessage serialization/OpenAI conversion Oct 15, 2026
@anakin87 anakin87 self-assigned this Oct 15, 2026
@anakin87
anakin87 marked this pull request as ready for review October 15, 2026 13:38
@anakin87
anakin87 requested a review from a team as a code owner October 15, 2026 13:38
@anakin87
anakin87 requested review from sjrl and removed request for a team October 15, 2026 13:38

@sjrl sjrl 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.

Looks good!

@anakin87
anakin87 merged commit da7e632 into main Oct 16, 2026
28 checks passed
@anakin87
anakin87 deleted the chatmessage-refactor-conversion branch October 16, 2026 07:49

This branch was successfully deployed

1 active deployment
Preview — 8c2500ab Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants