mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-10-27 06:30:42 +01:00
Refactor tool handling in Ollama class to merge request-specific and globally registered tools into a single list, ensuring original requests remain unmodified. Also, remove unnecessary newline in documentation for model pulling command.
This commit is contained in:
@@ -209,7 +209,6 @@ 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.
|
||||
|
||||
@@ -804,9 +804,21 @@ 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(request.getTools());
|
||||
chatRequest.setTools(allTools);
|
||||
if (streamObserver != null) {
|
||||
chatRequest.setStream(true);
|
||||
if (streamObserver.getResponseStreamHandler() != null) {
|
||||
|
||||
Reference in New Issue
Block a user