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 Amazon Bedrock Mistral Large model #198

Merged
merged 20 commits into from
Apr 9, 2024
Merged

Conversation

curlyfro
Copy link
Contributor

@curlyfro curlyfro commented Apr 9, 2024

also added default ChatSettings for all Bedrock models

Summary by CodeRabbit

  • New Features
    • Enhanced chat functionality across various AI models with the addition of new settings and parameters to improve chat response generation.
    • Introduced new classes for specific AI models to provide tailored chat settings, including default values and calculation methods based on input parameters.
  • Refactor
    • Updated and standardized the naming convention for chat settings across different AI models to improve clarity and consistency.
    • Removed the MaximumInputLength property from embedding models to align with updated input length constraints.
  • Documentation
    • Added and updated method documentation to reflect new parameters, settings, and their purposes in generating chat responses.

curlyfro and others added 16 commits March 23, 2024 19:01
remove legacy Bedrock anthropic.claude-v1 model
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

sweep-ai bot commented Apr 9, 2024

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

This is an automated message generated by Sweep AI.

Copy link
Contributor

coderabbitai bot commented Apr 9, 2024

Walkthrough

The recent updates across chat and embedding models in the project aim to enhance functionality and customization. These changes introduce new methods for generating responses, refine settings for tailored interactions, and optimize input handling for improved model performance and adaptability.

Changes

Files Changes
src/Providers/Amazon.Bedrock/src/Chat/*.cs Various chat models updated with new methods and settings adjustments.
src/Providers/Amazon.Bedrock/src/Chat/Settings/*.cs Introduction of new settings classes extending BedrockChatSettings for enhanced customization.
src/Providers/Amazon.Bedrock/src/Embedding/*.cs Removal of MaximumInputLength property and addition of CreateEmbeddingsAsync method for embedding models.
src/Providers/Amazon.Bedrock/src/Embedding/Settings/*.cs New settings classes introduced to calculate and manage settings for embeddings.
src/Databases/OpenSearch/src/LangChain.Databases.OpenSearch.csproj Update in project metadata by including additional tags related to AWS, Amazon, OpenSearch, and API.

🐇✨
Changes unfold, in code they dance,
New methods sprout, models enhance.
Constraints released, models now soar,
In the realm of AI, they explore more.
🌼📜🌟
Progress strides in this digital land,
Where innovation blooms, with a magical hand.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d3d563e and bcbe193.
Files selected for processing (19)
  • src/Directory.Packages.props (1 hunks)
  • src/Providers/Abstractions/src/Embedding/IEmbeddingModel.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Ai21LabsJurassic2ChatModel.cs (4 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AmazonTitanChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaude3ChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaudeChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/CohereCommandChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/MetaLlama2ChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/MistralInstructChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/Ai21LabsJurassic2ChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/AmazonTitanChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/AnthropicChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/AnthropicClaude3ChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/CohereCommandChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/MetaLlama2ChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/Settings/MistralInstructChatSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanEmbeddingModel.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanImageEmbeddingModel.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Predefined/Mistral.cs (1 hunks)
Files not reviewed due to errors (4)
  • (no review received)
  • (no review received)
  • (no review received)
  • (no review received)
Additional comments not posted (18)
src/Providers/Abstractions/src/Embedding/IEmbeddingModel.cs (1)

6-11: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-13]

Removal of MaximumInputLength aligns with PR objectives. Ensure all implementations of IEmbeddingModel are updated accordingly.

src/Providers/Amazon.Bedrock/src/Predefined/Mistral.cs (1)

12-14: Addition of MistralLarge class is consistent with the framework's model structure.

src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanEmbeddingModel.cs (1)

10-15: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-37]

Ensure the removal of MaximumInputLength does not impact the handling of large inputs in CreateEmbeddingsAsync.

src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanImageEmbeddingModel.cs (1)

10-15: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-37]

Ensure the removal of MaximumInputLength does not impact the handling of large inputs or large numbers of images in CreateEmbeddingsAsync.

src/Providers/Amazon.Bedrock/src/Chat/Ai21LabsJurassic2ChatModel.cs (1)

58-80: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [13-79]

Enhancements to GenerateAsync and addition of CreateBodyJson improve flexibility and maintainability.

src/Providers/Amazon.Bedrock/src/Chat/Settings/AnthropicChatSettings.cs (1)

1-80: Introduction of AnthropicChatSettings aligns with the framework's approach to model-specific chat settings.

src/Providers/Amazon.Bedrock/src/Chat/Settings/MetaLlama2ChatSettings.cs (1)

1-80: Introduction of MetaLlama2ChatSettings maintains consistency in handling model-specific chat settings.

src/Providers/Amazon.Bedrock/src/Chat/Settings/AmazonTitanChatSettings.cs (1)

1-80: Introduction of AmazonTitanChatSettings complements the framework's standardized approach to chat settings.

src/Providers/Amazon.Bedrock/src/Chat/Settings/CohereCommandChatSettings.cs (2)

4-15: Ensure the default settings align with the intended use cases for CohereCommandChatSettings.


25-78: Consider validating the input parameters of the Calculate method to ensure they are not all null, which could lead to unexpected behavior.

src/Providers/Amazon.Bedrock/src/Chat/Settings/MistralInstructChatSettings.cs (2)

4-15: Ensure the default settings for MistralInstructChatSettings are appropriate for the Mistral model's requirements.


25-78: Consider adding input validation to the Calculate method to prevent potential issues when all input settings are null.

src/Providers/Amazon.Bedrock/src/Chat/Settings/AnthropicClaude3ChatSettings.cs (2)

4-15: Verify that the default settings for AnthropicClaude3ChatSettings meet the specific needs of the Anthropic Claude 3 model.


25-78: Recommend adding parameter validation in the Calculate method to handle cases where all input settings might be null.

src/Providers/Amazon.Bedrock/src/Chat/Settings/Ai21LabsJurassic2ChatSettings.cs (2)

4-15: Confirm that the default settings for Ai21LabsJurassic2ChatSettings are correctly configured for the Ai21 Labs Jurassic 2 model.


25-78: Suggest implementing input validation in the Calculate method to ensure robustness when all input settings are null.

src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaude3ChatModel.cs (1)

22-22: Changes to GenerateAsync method align well with the class's focus on Anthropic models.

src/Directory.Packages.props (1)

33-33: Addition of "Microsoft.AspNetCore.StaticFiles" package is noted. Ensure compatibility with other project dependencies.

BinaryData? image = null)
{
settings = settings ?? throw new ArgumentNullException(nameof(settings));
usedSettings = usedSettings ?? throw new ArgumentNullException(nameof(usedSettings));
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using modern C# syntax for null checking.

- usedSettings = usedSettings ?? throw new ArgumentNullException(nameof(usedSettings));
+ _ = usedSettings ?? throw new ArgumentNullException(nameof(usedSettings));

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
usedSettings = usedSettings ?? throw new ArgumentNullException(nameof(usedSettings));
_ = usedSettings ?? throw new ArgumentNullException(nameof(usedSettings));

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between bcbe193 and 894ad23.
Files selected for processing (7)
  • src/Providers/Amazon.Bedrock/src/Chat/Ai21LabsJurassic2ChatModel.cs (4 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AmazonTitanChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaude3ChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaudeChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/CohereCommandChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/MetaLlama2ChatModel.cs (3 hunks)
  • src/Providers/Amazon.Bedrock/src/Chat/MistralInstructChatModel.cs (3 hunks)
Files skipped from review as they are similar to previous changes (7)
  • src/Providers/Amazon.Bedrock/src/Chat/Ai21LabsJurassic2ChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/AmazonTitanChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaude3ChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/AnthropicClaudeChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/CohereCommandChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/MetaLlama2ChatModel.cs
  • src/Providers/Amazon.Bedrock/src/Chat/MistralInstructChatModel.cs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 894ad23 and 5b4e9da.
Files selected for processing (7)
  • src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanEmbeddingModel.cs (2 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanImageEmbeddingModel.cs (2 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/CohereEmbeddingModel.cs (4 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/Settings/AmazonEmbeddingSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/Settings/AmazonMultiModalEmbeddingSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/src/Embedding/Settings/CohereEmbeddingSettings.cs (1 hunks)
  • src/Providers/Amazon.Bedrock/test/BedrockTests.cs (2 hunks)
Additional comments not posted (12)
src/Providers/Amazon.Bedrock/src/Embedding/Settings/CohereEmbeddingSettings.cs (2)

4-10: Consider documenting the default settings for clarity.


20-43: Ensure proper handling of null values in Calculate method to avoid potential InvalidOperationException.

src/Providers/Amazon.Bedrock/src/Embedding/Settings/AmazonEmbeddingSettings.cs (2)

4-10: Consider documenting the default settings for clarity.


20-43: Ensure proper handling of null values in Calculate method to avoid potential InvalidOperationException.

src/Providers/Amazon.Bedrock/src/Embedding/Settings/AmazonMultiModalEmbeddingSettings.cs (1)

4-10: Consider documenting the default settings for clarity.

src/Providers/Amazon.Bedrock/src/Embedding/CohereEmbeddingModel.cs (2)

14-20: Ensure the method documentation is updated to reflect the new parameters and their purposes.


43-53: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [30-64]

Validate the handling of MaximumInputLength and Dimensions in usedSettings to ensure they are correctly applied.

Verification successful

The handling of MaximumInputLength and Dimensions in usedSettings is consistently and correctly applied across the application, as evidenced by their usage in different embedding models for splitting text and initializing float arrays, respectively. This aligns with the expected behavior for these settings in the context of embedding models.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the handling of MaximumInputLength and Dimensions in usedSettings is consistent and correct across the application.
rg "usedSettings.MaximumInputLength"
rg "usedSettings.Dimensions"

Length of output: 841

src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanEmbeddingModel.cs (2)

14-20: Ensure the method documentation is updated to reflect the new parameters and their purposes.


31-31: Validate the handling of MaximumInputLength and Dimensions in usedSettings to ensure they are correctly applied.

Verification successful

The handling of MaximumInputLength and Dimensions in usedSettings is verified to be consistent and correctly applied across the application. The usage in different embedding models aligns with the expected functionality of these settings.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the handling of MaximumInputLength and Dimensions in usedSettings is consistent and correct across the application.
rg "usedSettings.MaximumInputLength"
rg "usedSettings.Dimensions"

Length of output: 841

src/Providers/Amazon.Bedrock/src/Embedding/AmazonTitanImageEmbeddingModel.cs (2)

14-19: Ensure the method documentation is updated to reflect the new parameters and their purposes.


29-29: Validate the handling of MaximumInputLength and Dimensions in usedSettings to ensure they are correctly applied.

Verification successful

The provided shell script output indicates that both MaximumInputLength and Dimensions properties of usedSettings are being utilized in the application, specifically within the context of splitting text based on MaximumInputLength and creating float arrays based on Dimensions. This usage occurs across different embedding models (AmazonTitanImageEmbeddingModel, CohereEmbeddingModel, and AmazonTitanEmbeddingModel), suggesting a consistent application of these settings.

Given this context, it appears that the handling of MaximumInputLength and Dimensions in usedSettings is indeed consistent and correctly applied across the application, as evidenced by their use in splitting text and allocating arrays for embeddings, respectively. This consistency in application supports the correctness of their implementation in relation to the original review comment's concern.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the handling of MaximumInputLength and Dimensions in usedSettings is consistent and correct across the application.
rg "usedSettings.MaximumInputLength"
rg "usedSettings.Dimensions"

Length of output: 841

src/Providers/Amazon.Bedrock/test/BedrockTests.cs (1)

295-307: Ensure the TestEmbedding method correctly uses the prompt variable and validates the embedding results.

@HavenDV HavenDV enabled auto-merge (squash) April 9, 2024 10:29
@HavenDV HavenDV merged commit aef21a8 into tryAGI:main Apr 9, 2024
2 checks passed
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.

None yet

2 participants