Skip to content

Commit 036c45a

Browse files
committed
When we see a tool call being prepared, update the msgtype of the response event to 'app.boxel.command'
1 parent 0d3de3b commit 036c45a

File tree

2 files changed

+61
-8
lines changed

2 files changed

+61
-8
lines changed

packages/ai-bot/tests/responding-test.ts

+53-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ module('Responding', (hooks) => {
656656
);
657657
});
658658

659-
<<<<<<< HEAD
660659
test('Handles sequence of thinking -> reasoning -> content correctly', async () => {
661660
await responder.ensureThinkingMessageSent();
662661

@@ -762,4 +761,57 @@ module('Responding', (hooks) => {
762761
);
763762
}
764763
});
764+
765+
test('Updates message type to command when tool call is in progress', async () => {
766+
await responder.initialize();
767+
await responder.onChunk({
768+
id: '0',
769+
created: 0,
770+
model: 'gpt-3.5-turbo',
771+
object: 'chat.completion.chunk',
772+
choices: [
773+
{
774+
delta: {
775+
tool_calls: [
776+
{
777+
index: 0,
778+
type: 'function',
779+
function: {
780+
name: 'patchCard',
781+
arguments: '',
782+
},
783+
},
784+
],
785+
},
786+
index: 0,
787+
finish_reason: 'stop',
788+
},
789+
],
790+
});
791+
792+
let sentEvents = fakeMatrixClient.getSentEvents();
793+
assert.equal(
794+
sentEvents.length,
795+
2,
796+
'Thinking message and event updating message type should be sent',
797+
);
798+
assert.equal(
799+
sentEvents[0].content.body,
800+
thinkingMessage,
801+
'Thinking message should be sent first',
802+
);
803+
assert.deepEqual(
804+
sentEvents[1].content['msgtype'],
805+
APP_BOXEL_COMMAND_MSGTYPE,
806+
'The message type should reflect that the model is preparing a tool call',
807+
);
808+
assert.deepEqual(
809+
sentEvents[1].content['m.relates_to'],
810+
{
811+
rel_type: 'm.replace',
812+
event_id: '0',
813+
},
814+
'The tool call event should replace the thinking message',
815+
);
816+
});
765817
});

pnpm-lock.yaml

+8-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)