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

ValidationException in BedrockRuntime with Spring AI - Missing required keys and extraneous keys #2276

Open
cjullien opened this issue Feb 18, 2025 · 1 comment

Comments

@cjullien
Copy link

cjullien commented Feb 18, 2025

I encountered an error when using AWS Bedrock with Spring AI. The following exception is thrown by the BedrockRuntime service:

Observed Issue:

Error Occured at launch time
software.amazon.awssdk.services.bedrockruntime.model.ValidationException: Malformed input request: #: required key [prompt] not found#: required key [max_tokens_to_sample] not found#: extraneous key [texts] is not permitted#: extraneous key [truncate] is not permitted#: extraneous key [input_type] is not permitted, please reformat your input and try again. (Service: BedrockRuntime, Status Code: 400, Request ID: XXXXX)

Expected Behavior

The request should be correctly formatted to be accepted by AWS Bedrock.

Input

  • Spring AI version: last bom version
  • AWS Bedrock model used: anthropic.claude-3-haiku-20240307-v1:0

Properties

AWS_BEDROCK_MODEL=anthropic.claude-3-haiku-20240307-v1:0
spring.ai.bedrock.cohere.embedding.enabled=true
spring.ai.bedrock.cohere.embedding.model=${AWS_BEDROCK_MODEL}
spring.ai.bedrock.cohere.embedding.options.truncate=none
spring.ai.bedrock.cohere.embedding.options.input-type=search_document
spring.ai.bedrock.titan.embedding.enabled=false
spring.ai.bedrock.titan.embedding.model=${AWS_BEDROCK_MODEL}

Dependencies

		<dependency>
			<groupId>org.springframework.ai</groupId>
			<artifactId>spring-ai-bedrock-converse-spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.ai</groupId>
			<artifactId>spring-ai-bedrock-ai-spring-boot-starter</artifactId>
		</dependency>
@dev-jonghoonpark
Copy link
Contributor

dev-jonghoonpark commented Feb 20, 2025

Anthropic Claude-3 Haiku is a chat model, not an embedding model.

Currently, in Spring AI, You can select a Cohere model instead:

  • cohere.embed-multilingual-v3
  • cohere.embed-english-v3
Property Description Default
spring.ai.bedrock.cohere.embedding.model The model id to use. See the CohereEmbeddingModel for the supported models. cohere.embed-multilingual-v3

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

No branches or pull requests

2 participants