Skip to content
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

Refactor Bedrock class to support Claude-3 model and improve error handling #720

Closed

Conversation

cta2106
Copy link

@cta2106 cta2106 commented Mar 26, 2024

This PR refactors the Bedrock class to support the Claude-3 model. The main changes include:

  1. Added support for the Claude-3 model which uses a different API format with messages instead of a single prompt. The use_messages flag is set based on the model name to determine the API format to use.

  2. Refactored the _create_body method to handle the different API formats for Claude-3 vs other models. It now constructs the appropriate request body based on the use_messages flag.

  3. Updated the _call_model method to handle the different response formats from Claude-3 vs other models. It extracts the completion text based on the expected response structure.

@aazizisoufiane
Copy link

@cta2106, I encountered the same "extraneous key [n] is not permitted, please reformat your input and try again." error as you did with Claude 3. To resolve it, I adjusted the code in aws_lm.py by placing del kwargs["n"] right after the check if "n" in kwargs.keys():. I think this adjustment should address issue #680.

@arnavsinghvi11
Copy link
Collaborator

Thanks @cta2106 @aazizisoufiane! Should we merge both #680 and #720 in that case? the changes make sense to me but I just want to confirm there are no behavior conflicts from merging either PR.

@aazizisoufiane
Copy link

@arnavsinghvi11 I've tested all Claude models on bedrock, for me there is no conflict.

@ammirsm
Copy link
Collaborator

ammirsm commented Apr 4, 2024

Thanks folks for the contribution here, can you please just lint the code with ruff config that we have to pass the checks?

@aazizisoufiane
Copy link

Hi @cta2106,

I ran ruff check . --fix-only on my local for aws_lm.py. It seems the linting request is about bedrock.py. Could you check this on your side? Let me know if I can help.

Thanks!

@cta2106
Copy link
Author

cta2106 commented Apr 4, 2024

Certainement Soufiane

@arnavsinghvi11
Copy link
Collaborator

@cta2106 looks good to merge after you run ruff check . --fix-only and push!

@drawal1
Copy link
Contributor

drawal1 commented Apr 5, 2024

Hey guys, please review PR #772 that tackles this issue with a much better redesign. Almost done...

@arnavsinghvi11
Copy link
Collaborator

@drawal1 is this PR good to close as well with #795 merged?

@drawal1
Copy link
Contributor

drawal1 commented Apr 15, 2024

yea. pretty sure this can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants