dify icon indicating copy to clipboard operation
dify copied to clipboard

Add suuport for AWS Bedrock Cohere embedding

Open kerlion opened this issue 1 year ago • 5 comments

Description

I missed 2 changed files in last PR, change 2 files, and added 2 files. Added support below 2 Cohere embedings.

  • cohere.embed-english-v3
  • cohere.embed-multilingual-v3

Fixes # (issue)

Type of Change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update, included: Dify Document
  • [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • [ ] Dependency upgrade

How Has This Been Tested?

Tested in my docer ENV Dify 0.6.2.

  • [ ] TODO

Suggested Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [x] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • [ ] optional I have made corresponding changes to the documentation
  • [ ] optional I have added tests that prove my fix is effective or that my feature works
  • [ ] optional New and existing unit tests pass locally with my changes

kerlion avatar Apr 13 '24 06:04 kerlion

Please fix the lint error. :)

crazywoola avatar Apr 13 '24 09:04 crazywoola

Please fix the lint error. :)

I have fixed the import order.

kerlion avatar Apr 14 '24 00:04 kerlion

Please fix the lint error. :)

Hi, the Bedrock Cohere name is a little different from Cohere name. I have tested it before , everything works fine.

kerlion avatar Apr 14 '24 13:04 kerlion

Please fix the lint error. :)

We cannot do the change like that, I tested it with name like xxxv3.0 today, it will reprot below error.

Arguments: (InvokeError(),) [2024-04-15 07:46:11,295: ERROR/MainProcess] consume document failed Traceback (most recent call last): File "/app/api/core/model_runtime/model_providers/bedrock/text_embedding/text_embedding.py", line 226, in _invoke_bedrock_embedding response = bedrock_runtime.invoke_model( File "/usr/local/lib/python3.10/site-packages/botocore/client.py", line 535, in _api_call return self._make_api_call(operation_name, kwargs) File "/usr/local/lib/python3.10/site-packages/botocore/client.py", line 983, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the InvokeModel operation: Could not resolve the foundation model from the provided model identifier.

kerlion avatar Apr 15 '24 07:04 kerlion

@guchenhe, @crazywoola PLS review it.

kerlion avatar Apr 16 '24 00:04 kerlion