Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ function extractMessagesFromConverseContent (role, contentBlocks) {
if (block == null || typeof block !== 'object') continue
if (typeof block.text === 'string') {
content += block.text
} else if (typeof block.guardContent?.text?.text === 'string') {
content += block.guardContent.text.text
Comment thread
BridgeAR marked this conversation as resolved.
} else if (block.toolUse) {
toolCalls.push(buildToolCall(block.toolUse))
} else if (block.toolResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ describe('bedrockruntime utils', () => {
})
})

it('reads the text of Converse guardContent blocks', () => {
const message = extractMessagesFromConverseContent('user', [
{ text: 'Context: ' },
{ guardContent: { text: { text: 'What is the dose?', qualifiers: ['guard_content'] } } },
{ text: ' Cite sources.' },
])

assert.deepStrictEqual(message, {
role: 'user',
content: 'Context: What is the dose? Cite sources.',
})
})

describe('converse stream extractor', () => {
it('returns an empty message when the stream fails before yielding a chunk', () => {
const generation = extractTextAndResponseReasonConverseFromStream()
Expand Down
Loading