Fixed URL building in APITool.java. Updated libraries for API, Launcher. Started applying NotNull annotation to methods and arguments in Core.java. Started handeling the big init block in Core.java. Added overloaded constructor for Core.java and made Core.ollamaIP a variabled that's definible Updated Tool.addTool return for 400 error.
This commit is contained in:
@@ -14,6 +14,8 @@ import me.zacharias.neuro.dock.wikipedia.WikipediaTool;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
import static me.zacharias.chat.core.Core.writeLog;
|
||||
@@ -48,9 +50,7 @@ public class Display {
|
||||
{
|
||||
|
||||
core.setOllamaObject/*NoMemory*/(OllamaObject.builder()
|
||||
//.setModel("llama3.2")
|
||||
//.setModel("gemma3:12b")
|
||||
.setModel("qwen3:8b")
|
||||
.setModel("llama3.2")
|
||||
.keep_alive(10)
|
||||
//.stream(false)
|
||||
//.addFileTools(FileHandlerLocation.DATA_FILES)
|
||||
@@ -61,10 +61,11 @@ public class Display {
|
||||
|
||||
core.addTool(new TimeTool(), 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());
|
||||
PythonRunner pythonRunner = new PythonRunner(core);
|
||||
core.addTool(pythonRunner, Core.Source.INTERNAL);
|
||||
//core.addTools(new MALAPITool().getOllamaTools());
|
||||
//core.addTools(new GeniusTools().getGeniusTools());
|
||||
//core.addTools(new WikipediaTool().getWikipediaToolsInstance());
|
||||
|
||||
APIApplication.start();
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public class PythonRunner extends OllamaFunctionTool {
|
||||
public PythonRunner(Core core) {
|
||||
this.core = core;
|
||||
|
||||
generateExternalTools();
|
||||
|
||||
try {
|
||||
serverSocket = new ServerSocket(6050);
|
||||
Thread thread = new Thread(() -> {
|
||||
@@ -350,27 +352,22 @@ public class PythonRunner extends OllamaFunctionTool {
|
||||
* Generates the external_tools.py file.<br>
|
||||
* This is meant to provide the python code with all ExternalTools defined in the OllamaObject.
|
||||
* @return The generated external_tools.py file
|
||||
* @throws IllegalStateException This is thrown when the external_tool_base.py can not be read, this should be handled by disabling the python runner.
|
||||
*/
|
||||
private String generateExternalTools() {
|
||||
private String generateExternalTools() throws IllegalStateException{
|
||||
StringBuilder code = new StringBuilder();
|
||||
|
||||
code.append("""
|
||||
import socket
|
||||
import json
|
||||
|
||||
HOST = "host.docker.internal"
|
||||
PORT = 6050
|
||||
|
||||
def connect(data):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect((HOST, PORT))
|
||||
data = data + "\\n"
|
||||
s.sendall(data.encode("utf-8"))
|
||||
responce = s.recv(4096)
|
||||
return responce.decode("utf-8")
|
||||
|
||||
|
||||
""");
|
||||
try (InputStream in = getClass().getResourceAsStream("/external_tool_base.py");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
|
||||
String tmp = null;
|
||||
while((tmp = reader.readLine()) != null)
|
||||
{
|
||||
code.append(tmp).append('\n');
|
||||
}
|
||||
}catch (Exception ex)
|
||||
{
|
||||
throw new IllegalStateException("Can not read the base external tools file, this is a fetal error for the python runner!");
|
||||
}
|
||||
|
||||
for(Pair<OllamaFunctionTool, String> funtionTool : core.getFuntionTools())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import socket
|
||||
import json
|
||||
import builtins
|
||||
|
||||
HOST = "host.docker.internal"
|
||||
PORT = 6050
|
||||
|
||||
def connect(data):
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect((HOST, PORT))
|
||||
data = data + "\n"
|
||||
s.sendall(data.encode("utf-8"))
|
||||
responce = s.recv(4096)
|
||||
return responce.decode("utf-8")
|
||||
|
||||
def print_output(text):
|
||||
data = {"function": "print_output", "arguments": [{"name": "text", "value": text}]}
|
||||
connect(json.dumps(data))
|
||||
|
||||
def _neurodock_print(*args, **kwargs):
|
||||
text = " ".join(str(a) for a in args)
|
||||
print_output(text)
|
||||
|
||||
builtins.print = _neurodock_print
|
||||
Reference in New Issue
Block a user