Class ToolContext
java.lang.Object
org.springframework.ai.chat.model.ToolContext
Represents the context for tool execution in a function calling scenario.
This class encapsulates a map of contextual information that can be passed to tools (functions) when they are called. It provides an immutable view of the context to ensure thread-safety and prevent modification after creation.
The context is typically populated from the toolContext
field of
FunctionCallingOptions
and is used in the function execution process.
The context map can contain any information that is relevant to the tool execution.
- Since:
- 1.0.0
- Author:
- Christian Tzolov
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The key for the running, tool call history stored in the context map. -
Constructor Summary
ConstructorDescriptionToolContext
(Map<String, Object> context) Constructs a new ToolContext with the given context map. -
Method Summary
Modifier and TypeMethodDescriptionReturns the immutable context map.Returns the tool call history from the context map.
-
Field Details
-
TOOL_CALL_HISTORY
The key for the running, tool call history stored in the context map.- See Also:
-
-
Constructor Details
-
ToolContext
Constructs a new ToolContext with the given context map.- Parameters:
context
- A map containing the tool context information. This map is wrapped in an unmodifiable view to prevent changes.
-
-
Method Details
-
getContext
Returns the immutable context map.- Returns:
- An unmodifiable view of the context map.
-
getToolCallHistory
Returns the tool call history from the context map.- Returns:
- The tool call history.
-