-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 passing top_k parameter for Bedrock Anthropic models #8131
Fix passing top_k parameter for Bedrock Anthropic models #8131
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
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 overall, just a couple minor points of feedback
for k, v in inference_params.items(): | ||
if ( | ||
k not in supported_converse_params | ||
and k not in supported_tool_call_params |
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.
is this deletion required ? I'm pretty sure we need to filter our specific guardrail params
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.
I just wanted to simplify the code a bit (using list comprehension instead of adding and then popping from the dict). From my understanding the before and after logic should be functionally equivalent, but if I'm wrong, I can revert it
"bedrock/mistral.mistral-7b-instruct-v0:2", | ||
] | ||
) | ||
def test_bedrock_top_k(model): |
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.
can you send a screenshot of this test working for all the API calls here ?
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.
i think he did
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.
Yeah I have it added it in the description, let me know if you need more screenshots
Is this okay to merge? @ishaan-jaff |
c9d0f4d
to
5015e87
Compare
@ishaan-jaff Just following up to see if this is fine to merge |
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, merging into staging branch to run through testing
Title
Fix passing top_k parameter for Bedrock Anthropic models
Relevant issues
Fixes #7782
Type
π Bug Fix
β Test
Changes
The bug arose from the fact that different bedrock models pass in the top_k parameter in different ways.
Specifically the nova model passes in the parameter through
and the anthropic model passes it in through
This PR checks the model types and sets the parameter based on that. Right now, this is a simple if statement, but a long term fix might be to create a new class for each model, and create handling logic for supported / model-specific param within each class. This way the overall converse handler does not need to know about these specifics.
This PR also simplifies the additional_model_fields creation logic
[REQUIRED] Testing - Attach a screenshot of any new tests passing locally
If UI changes, send a screenshot/GIF of working UI fixes
Tested the top_k param for 4 different models w/ real API calls:
![image](https://private-user-images.githubusercontent.com/10468083/408406890-59ec88da-501a-4367-9526-dd091b74ead1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1Mjc5NTYsIm5iZiI6MTczOTUyNzY1NiwicGF0aCI6Ii8xMDQ2ODA4My80MDg0MDY4OTAtNTllYzg4ZGEtNTAxYS00MzY3LTk1MjYtZGQwOTFiNzRlYWQxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDEwMDczNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRhMDQyMmM0ZDU4YjI3MTQ0MmM2MGNlM2I5ZDc2ZjQyNzZlZTJkM2EyYmVmMDg4MWUxZWMyZTk1YzY0YTQyMTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KOJWgmgbt9_b-TzgGbY-oqZK3PnAN_rAD8-TAhWczVs)
Tests still passed w/ mocks:
![image](https://private-user-images.githubusercontent.com/10468083/408471548-a4194ed3-f225-4e38-9e18-a7e6f9902939.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1Mjc5NTYsIm5iZiI6MTczOTUyNzY1NiwicGF0aCI6Ii8xMDQ2ODA4My80MDg0NzE1NDgtYTQxOTRlZDMtZjIyNS00ZTM4LTllMTgtYTdlNmY5OTAyOTM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDEwMDczNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMyMTI1ZDc1YmViNzQwY2YzZjA1OTNiZjdjMTRlMzE1NDMwOTUwYWIxNDkyZTI1Njc1MmZlMDk2MmZlZDExZmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.hr4pHbR2V0hf9p94lT3W1tynv-Ir3cd7NVjvSeV12NE)