Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
OllamaToolsResult.java
Go to the documentation of this file.
1/*
2 * Ollama4j - Java library for interacting with Ollama server.
3 * Copyright (c) 2025 Amith Koujalgi and contributors.
4 *
5 * Licensed under the MIT License (the "License");
6 * you may not use this file except in compliance with the License.
7 *
8*/
9package io.github.ollama4j.tools;
10
11import io.github.ollama4j.models.response.OllamaResult;
12import java.util.ArrayList;
13import java.util.List;
14import java.util.Map;
15import lombok.AllArgsConstructor;
16import lombok.Data;
17import lombok.NoArgsConstructor;
18
19@Data
20@NoArgsConstructor
21@AllArgsConstructor
22public class OllamaToolsResult {
23 private OllamaResult modelResult;
24 private Map<ToolFunctionCallSpec, Object> toolResults;
25
26 public List<ToolResult> getToolResults() {
27 List<ToolResult> results = new ArrayList<>();
28 if (this.toolResults == null) {
29 return results;
30 }
31 for (Map.Entry<ToolFunctionCallSpec, Object> r : this.toolResults.entrySet()) {
32 results.add(
33 new ToolResult(r.getKey().getName(), r.getKey().getArguments(), r.getValue()));
34 }
35 return results;
36 }
37
38 @Data
39 @NoArgsConstructor
40 @AllArgsConstructor
41 public static class ToolResult {
42 private String functionName;
43 private Map<String, Object> functionArguments;
44 private Object result;
45 }
46}