-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add serialization to State
/ move State
to agents.state
#9345
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
Conversation
Pull Request Test Coverage Report for Build 15205617087Details
💛 - Coveralls |
I’ve kept the current |
State
/ move State
to utilsState
/ move State
to agents.state
@Amnah199 a general question for you. While working on this did you find that we are missing |
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.
Looks great! Thanks for all of the work on this!
haystack/utils/base_serialization.py
Outdated
@@ -54,87 +54,238 @@ class does not have a `from_dict` method. | |||
return obj_class.from_dict(data["data"]) | |||
|
|||
|
|||
def serialize_value(value: Any) -> Any: | |||
def serialize_value_with_schema(payload: Dict[str, Any]) -> Dict[str, Any]: |
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.
@Amnah199 sorry last comment, should we make this method private for now so it's easy to change in the future if need be?
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.
Good idea, until we have more confidence in this!
Related Issues
State
#9286Proposed Changes:
serialize_value
anddeserialize_value
utility methods in theutils
module. These methods encapsulate logic that is also used in the breakpoints de/serialization logic andtracing.utils.coerce_tag_value
(except the json load). Once the breakpoints feature is merged in haystack, it can reuse these centralized utility functions.State
class to theutils
module, as it is not actually a data class. A deprecation warning is added to the existing State class in the dataclasses module to guide users toward the updated implementation.How did you test it?
Moved the existing tests to
test_utils_state.py
and added two new tests for serialization and deserialization.