feat: Add options to filter conversation history messages used in sequential LLM and Agent nodes (#3653)

* feat: Add option to disable conversation history

- Add new `disableConversationHistory` boolean parameter in LLMNodes.ts and Agent.ts to optionally skip including conversation history in prompts
- Fix potential error in Agent.ts when messages array is empty by adding null safety checks
- Improve memory efficiency by allowing stateless interactions when history isn't needed

* feat: add conversation history filtering options

Replace the disable conversation history feature with a more flexible filtering system that allows selecting:
- User question only
- Last message only
- All messages (default)
- No messages

This provides more granular control over conversation context management.

* chore: break lines

* chore: removed ending semi columns

* chore: fix eslint errors

* fix(sequentialagents): improve conversation history filtering logic

- Remove unnecessary state.messages check for user_question case
- Add proper null handling for last_message and all_messages cases
- Remove @ts-ignore comments with proper typing

* Update LLMNode.ts

* Update Agent.ts

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
Jean Ibarz
2024-12-12 14:29:28 +01:00
committed by GitHub
parent d974564ba5
commit 26b78ad55a
4 changed files with 147 additions and 29 deletions
+1
View File
@@ -183,6 +183,7 @@ export interface IMultiAgentNode {
}
type SeqAgentType = 'agent' | 'condition' | 'end' | 'start' | 'tool' | 'state' | 'llm'
export type ConversationHistorySelection = 'user_question' | 'last_message' | 'all_messages' | 'empty'
export interface ISeqAgentNode {
id: string