Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce class method to create ChatMessage from the OpenAI dictionary format #8670

Merged
merged 8 commits into from
Jan 2, 2025

Conversation

anakin87
Copy link
Member

@anakin87 anakin87 commented Dec 20, 2024

Related Issues

Proposed Changes:

  • introduce ChatMessage.from_openai_dict_format class method: It allows you to create a ChatMessage
    from a dictionary in the format expected by OpenAI's Chat API.

How did you test it?

CI, new 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 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 documented my code
  • I ran pre-commit hooks and fixed any issue

@github-actions github-actions bot added topic:tests type:documentation Improvements on the docs labels Dec 20, 2024
@anakin87 anakin87 changed the title feat: introduce class method to creat ChatMessage from the OpenAI dictionary format feat: introduce class method to create ChatMessage from the OpenAI dictionary format Dec 20, 2024
@coveralls
Copy link
Collaborator

coveralls commented Dec 20, 2024

Pull Request Test Coverage Report for Build 12580908361

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.04%) to 90.988%

Files with Coverage Reduction New Missed Lines %
components/generators/chat/openai.py 2 96.24%
Totals Coverage Status
Change from base Build 12443798462: 0.04%
Covered Lines: 8541
Relevant Lines: 9387

💛 - Coveralls

@anakin87 anakin87 marked this pull request as ready for review December 20, 2024 18:21
@anakin87 anakin87 requested review from a team as code owners December 20, 2024 18:21
@anakin87 anakin87 requested review from dfokina and mpangrazzi and removed request for a team December 20, 2024 18:21
Copy link
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

I've left two comments, but looks already quite good to me!

haystack/dataclasses/chat_message.py Outdated Show resolved Hide resolved
haystack/dataclasses/chat_message.py Show resolved Hide resolved
@anakin87 anakin87 requested a review from mpangrazzi January 2, 2025 10:00
@anakin87 anakin87 enabled auto-merge (squash) January 2, 2025 10:20
@anakin87 anakin87 merged commit 7b4d9ba into main Jan 2, 2025
18 checks passed
@anakin87 anakin87 deleted the chatmsg-from-openai-dict branch January 2, 2025 10:34
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.

ChatMessage: expose from_openai_dict and to_openai_dict utility functions
3 participants