Skip to content

Commit 2fc90d1

Browse files
committed
hotfix: missing hash property on Message
1 parent 08e4c46 commit 2fc90d1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/api/message.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,14 @@ content_parts: list[Content] = Field([], repr=False)
733733

734734
Interior str content or structured content parts.
735735

736+
### hash
737+
738+
```python
739+
hash: int
740+
```
741+
742+
Returns a weak hash of the functional message content, ignoring UUID, metadata, and supplementary fields.
743+
736744
### metadata
737745

738746
```python

rigging/message.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,13 @@ def rename_content(self, handler: SerializerFunctionWrapHandler) -> t.Any:
502502
serialized["content"] = serialized.pop("content_parts")
503503
return serialized
504504

505+
@property
506+
def hash(self) -> int:
507+
"""
508+
Returns a weak hash of the functional message content, ignoring UUID, metadata, and supplementary fields.
509+
"""
510+
return hash(str(self.to_openai(compatibility_flags=set())))
511+
505512
@property
506513
@te.deprecated(".all_content is deprecated, use .content_parts instead", category=None)
507514
def all_content(self) -> str | list[Content]:

0 commit comments

Comments
 (0)