Ollama4j
A Java library (wrapper/binding) for Ollama server.
Loading...
Searching...
No Matches
WeatherTool.java
Go to the documentation of this file.
1
package
io.github.ollama4j.tools.sampletools;
2
3
import
io.github.ollama4j.tools.Tools;
4
5
import
java.util.Map;
6
7
@SuppressWarnings(
"resource"
)
8
public class
WeatherTool
{
9
private
String paramCityName =
"cityName"
;
10
11
public
WeatherTool
() {
12
}
13
14
public
String
getCurrentWeather
(Map<String, Object> arguments) {
15
String city = (String) arguments.get(paramCityName);
16
return
"It is sunny in "
+ city;
17
}
18
19
public
Tools.ToolSpecification
getSpecification
() {
20
return
Tools
.
ToolSpecification
.builder()
21
.functionName(
"weather-reporter"
)
22
.functionDescription(
23
"You are a tool who simply finds the city name from the user's message input/query about weather."
)
24
.toolFunction(this::getCurrentWeather)
25
.toolPrompt(
26
Tools
.
PromptFuncDefinition
.builder()
27
.type(
"prompt"
)
28
.function(
29
Tools
.
PromptFuncDefinition
.
PromptFuncSpec
30
.builder()
31
.name(
"get-city-name"
)
32
.description(
"Get the city name"
)
33
.parameters(
34
Tools
.
PromptFuncDefinition
.
Parameters
35
.builder()
36
.type(
"object"
)
37
.properties(
38
Map.of(
39
paramCityName,
40
Tools
.
PromptFuncDefinition
.
Property
41
.builder()
42
.type(
"string"
)
43
.description(
44
"The name of the city. e.g. Bengaluru"
)
45
.required(
true
)
46
.build()))
47
.required(java.util.List
48
.of(paramCityName))
49
.build())
50
.build())
51
.build())
52
.build();
53
}
54
}
io.github.ollama4j.tools.Tools.PromptFuncDefinition.Parameters
Definition
Tools.java:52
io.github.ollama4j.tools.Tools.PromptFuncDefinition.PromptFuncSpec
Definition
Tools.java:42
io.github.ollama4j.tools.Tools.PromptFuncDefinition.Property
Definition
Tools.java:62
io.github.ollama4j.tools.Tools.PromptFuncDefinition
Definition
Tools.java:34
io.github.ollama4j.tools.Tools.ToolSpecification
Definition
Tools.java:22
io.github.ollama4j.tools.Tools
Definition
Tools.java:19
io.github.ollama4j.tools.sampletools.WeatherTool.getCurrentWeather
String getCurrentWeather(Map< String, Object > arguments)
Definition
WeatherTool.java:14
io.github.ollama4j.tools.sampletools.WeatherTool.WeatherTool
WeatherTool()
Definition
WeatherTool.java:11
io.github.ollama4j.tools.sampletools.WeatherTool.getSpecification
Tools.ToolSpecification getSpecification()
Definition
WeatherTool.java:19
src
main
java
io
github
ollama4j
tools
sampletools
WeatherTool.java
Generated by
1.13.2