Class MessagesModelHook
java.lang.Object
com.alibaba.cloud.ai.graph.agent.hook.messages.MessagesModelHook
- All Implemented Interfaces:
Hook,Prioritized
- Direct Known Subclasses:
PIIDetectionHook,ReturnDirectModelHook,SummarizationHook
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInternal static class that proxies MessagesModelHook and implements AsyncNodeActionWithConfig interface for afterModel hook.static classInternal static class that proxies MessagesModelHook and implements AsyncNodeActionWithConfig interface. -
Field Summary
Fields inherited from interface com.alibaba.cloud.ai.graph.agent.Prioritized
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionafterModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) Creates an AfterModelAction instance for the given MessagesModelHook.beforeModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) Creates a BeforeModelAction instance for the given MessagesModelHook.getAgent()Gets the ReactAgent instance that owns this hook.Gets the name of the agent that owns this hook.intgetOrder()Returns the order value for this object.voidsetAgent(ReactAgent agent) Sets the ReactAgent instance that owns this hook.voidsetAgentName(String agentName) Sets the name of the agent that owns this hook.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alibaba.cloud.ai.graph.agent.hook.Hook
canJumpTo, getHookPositions, getKeyStrategys, getModelInterceptors, getName, getToolInterceptors, getTools
-
Constructor Details
-
MessagesModelHook
public MessagesModelHook()
-
-
Method Details
-
beforeModel
public AgentCommand beforeModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) -
afterModel
public AgentCommand afterModel(List<org.springframework.ai.chat.messages.Message> previousMessages, RunnableConfig config) -
setAgentName
Description copied from interface:HookSets the name of the agent that owns this hook. This is typically called by the framework during agent initialization.- Specified by:
setAgentNamein interfaceHook- Parameters:
agentName- the agent name, must not be null
-
getAgentName
Description copied from interface:HookGets the name of the agent that owns this hook.- Specified by:
getAgentNamein interfaceHook- Returns:
- the agent name, or null if not set
-
getAgent
Description copied from interface:HookGets the ReactAgent instance that owns this hook. This allows hooks to access the agent's state and configuration. -
setAgent
Description copied from interface:HookSets the ReactAgent instance that owns this hook. This is typically called by the framework during agent initialization. -
getOrder
public int getOrder()Description copied from interface:PrioritizedReturns the order value for this object.The order value determines the priority of this object when sorted with other
Prioritizedobjects. Objects with smaller order values will be sorted before objects with larger order values (ascending order).For example:
- An object with order 1 will be placed before an object with order 5
- An object with order 10 will be placed before an object with order 20
- Specified by:
getOrderin interfacePrioritized- Returns:
- the order value (smaller values indicate higher priority)
-
beforeModelAction
Creates a BeforeModelAction instance for the given MessagesModelHook.- Parameters:
hook- the MessagesModelHook instance to proxy- Returns:
- a BeforeModelAction instance
-
afterModelAction
Creates an AfterModelAction instance for the given MessagesModelHook.- Parameters:
hook- the MessagesModelHook instance to proxy- Returns:
- an AfterModelAction instance
-