Quick and dirty commit, due to heaste of this needing

This commit is contained in:
2025-06-08 22:01:17 +02:00
parent 840ad468e3
commit 57fc7f2533
19 changed files with 334 additions and 63 deletions

View File

@@ -8,7 +8,9 @@ version = '1.0-SNAPSHOT'
dependencies {
implementation project(":Core")
implementation project(":MALAPITool")
implementation project(":GeniusAPI")
implementation project(":API")
implementation project(":WikipediaTool")
}
test {

View File

@@ -8,6 +8,9 @@ import me.zacharias.chat.core.files.FileHandlerLocation;
import me.zacharias.chat.core.memory.CoreMemory;
import me.zacharias.chat.mal.api.MALAPITool;
import me.zacharias.chat.ollama.*;
import me.zacharias.chat.ollama.utils.SystemMessage;
import me.zacharias.neuro.dock.genius.GeniusTools;
import me.zacharias.neuro.dock.wikipedia.WikipediaTool;
import org.json.JSONObject;
import java.io.*;
@@ -51,13 +54,17 @@ public class Display {
.keep_alive(10)
//.stream(false)
//.addFileTools(FileHandlerLocation.DATA_FILES)
.addMessages(new SystemMessage("You need to emulate feelings and emotions."))
.build());
core.enablePlugins(Core.PLUGIN_DIRECTORY);
core.addTool(new TimeTool(), Core.Source.INTERNAL);
//core.addTool(new PythonRunner(core), Core.Source.INTERNAL);
// TODO: Well Docker failes when luanched.... Fuck
// core.addTool(new PythonRunner(core), Core.Source.INTERNAL);
core.addTools(new MALAPITool().getOllamaTools());
core.addTools(new GeniusTools().getGeniusTools());
core.addTools(new WikipediaTool().getWikipediaToolsInstance());
APIApplication.start();
@@ -98,9 +105,12 @@ public class Display {
case "help":
System.out.print("""
Available commands:
/help Prints this help message.
/bye Exits the program.
/write Flushes the current log stream to file.
/help Prints this help message.
/bye Exits the program.
/write Flushes the current log stream to file.
/list Lists all available tools.
/working Prints the current working directories.
/peek Peeks the current memory.
""");
break;
case "bye":
@@ -114,7 +124,7 @@ public class Display {
case "peek":
CoreMemory coreMemory = CoreMemory.getInstance();
StringBuilder buffer = new StringBuilder("[");
ArrayList<String> memory = new ArrayList<>(coreMemory.getMemory());
ArrayList<String> memory = new ArrayList<>(coreMemory.getMemoriesArray());
for(int i = 0; i < memory.size(); i++) {
String mem = memory.get(i);
buffer.append("\"").append(mem).append("\"");
@@ -126,6 +136,29 @@ public class Display {
writeLog("Memory peek: "+buffer.toString());
System.out.println(buffer.toString());
break;
case "list":
writeLog("Tools installed in this instance");
for(Pair<OllamaFunctionTool, String> funtion : core.getFuntionTools()) {
StringBuilder args = new StringBuilder();
OllamaPerameter perameter = funtion.getKey().parameters();
if (perameter != null) {
JSONObject obj = perameter.getProperties();
for (String name : obj.keySet()) {
args.append(args.toString().isBlank() ? "" : ", ").append(obj.getJSONObject(name).getString("type")).append(Arrays.stream(perameter.getRequired()).anyMatch(str -> str.equalsIgnoreCase(name)) ? "" : "?").append(" ").append(name);
}
}
System.out.println("> Function: " + funtion.getKey().name() + "(" + args + ") [" + funtion.getValue() + "]");
writeLog("Function: " + funtion.getKey().name() + "(" + args + ") [" + funtion.getValue() + "]");
}
break;
case "working":
System.out.println("Working directories:\n" +
" Data: " + Core.DATA_DIR.getAbsolutePath() + "\n" +
" DateFiles: " + FileHandlerLocation.DATA_FILES + "\n" +
" Plugins: " + Core.PLUGIN_DIRECTORY.getAbsolutePath());
break;
default:
System.out.println("Unknown command: " + message);
}