Skip to content

Commit

Permalink
chore: adjust test
Browse files Browse the repository at this point in the history
  • Loading branch information
KavithaSiva committed Feb 10, 2025
1 parent d611937 commit 56222b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/langchain/src/openai/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ describe('Mapping Functions', () => {
...defaultOptions,
...options
});
// Todo find a better way to remove undefined properties
expect(JSON.parse(JSON.stringify(mapping))).toStrictEqual(request);
expect(mapping).toMatchObject(request);
const assistantMessage = mapping.messages.filter(
message => message.role === 'assistant'
)[0];
expect(assistantMessage.tool_calls).toBeUndefined();
});

it('throws an error if the message type is not supported', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/langchain/src/openai/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function mapAiMessageToAzureOpenAiAssistantMessage(
message.additional_kwargs.tool_calls;
return {
name: message.name,
...(tool_calls?.length && { tool_calls }),
...(tool_calls?.length ? { tool_calls } : {}),
function_call: message.additional_kwargs.function_call,
content:
message.content as AzureOpenAiChatCompletionRequestAssistantMessage['content'],
Expand Down

0 comments on commit 56222b5

Please sign in to comment.