Working on fixing the implementation of PythonRunner.java
build / build (push) Has been cancelled

added a global cache directory, not fully properly implemented, and dose not respect t.ex the FreeDesktop specifications for cache directories and files

OPS this is a partial commit! things might not add up on this commit.
This commit is contained in:
2026-05-04 18:17:15 +02:00
parent 96a6ed169e
commit 7dfaffc862
6 changed files with 254 additions and 71 deletions
@@ -77,6 +77,7 @@ public class Core {
public static String DATA;
public static File DATA_DIR;
public static File PLUGIN_DIRECTORY;
public static File CACHE_DIRECTORY;
static {
setDataDirectory("AI-Chat");
@@ -117,6 +118,11 @@ public class Core {
if(!PLUGIN_DIRECTORY.exists()) {
PLUGIN_DIRECTORY.mkdirs();
}
CACHE_DIRECTORY = new File(DATA + "/cache");
if(!CACHE_DIRECTORY.exists()) {
CACHE_DIRECTORY.mkdirs();
}
}
/**
@@ -261,6 +267,13 @@ public class Core {
if(this.ollamaObject == null) {
this.ollamaObject = ollamaObject;
for(Pair<OllamaTool, String> tool : ollamaObject.getTools()) {
if(tool.getKey() instanceof OllamaFunctionTool functionTool)
{
funtionTools.add(new Pair<>(functionTool, tool.getValue()));
}
}
addTool(new AddMemoryFunction(), Source.CORE);
addTool(new RemoveMemoryFunction(), Source.CORE);
addTool(new GetMemoryFunction(), Source.CORE);
@@ -280,6 +293,12 @@ public class Core {
public void setOllamaObjectNoMemory(OllamaObject ollamaObject) {
if(this.ollamaObject == null) {
this.ollamaObject = ollamaObject;
for(Pair<OllamaTool, String> tool : ollamaObject.getTools()) {
if(tool.getKey() instanceof OllamaFunctionTool functionTool)
{
funtionTools.add(new Pair<>(functionTool, tool.getValue()));
}
}
}
else {
throw new IllegalArgumentException("Ollama object is already set");
@@ -434,7 +453,9 @@ public class Core {
if(jsonObject.has("function"))
{
JSONObject function = jsonObject.getJSONObject("function");
List<Pair<OllamaFunctionTool, String>> functions = funtionTools.stream().filter(func -> (func.getKey().name()+func.getValue()).equalsIgnoreCase(function.getString("name"))).toList();
List<Pair<OllamaFunctionTool, String>> functions = funtionTools.stream()
.filter(func -> (
func.getKey().name()+func.getValue()).equalsIgnoreCase(function.getString("name"))).toList();
ArrayList<OllamaFunctionArgument> argumentArrayList = new ArrayList<>();