-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/n8n-io/n8n into node-2266-…
…community-issue-the-microsoft-onedrive-node-is-not-working
- Loading branch information
Showing
53 changed files
with
739 additions
and
559 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { z } from 'zod'; | ||
|
||
export const heartbeatMessageSchema = z.object({ | ||
type: z.literal('heartbeat'), | ||
}); | ||
|
||
export type HeartbeatMessage = z.infer<typeof heartbeatMessageSchema>; | ||
|
||
export const createHeartbeatMessage = (): HeartbeatMessage => ({ | ||
type: 'heartbeat', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/test/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AIMessage, HumanMessage } from '@langchain/core/messages'; | ||
import { BufferWindowMemory } from 'langchain/memory'; | ||
|
||
import { getChatMessages } from '../helpers/utils'; | ||
|
||
describe('OpenAI message history', () => { | ||
it('should only get a limited number of messages', async () => { | ||
const memory = new BufferWindowMemory({ | ||
returnMessages: true, | ||
k: 2, | ||
}); | ||
expect(await getChatMessages(memory)).toEqual([]); | ||
|
||
await memory.saveContext( | ||
[new HumanMessage({ content: 'human 1' })], | ||
[new AIMessage({ content: 'ai 1' })], | ||
); | ||
// `k` means turns, but `getChatMessages` returns messages, so a Human and an AI message. | ||
expect((await getChatMessages(memory)).length).toEqual(2); | ||
|
||
await memory.saveContext( | ||
[new HumanMessage({ content: 'human 2' })], | ||
[new AIMessage({ content: 'ai 2' })], | ||
); | ||
expect((await getChatMessages(memory)).length).toEqual(4); | ||
expect((await getChatMessages(memory)).map((msg) => msg.content)).toEqual([ | ||
'human 1', | ||
'ai 1', | ||
'human 2', | ||
'ai 2', | ||
]); | ||
|
||
// We expect this to be trimmed... | ||
await memory.saveContext( | ||
[new HumanMessage({ content: 'human 3' })], | ||
[new AIMessage({ content: 'ai 3' })], | ||
); | ||
expect((await getChatMessages(memory)).length).toEqual(4); | ||
expect((await getChatMessages(memory)).map((msg) => msg.content)).toEqual([ | ||
'human 2', | ||
'ai 2', | ||
'human 3', | ||
'ai 3', | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.