Compare commits

..

1 Commits

Author SHA1 Message Date
Amith Koujalgi
b456feda64 Merge pull request #225 from ollama4j/fix-docs-build
Some checks failed
CodeQL / Analyze (java) (push) Failing after 12s
CodeQL / Analyze (javascript) (push) Failing after 10s
Mark stale issues / stale (push) Failing after 15s
Mark stale issues and PRs / stale (push) Failing after 1m50s
Update Docs Build GHA
2025-10-23 12:11:35 +05:30
3 changed files with 3 additions and 26 deletions

View File

@@ -209,6 +209,7 @@ To download/pull the model into your Ollama server, run the following command in
```shell
ollama pull mistral
```
You can list the models available on your model server by running the following command in your terminal.

View File

@@ -31,19 +31,7 @@ You could do that with ease with the `function calling` capabilities of the mode
### Create Tools/Functions
There are two ways to create and register your tools:
1. **Define static or regular methods and register them explicitly as tools.**
You can create standalone functions (static or instance methods) and manually associate them with your tool specifications.
2. **Use annotation-based tool discovery for automatic registration.**
By annotating your tool methods, you can leverage `registerAnnotatedTools()` to automatically scan your classpath, find all annotated tool functions, and register them without extra boilerplate.
Learn more about annotation-based tool registration [here](/apis-generate/chat-with-tools#annotation-based-tool-registration).
Choose the approach that best fits your project—manual for precise control, or annotation-based for easier scaling.
Let's start by exploring the first approach: manually defining and registering your tools/functions.
We can create static functions as our tools.
This function takes the arguments `location` and `fuelType` and performs an operation with these arguments and returns
fuel price value.

View File

@@ -804,21 +804,9 @@ public class Ollama {
ocm.setResponse(request.getPrompt());
chatRequest.setMessages(msgs);
msgs.add(ocm);
// Merge request's tools and globally registered tools into a new list to avoid mutating the
// original request
List<Tools.Tool> allTools = new ArrayList<>();
if (request.getTools() != null) {
allTools.addAll(request.getTools());
}
List<Tools.Tool> registeredTools = this.getRegisteredTools();
if (registeredTools != null) {
allTools.addAll(registeredTools);
}
OllamaChatTokenHandler hdlr = null;
chatRequest.setUseTools(true);
chatRequest.setTools(allTools);
chatRequest.setTools(request.getTools());
if (streamObserver != null) {
chatRequest.setStream(true);
if (streamObserver.getResponseStreamHandler() != null) {