-
Notifications
You must be signed in to change notification settings - Fork 2k
Replace ChatMessage.from_hf_api with from_dict with asdict #1076
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
Replace ChatMessage.from_hf_api with from_dict with asdict #1076
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, nice simplifying change!
src/smolagents/models.py
Outdated
@classmethod | ||
def from_hf_api(cls, tool_call: "ChatCompletionOutputToolCall") -> "ChatMessageToolCall": | ||
warnings.warn( | ||
"ChatMessageToolCall.from_hf_api is deprecated and will be removed in version 2.0.0. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we're not sure to do a 2.0.0 soon, isn't it better to indicate a medium version, like 1.16?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breaking changes are typically only allowed in major versions to ensure stability and backward compatibility. If a change introduces breaking modifications, it would generally be reserved for a 2.0.0 release rather than a minor version like 1.16.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In transformers I saw breaking changes being planned for a few minor releases in advance, as we did here: huggingface/transformers#36415 The issue I see with waiting for a major release is that we're not planning to do one soon, while we should probably plan to deprecate from_hf_api
, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you think it is OK to introduce breaking changes in minor versions...
I just take note to inform users who ask about API stability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could also agree in the deprecation cycle duration: you are proposing next_minor + 3 versions, is it OK?
A problem I did not foresee: after huggingface-hub-0.30.0 (https://pypi.org/project/huggingface-hub/0.30.0/) the dataclass fields are no longer aligned with the corrsponding smolagents dataclass: https://github.com/huggingface/huggingface_hub/pull/2832/files#diff-e3fbb4c028015b8d172390c8acd9b0d4ca985d05c639fdb74c598a506152db6eR208
We need to decide how to handle this discrepancy:
@aymeric-roucher, do you have a preference on the best approach here? |
@albertvillanova let's drop the |
It is what I did. We should maybe ask to the transformers/huggingface-hub teams why they added that field... |
More details on why the I don't have much more context to provide as I was not involved in this addition. Better to ask in Slack if there is any limitations in smolagents around that field. |
Thanks so much for the context, @Wauplin: we had missed that. Looking into it... |
Replace
ChatMessage.from_hf_api
withfrom_dict
withasdict
.TODO:
ChatMessage.from_hf_api
Follow up to: