Added a lot of things, but i guse bigest part is the external_tools.py generator
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package me.zacharias.chat.display;
|
||||
|
||||
import me.zacharias.chat.core.Core;
|
||||
import me.zacharias.chat.core.Pair;
|
||||
import me.zacharias.chat.core.PrintMessageHandler;
|
||||
import me.zacharias.chat.ollama.*;
|
||||
import org.json.JSONObject;
|
||||
@@ -30,38 +31,35 @@ public class Display {
|
||||
core.setOllamaObject(OllamaObject.builder()
|
||||
.setModel("llama3-AI")
|
||||
.keep_alive(10)
|
||||
.addTool(new TimeTool())
|
||||
.addTool(new PythonRunner())
|
||||
.stream(false)
|
||||
.build());
|
||||
|
||||
core.addTool(new TimeTool(), "Internal");
|
||||
core.addTool(new PythonRunner(core), "Internal");
|
||||
|
||||
writeLog("Creating base OllamaObject with model: "+core.getOllamaObject().getModel());
|
||||
|
||||
System.out.println("Installed tools");
|
||||
writeLog("Tools installed in this instance");
|
||||
|
||||
for(OllamaTool tool : core.getOllamaObject().getTools())
|
||||
for(Pair<OllamaFuntionTool, String> funtion : core.getFuntionTools())
|
||||
{
|
||||
if(tool instanceof OllamaFuntionTool funtion)
|
||||
{
|
||||
StringBuilder args = new StringBuilder();
|
||||
OllamaPerameter perameter = funtion.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);
|
||||
}
|
||||
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.name()+"("+args+")");
|
||||
writeLog("Function: "+funtion.name()+"("+args+")");
|
||||
core.addFuntionTool(funtion);
|
||||
}
|
||||
|
||||
System.out.println("> Function: "+funtion.getKey().name()+"("+args+") ["+funtion.getValue()+"]");
|
||||
writeLog("Function: "+funtion.getKey().name()+"("+args+") ["+funtion.getValue()+"]");
|
||||
}
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
System.out.println("Message Trsnscription:");
|
||||
System.out.println("Message Transcription:");
|
||||
try {
|
||||
while (true) {
|
||||
System.out.print("> ");
|
||||
|
||||
Reference in New Issue
Block a user