-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separated tools from one class to multiple, fixed a bug where if tool…
… was not inside AiLama then it would throw error, and fixed minor bugs
- Loading branch information
Showing
11 changed files
with
183 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...java/me/ailama/handler/other/SearXNG.java → ...ava/me/ailama/handler/models/SearXNG.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/ailama/handler/other/SearXNGResult.java → .../ailama/handler/models/SearXNGResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...in/java/me/ailama/handler/other/Tool.java → ...n/java/me/ailama/handler/models/Tool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package me.ailama.tools; | ||
|
||
import me.ailama.handler.annotations.Args; | ||
import me.ailama.handler.annotations.Tool; | ||
import me.ailama.main.AiLama; | ||
|
||
public class ApiTools { | ||
@Tool(name = "currencyRate", description = "Converts a currency rate to another", arguments = { | ||
@Args(name = "amount", Type = "double", description = "Amount to convert", noNull = true), | ||
@Args(name = "currency1", Type = "string", description = "Currency to convert from, Like INR"), | ||
@Args(name = "currency2", Type = "string", description = "Currency to convert to, Like USD") | ||
}) | ||
public String currencyRate(Double amount, String currency1, String currency2) { | ||
final double finalRate = Double.parseDouble(AiLama.getInstance().getRates(currency1.toLowerCase(),currency2.toLowerCase())); | ||
final double conv = finalRate * amount; | ||
return String.format("%.4f", conv); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package me.ailama.tools; | ||
|
||
import me.ailama.handler.annotations.Args; | ||
import me.ailama.handler.annotations.Tool; | ||
|
||
public class MathTools { | ||
|
||
@Tool(name = "add", description = "Addition ('+') of two numbers like N1+N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String add(Number a, Number b) { | ||
return String.valueOf(a.doubleValue() + b.doubleValue()); | ||
} | ||
|
||
@Tool(name = "subtract", description = "Subtraction ('-') of two numbers like N1-N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String subtract(Number a, Number b) { | ||
return String.valueOf(a.doubleValue() - b.doubleValue()); | ||
} | ||
|
||
@Tool(name = "multiply", description = "Multiplication ('*') of two numbers like N1*N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String multiply(Number a, Number b) { | ||
return String.valueOf(a.doubleValue() * b.doubleValue()); | ||
} | ||
|
||
@Tool(name = "divide", description = "Division ('/') of two numbers like N1/N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String divide(Number a, Number b) { | ||
return String.valueOf(a.doubleValue() / b.doubleValue()); | ||
} | ||
|
||
@Tool(name = "modulus", description = "Modulus ('%') of two numbers like N1%N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String modulus(Number a, Number b) { | ||
return String.valueOf(a.doubleValue() % b.doubleValue()); | ||
} | ||
|
||
@Tool(name = "power", description = "Power ('^') of two numbers like N1^N2", arguments = { | ||
@Args(name = "a", Type = "number"), | ||
@Args(name = "b", Type = "number") | ||
}) | ||
public String power(Number a, Number b) { | ||
return String.valueOf(Math.pow(a.doubleValue(), b.doubleValue())); | ||
} | ||
|
||
@Tool(name = "sqrt", description = "Square root of a number like sqrt(N1)", arguments = { | ||
@Args(name = "a", Type = "number") | ||
}) | ||
public String sqrt(Number a) { | ||
return String.valueOf(Math.sqrt(a.doubleValue())); | ||
} | ||
|
||
@Tool(name = "cubeRoot", description = "Cube root of a number", arguments = { | ||
@Args(name = "a", Type = "number") | ||
}) | ||
public String cubeRoot(Number a) { | ||
return String.valueOf(Math.cbrt(a.doubleValue())); | ||
} | ||
|
||
} |
Oops, something went wrong.