Updated OllamaFunctionTool.toString to reflect what the Ollama API actually wants
build / build (push) Has been cancelled
build / build (push) Has been cancelled
Added @NotNull annotation to OllamaFunctionTool.name and OllamaFunctionTool.parameters since the documentation reports as these being required Made sure that OllamaFunctionTool.description is actually optional as the Ollama API docs define
This commit is contained in:
@@ -8,6 +8,8 @@ import me.zacharias.chat.ollama.OllamaFunctionTool;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jspecify.annotations.NonNull;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
@@ -45,7 +47,7 @@ public class APITool extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NonNull String name() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +57,7 @@ public class APITool extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
OllamaPerameter.OllamaPerameterBuilder parameter = OllamaPerameter.builder();
|
OllamaPerameter.OllamaPerameterBuilder parameter = OllamaPerameter.builder();
|
||||||
for (ToolArgument argument : arguments) {
|
for (ToolArgument argument : arguments) {
|
||||||
parameter.addProperty(argument.getName(), argument.getType(), argument.getDescription(), argument.isRequired());
|
parameter.addProperty(argument.getName(), argument.getType(), argument.getDescription(), argument.isRequired());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import me.zacharias.chat.ollama.OllamaFunctionTool;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -13,7 +14,7 @@ import java.nio.file.Path;
|
|||||||
public class ReadFileTool extends OllamaFunctionTool {
|
public class ReadFileTool extends OllamaFunctionTool {
|
||||||
FileHandler fs = FileHandler.getInstance();
|
FileHandler fs = FileHandler.getInstance();
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "read_file";
|
return "read_file";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ public class ReadFileTool extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("file_path", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The path to the file to be read")
|
.addProperty("file_path", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The path to the file to be read")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import me.zacharias.chat.ollama.OllamaFunctionTool;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the add_memory function.<br>
|
* Provides the add_memory function.<br>
|
||||||
@@ -17,7 +18,7 @@ public class AddMemoryFunction extends OllamaFunctionTool {
|
|||||||
CoreMemory memory = CoreMemory.getInstance();
|
CoreMemory memory = CoreMemory.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "add_memory";
|
return "add_memory";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public class AddMemoryFunction extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("memory", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The memory to remember", true)
|
.addProperty("memory", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The memory to remember", true)
|
||||||
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to remember", true)
|
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to remember", true)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class GetMemoriesFunction extends OllamaFunctionTool {
|
public class GetMemoriesFunction extends OllamaFunctionTool {
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_memories";
|
return "get_memories";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ public class GetMemoriesFunction extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import org.json.JSONArray;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the get_memory function.<br>
|
* Provides the get_memory function.<br>
|
||||||
@@ -18,7 +17,7 @@ public class GetMemoryFunction extends OllamaFunctionTool {
|
|||||||
CoreMemory memory = CoreMemory.getInstance();
|
CoreMemory memory = CoreMemory.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_memory";
|
return "get_memory";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,7 +27,7 @@ public class GetMemoryFunction extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to retrieve", true)
|
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to retrieve", true)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
|
||||||
public class GetMemoryIdentitiesFunction extends OllamaFunctionTool {
|
public class GetMemoryIdentitiesFunction extends OllamaFunctionTool {
|
||||||
CoreMemory memory = CoreMemory.getInstance();
|
CoreMemory memory = CoreMemory.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_memory_identities";
|
return "get_memory_identities";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public class GetMemoryIdentitiesFunction extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import me.zacharias.chat.ollama.OllamaFunctionTool;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the remove_memory function.<br>
|
* Provides the remove_memory function.<br>
|
||||||
@@ -17,7 +18,7 @@ public class RemoveMemoryFunction extends OllamaFunctionTool {
|
|||||||
CoreMemory memory = CoreMemory.getInstance();
|
CoreMemory memory = CoreMemory.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "remove_memory";
|
return "remove_memory";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ public class RemoveMemoryFunction extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to forget", true)
|
.addProperty("identity", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The identity of the memory to forget", true)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package me.zacharias.chat.ollama;
|
|||||||
|
|
||||||
import me.zacharias.chat.core.Core;
|
import me.zacharias.chat.core.Core;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -9,16 +10,22 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public abstract class OllamaFunctionTool implements OllamaTool {
|
public abstract class OllamaFunctionTool implements OllamaTool {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This field is set via Reflection injection from {@link OllamaObject#addTool(OllamaTool, String)}.
|
||||||
|
* As is, it will be over written. Do not set it yourself.
|
||||||
|
*/
|
||||||
protected String source = "";
|
protected String source = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
ret.put("tool", "function");
|
ret.put("type", "function");
|
||||||
|
|
||||||
JSONObject function = new JSONObject();
|
JSONObject function = new JSONObject();
|
||||||
function.put("name", name()+(source != null ? source : ""));
|
function.put("name", name()+(source != null ? source : ""));
|
||||||
function.put("description", description());
|
if(description() != null) {
|
||||||
|
function.put("description", description());
|
||||||
|
}
|
||||||
function.put("parameters", (parameters() == null?
|
function.put("parameters", (parameters() == null?
|
||||||
new JSONObject() : new JSONObject(parameters().toString())));
|
new JSONObject() : new JSONObject(parameters().toString())));
|
||||||
|
|
||||||
@@ -32,6 +39,7 @@ public abstract class OllamaFunctionTool implements OllamaTool {
|
|||||||
* This is used by Ollama to know what the tool is
|
* This is used by Ollama to know what the tool is
|
||||||
* @return The name of the tool
|
* @return The name of the tool
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
abstract public String name();
|
abstract public String name();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,14 +47,18 @@ public abstract class OllamaFunctionTool implements OllamaTool {
|
|||||||
* This is used by Ollama to know what the tool does
|
* This is used by Ollama to know what the tool does
|
||||||
* @return The description of the tool
|
* @return The description of the tool
|
||||||
*/
|
*/
|
||||||
abstract public String description();
|
public String description(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parameters of the tool
|
* The parameters of the tool
|
||||||
* This is used by Ollama to know what parameters the tool takes
|
* This is used by Ollama to know what parameters the tool takes
|
||||||
* If null, the tool does not take any parameters
|
* If null, the tool does not take any parameters
|
||||||
|
*
|
||||||
* @return The parameters of the tool or null if the tool does not take any parameters
|
* @return The parameters of the tool or null if the tool does not take any parameters
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
abstract public OllamaPerameter parameters();
|
abstract public OllamaPerameter parameters();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package me.zacharias.chat.display;
|
package me.zacharias.chat.display;
|
||||||
|
|
||||||
import com.github.dockerjava.api.DockerClient;
|
import com.github.dockerjava.api.DockerClient;
|
||||||
import com.github.dockerjava.api.async.ResultCallback;
|
|
||||||
import com.github.dockerjava.api.command.*;
|
|
||||||
import com.github.dockerjava.api.model.Frame;
|
|
||||||
import com.github.dockerjava.api.model.HostConfig;
|
import com.github.dockerjava.api.model.HostConfig;
|
||||||
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
||||||
import com.github.dockerjava.core.DockerClientImpl;
|
import com.github.dockerjava.core.DockerClientImpl;
|
||||||
@@ -14,8 +11,10 @@ import me.zacharias.chat.core.Pair;
|
|||||||
import me.zacharias.chat.ollama.*;
|
import me.zacharias.chat.ollama.*;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.jspecify.annotations.NonNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
@@ -28,7 +27,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static me.zacharias.chat.core.Core.writeLog;
|
import static me.zacharias.chat.core.Core.writeLog;
|
||||||
|
|
||||||
@@ -266,7 +264,7 @@ public class PythonRunner extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NonNull String name() {
|
||||||
return "python_runner";
|
return "python_runner";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +274,7 @@ public class PythonRunner extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("code", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The code to be executed, optional if a file with the same name exists.")
|
.addProperty("code", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The code to be executed, optional if a file with the same name exists.")
|
||||||
.addProperty("name", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The name of the python code")
|
.addProperty("name", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The name of the python code")
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jspecify.annotations.NonNull;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -20,12 +22,12 @@ public class TimeTool extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NonNull String name() {
|
||||||
return "get_current_date";
|
return "get_current_date";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
|||||||
import me.zacharias.neuro.dock.genius.GeniusEndpoint;
|
import me.zacharias.neuro.dock.genius.GeniusEndpoint;
|
||||||
import me.zacharias.neuro.dock.genius.GeniusEndpointTool;
|
import me.zacharias.neuro.dock.genius.GeniusEndpointTool;
|
||||||
import me.zacharias.neuro.dock.genius.GeniusTools;
|
import me.zacharias.neuro.dock.genius.GeniusTools;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ public class FindSong extends GeniusEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "findsong";
|
return "findsong";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ public class FindSong extends GeniusEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("title", STRING, "The title, artitst, and song_id of the song to find.", true)
|
.addProperty("title", STRING, "The title, artitst, and song_id of the song to find.", true)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
|||||||
import me.zacharias.neuro.dock.genius.GeniusEndpoint;
|
import me.zacharias.neuro.dock.genius.GeniusEndpoint;
|
||||||
import me.zacharias.neuro.dock.genius.GeniusEndpointTool;
|
import me.zacharias.neuro.dock.genius.GeniusEndpointTool;
|
||||||
import me.zacharias.neuro.dock.genius.GeniusTools;
|
import me.zacharias.neuro.dock.genius.GeniusTools;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@@ -15,8 +16,6 @@ import org.jsoup.nodes.Node;
|
|||||||
import org.jsoup.nodes.TextNode;
|
import org.jsoup.nodes.TextNode;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static me.zacharias.chat.core.Core.writeLog;
|
import static me.zacharias.chat.core.Core.writeLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,7 +39,7 @@ public class GetLyrics extends GeniusEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_lyrics";
|
return "get_lyrics";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ public class GetLyrics extends GeniusEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("song_id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The ID of the song to get lyrics for.", true)
|
.addProperty("song_id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The ID of the song to get lyrics for.", true)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@MALEndpoint
|
@MALEndpoint
|
||||||
@@ -20,7 +20,7 @@ public class GetAnimeDetails extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_anime_details";
|
return "get_anime_details";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class GetAnimeDetails extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The id of the anime", true)
|
.addProperty("id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The id of the anime", true)
|
||||||
.addProperty("fields", OllamaPerameter.OllamaPerameterBuilder.Type.ARRAY, "The fields to return, defaults to [\"id\", \"title\", \"synopsis\", \"genres\"]")
|
.addProperty("fields", OllamaPerameter.OllamaPerameterBuilder.Type.ARRAY, "The fields to return, defaults to [\"id\", \"title\", \"synopsis\", \"genres\"]")
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@MALEndpoint
|
@MALEndpoint
|
||||||
public class GetAnimeList extends MALEndpointTool {
|
public class GetAnimeList extends MALEndpointTool {
|
||||||
@@ -20,7 +20,7 @@ public class GetAnimeList extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_anime_list";
|
return "get_anime_list";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class GetAnimeList extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("query", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The query to search for",true)
|
.addProperty("query", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The query to search for",true)
|
||||||
.addProperty("offset", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The offset to start from")
|
.addProperty("offset", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The offset to start from")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public class GetManagDetails extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_manag_details";
|
return "get_manag_details";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ public class GetManagDetails extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The id of the manga", true)
|
.addProperty("id", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The id of the manga", true)
|
||||||
.addProperty("fields", OllamaPerameter.OllamaPerameterBuilder.Type.ARRAY, "The fields to return, defaults to [\"id\", \"title\", \"synopsis\", \"genres\"]")
|
.addProperty("fields", OllamaPerameter.OllamaPerameterBuilder.Type.ARRAY, "The fields to return, defaults to [\"id\", \"title\", \"synopsis\", \"genres\"]")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ public class GetMangaList extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_manga_list";
|
return "get_manga_list";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ public class GetMangaList extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("query", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The query to search for",true)
|
.addProperty("query", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The query to search for",true)
|
||||||
.addProperty("offset", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The offset to start from")
|
.addProperty("offset", OllamaPerameter.OllamaPerameterBuilder.Type.INT, "The offset to start from")
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
import me.zacharias.chat.ollama.OllamaPerameter;
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class GetWikiPageText extends OllamaFunctionTool {
|
public class GetWikiPageText extends OllamaFunctionTool {
|
||||||
Wiki wiki = WikipediaTool.wiki;
|
Wiki wiki = WikipediaTool.wiki;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String name() {
|
public @NotNull String name() {
|
||||||
return "get_wiki_page_text";
|
return "get_wiki_page_text";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ public class GetWikiPageText extends OllamaFunctionTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public @NotNull OllamaPerameter parameters() {
|
||||||
return OllamaPerameter.builder()
|
return OllamaPerameter.builder()
|
||||||
.addProperty("title", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The title of the Wikipedia page to retrieve text from.", true)
|
.addProperty("title", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "The title of the Wikipedia page to retrieve text from.", true)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user