⚠️ Refactoring of ChatMessage
#8721
Replies: 2 comments 4 replies
-
As a user, I appreciate the changes you're introducing to future-proofing like tool support. However, I have some constructive feedback regarding the re-factorization: The previous implementation with direct constructor usage: user_message = ChatMessage(role=ChatRole.USER, content="What is the capital of Australia?") feels more aligned with common API patterns in the ecosystem. Major providers like OpenAI and Ollama follow this convention for their API. Two main concerns:
|
Beta Was this translation helpful? Give feedback.
-
@d-kleine @lambda-science thank you for the feedback... About using a format for In any case, we are also exposing some utility functions to convert from/to OpenAI format: @d-kleine Could you explain your second point a bit more? |
Beta Was this translation helpful? Give feedback.
-
Starting with version 2.9.0, the
content
attributeChatMessage
has been removed and replaced with a newtext
property for accessing the textual value of aChatMessage
. This change introduces a breaking change for existing implementations.Additionally, the "function" role and the
ChatMessage.from_function
class method has been deprecated in 2.9.0 and will be removed in Haystack 2.10.0.How to use the new
ChatMessage
Additionally, if your pipeline includes a
ChatPromptBuilder
serialized withhaystack-ai
version earlier than 2.9.0, deserialization may fail due to the field change. To address this issue, refer to the Migrating From Legacy ChatMessage guide for the necessary migration steps.Why are we doing this?
ChatMessage
dataclass has been refactored to improve flexibility and compatibility. This change ensures future-proofing and better support for features like tool calls and their resultsLet us know 🙌
If you have any questions or comments regarding this refactoring, feel free to comment on this post or message the
#haystack
channel on Discord.Beta Was this translation helpful? Give feedback.
All reactions