Class OllamaFunctionTool
java.lang.Object
me.neurodock.ollama.OllamaFunctionTool
- All Implemented Interfaces:
OllamaTool
- Direct Known Subclasses:
AddArrayMemory, AddMemoryFunction, GetArrayedMemories, GetArrayMemory, GetMemoriesFunction, GetMemoryFunction, GetMemoryIdentitiesFunction, ReadFileTool, RemoveMemoryFunction, WriteFileTool
Represents a tool that Ollama can call.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThis field is set via Reflection injection fromOllamaObject.addTool(OllamaTool, String). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe description of the tool This is used by Ollama to know what the tool doesabstract @NotNull OllamaToolResponsefunction(OllamaFunctionArgument... args) The function of the tool.
This is used by Ollama to call the tool.
ThrowOllamaToolErrorExceptionif the tool encounters an error instead of normal exceptions.abstract @NotNull Stringname()The name of the tool This is used by Ollama to know what the tool isabstract @NotNull OllamaPerameterThe parameters of the tool This is used by Ollama to know what parameters the tool takes If null, the tool does not take any parametersrenderCalling(org.json.JSONObject calling) Generates a string representation of this tool calling for rendering.toString()
-
Field Details
-
source
This field is set via Reflection injection fromOllamaObject.addTool(OllamaTool, String). As is, it will be overwritten. Do not set it yourself.
-
-
Constructor Details
-
OllamaFunctionTool
public OllamaFunctionTool()
-
-
Method Details
-
toString
-
renderCalling
Generates a string representation of this tool calling for rendering.- Parameters:
calling- the raw JSON sent from Ollama describing the complete function call- Returns:
- an
Optionalcontaining the formatted representation if this calling should be rendered, orOptional.empty()otherwise
-
name
The name of the tool This is used by Ollama to know what the tool is- Returns:
- The name of the tool
-
description
The description of the tool This is used by Ollama to know what the tool does- Returns:
- The description of the tool
-
parameters
The parameters of the tool This is used by Ollama to know what parameters the tool takes If null, the tool does not take any parameters- Returns:
- The parameters of the tool or null if the tool does not take any parameters
-
function
The function of the tool.
This is used by Ollama to call the tool.
ThrowOllamaToolErrorExceptionif the tool encounters an error instead of normal exceptions. TheOllamaToolErrorExceptiongets handled more gracefully byCore.handleResponse(JSONObject)- Parameters:
args- The arguments to pass to the tool, if any- Returns:
- The response from the tool, if null return
OllamaToolResponse - Throws:
OllamaToolErrorException- If the tool encounters an error
-