aws_bedrock_embeddings: support Cohere input_type and v4 response#4473
aws_bedrock_embeddings: support Cohere input_type and v4 response#4473squiidz wants to merge 3 commits into
Conversation
|
Commits Review
|
Cohere embedding models on Bedrock require an `input_type` field
(`search_document`, `search_query`, etc.) to produce correct asymmetric
embeddings, and Cohere Embed v4 changed the response schema from
`{"embeddings": [[...]]}` to `{"embeddings": {"float": [[...]]}}`.
Dispatch the request body shape and response parsing on the model ID,
using a substring match on "cohere" so regional inference profiles
like `us.cohere.embed-v4:0` are detected. Both v3 and v4 response
shapes are now accepted. Titan model code paths are unchanged
ec687d9 to
c7e85df
Compare
|
Commits Review LGTM |
…e time Bedrock rejects Cohere embed requests without an input_type, so fail once at config parse with a clear message instead of per message at runtime. Add a changelog entry for the Cohere request-shape fix.
| assert.ErrorContains(t, err, "expected a single embeddings response") | ||
| } | ||
|
|
||
| func TestNewProcessor_CohereRequiresInputType(t *testing.T) { |
There was a problem hiding this comment.
Test function names should use camelCase without underscores per the project's test conventions: write TestNewProcessorCohereRequiresInputType instead of TestNewProcessor_CohereRequiresInputType (the convention is "Write TestMyProcessorBadArgs, not TestMyProcessor_BadArgs").
|
Commits
Otherwise commit granularity and message format are good. Review The Cohere request/response dispatch is clean and well-tested (request shape, v3/v4 response parsing, parse-time validation). One minor convention issue:
|
Cohere embedding models on Bedrock require an
input_typefield(
search_document,search_query, etc.) to produce correct asymmetricembeddings, and Cohere Embed v4 changed the response schema from
{"embeddings": [[...]]}to{"embeddings": {"float": [[...]]}}.Dispatch the request body shape and response parsing on the model ID,
using a substring match on "cohere" so regional inference profiles
like
us.cohere.embed-v4:0are detected. Both v3 and v4 responseshapes are now accepted. Titan model code paths are unchanged