Invoke AWS Bedrock Mistral model have issues #4625

Closed
opened 2026-02-21 18:07:17 -05:00 by yindo · 3 comments
Owner

Originally created by @SIN1109 on GitHub (Jul 16, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.13

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Create chatbot agent in Studio without any PE, just type in "hello" in the chat. It will response errror:

[bedrock] Error: An error occurred (validationException) when calling the InvokeModelWithResponseStream operation: Validation Error

It will have issues for both

mistral.mistral-7b-instruct-v0:2
mistral.mixtral-8x7b-instruct-v0:1

Also tested Claude3 Sonnet and Titan amazon.titan-text-express-v1 without issues.

The AK/SK and region also been validated.

✔️ Expected Behavior

Can use Mistral model in dify.ai via bedrock integrations

Actual Behavior

image

Originally created by @SIN1109 on GitHub (Jul 16, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.13 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Create chatbot agent in Studio without any PE, just type in "hello" in the chat. It will response errror: [bedrock] Error: An error occurred (validationException) when calling the InvokeModelWithResponseStream operation: Validation Error It will have issues for both mistral.mistral-7b-instruct-v0:2 mistral.mixtral-8x7b-instruct-v0:1 Also tested Claude3 Sonnet and Titan amazon.titan-text-express-v1 without issues. The AK/SK and region also been validated. ### ✔️ Expected Behavior Can use Mistral model in dify.ai via bedrock integrations ### ❌ Actual Behavior ![image](https://github.com/user-attachments/assets/b7b05a8d-1bbb-4dd1-9dd6-534eff8c3558)
yindo added the 🐞 bug label 2026-02-21 18:07:17 -05:00
yindo closed this issue 2026-02-21 18:07:17 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 16, 2024):

@SIN1109 Hello there! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together!

To resolve the validationException error when invoking the AWS Bedrock Mistral model using the Dify platform, ensure the following:

  1. Correct Credentials: Verify that the AWS credentials (Access Key, Secret Access Key, and Region) are correct and have the necessary permissions.

  2. Model Parameters: Ensure that the parameters for the Mistral model are correctly set. The required parameters for the Mistral model are:

    • temperature: Optional, default is 0.5
    • top_p: Optional, default is 0.9
    • top_k: Optional, default is 50, with a maximum of 200
    • max_tokens: Required, default is 512, with a minimum of 1 and a maximum of 8192
    • context_size: 32000
  3. Configuration File: Ensure that the bedrock.yaml configuration file is correctly set up with the necessary environment variables and model parameters.

  4. Validation Method: The validate_provider_credentials method in the MistralAIProvider class is responsible for validating the credentials. Ensure that this method is correctly implemented and that the credentials are valid.

Here is a relevant code snippet for validating the credentials:

class MistralAIProvider(ModelProvider):

    def validate_provider_credentials(self, credentials: dict) -> None:
        try:
            model_instance = self.get_model_instance(ModelType.LLM)
            model_instance.validate_credentials(
                model='open-mistral-7b',
                credentials=credentials
            )
        except CredentialsValidateFailedError as ex:
            raise ex
        except Exception as ex:
            logger.exception(f'{self.get_provider_schema().provider} credentials validate failed')
            raise ex

Additionally, ensure that the InvokeModelWithResponseStream operation is correctly handled in the Dify platform. The payload for the Mistral model should be correctly formatted and passed to the AWS Bedrock runtime client.

If the credentials and parameters are correct and you are still encountering the error, you may need to debug further by logging the exact exception message or checking the implementation of the validate_credentials method in the model instance [1][2][3][4].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 16, 2024): <!-- Greeting --> @SIN1109 Hello there! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's tackle this issue together! <!-- Answer --> To resolve the `validationException` error when invoking the AWS Bedrock Mistral model using the Dify platform, ensure the following: 1. **Correct Credentials**: Verify that the AWS credentials (Access Key, Secret Access Key, and Region) are correct and have the necessary permissions. 2. **Model Parameters**: Ensure that the parameters for the Mistral model are correctly set. The required parameters for the Mistral model are: - `temperature`: Optional, default is 0.5 - `top_p`: Optional, default is 0.9 - `top_k`: Optional, default is 50, with a maximum of 200 - `max_tokens`: Required, default is 512, with a minimum of 1 and a maximum of 8192 - `context_size`: 32000 3. **Configuration File**: Ensure that the `bedrock.yaml` configuration file is correctly set up with the necessary environment variables and model parameters. 4. **Validation Method**: The `validate_provider_credentials` method in the `MistralAIProvider` class is responsible for validating the credentials. Ensure that this method is correctly implemented and that the credentials are valid. Here is a relevant code snippet for validating the credentials: ```python class MistralAIProvider(ModelProvider): def validate_provider_credentials(self, credentials: dict) -> None: try: model_instance = self.get_model_instance(ModelType.LLM) model_instance.validate_credentials( model='open-mistral-7b', credentials=credentials ) except CredentialsValidateFailedError as ex: raise ex except Exception as ex: logger.exception(f'{self.get_provider_schema().provider} credentials validate failed') raise ex ``` Additionally, ensure that the `InvokeModelWithResponseStream` operation is correctly handled in the Dify platform. The payload for the Mistral model should be correctly formatted and passed to the AWS Bedrock runtime client. If the credentials and parameters are correct and you are still encountering the error, you may need to debug further by logging the exact exception message or checking the implementation of the `validate_credentials` method in the model instance <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/mistralai/mistralai.py)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/bedrock/text_embedding/text_embedding.py)</sup><sup>[[3]](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/bedrock/llm/llm.py)</sup><sup>[[4]](https://github.com/langgenius/dify/blob/main/api/tests/integration_tests/model_runtime/bedrock/test_llm.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@longzhihun commented on GitHub (Jul 16, 2024):

the issue was fixed in main branch, please have a look.

@longzhihun commented on GitHub (Jul 16, 2024): the issue was fixed in main branch, please have a look.
Author
Owner

@crazywoola commented on GitHub (Jul 16, 2024):

Link https://github.com/langgenius/dify/pull/6299

@crazywoola commented on GitHub (Jul 16, 2024): Link https://github.com/langgenius/dify/pull/6299
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4625