-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
base: main
Are you sure you want to change the base?
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
top_k=2, | ||
client=client | ||
) | ||
except Exception as e: |
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 do you catch exceptions in the test and just print it?
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.
it's a mock call - the test is checking for the input. the mock call isn't returning a response, so for the mock test the translation output error is expected
Is this okay to merge? @ishaan-jaff |
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:
Tests still passed w/ mocks: