forked from Chat_things/NeuroDock
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
943c8470a5
|
|||
|
4262dd68c6
|
|||
|
2cf0428d2a
|
|||
|
bbf3c645b0
|
|||
|
4015d37657
|
|||
|
5886d164b4
|
|||
| ab72e1ff78 | |||
|
db53028d1e
|
|||
|
bf5ae6dd3c
|
|||
|
fbf7c504b1
|
|||
|
8426bcac37
|
|||
|
5724a2342d
|
|||
|
95ac78b2d2
|
22
.gitea/workflows/build.yml
Normal file
22
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: arch
|
||||||
|
steps:
|
||||||
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -14,7 +14,6 @@
|
|||||||
<option value="$PROJECT_DIR$/Display" />
|
<option value="$PROJECT_DIR$/Display" />
|
||||||
<option value="$PROJECT_DIR$/GeniusAPI" />
|
<option value="$PROJECT_DIR$/GeniusAPI" />
|
||||||
<option value="$PROJECT_DIR$/MALAPITool" />
|
<option value="$PROJECT_DIR$/MALAPITool" />
|
||||||
<option value="$PROJECT_DIR$/MovieSugest" />
|
|
||||||
<option value="$PROJECT_DIR$/WikipediaTool" />
|
<option value="$PROJECT_DIR$/WikipediaTool" />
|
||||||
<option value="$PROJECT_DIR$/launcher" />
|
<option value="$PROJECT_DIR$/launcher" />
|
||||||
</set>
|
</set>
|
||||||
|
|||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -7,7 +7,7 @@
|
|||||||
<component name="FrameworkDetectionExcludesConfiguration">
|
<component name="FrameworkDetectionExcludesConfiguration">
|
||||||
<file type="web" url="file://$PROJECT_DIR$" />
|
<file type="web" url="file://$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="corretto-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -14,7 +14,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||||
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
|
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.0-M1'
|
||||||
//implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
//implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'me.zacharias'
|
group = 'me.zacharias'
|
||||||
version = '1.0-SNAPSHOT'
|
version = '1.3'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static me.zacharias.chat.ollama.OllamaFunctionArgument.deconstructOllamaFunctionArguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Main class for the System, responsible for managing the OllamaObject, tools, and the Ollama API.
|
* The Main class for the System, responsible for managing the OllamaObject, tools, and the Ollama API.
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +54,7 @@ public class Core {
|
|||||||
/**
|
/**
|
||||||
* The IP of the Ollama API.
|
* The IP of the Ollama API.
|
||||||
*/
|
*/
|
||||||
private String ollamaIP = "localhost";//"192.168.5.184";
|
private String ollamaIP = "10.0.1.101";//"192.168.5.184";
|
||||||
/**
|
/**
|
||||||
* The port of the Ollama API.
|
* The port of the Ollama API.
|
||||||
*/
|
*/
|
||||||
@@ -71,11 +73,15 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
private boolean supportColor;
|
private boolean supportColor;
|
||||||
|
|
||||||
public static final String DATA;
|
public static String DATA;
|
||||||
public static final File DATA_DIR;
|
public static File DATA_DIR;
|
||||||
public static final File PLUGIN_DIRECTORY;
|
public static File PLUGIN_DIRECTORY;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
setDataDirectory("AI-Chat");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDataDirectory(String dataDirectory) {
|
||||||
String data;
|
String data;
|
||||||
|
|
||||||
if(System.getenv("AI_CHAT_DEBUG") != null) {
|
if(System.getenv("AI_CHAT_DEBUG") != null) {
|
||||||
@@ -86,13 +92,13 @@ public class Core {
|
|||||||
if(localappdata == null) {
|
if(localappdata == null) {
|
||||||
localappdata = System.getenv("APPDATA");
|
localappdata = System.getenv("APPDATA");
|
||||||
}
|
}
|
||||||
data = localappdata + "/AI-CHAT";
|
data = localappdata + "/"+ dataDirectory;
|
||||||
}
|
}
|
||||||
else if (System.getProperty("os.name").toLowerCase().contains("linux")) {
|
else if (System.getProperty("os.name").toLowerCase().contains("linux")) {
|
||||||
data = System.getenv("HOME") + "/.local/share/AI-CHAT";
|
data = System.getenv("HOME") + "/.local/share/" + dataDirectory;
|
||||||
}
|
}
|
||||||
else if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
else if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||||
data = System.getProperty("user.home") + "/Library/Application Support/AI-CHAT";
|
data = System.getProperty("user.home") + "/Library/Application Support/"+ dataDirectory;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data = "./data";
|
data = "./data";
|
||||||
@@ -193,7 +199,7 @@ public class Core {
|
|||||||
messagesWriter.write(messages.toString());
|
messagesWriter.write(messages.toString());
|
||||||
messagesWriter.close();
|
messagesWriter.close();
|
||||||
|
|
||||||
File f = new File("./data/messages.json");
|
File f = new File(DATA_DIR,"messages.json");
|
||||||
if(f.exists())
|
if(f.exists())
|
||||||
{
|
{
|
||||||
f.delete();
|
f.delete();
|
||||||
@@ -261,7 +267,7 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public void addTool(OllamaFunctionTool functionTool, @MagicConstant(valuesFromClass = Source.class) String source) {
|
public void addTool(OllamaFunctionTool functionTool, @MagicConstant(valuesFromClass = Source.class) String source) {
|
||||||
funtionTools.add(new Pair<>(functionTool, source));
|
funtionTools.add(new Pair<>(functionTool, source));
|
||||||
ollamaObject.addTool(functionTool);
|
ollamaObject.addTool(functionTool, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -402,34 +408,36 @@ public class Core {
|
|||||||
if(jsonObject.has("function"))
|
if(jsonObject.has("function"))
|
||||||
{
|
{
|
||||||
JSONObject function = jsonObject.getJSONObject("function");
|
JSONObject function = jsonObject.getJSONObject("function");
|
||||||
List<Pair<OllamaFunctionTool, String>> functions = funtionTools.stream().filter(func -> (func.getKey().name()).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<>();
|
||||||
|
|
||||||
|
JSONObject arguments = function.getJSONObject("arguments");
|
||||||
|
|
||||||
|
for (String key : arguments.keySet()) {
|
||||||
|
argumentArrayList.add(new OllamaFunctionArgument(key, arguments.get(key)));
|
||||||
|
}
|
||||||
|
|
||||||
if(functions.isEmpty()) {
|
if(functions.isEmpty()) {
|
||||||
ollamaObject.addMessage(new OllamaToolError("Function '"+function.getString("name")+"' does not exist"));
|
ollamaObject.addMessage(new OllamaToolError("Function '"+function.getString("name")+"' does not exist"));
|
||||||
printMessageHandler.printMessage((supportColor ?"\u001b[31m":"")+"Tried funtion call "+function.getString("name")+" but failed to find it."+(printMessageHandler.color()?"\u001b[0m":""));
|
printMessageHandler.printMessage((supportColor ?"\u001b[31m":"")+"Tried funtion call "+function.getString("name")+"("+deconstructOllamaFunctionArguments(argumentArrayList)+") but failed to find it."+(printMessageHandler.color()?"\u001b[0m":""));
|
||||||
writeLog("Failed function call to "+function.getString("name"));
|
writeLog("Failed function call to "+function.getString("name"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
OllamaFunctionTool func = functions.getFirst().getKey();
|
OllamaFunctionTool func = functions.getFirst().getKey();
|
||||||
|
|
||||||
ArrayList<OllamaFunctionArgument> argumentArrayList = new ArrayList<>();
|
// TODO: Check so all arguments is the correct type, else error out in a safe mannet.
|
||||||
|
|
||||||
JSONObject arguments = function.getJSONObject("arguments");
|
|
||||||
|
|
||||||
for (String key : arguments.keySet()) {
|
|
||||||
argumentArrayList.add(new OllamaFunctionArgument(key, arguments.get(key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OllamaToolRespnce function1 = func.function(argumentArrayList.toArray(new OllamaFunctionArgument[0]));
|
OllamaToolRespnce function1 = func.function(argumentArrayList.toArray(new OllamaFunctionArgument[0]));
|
||||||
ollamaObject.addMessage(function1);
|
ollamaObject.addMessage(function1);
|
||||||
printMessageHandler.printMessage((supportColor?"\u001b[34m":"")+"Call "+func.name() + (supportColor?"\u001b[0m":""));
|
printMessageHandler.printMessage((supportColor?"\u001b[34m":"")+"Call "+func.name() + "(" + deconstructOllamaFunctionArguments(argumentArrayList) + ")" + (supportColor?"\u001b[0m":""));
|
||||||
writeLog("Successfully function call " + func.name() + " output: " + function1.getResponse());
|
writeLog("Successfully function call " + func.name() + " output: " + function1.getResponse());
|
||||||
} catch (OllamaToolErrorException e) {
|
} catch (OllamaToolErrorException e) {
|
||||||
ollamaObject.addMessage(new OllamaToolError(e.getMessage()));
|
ollamaObject.addMessage(new OllamaToolError(e.getMessage()));
|
||||||
printMessageHandler.printMessage((supportColor?"\u001b[31m":"")+"Tried funtion call " + func.name() + " but failed due to " + e.getError() + (supportColor?"\u001b[0m":""));
|
printMessageHandler.printMessage((supportColor?"\u001b[31m":"")+"Tried funtion call " + func.name() + "("+deconstructOllamaFunctionArguments(argumentArrayList)+") but failed due to " + e.getError() + (supportColor?"\u001b[0m":""));
|
||||||
writeLog(e.getMessage());
|
writeLog("ERROR: "+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,6 +470,10 @@ public class Core {
|
|||||||
*/
|
*/
|
||||||
public static void writeLog(String message)
|
public static void writeLog(String message)
|
||||||
{
|
{
|
||||||
|
if(logWriter == null) {
|
||||||
|
System.err.println("!! Log writer is not initialized !!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd%EEEE HH:mm:ss'#'SSS");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd%EEEE HH:mm:ss'#'SSS");
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public class LaunchOptions {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LaunchOptions() {}
|
||||||
|
|
||||||
private boolean loadOld = true;
|
private boolean loadOld = true;
|
||||||
private boolean autoAccept;
|
private boolean autoAccept;
|
||||||
private boolean serverMode;
|
private boolean serverMode;
|
||||||
|
|||||||
@@ -18,4 +18,18 @@ public interface PrintMessageHandler {
|
|||||||
* @return a boolean indicating if color is supported by the PrintMessageHandler.
|
* @return a boolean indicating if color is supported by the PrintMessageHandler.
|
||||||
*/
|
*/
|
||||||
boolean color();
|
boolean color();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default method to print error messages to the user or API Client.
|
||||||
|
* This uses ANSI escape codes to color the output red if color is supported.
|
||||||
|
* @param message The error message to be printed.
|
||||||
|
* If color is not supported, it will print the message without color.
|
||||||
|
*/
|
||||||
|
default void printError(String message) {
|
||||||
|
if (color()) {
|
||||||
|
printMessage("\u001B[31m" + message + "\u001B[0m"); // Red color for errors
|
||||||
|
} else {
|
||||||
|
printMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package me.zacharias.chat.ollama;
|
package me.zacharias.chat.ollama;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an argument passed to a tool.
|
* Represents an argument passed to a tool.
|
||||||
*
|
*
|
||||||
@@ -37,4 +39,24 @@ public record OllamaFunctionArgument(String argument, Object value) {
|
|||||||
public Object value() {
|
public Object value() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String deconstructOllamaFunctionArgument(OllamaFunctionArgument argument) {
|
||||||
|
return argument.argument() + ": " + argument.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String deconstructOllamaFunctionArguments(OllamaFunctionArgument... arguments) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (OllamaFunctionArgument argument : arguments) {
|
||||||
|
sb.append(deconstructOllamaFunctionArgument(argument)).append(", ");
|
||||||
|
}
|
||||||
|
return sb.toString().replaceAll(", $", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String deconstructOllamaFunctionArguments(ArrayList<OllamaFunctionArgument> arguments) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (OllamaFunctionArgument argument : arguments) {
|
||||||
|
sb.append(deconstructOllamaFunctionArgument(argument)).append(", ");
|
||||||
|
}
|
||||||
|
return sb.toString().replaceAll(", $", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,15 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public abstract class OllamaFunctionTool implements OllamaTool {
|
public abstract class OllamaFunctionTool implements OllamaTool {
|
||||||
|
|
||||||
|
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("tool", "function");
|
||||||
|
|
||||||
JSONObject function = new JSONObject();
|
JSONObject function = new JSONObject();
|
||||||
function.put("name", name());
|
function.put("name", name()+(source != null ? source : ""));
|
||||||
function.put("description", description());
|
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())));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.zacharias.chat.ollama;
|
|||||||
import com.sun.source.util.Plugin;
|
import com.sun.source.util.Plugin;
|
||||||
import me.zacharias.chat.core.Core;
|
import me.zacharias.chat.core.Core;
|
||||||
import me.zacharias.chat.core.LaunchOptions;
|
import me.zacharias.chat.core.LaunchOptions;
|
||||||
|
import me.zacharias.chat.core.Pair;
|
||||||
import me.zacharias.chat.core.files.FileHandlerLocation;
|
import me.zacharias.chat.core.files.FileHandlerLocation;
|
||||||
import me.zacharias.chat.core.files.FileHandler;
|
import me.zacharias.chat.core.files.FileHandler;
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ import org.json.JSONObject;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -41,7 +43,7 @@ public class OllamaObject {
|
|||||||
/**
|
/**
|
||||||
* The tools of the Ollama Object.
|
* The tools of the Ollama Object.
|
||||||
*/
|
*/
|
||||||
ArrayList<OllamaTool> tools;
|
ArrayList<Pair<OllamaTool, String>> tools;
|
||||||
/**
|
/**
|
||||||
* The format of the Ollama Object.
|
* The format of the Ollama Object.
|
||||||
*/
|
*/
|
||||||
@@ -69,7 +71,7 @@ public class OllamaObject {
|
|||||||
* @param stream If the Ollama Object is streamed. see {@link OllamaObject#stream}
|
* @param stream If the Ollama Object is streamed. see {@link OllamaObject#stream}
|
||||||
* @param keep_alive The keep alive of the Ollama Object. see {@link OllamaObject#keep_alive}
|
* @param keep_alive The keep alive of the Ollama Object. see {@link OllamaObject#keep_alive}
|
||||||
*/
|
*/
|
||||||
private OllamaObject(String model, ArrayList<OllamaMessage> messages, ArrayList<OllamaTool> tools, JSONObject format, Map<String, Object> options, boolean stream, String keep_alive) {
|
private OllamaObject(String model, ArrayList<OllamaMessage> messages, ArrayList<Pair<OllamaTool, String>> tools, JSONObject format, Map<String, Object> options, boolean stream, String keep_alive) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
this.tools = tools;
|
this.tools = tools;
|
||||||
@@ -77,7 +79,7 @@ public class OllamaObject {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.keep_alive = keep_alive;
|
this.keep_alive = keep_alive;
|
||||||
LaunchOptions launchOptions = new LaunchOptions();
|
LaunchOptions launchOptions = LaunchOptions.getInstance();
|
||||||
if(launchOptions.isLoadOld()) {
|
if(launchOptions.isLoadOld()) {
|
||||||
System.out.println("Loading old data...");
|
System.out.println("Loading old data...");
|
||||||
File f = new File(Core.DATA_DIR+"/messages.json");
|
File f = new File(Core.DATA_DIR+"/messages.json");
|
||||||
@@ -105,6 +107,10 @@ public class OllamaObject {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("No old data found, skipping loading old data.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +134,7 @@ public class OllamaObject {
|
|||||||
* Gets the tools
|
* Gets the tools
|
||||||
* @return The tools
|
* @return The tools
|
||||||
*/
|
*/
|
||||||
public ArrayList<OllamaTool> getTools() {
|
public ArrayList<Pair<OllamaTool, String>> getTools() {
|
||||||
return tools;
|
return tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,8 +142,29 @@ public class OllamaObject {
|
|||||||
* Adds a tool to the Ollama Object
|
* Adds a tool to the Ollama Object
|
||||||
* @param tool The tool to add
|
* @param tool The tool to add
|
||||||
*/
|
*/
|
||||||
public void addTool(OllamaTool tool) {
|
public void addTool(OllamaTool tool, @MagicConstant(valuesFromClass = Core.Source.class) String source) {
|
||||||
tools.add(tool);
|
// We inject the source into the tool's source field if it exists, This is to not cause issues with duplicate tools
|
||||||
|
Class<? extends Object> clazz = tool.getClass();
|
||||||
|
Field field = null;
|
||||||
|
while(!clazz.equals(Object.class)) {
|
||||||
|
try {
|
||||||
|
field = clazz.getDeclaredField("source");
|
||||||
|
if (field != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException ignore){}
|
||||||
|
clazz = clazz.getSuperclass();
|
||||||
|
}
|
||||||
|
if (field != null) {
|
||||||
|
field.setAccessible(true);
|
||||||
|
try {
|
||||||
|
field.set(tool, source);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Core.writeLog("ERROR: "+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tools.add(new Pair<>(tool, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeTool(OllamaTool tool) {
|
public void removeTool(OllamaTool tool) {
|
||||||
@@ -189,8 +216,11 @@ public class OllamaObject {
|
|||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
|
|
||||||
JSONArray tools = new JSONArray();
|
JSONArray tools = new JSONArray();
|
||||||
for (OllamaTool tool : this.tools) {
|
for (Pair<OllamaTool, String> tool : this.tools) {
|
||||||
tools.put(new JSONObject(tool.toString()));
|
if(tool.getKey().getClass().isInterface()) continue;
|
||||||
|
JSONObject obj = new JSONObject(tool.getKey().toString());
|
||||||
|
//obj.put("name", obj.getString("name") + tool.getValue()); // Injects the source of the tool into the name
|
||||||
|
tools.put(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONArray messages = new JSONArray();
|
JSONArray messages = new JSONArray();
|
||||||
@@ -232,7 +262,7 @@ public class OllamaObject {
|
|||||||
/**
|
/**
|
||||||
* The tools of the Ollama Object.
|
* The tools of the Ollama Object.
|
||||||
*/
|
*/
|
||||||
ArrayList<OllamaTool> tools = new ArrayList<>();
|
ArrayList<Pair<OllamaTool, String>> tools = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* The format of the Ollama Object.
|
* The format of the Ollama Object.
|
||||||
*/
|
*/
|
||||||
@@ -321,30 +351,72 @@ public class OllamaObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a tool to the Ollama Object
|
* Adds a tool to the Ollama Object
|
||||||
|
* Assumes the tool is from an external source, see {@link OllamaObject.OllamaObjectBuilder#addTool(OllamaTool, String)} to specify the source
|
||||||
* @param tool The tool to add
|
* @param tool The tool to add
|
||||||
* @return The {@link OllamaObjectBuilder}
|
* @return The {@link OllamaObjectBuilder}
|
||||||
*/
|
*/
|
||||||
public OllamaObjectBuilder addTool(OllamaTool tool) {
|
public OllamaObjectBuilder addTool(OllamaTool tool) {
|
||||||
this.tools.add(tool);
|
this.tools.add(new Pair<>(tool, Core.Source.EXTERNAL));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a tool to the Ollama Object
|
||||||
|
* This allows you to specify the source of the tool, see {@link OllamaObject.OllamaObjectBuilder#addTool(OllamaTool)} to add a tool from an external source
|
||||||
|
* @param tool The tool to add
|
||||||
|
* @return The {@link OllamaObjectBuilder}
|
||||||
|
*/
|
||||||
|
public OllamaObjectBuilder addTool(OllamaTool tool, @MagicConstant(valuesFromClass = Core.Source.class) String source) {
|
||||||
|
this.tools.add(new Pair<>(tool, source));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds tools to the Ollama Object
|
* Adds tools to the Ollama Object
|
||||||
|
* Assumes the tools are from an external source, see {@link OllamaObject.OllamaObjectBuilder#addTools(ArrayList)}} to specify the source
|
||||||
* @param tools The tools to add
|
* @param tools The tools to add
|
||||||
* @return The {@link OllamaObjectBuilder}
|
* @return The {@link OllamaObjectBuilder}
|
||||||
*/
|
*/
|
||||||
public OllamaObjectBuilder addTools(ArrayList<? extends OllamaTool> tools) {
|
public OllamaObjectBuilder addToolsExternal(ArrayList<? extends OllamaTool> tools) {
|
||||||
this.tools.addAll(tools);
|
for (OllamaTool tool : tools) {
|
||||||
|
this.tools.add(new Pair<>(tool, Core.Source.EXTERNAL));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds tools to the Ollama Object
|
* Adds tools to the Ollama Object
|
||||||
|
* This allows you to specify the source of the tools, see {@link OllamaObject.OllamaObjectBuilder#addToolsExternal(ArrayList)}} to add tools from an external source
|
||||||
|
* @param tools The tools to add
|
||||||
|
* @return The {@link OllamaObjectBuilder}
|
||||||
|
*/
|
||||||
|
public OllamaObjectBuilder addTools(ArrayList<Pair<? extends OllamaTool, String>> tools) {
|
||||||
|
for(Pair<? extends OllamaTool, String> tool : tools) {
|
||||||
|
this.tools.add(new Pair<>(tool.getKey(), tool.getValue()));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds tools to the Ollama Object
|
||||||
|
* Assumes the tools are from an external source, see {@link OllamaObject.OllamaObjectBuilder#addTools(Pair[])}} to specify the source
|
||||||
* @param tools The tools to add
|
* @param tools The tools to add
|
||||||
* @return The {@link OllamaObjectBuilder}
|
* @return The {@link OllamaObjectBuilder}
|
||||||
*/
|
*/
|
||||||
public OllamaObjectBuilder addTools(OllamaTool... tools) {
|
public OllamaObjectBuilder addTools(OllamaTool... tools) {
|
||||||
|
for(OllamaTool tool : tools) {
|
||||||
|
this.tools.add(new Pair<>(tool, Core.Source.EXTERNAL));
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds tools to the Ollama Object
|
||||||
|
* This allows you to specify the source of the tools, see {@link OllamaObject.OllamaObjectBuilder#addTools(OllamaTool[])} to add tools from an external source
|
||||||
|
* @param tools The tools to add
|
||||||
|
* @return The {@link OllamaObjectBuilder}
|
||||||
|
*/
|
||||||
|
public OllamaObjectBuilder addTools(Pair<OllamaTool, String>... tools) {
|
||||||
this.tools.addAll(List.of(tools));
|
this.tools.addAll(List.of(tools));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,11 @@ public class OllamaPerameter {
|
|||||||
/**
|
/**
|
||||||
* Represents a array parameter.
|
* Represents a array parameter.
|
||||||
*/
|
*/
|
||||||
ARRAY("array");
|
ARRAY("array"),
|
||||||
|
/**
|
||||||
|
* Represents a object parameter.
|
||||||
|
*/
|
||||||
|
OBJECT("object");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of the parameter.
|
* The type of the parameter.
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ dependencies {
|
|||||||
implementation project(":GeniusAPI")
|
implementation project(":GeniusAPI")
|
||||||
implementation project(":API")
|
implementation project(":API")
|
||||||
implementation project(":WikipediaTool")
|
implementation project(":WikipediaTool")
|
||||||
implementation project(":MovieSugest")
|
|
||||||
|
implementation("com.github.docker-java:docker-java-core:3.6.0")
|
||||||
|
implementation("com.github.docker-java:docker-java-transport-httpclient5:3.6.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.zacharias.chat.display;
|
package me.zacharias.chat.display;
|
||||||
|
|
||||||
//import me.zacharias.chat.api.APIApplication;
|
import me.zacharias.chat.api.APIApplication;
|
||||||
import me.noah.movie.sugest.MovieSugestTool;
|
|
||||||
import me.zacharias.chat.core.Core;
|
import me.zacharias.chat.core.Core;
|
||||||
import me.zacharias.chat.core.Pair;
|
import me.zacharias.chat.core.Pair;
|
||||||
import me.zacharias.chat.core.PrintMessageHandler;
|
import me.zacharias.chat.core.PrintMessageHandler;
|
||||||
@@ -48,10 +47,10 @@ public class Display {
|
|||||||
public Display()
|
public Display()
|
||||||
{
|
{
|
||||||
|
|
||||||
core.setOllamaObjectNoMemory(OllamaObject.builder()
|
core.setOllamaObject/*NoMemory*/(OllamaObject.builder()
|
||||||
.setModel("llama3.2")
|
//.setModel("llama3.2")
|
||||||
//.setModel("gemma3:12b")
|
//.setModel("gemma3:12b")
|
||||||
// .setModel("qwen3:8b")
|
.setModel("qwen3:8b")
|
||||||
.keep_alive(10)
|
.keep_alive(10)
|
||||||
//.stream(false)
|
//.stream(false)
|
||||||
//.addFileTools(FileHandlerLocation.DATA_FILES)
|
//.addFileTools(FileHandlerLocation.DATA_FILES)
|
||||||
@@ -62,13 +61,12 @@ public class Display {
|
|||||||
|
|
||||||
core.addTool(new TimeTool(), Core.Source.INTERNAL);
|
core.addTool(new TimeTool(), Core.Source.INTERNAL);
|
||||||
// TODO: Well Docker failes when luanched.... Fuck
|
// TODO: Well Docker failes when luanched.... Fuck
|
||||||
// core.addTool(new PythonRunner(core), Core.Source.INTERNAL);
|
//core.addTool(new PythonRunner(core), Core.Source.INTERNAL);
|
||||||
// core.addTools(new MALAPITool().getOllamaTools());
|
core.addTools(new MALAPITool().getOllamaTools());
|
||||||
// core.addTools(new GeniusTools().getGeniusTools());
|
core.addTools(new GeniusTools().getGeniusTools());
|
||||||
core.addTools(new WikipediaTool().getWikipediaToolsInstance());
|
core.addTools(new WikipediaTool().getWikipediaToolsInstance());
|
||||||
core.addTools(new MovieSugestTool().getMovieSugestTools());
|
|
||||||
|
|
||||||
// APIApplication.start();
|
APIApplication.start();
|
||||||
|
|
||||||
//core.getOllamaObject().addMessage(new OllamaMessage(OllamaMessageRole.SYSTEM, "Have a nice tone and use formal wording"));
|
//core.getOllamaObject().addMessage(new OllamaMessage(OllamaMessageRole.SYSTEM, "Have a nice tone and use formal wording"));
|
||||||
|
|
||||||
@@ -111,6 +109,7 @@ public class Display {
|
|||||||
/bye Exits the program.
|
/bye Exits the program.
|
||||||
/write Flushes the current log stream to file.
|
/write Flushes the current log stream to file.
|
||||||
/list Lists all available tools.
|
/list Lists all available tools.
|
||||||
|
/corelist Lists all tools according to the OllamaObject.
|
||||||
/working Prints the current working directories.
|
/working Prints the current working directories.
|
||||||
/peek Peeks the current memory.
|
/peek Peeks the current memory.
|
||||||
""");
|
""");
|
||||||
@@ -155,6 +154,14 @@ public class Display {
|
|||||||
writeLog("Function: " + funtion.getKey().name() + "(" + args + ") [" + funtion.getValue() + "]");
|
writeLog("Function: " + funtion.getKey().name() + "(" + args + ") [" + funtion.getValue() + "]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "corelist":
|
||||||
|
writeLog("Tools installed in this instance acording to the coire OllamaObject");
|
||||||
|
|
||||||
|
for(Pair<OllamaTool, String> funtion : core.getOllamaObject().getTools()) {
|
||||||
|
System.out.println("> Function: " + funtion.getKey().toString());
|
||||||
|
writeLog("Function: " + funtion.getKey().toString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "working":
|
case "working":
|
||||||
System.out.println("Working directories:\n" +
|
System.out.println("Working directories:\n" +
|
||||||
" Data: " + Core.DATA_DIR.getAbsolutePath() + "\n" +
|
" Data: " + Core.DATA_DIR.getAbsolutePath() + "\n" +
|
||||||
|
|||||||
@@ -8,19 +8,23 @@ import com.github.dockerjava.api.model.BuildResponseItem;
|
|||||||
import com.github.dockerjava.api.model.Frame;
|
import com.github.dockerjava.api.model.Frame;
|
||||||
import com.github.dockerjava.api.model.Statistics;
|
import com.github.dockerjava.api.model.Statistics;
|
||||||
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
import com.github.dockerjava.core.DefaultDockerClientConfig;
|
||||||
import com.github.dockerjava.core.DockerClientBuilder;
|
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
|
||||||
|
import com.github.dockerjava.transport.DockerHttpClient;
|
||||||
import me.zacharias.chat.core.Core;
|
import me.zacharias.chat.core.Core;
|
||||||
import me.zacharias.chat.core.Pair;
|
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.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -112,13 +116,48 @@ public class PythonRunner extends OllamaFunctionTool {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultDockerClientConfig.Builder config
|
DefaultDockerClientConfig config
|
||||||
= DefaultDockerClientConfig.createDefaultConfigBuilder()
|
= DefaultDockerClientConfig.createDefaultConfigBuilder()
|
||||||
.withDockerHost("tcp://localhost:2375")
|
.withDockerHost("tcp://localhost:2375")
|
||||||
.withDockerTlsVerify(false);
|
.withDockerTlsVerify(false)
|
||||||
dockerClient = DockerClientBuilder
|
.withDockerCertPath("~/.docker")
|
||||||
.getInstance(config)
|
|
||||||
.build();
|
.build();
|
||||||
|
DockerHttpClient dockerHttpClient = new ApacheDockerHttpClient.Builder()
|
||||||
|
.dockerHost(config.getDockerHost())
|
||||||
|
.maxConnections(10)
|
||||||
|
.connectionTimeout(Duration.ofSeconds(100))
|
||||||
|
.responseTimeout(Duration.ofSeconds(100))
|
||||||
|
.sslConfig(config.getSSLConfig())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
DockerHttpClient.Request ping = DockerHttpClient.Request.builder()
|
||||||
|
.method(DockerHttpClient.Request.Method.GET)
|
||||||
|
.path("/_ping")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try(DockerHttpClient.Response response = dockerHttpClient.execute(ping))
|
||||||
|
{
|
||||||
|
if(!(response.getStatusCode() == 200))
|
||||||
|
{
|
||||||
|
writeLog("Failed to ping docker");
|
||||||
|
System.out.println("Failed to ping docker. Docker components is disabled.");
|
||||||
|
dockerClient = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!(IOUtils.toString(response.getBody(), Charset.defaultCharset()).equals("OK")))
|
||||||
|
{
|
||||||
|
writeLog("Failed to ping docker");
|
||||||
|
System.out.println("Failed to ping docker. Docker components is disabled.");
|
||||||
|
dockerClient = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
writeLog("Failed to ping docker");
|
||||||
|
System.out.println("Failed to ping docker. Docker components is disabled.");
|
||||||
|
dockerClient = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,6 +181,10 @@ public class PythonRunner extends OllamaFunctionTool {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaToolRespnce function(OllamaFunctionArgument... args) {
|
public OllamaToolRespnce function(OllamaFunctionArgument... args) {
|
||||||
|
if(dockerClient == null)
|
||||||
|
{
|
||||||
|
return new OllamaToolRespnce(name(), "Docker is disabled");
|
||||||
|
}
|
||||||
if(args.length == 0)
|
if(args.length == 0)
|
||||||
{
|
{
|
||||||
throw new OllamaToolErrorException(name(), "Missing code argument");
|
throw new OllamaToolErrorException(name(), "Missing code argument");
|
||||||
|
|||||||
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hc.client5.http.ssl;
|
||||||
|
|
||||||
|
import javax.net.ssl.HostnameVerifier;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLEngine;
|
||||||
|
import javax.net.ssl.SSLParameters;
|
||||||
|
|
||||||
|
import org.apache.hc.core5.annotation.Contract;
|
||||||
|
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||||
|
import org.apache.hc.core5.function.Factory;
|
||||||
|
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
|
||||||
|
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
|
||||||
|
import org.apache.hc.core5.reactor.ssl.TlsDetails;
|
||||||
|
import org.apache.hc.core5.ssl.SSLContexts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TLS upgrade strategy for non-blocking client connections.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||||
|
public class DefaultClientTlsStrategy extends AbstractClientTlsStrategy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public static DefaultClientTlsStrategy createDefault() {
|
||||||
|
return new DefaultClientTlsStrategy(
|
||||||
|
SSLContexts.createDefault(),
|
||||||
|
HostnameVerificationPolicy.BOTH,
|
||||||
|
HttpsSupport.getDefaultHostnameVerifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public static DefaultClientTlsStrategy createSystemDefault() {
|
||||||
|
return new DefaultClientTlsStrategy(
|
||||||
|
SSLContexts.createSystemDefault(),
|
||||||
|
HttpsSupport.getSystemProtocols(),
|
||||||
|
HttpsSupport.getSystemCipherSuits(),
|
||||||
|
SSLBufferMode.STATIC,
|
||||||
|
HostnameVerificationPolicy.BOTH,
|
||||||
|
HttpsSupport.getDefaultHostnameVerifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #createDefault()}.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static TlsStrategy getDefault() {
|
||||||
|
return createDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #createSystemDefault()}.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static TlsStrategy getSystemDefault() {
|
||||||
|
return createSystemDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated To be removed.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
private Factory<SSLEngine, TlsDetails> tlsDetailsFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link DefaultClientTlsStrategy#DefaultClientTlsStrategy(SSLContext, String[], String[], SSLBufferMode, HostnameVerifier)}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public DefaultClientTlsStrategy(
|
||||||
|
final SSLContext sslContext,
|
||||||
|
final String[] supportedProtocols,
|
||||||
|
final String[] supportedCipherSuites,
|
||||||
|
final SSLBufferMode sslBufferManagement,
|
||||||
|
final HostnameVerifier hostnameVerifier,
|
||||||
|
final Factory<SSLEngine, TlsDetails> tlsDetailsFactory) {
|
||||||
|
super(sslContext, supportedProtocols, supportedCipherSuites, sslBufferManagement, HostnameVerificationPolicy.CLIENT, hostnameVerifier);
|
||||||
|
this.tlsDetailsFactory = tlsDetailsFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public DefaultClientTlsStrategy(
|
||||||
|
final SSLContext sslContext,
|
||||||
|
final String[] supportedProtocols,
|
||||||
|
final String[] supportedCipherSuites,
|
||||||
|
final SSLBufferMode sslBufferManagement,
|
||||||
|
final HostnameVerificationPolicy hostnameVerificationPolicy,
|
||||||
|
final HostnameVerifier hostnameVerifier) {
|
||||||
|
super(sslContext, supportedProtocols, supportedCipherSuites, sslBufferManagement, hostnameVerificationPolicy, hostnameVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultClientTlsStrategy(
|
||||||
|
final SSLContext sslContext,
|
||||||
|
final String[] supportedProtocols,
|
||||||
|
final String[] supportedCipherSuites,
|
||||||
|
final SSLBufferMode sslBufferManagement,
|
||||||
|
final HostnameVerifier hostnameVerifier) {
|
||||||
|
this(sslContext, supportedProtocols, supportedCipherSuites, sslBufferManagement, HostnameVerificationPolicy.CLIENT, hostnameVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultClientTlsStrategy(
|
||||||
|
final SSLContext sslContext,
|
||||||
|
final HostnameVerifier hostnameVerifier) {
|
||||||
|
this(sslContext, null, null, SSLBufferMode.STATIC, hostnameVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public DefaultClientTlsStrategy(
|
||||||
|
final SSLContext sslContext,
|
||||||
|
final HostnameVerificationPolicy hostnameVerificationPolicy,
|
||||||
|
final HostnameVerifier hostnameVerifier) {
|
||||||
|
this(sslContext, null, null, SSLBufferMode.STATIC, hostnameVerificationPolicy, hostnameVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultClientTlsStrategy(final SSLContext sslContext) {
|
||||||
|
this(sslContext, HttpsSupport.getDefaultHostnameVerifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void applyParameters(final SSLEngine sslEngine, final SSLParameters sslParameters, final String[] appProtocols) {
|
||||||
|
sslParameters.setApplicationProtocols(appProtocols);
|
||||||
|
sslEngine.setSSLParameters(sslParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecated")
|
||||||
|
TlsDetails createTlsDetails(final SSLEngine sslEngine) {
|
||||||
|
return tlsDetailsFactory != null ? tlsDetailsFactory.create(sslEngine) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.apache.hc.client5.http.ssl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname verification policy.
|
||||||
|
*
|
||||||
|
* @see javax.net.ssl.HostnameVerifier
|
||||||
|
* @see DefaultHostnameVerifier
|
||||||
|
*
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public enum HostnameVerificationPolicy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname verification is delegated to the JSSE provider, usually executed during the TLS handshake.
|
||||||
|
*/
|
||||||
|
BUILTIN,
|
||||||
|
/**
|
||||||
|
* Hostname verification is executed by HttpClient post TLS handshake.
|
||||||
|
*/
|
||||||
|
CLIENT,
|
||||||
|
/**
|
||||||
|
* Hostname verification is executed by the JSSE provider and by HttpClient post TLS handshake.
|
||||||
|
*/
|
||||||
|
BOTH
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package org.apache.hc.client5.http.ssl;
|
||||||
|
|
||||||
|
import org.apache.hc.core5.annotation.Contract;
|
||||||
|
import org.apache.hc.core5.annotation.ThreadingBehavior;
|
||||||
|
import org.apache.hc.core5.http.protocol.HttpContext;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLSocket;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
@Contract(threading = ThreadingBehavior.STATELESS)
|
||||||
|
public interface TlsSocketStrategy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upgrades the given plain socket and executes the TLS handshake over it.
|
||||||
|
*
|
||||||
|
* @param socket the existing plain socket
|
||||||
|
* @param target the name of the target host.
|
||||||
|
* @param port the port to connect to on the target host.
|
||||||
|
* @param context the actual HTTP context.
|
||||||
|
* @param attachment connect request attachment.
|
||||||
|
* @return socket upgraded to TLS.
|
||||||
|
*/
|
||||||
|
SSLSocket upgrade(
|
||||||
|
Socket socket,
|
||||||
|
String target,
|
||||||
|
int port,
|
||||||
|
Object attachment,
|
||||||
|
HttpContext context) throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
25
GeniusAPI/README.md
Normal file
25
GeniusAPI/README.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Genius API
|
||||||
|
|
||||||
|
## Important notes
|
||||||
|
### Legal Notice
|
||||||
|
|
||||||
|
This tool is provided for educational and experimental purposes only.
|
||||||
|
|
||||||
|
Please be aware that the Genius API Terms of Service **prohibit** web scraping of their website. This project contains code that performs scraping to retrieve song lyrics directly from Genius.com, which may violate those terms.
|
||||||
|
|
||||||
|
Since Genius does not provide official API endpoints for lyrics due to copyright restrictions, this tool includes scraping functionality as a workaround. However, scraping may result in legal or technical consequences such as IP bans, rate limiting, or other restrictions imposed by Genius.
|
||||||
|
|
||||||
|
**Use this tool responsibly and at your own risk.** The author does not encourage or endorse violating any third-party terms of service or applicable laws and disclaims any liability arising from misuse.
|
||||||
|
|
||||||
|
Whenever possible, prefer using official API endpoints and respect copyright laws.
|
||||||
|
|
||||||
|
## API key required
|
||||||
|
This tool requires a Genius API key to work since it fetches song metadata from the Genius API.
|
||||||
|
|
||||||
|
The API key shuld be stored in `${DATA_DIR}/geniusapi.json` using the following format:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"client_id": "<your_client_id>",
|
||||||
|
"client_secret": "<your_client_secret>"
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package me.zacharias.neuro.dock.genius;
|
package me.zacharias.neuro.dock.genius;
|
||||||
|
|
||||||
import com.google.common.reflect.ClassPath;
|
|
||||||
import io.github.classgraph.ClassGraph;
|
import io.github.classgraph.ClassGraph;
|
||||||
import io.github.classgraph.ClassInfo;
|
import io.github.classgraph.ClassInfo;
|
||||||
import io.github.classgraph.ClassInfoList;
|
import io.github.classgraph.ClassInfoList;
|
||||||
|
|||||||
@@ -19,6 +19,20 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static me.zacharias.chat.core.Core.writeLog;
|
import static me.zacharias.chat.core.Core.writeLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is an Ollama tool that fetches the lyrics of a song by its ID from the Genius API.
|
||||||
|
* It extends the GeniusEndpointTool to utilize the GeniusTools instance for API calls and caching.
|
||||||
|
* <p>
|
||||||
|
* <h1>Legal Notice</h1>
|
||||||
|
* <p>
|
||||||
|
* I (the developer) do NOT own the rights to the lyrics fetched by this tool, nor do I endorse scraping lyrics from Genius.com,
|
||||||
|
* which may violate their Terms of Service.
|
||||||
|
* </p>
|
||||||
|
* <p>
|
||||||
|
* I disclaim any responsibility or liability for how this tool is used.
|
||||||
|
* Use this tool at your own risk, and please respect all applicable copyright laws and third-party terms.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
@GeniusEndpoint
|
@GeniusEndpoint
|
||||||
public class GetLyrics extends GeniusEndpointTool {
|
public class GetLyrics extends GeniusEndpointTool {
|
||||||
public GetLyrics(GeniusTools geniusTools) {
|
public GetLyrics(GeniusTools geniusTools) {
|
||||||
@@ -45,19 +59,27 @@ public class GetLyrics extends GeniusEndpointTool {
|
|||||||
@Override
|
@Override
|
||||||
public OllamaToolRespnce function(OllamaFunctionArgument... args) {
|
public OllamaToolRespnce function(OllamaFunctionArgument... args) {
|
||||||
|
|
||||||
|
if(!( args[0].value() instanceof Integer)) {
|
||||||
|
throw new OllamaToolErrorException(this.name(), "The song_id must be an integer.");
|
||||||
|
}
|
||||||
|
|
||||||
String lyricsStr = geniusToolsInstance.hasCache((int) args[0].value());
|
String lyricsStr = geniusToolsInstance.hasCache((int) args[0].value());
|
||||||
|
|
||||||
if(lyricsStr != null)
|
if(lyricsStr != null)
|
||||||
{
|
{
|
||||||
// If we have a cached response, return it
|
return new OllamaToolRespnce(this.name(), lyricsStr.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject obj = geniusToolsInstance.getGeniusEndpoint("/songs/" + args[0].value(), null);
|
JSONObject obj = geniusToolsInstance.getGeniusEndpoint("/songs/" + args[0].value(), null);
|
||||||
|
|
||||||
String lyrics_path = obj.getJSONObject("response").getJSONObject("song").getString("url");
|
String lyrics_path = obj.getJSONObject("response").getJSONObject("song").getString("url");
|
||||||
try {
|
try {
|
||||||
|
// WARNING: This request scrapes the lyrics from the Genius website.
|
||||||
|
// Which is against their Terms of Service. Use responsibly
|
||||||
Document doc = Jsoup.connect(lyrics_path)
|
Document doc = Jsoup.connect(lyrics_path)
|
||||||
.userAgent("Mozilla/5.0")
|
.userAgent("insomnia/11.1.0") // TODO: replace with somthing else then insomnia! since we in no way support what ever Insomnia's User-Agent says we do
|
||||||
|
.header("host", "genius.com")
|
||||||
|
.header("accept", "*/*")
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
writeLog("Fetching lyrics from: " + lyrics_path);
|
writeLog("Fetching lyrics from: " + lyrics_path);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class GetAnimeDetails extends MALEndpointTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OllamaPerameter parameters() {
|
public 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\"]")
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'java'
|
|
||||||
}
|
|
||||||
|
|
||||||
group = 'me.zacharias'
|
|
||||||
version = '1.0-SNAPSHOT'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testImplementation platform('org.junit:junit-bom:5.10.0')
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
|
||||||
implementation project(":Core")
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package me.noah.movie.sugest;
|
|
||||||
|
|
||||||
import me.noah.movie.sugest.endpoints.GetMovieByTitle;
|
|
||||||
import me.zacharias.chat.core.Core;
|
|
||||||
import me.zacharias.chat.ollama.OllamaFunctionTools;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class MovieSugestTool {
|
|
||||||
private OllamaFunctionTools movieSugestTools;
|
|
||||||
|
|
||||||
private static final String BASE_URL = "https://api.themoviedb.org/3";
|
|
||||||
|
|
||||||
private String authentication;
|
|
||||||
|
|
||||||
public MovieSugestTool(){
|
|
||||||
this.movieSugestTools = OllamaFunctionTools.builder()
|
|
||||||
.addTool(new GetMovieByTitle(this), Core.Source.INTERNAL)
|
|
||||||
.build();
|
|
||||||
try {
|
|
||||||
JSONObject obj = new JSONObject(Files.readString(Path.of(Core.DATA_DIR + "/movieapi.json")));
|
|
||||||
this.authentication = obj.getString("API-key");
|
|
||||||
//this.Client_Secret = obj.getString("client_secret");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OllamaFunctionTools getMovieSugestTools() {
|
|
||||||
return movieSugestTools;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JSONObject APIRequest(String endpoint, HashMap<String, String> params) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
String urlParams = ParameterStringBuilder.getParamsString(params);
|
|
||||||
|
|
||||||
URL url = new URI(this.BASE_URL + endpoint + "?" + urlParams).toURL();
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setRequestMethod("GET");
|
|
||||||
connection.setRequestProperty("Content-Type", "application/json");
|
|
||||||
connection.setRequestProperty("api_key", this.authentication);
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
connection.setConnectTimeout(80 * 1000);
|
|
||||||
|
|
||||||
int responseCode = connection.getResponseCode();
|
|
||||||
|
|
||||||
// HTTP_OK or 200 response code generally means that the server ran successfully without any errors
|
|
||||||
StringBuilder response = new StringBuilder();
|
|
||||||
|
|
||||||
// Read response content
|
|
||||||
// connection.getInputStream() purpose is to obtain an input stream for reading the server's response.
|
|
||||||
try (
|
|
||||||
BufferedReader reader = new BufferedReader( new InputStreamReader( connection.getInputStream()))) {
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
response.append(line); // Adds every line to response till the end of file.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
||||||
|
|
||||||
|
|
||||||
connection.disconnect();
|
|
||||||
return new JSONObject(response.toString());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
connection.disconnect();
|
|
||||||
System.err.println("Error: HTTP Response code - " + responseCode + "\n"+response.toString());
|
|
||||||
throw new RuntimeException("HTTP Response code - " + responseCode);
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Error: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package me.noah.movie.sugest;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ParameterStringBuilder {
|
|
||||||
public static String getParamsString(Map<String, String> params)
|
|
||||||
throws UnsupportedEncodingException {
|
|
||||||
if(params == null)
|
|
||||||
return "";
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
||||||
result.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8));
|
|
||||||
result.append("=");
|
|
||||||
result.append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8));
|
|
||||||
result.append("&");
|
|
||||||
}
|
|
||||||
|
|
||||||
String resultString = result.toString();
|
|
||||||
return !resultString.isEmpty()
|
|
||||||
? resultString.substring(0, resultString.length() - 1)
|
|
||||||
: resultString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package me.noah.movie.sugest.endpoints;
|
|
||||||
|
|
||||||
import me.noah.movie.sugest.MovieSugestTool;
|
|
||||||
import me.zacharias.chat.ollama.OllamaFunctionArgument;
|
|
||||||
import me.zacharias.chat.ollama.OllamaFunctionTool;
|
|
||||||
import me.zacharias.chat.ollama.OllamaPerameter;
|
|
||||||
import me.zacharias.chat.ollama.OllamaToolRespnce;
|
|
||||||
import me.zacharias.chat.ollama.exceptions.OllamaToolErrorException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class GetMovieByTitle extends OllamaFunctionTool{
|
|
||||||
private final MovieSugestTool instance;
|
|
||||||
|
|
||||||
public GetMovieByTitle(MovieSugestTool instance) {
|
|
||||||
this.instance = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return "movie_description";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String description() {
|
|
||||||
return "get the details of movie";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OllamaPerameter parameters() {
|
|
||||||
return OllamaPerameter.builder()
|
|
||||||
.addProperty("query", OllamaPerameter.OllamaPerameterBuilder.Type.STRING, "Movie or sereis title", true)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OllamaToolRespnce function(OllamaFunctionArgument... args) {
|
|
||||||
String query = null;
|
|
||||||
|
|
||||||
if (args.length > 0){
|
|
||||||
query = (String) args[0] .value();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new OllamaToolErrorException(name(), "query most be specefied");
|
|
||||||
}
|
|
||||||
HashMap < String, String > map = new HashMap<>();
|
|
||||||
map.put("query", query);
|
|
||||||
map.put("include_adult", "true");
|
|
||||||
|
|
||||||
JSONObject obj = instance.APIRequest("search/movie", map);
|
|
||||||
|
|
||||||
ArrayList < String > overviews = new ArrayList<>();
|
|
||||||
for (Object obj1: obj.getJSONArray("results")){
|
|
||||||
if (obj instanceof JSONObject result){
|
|
||||||
overviews.add(result.getString("overview"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OllamaToolRespnce(name(), overviews.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
13
README.md
13
README.md
@@ -1,5 +1,6 @@
|
|||||||
# Chat thing
|
# NeuroDock
|
||||||
(better name pending probably)
|
Note:
|
||||||
|
This project is not in colabiration with Neuro-Sama, Vedal987, Alexcra. This is an independent project and name, aswell as use case similarities are cucidental.
|
||||||
|
|
||||||
## What is it?
|
## What is it?
|
||||||
Well it's basically a font end for Ollama like [Open-WebUI](https://openwebui.com/), but meant to run a local model and open up a somewhat easy to use API system for tools.
|
Well it's basically a font end for Ollama like [Open-WebUI](https://openwebui.com/), but meant to run a local model and open up a somewhat easy to use API system for tools.
|
||||||
@@ -9,6 +10,14 @@ While the primary goal is providing a somewhat more modular frontend for Ollama,
|
|||||||
|
|
||||||
simple examples are in the Display module where i gave it the ability to access python through docker and get the current date and time both with the [OllamaFunctionTool](https://server.4zellen.se:3000/Zacharias/chat_thing/src/branch/master/Core/src/main/java/me/zacharias/chat/ollama/OllamaFunctionTool.java) thru my Ollama framework
|
simple examples are in the Display module where i gave it the ability to access python through docker and get the current date and time both with the [OllamaFunctionTool](https://server.4zellen.se:3000/Zacharias/chat_thing/src/branch/master/Core/src/main/java/me/zacharias/chat/ollama/OllamaFunctionTool.java) thru my Ollama framework
|
||||||
|
|
||||||
|
## Legal Notice Regarding Scraping
|
||||||
|
|
||||||
|
A submodule of this project includes functionality that scrapes song lyrics directly from Genius.com, which violates Genius API's Terms of Service.
|
||||||
|
|
||||||
|
The author **does not endorse or encourage** scraping or any other use that violates third-party terms or copyright laws.
|
||||||
|
|
||||||
|
Use this software **at your own risk**. The author disclaims any liability for legal or technical consequences arising from its use.
|
||||||
|
|
||||||
## API
|
## API
|
||||||
The documentation for the API is available at the gitea wiki under [API docs](https://server.4zellen.se:3000/Chat_things/NeuroDock/wiki/API-Docs)
|
The documentation for the API is available at the gitea wiki under [API docs](https://server.4zellen.se:3000/Chat_things/NeuroDock/wiki/API-Docs)
|
||||||
|
|
||||||
|
|||||||
32
build.gradle
32
build.gradle
@@ -7,6 +7,9 @@ group = 'me.zacharias'
|
|||||||
version = '1.0-SNAPSHOT'
|
version = '1.0-SNAPSHOT'
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
@@ -19,7 +22,6 @@ subprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.json:json:20250107")
|
implementation("org.json:json:20250107")
|
||||||
implementation("com.github.docker-java:docker-java:3.4.1")
|
|
||||||
implementation("org.jetbrains:annotations:23.1.0")
|
implementation("org.jetbrains:annotations:23.1.0")
|
||||||
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
|
||||||
@@ -43,4 +45,32 @@ subprojects {
|
|||||||
archives sourcesJar
|
archives sourcesJar
|
||||||
archives javadocJar
|
archives javadocJar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make Javadoc generation non-fatal to avoid publish failures on bad Javadoc
|
||||||
|
tasks.withType(Javadoc).configureEach {
|
||||||
|
options.addBooleanOption('Xdoclint:none', true)
|
||||||
|
failOnError = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configure local Maven publishing for modules that have a Java component
|
||||||
|
afterEvaluate { proj ->
|
||||||
|
if (components.findByName("java") != null) {
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
if (tasks.findByName('sourcesJar')) artifact tasks.sourcesJar
|
||||||
|
if (tasks.findByName('javadocJar')) artifact tasks.javadocJar
|
||||||
|
pom {
|
||||||
|
name = proj.name
|
||||||
|
description = "${proj.name} module of AI-test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class Launcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "--api" -> {
|
case "--api" -> {
|
||||||
System.out.println("API available at https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs");
|
System.out.println("API available at https://git.server.4zellen.se/Zacharias/chat_thing/wiki/API-Docs");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "--help", "-h" -> {
|
case "--help", "-h" -> {
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ include 'API', 'Core', 'Display', 'launcher'
|
|||||||
|
|
||||||
|
|
||||||
include 'MALAPITool'
|
include 'MALAPITool'
|
||||||
|
/**
|
||||||
|
* LEGAL WARNING:
|
||||||
|
* This module contains code that scrapes lyrics from Genius.com, which is against Genius API's Terms of Service.
|
||||||
|
*
|
||||||
|
* If you wish to avoid any potential legal issues, comment out or remove the line below and ensure no modules depend on this.
|
||||||
|
* The core NeuroDock system will still function without this module.
|
||||||
|
*/
|
||||||
include 'GeniusAPI'
|
include 'GeniusAPI'
|
||||||
include 'WikipediaTool'
|
|
||||||
include 'MovieSugest'
|
|
||||||
|
|
||||||
|
include 'WikipediaTool'
|
||||||
Reference in New Issue
Block a user