forked from neurodock/NeuroDock
refactor: me.zacharias.chat → me.neurodock, org rename cleanup
- Renamed package from me.zacharias.chat to me.neurodock across all 8 modules - Updated Gradle group from me.zacharias.neurodock to me.neurodock - Updated README and other files to reflect new Gitea org URL (Chat_things → neurodock) Dev note: 95 files touched. The Great Refactor is complete, long may it rest.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package me.neurodock.api.controllers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import me.neurodock.api.APIApplication;
|
||||
import me.neurodock.api.condations.EnableIfNotDisplay;
|
||||
import me.neurodock.api.payload.request.NewQurryResponceHook;
|
||||
import me.neurodock.ollama.OllamaMessage;
|
||||
import me.neurodock.ollama.OllamaMessageRole;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Conditional(EnableIfNotDisplay.class)
|
||||
@RestController
|
||||
@RequestMapping("/v1/message")
|
||||
public class Message {
|
||||
|
||||
private final APIApplication apiApplication;
|
||||
|
||||
public Message(APIApplication apiApplication) {
|
||||
this.apiApplication = apiApplication;
|
||||
}
|
||||
|
||||
@GetMapping("/query")
|
||||
public ResponseEntity<String> query(@RequestParam(name = "query", required = true) String query) {
|
||||
if (query == null || query.isEmpty()) {
|
||||
return ResponseEntity.badRequest().body("Query cannot be null or empty");
|
||||
}
|
||||
Thread t = new Thread(() -> {
|
||||
apiApplication.getCore().getOllamaObject().addMessage(new OllamaMessage(OllamaMessageRole.USER, query));
|
||||
apiApplication.getCore().handleResponce(apiApplication.getCore().qurryOllama());
|
||||
});
|
||||
t.start();
|
||||
return ResponseEntity.ok("Query received");
|
||||
}
|
||||
|
||||
@PostMapping("/addResponseHook")
|
||||
@ApiResponses(value = {
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "Response hook added successfully"),
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "400", description = "Invalid request data"),
|
||||
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "500", description = "Internal server error")
|
||||
})
|
||||
public ResponseEntity<String> addResponseHook(@RequestBody NewQurryResponceHook request) {
|
||||
if (request.getUrl() == null || request.getUrl().isEmpty()) {
|
||||
return ResponseEntity.badRequest().body("URL cannot be null or empty");
|
||||
}
|
||||
|
||||
try {
|
||||
apiApplication.addQurryResponseHook(request);
|
||||
|
||||
return ResponseEntity.ok("Response hook added successfully: " + request.getUrl());
|
||||
}catch (IllegalArgumentException e) {
|
||||
return ResponseEntity.badRequest().body("Invalid request data: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(500).body("Internal server error: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package me.neurodock.api.controllers;
|
||||
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import me.neurodock.api.APIApplication;
|
||||
import me.neurodock.api.payload.request.NewToolRequest;
|
||||
import me.neurodock.api.payload.response.NewToolResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/tool")
|
||||
public class Tool {
|
||||
APIApplication application;
|
||||
|
||||
public Tool(APIApplication application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new tool to the application.
|
||||
*
|
||||
* @param request The request containing the tool details.
|
||||
* @return A response entity containing the tool details or an error message.
|
||||
*/
|
||||
@PostMapping("addTool")
|
||||
@ApiResponse(responseCode = "200", description = "Tool added successfully", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = NewToolResponse.class)))
|
||||
@ApiResponse(responseCode = "400", description = "Tool already exists", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = String.class)))
|
||||
public ResponseEntity<?> addTool(@RequestBody NewToolRequest request) {
|
||||
if(application.addTool(request.getName(), request)) {
|
||||
String[] arguments = new String[request.getArguments().length];
|
||||
for(int i = 0; i < arguments.length; i++) {
|
||||
arguments[i] = request.getArguments()[i].getName()+":("+request.getArguments()[i].getType()+")";
|
||||
}
|
||||
return ResponseEntity.ok(new NewToolResponse(request.getName(), request.getDescription(), arguments));
|
||||
} else {
|
||||
return ResponseEntity.badRequest().body("Tool already exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user