mirror of
https://github.com/n8n-io/n8n.git
synced 2025-12-05 19:27:26 -06:00
chore(ai-builder): Use isAIMessage for LangGraph v1 compatibility (no-changelog) (#22807)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
||||
import type { ToolMessage } from '@langchain/core/messages';
|
||||
import { AIMessage, HumanMessage, RemoveMessage } from '@langchain/core/messages';
|
||||
import { AIMessage, HumanMessage, isAIMessage, RemoveMessage } from '@langchain/core/messages';
|
||||
import type { RunnableConfig } from '@langchain/core/runnables';
|
||||
import type { LangChainTracer } from '@langchain/core/tracers/tracer_langchain';
|
||||
import type { MemorySaver, StateSnapshot } from '@langchain/langgraph';
|
||||
@@ -287,7 +287,7 @@ export class WorkflowBuilderAgent {
|
||||
|
||||
const shouldContinue = ({ messages }: typeof WorkflowState.State) => {
|
||||
const lastMessage = messages[messages.length - 1];
|
||||
if (!(lastMessage instanceof AIMessage)) {
|
||||
if (!lastMessage || !isAIMessage(lastMessage)) {
|
||||
throw new WorkflowStateError('Expected last message to be generated by the AI agent');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user