bedrock: Fix empty tool input on project diagnostic in bedrock (#33369)
Bedrock [do not accept][1] `null` as a JSON value input for the tool call when called back. Instead of passing null, we will pass back an empty object, which is accepted by API Closes #33204 Release Notes: - Fixed project diagnostic tool call for bedrock [1]: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ToolUseBlock.html
This commit is contained in:
parent
1c6b4712a3
commit
c6ff58675f
1 changed files with 16 additions and 8 deletions
|
@ -648,14 +648,22 @@ pub fn into_bedrock(
|
|||
|
||||
Some(BedrockInnerContent::ReasoningContent(redacted))
|
||||
}
|
||||
MessageContent::ToolUse(tool_use) => BedrockToolUseBlock::builder()
|
||||
.name(tool_use.name.to_string())
|
||||
.tool_use_id(tool_use.id.to_string())
|
||||
.input(value_to_aws_document(&tool_use.input))
|
||||
.build()
|
||||
.context("failed to build Bedrock tool use block")
|
||||
.log_err()
|
||||
.map(BedrockInnerContent::ToolUse),
|
||||
MessageContent::ToolUse(tool_use) => {
|
||||
let input = if tool_use.input.is_null() {
|
||||
// Bedrock API requires valid JsonValue, not null, for tool use input
|
||||
value_to_aws_document(&serde_json::json!({}))
|
||||
} else {
|
||||
value_to_aws_document(&tool_use.input)
|
||||
};
|
||||
BedrockToolUseBlock::builder()
|
||||
.name(tool_use.name.to_string())
|
||||
.tool_use_id(tool_use.id.to_string())
|
||||
.input(input)
|
||||
.build()
|
||||
.context("failed to build Bedrock tool use block")
|
||||
.log_err()
|
||||
.map(BedrockInnerContent::ToolUse)
|
||||
},
|
||||
MessageContent::ToolResult(tool_result) => {
|
||||
BedrockToolResultBlock::builder()
|
||||
.tool_use_id(tool_result.tool_use_id.to_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue