Skip to content

Commit

Permalink
Removed Redundant System Out
Browse files Browse the repository at this point in the history
Removed Test Tool

Fixed bug where responses from response array would be used even if the tool is not response formatted
  • Loading branch information
ZeyoYT committed May 30, 2024
1 parent cf33c4d commit 0f4dbfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/main/java/me/ailama/commands/AiCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ public void handleCommand(SlashCommandInteractionEvent event) {
else
{
// if tooled.response contains a string that has ({response}) in it, replace it with the result of the tool
if(tooled.response != null && tooled.response.length > 0) {
if(OllamaManager.getInstance().isToolResponseFormatted(tooled.name)) {

System.out.println(Arrays.toString(tooled.response));
response = String.join("\n\n", tooled.response).replace("({response})", OllamaManager.getInstance().executeTool(tooled.name, tooled.parameters.values().toArray()).toString());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ public boolean isToolRawResponse(String toolName) {
return getTool(toolName) != null && getTool(toolName).getAnnotation(Tool.class).rawResponse();
}

public boolean isToolResponseFormatted(String toolName) {
return getTool(toolName) != null && getTool(toolName).getAnnotation(Tool.class).responseFormatter();
}

// Execute the Tool
public Object executeTool(String toolName, Object... args) {

Expand Down
7 changes: 0 additions & 7 deletions src/main/java/me/ailama/tools/UtilityTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,4 @@ public String toolsJson() {

return gson.toJson(jsonElement);
}

@Tool(name = "testTool", description = "Test the tool", parameters = {
@Parameter(name = "fruitName", Type = "string")
}, responseFormatter = true)
public String testTool(String resp) {
return resp;
}
}

0 comments on commit 0f4dbfa

Please sign in to comment.