forked from Chat_things/NeuroDock
feat(api): major refactor from TCP socket to HTTP REST via Spring Boot
This commit introduces a large-scale refactor that replaces the existing TCP-based API with a Spring Boot-powered HTTP REST architecture. Due to the size and scope of this change, only essential structural notes are included below. High-level changes: - Replaced TCP-based communication with RESTful endpoints - Introduced Spring Boot for API handling and configuration - Refactored internal core logic to support REST architecture New/Updated API components: - `APIApplication.java`: Main Spring Boot entry point - `MessageController.java`: Handles LLM-related queries - `ToolController.java`: Handles adding/removing tools - `NewToolRequest.java` / `NewToolResponse.java`: Data models for tool addition - `NewQueryResponseHook.java`: Webhook handler for LLM query results - `WebhookError.java`: Model for reporting webhook errors - `EnableIfNotDisplay.java`: Conditional configuration for TTY context - Other supporting classes (e.g., `ToolArgument`, `ToolRequest`) Core changes: - `Core.java`: Removed deprecated `addFunctionTool`, added `removeTool` - `LaunchOptions.java`: Added `notDisplay` flag for headless operation - `OllamaObject.java`: Implements tool removal logic Launcher/display changes: - `Launcher.java`: Starts `APIApplication` if not in TTY mode - `Display.java`: Integrates REST API contextually with TTY display NOTE: Several classes are included but not yet fully utilized; these are placeholders for upcoming features (e.g., `MessageResponse`, `ToolRequest`). BREAKING CHANGE: This refactors removes all TCP-based API code and replaces it with HTTP REST using Spring Boot. Any clients or modules depending on the old TCP interface will need to be updated.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
|
||||
id 'org.springframework.boot' version '3.2.2'
|
||||
id 'io.spring.dependency-management' version '1.1.4'
|
||||
}
|
||||
|
||||
group = 'me.zacharias'
|
||||
@@ -9,10 +12,20 @@ dependencies {
|
||||
implementation project(":Display")
|
||||
implementation project(":API")
|
||||
implementation project(":Core")
|
||||
|
||||
afterEvaluate {
|
||||
boolean hasAPIDependency = configurations.implementation.dependencies.any { it.name.contains('API') }
|
||||
|
||||
if (hasAPIDependency) {
|
||||
dependencies.add("implementation", 'org.springframework.boot:spring-boot-starter-web')
|
||||
dependencies.add("implementation", 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0')
|
||||
dependencies.add("testImplementation", 'org.springframework.boot:spring-boot-starter-test')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jar{
|
||||
manifest {
|
||||
attributes 'Main-Class': 'me.zacharias.chat.launcher.Launcher'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package me.zacharias.chat.launcher;
|
||||
|
||||
import me.zacharias.chat.api.server.APIServer;
|
||||
//import me.zacharias.chat.api.APIApplication;
|
||||
import me.zacharias.chat.api.APIApplication;
|
||||
import me.zacharias.chat.core.LaunchOptions;
|
||||
import me.zacharias.chat.display.Display;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* The launcher for AI_chat.<br>
|
||||
* This is the main class of the application and is responsible for handling the command line arguments.
|
||||
@@ -49,7 +52,7 @@ public class Launcher {
|
||||
}
|
||||
case "--help", "-h" -> {
|
||||
System.out.println("""
|
||||
Launch options for AI_chat
|
||||
Launch options for NeuroChat:
|
||||
-h --help Provides this help message
|
||||
-s --server Starts the application as API server
|
||||
-p --port Provides the port number that the API server should use, defaults to 39075
|
||||
@@ -84,9 +87,16 @@ public class Launcher {
|
||||
|
||||
if (options.isServerMode()) {
|
||||
System.out.println("Starting in API mode...");
|
||||
new APIServer();
|
||||
try {
|
||||
APIApplication.start();
|
||||
}catch (Exception e)
|
||||
{
|
||||
System.out.println("Failed to start API server: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println("Starting in Display mode...");
|
||||
options.setNotDisplay(false);
|
||||
new Display();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user