Skip to content

Commit

Permalink
test: Improved test coverage of normalizing claude 3 messages (newrel…
Browse files Browse the repository at this point in the history
  • Loading branch information
bizob2828 authored Jan 17, 2025
1 parent 6a83abf commit cc65763
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/unit/llm-events/aws-bedrock/bedrock-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ test('claude35 malformed payload produces reasonable values', async (t) => {
assert.equal(cmd.temperature, undefined)
})

test('claude35 skips a message that is null in `body.messages`', async (t) => {
const malformedPayload = structuredClone(claude35)
malformedPayload.body.messages = [{ role: 'user', content: 'who are you' }, null]
t.nr.updatePayload(malformedPayload)
const cmd = new BedrockCommand(t.nr.input)
assert.equal(cmd.isClaude3(), true)
assert.deepEqual(cmd.prompt, [{ role: 'user', content: 'who are you' }])
})

test('claude35 handles defaulting prompt to empty array when `body.messages` is null', async (t) => {
const malformedPayload = structuredClone(claude35)
malformedPayload.body.messages = null
t.nr.updatePayload(malformedPayload)
const cmd = new BedrockCommand(t.nr.input)
assert.equal(cmd.isClaude3(), true)
assert.deepEqual(cmd.prompt, [])
})

test('claude35 minimal command works', async (t) => {
t.nr.updatePayload(structuredClone(claude35))
const cmd = new BedrockCommand(t.nr.input)
Expand Down

0 comments on commit cc65763

Please sign in to comment.