Skip to content

Commit

Permalink
fix silly unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Jan 3, 2024
1 parent 5f94ec3 commit 2854f7d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/llm/chat-completion-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const createDefaultParams = {
class LlmChatCompletionMessage extends LlmEvent {
constructor(params = defaultParams) {
const { agent, response, index, completionId } = params
super({ agent, response })
super(params)

this.is_response = Object.keys(response) > 0
this.conversation_id = this.conversationId(agent)
Expand Down
4 changes: 2 additions & 2 deletions lib/llm/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class LlmEvent {
* @returns {Promise<LlmEvent>}
*/
static async create(params = createDefaultParams) {
const { agent, awsClient, response } = params
const event = new LlmEvent({ agent, response })
const { awsClient } = params
const event = new LlmEvent(params)
await event.addKeyDigits(awsClient)
return event
}
Expand Down
13 changes: 11 additions & 2 deletions tests/unit/llm/chat-completion-message.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,22 @@ tap.beforeEach((t) => {
t.context.response = {
headers: {
'x-amzn-requestid': 'request-1'
},
body: Buffer.from('{"foo":"foo"}')
}

t.context.invokeCommand = {
input: {
accept: 'application/json',
contentType: 'application/json',
modelId: 'amazon.titan-text-express-v1',
body: '{"foo":"foo"}'
}
}
})

tap.test('create creates a new instance', async (t) => {
const { agent, awsClient, response } = t.context
const event = await LlmChatCompletionMessage.create({ agent, awsClient, response })
const event = await LlmChatCompletionMessage.create(t.context)
t.type(event, LlmEvent)
t.type(event, LlmChatCompletionMessage)
t.equal(event.api_key_last_four_digits, '6789')
Expand Down
13 changes: 11 additions & 2 deletions tests/unit/llm/event.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ tap.beforeEach((t) => {
t.context.response = {
headers: {
'x-amzn-requestid': 'request-1'
},
body: Buffer.from('{"foo":"foo"}')
}

t.context.invokeCommand = {
input: {
accept: 'application/json',
contentType: 'application/json',
modelId: 'amazon.titan-text-express-v1',
body: '{"foo":"foo"}'
}
}
})

tap.test('create creates a new instance', async (t) => {
const { agent, awsClient, response } = t.context
const event = await LlmEvent.create({ agent, awsClient, response })
const event = await LlmEvent.create(t.context)
t.ok(event)
t.equal(event.api_key_last_four_digits, '6789')
})

0 comments on commit 2854f7d

Please sign in to comment.