Files
ragflow/conf/models/bedrock.json
tmimmanuel f78ef328bb Go: implement Bedrock embeddings (#15543)
### What problem does this PR solve?

Fixes #15542.

AWS Bedrock support for the Go model provider layer was added in #15166,
but embedding support was intentionally left out of scope and
`BedrockModel.Embed(...)` still returned the `no such method` sentinel.
This PR implements Bedrock text embeddings under the umbrella provider
tracker #14736.

### What this PR includes

- `internal/entity/models/bedrock.go`: implement
`BedrockModel.Embed(...)` through Bedrock Runtime `InvokeModel` with
existing SigV4 auth, region resolution, and runtime URL helpers.
- Titan embeddings: supports `amazon.titan-embed-text-v1` and
`amazon.titan-embed-text-v2:0`; v2 forwards `EmbeddingConfig.Dimension`
as `dimensions` when provided, while v1 keeps the payload minimal.
- Cohere embeddings: supports `cohere.embed-english-v3`,
`cohere.embed-multilingual-v3`, and `cohere.embed-v4:0`; batches input
texts and maps returned vectors to RAGFlow `EmbeddingData` in input
order.
- `conf/models/bedrock.json`: adds the `embedding` URL suffix (`invoke`)
and Bedrock embedding model entries.
- `internal/entity/models/bedrock_test.go`: adds unit tests for Titan,
Cohere, typed Cohere responses, validation, empty input, unsupported
models, and HTTP error propagation.

Reference docs:

- Bedrock InvokeModel API:
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html
- Titan Text Embeddings:
https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html
- Cohere Embed models on Bedrock:
https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-embed.html

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

### How was this tested?

- [x] `jq empty conf/models/bedrock.json`
- [x] `git diff --check`
- [x] `go test ./internal/entity/models/... -run Bedrock -count=1`
- [x] `go test ./internal/entity/models/... -run '^$' -count=1`
- [x] `go test ./internal/entity/models/... -run Bedrock -race -count=1`

Note: `go test ./internal/entity/models/... -count=1` currently fails in
unrelated existing Astraflow coverage
(`TestAstraflowEmbedReturnsNoSuchMethod` panics in
`internal/entity/models/astraflow.go`). The Bedrock-specific tests and
compile-only package check pass.
2026-06-05 13:26:32 +08:00

152 lines
2.8 KiB
JSON

{
"name": "Bedrock",
"url_suffix": {
"chat": "converse",
"models": "foundation-models",
"embedding": "invoke"
},
"class": "bedrock",
"models": [
{
"name": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"max_tokens": 200000,
"model_types": [
"chat"
]
},
{
"name": "anthropic.claude-3-5-haiku-20241022-v1:0",
"max_tokens": 200000,
"model_types": [
"chat"
]
},
{
"name": "anthropic.claude-3-opus-20240229-v1:0",
"max_tokens": 200000,
"model_types": [
"chat"
]
},
{
"name": "anthropic.claude-3-sonnet-20240229-v1:0",
"max_tokens": 200000,
"model_types": [
"chat"
]
},
{
"name": "anthropic.claude-3-haiku-20240307-v1:0",
"max_tokens": 200000,
"model_types": [
"chat"
]
},
{
"name": "meta.llama3-1-405b-instruct-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "meta.llama3-1-70b-instruct-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "meta.llama3-1-8b-instruct-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "mistral.mistral-large-2407-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "mistral.mixtral-8x7b-instruct-v0:1",
"max_tokens": 32000,
"model_types": [
"chat"
]
},
{
"name": "amazon.nova-pro-v1:0",
"max_tokens": 300000,
"model_types": [
"chat"
]
},
{
"name": "amazon.nova-lite-v1:0",
"max_tokens": 300000,
"model_types": [
"chat"
]
},
{
"name": "amazon.nova-micro-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "cohere.command-r-plus-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "cohere.command-r-v1:0",
"max_tokens": 128000,
"model_types": [
"chat"
]
},
{
"name": "amazon.titan-embed-text-v2:0",
"max_tokens": 8192,
"model_types": [
"embedding"
]
},
{
"name": "amazon.titan-embed-text-v1",
"max_tokens": 8192,
"model_types": [
"embedding"
]
},
{
"name": "cohere.embed-english-v3",
"max_tokens": 512,
"model_types": [
"embedding"
]
},
{
"name": "cohere.embed-multilingual-v3",
"max_tokens": 512,
"model_types": [
"embedding"
]
},
{
"name": "cohere.embed-v4:0",
"max_tokens": 128000,
"model_types": [
"embedding"
]
}
]
}