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

feat: added support for A21 and Amazon Titan models via bedrock api #1101

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

awsyshah
Copy link

@awsyshah awsyshah commented May 8, 2024

Closes #1076

📑 Description

Included support for A21 & Amazon Titan Model through the bedrock api, using a case structure to enable future flexibility to continue adding other models available. As Bedrock supports quite a few models not adding them all in a single merge.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

ℹ Additional Information

@awsyshah awsyshah requested review from a team as code owners May 8, 2024 14:27
pkg/ai/amazonbedrock.go Outdated Show resolved Hide resolved
pkg/ai/amazonbedrock.go Show resolved Hide resolved
@awsyshah
Copy link
Author

@AlexsJones did you get a chance to review this for the changes and if it is ok to merge now ?

@AlexsJones
Copy link
Member

I need to test it first, will try to get around to it ASAP

@awsyshah
Copy link
Author

I need to test it first, will try to get around to it ASAP

@AlexsJones just adding some screenshots of the runs if that helps.

image

image

image

@lenaxia
Copy link

lenaxia commented Jun 26, 2024

If you're looking for a workaround, would suggest using LiteLLM to proxy Bedrock

Copy link
Contributor

@JuHyung-Son JuHyung-Son left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good start! i left some comments

pkg/ai/amazonbedrock.go Outdated Show resolved Hide resolved
case ModelAnthropicClaudeV2, ModelAnthropicClaudeV1, ModelAnthropicClaudeInstantV1:
type InvokeModelResponseBody struct {
Completion string `json:"completion"`
Stop_reason string `json:"stop_reason"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be StopReason?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then variable name would be StopReason and json value would be stop_reason .
does this makes error??

}
return output.Completion, nil
case ModelA21J2UltraV1, ModelA21J2JumboInstruct:
type Data struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good to define these types in case??
I suggest to put these out of case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is put type on out of the functions. I think this will break the readability of the code and will have to be fixed anyway if any changes are made in the future.

@AlexsJones
Copy link
Member

Can you respond to comments and we will merge this next week @awsyshah ?

@awsyshah
Copy link
Author

made the key suggest improvement of moving some of the constants to config. The other vars are as per the API or not need outside of the case and hence declared within it. Please review.

@JuHyung-Son
Copy link
Contributor

comments are not fixed

@awsyshah
Copy link
Author

comments are not fixed

Hi @JuHyung-Son ,

Sorry for the trouble there, can I request which are the specific ones you want changed.

The first action of moving the constants like maxTokens to config is done right ? or is my understanding / implementation incorrect ?

For Comment 2 , the stop_reason , that call used is as per the documentation from :https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages.html

For Comment 3: The type you have commented on is only used once and that is if it is a a21 model so its defined within the area so as its only ever used there. The rest of the code has not use of it , is it still better to just define it up top even is only ever to be used if the model is one of the A21 one and may not be used otherwise ?

Let me know and I will make the changes so we can have this merged.

Thanks

Copy link
Contributor

@JuHyung-Son JuHyung-Son left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i got it.
LGTM!

@AlexsJones AlexsJones enabled auto-merge (squash) September 2, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Proposed
Development

Successfully merging this pull request may close these issues.

[Question]: Integration with Amazon bedrock issue
4 participants