-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
fix: add handling for List[non-object] types #521
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ea78b4
add handling for List[non-object] types
shreya-51 0a62971
Merge branch 'main' into claude_improvements
shreya-51 f3753fc
update poetry lock
shreya-51 1a911bc
Merge branch 'claude_improvements' of https://github.com/shreya-51/in…
shreya-51 a217659
poetry.lock
shreya-51 6ea4c06
ruff
shreya-51 595a455
Merge branch 'main' into claude_improvements
jxnl f354e0e
Merge branch 'main' into claude_improvements
jxnl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,31 @@ class User(BaseModel): | |
assert resp.address.house_number == 123 | ||
assert resp.address.street_name == "First Avenue" | ||
|
||
@pytest.mark.skip | ||
def test_list(): | ||
class User(BaseModel): | ||
name: str | ||
age: int | ||
family: List[str] | ||
|
||
resp = create( | ||
model="claude-3-opus-20240229", # Fails with claude-3-haiku-20240307 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interesting, we should mention this ins some kind of "anthropic tips" part |
||
max_tokens=1024, | ||
max_retries=0, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Create a user for a model with a name, age, and family members.", | ||
} | ||
], | ||
response_model=User, | ||
) | ||
|
||
assert isinstance(resp, User) | ||
assert isinstance(resp.family, List) | ||
for member in resp.family: | ||
assert isinstance(member, str) | ||
|
||
@pytest.mark.skip | ||
def test_nested_list(): | ||
class Properties(BaseModel): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The variable 'nested_list_found' is set to True when a nested List type is found but it is not reset to False for non-nested List types. This could potentially cause issues if a non-nested List type follows a nested List type as 'nested_list_found' would still be True. Consider resetting 'nested_list_found' to False for non-nested List types.