-
Notifications
You must be signed in to change notification settings - Fork 121
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.
@izellevy see a few suggestions
|
||
# In the case of StuffingContextBuilder, we simply want the text representation to | ||
# be a json. Other ContextContent subclasses may render into text differently | ||
def to_text(self, **kwargs): | ||
return self.json(**kwargs) | ||
return json.dumps(self.model_dump(), **kwargs) |
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.
Why not use self.dump_json()
?
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.
Because we pass args to json_dumps (such as indent). This was supported in v1 but not v2 (.model_dump_json does not get indent in pydantic v2)
@@ -127,7 +127,7 @@ def expected_chunks(documents): | |||
'\ntext in level 3\n#### Level 4\ntext in level 4\n##### Level 5' | |||
'\ntext in level 5\n###### Level 6\ntext in level 6', | |||
source='doc_1', | |||
metadata={'test': '1'}, |
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.
Why was this cast to str
before? (Seems like we had a bug?)
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.
Kinda bug of Union parsing in pydantic v1. In pydantic v2 there is smart unions so they fixed this problem.
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.
LGTM
@izellevy please make sure you run tests at least once (locally on your machine) with |
@igiloh-pinecone checked and made sure it works with all extras |
Problem
Currently we only support Pydantic v1 which is a problem for some users.
Solution
Migrating to Pydantic v2
Type of Change
Test Plan
Describe specific steps for validating this change.