forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErgonomicTestTools$$CopilotToolMeta.java
More file actions
68 lines (63 loc) · 4.06 KB
/
Copy pathErgonomicTestTools$$CopilotToolMeta.java
File metadata and controls
68 lines (63 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Hand-written test fixture mimicking CopilotToolProcessor output.
package com.github.copilot.e2e;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.copilot.rpc.ToolDefinition;
import com.github.copilot.tool.CopilotToolMetadataProvider;
import java.util.*;
import java.util.concurrent.CompletableFuture;
public final class ErgonomicTestTools$$CopilotToolMeta implements CopilotToolMetadataProvider<ErgonomicTestTools> {
private static Map<String, Object> withMeta(Map<String, Object> base, String description, Object defaultValue) {
var result = new LinkedHashMap<String, Object>(base);
if (description != null)
result.put("description", description);
if (defaultValue != null)
result.put("default", defaultValue);
return Collections.unmodifiableMap(result);
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public List<ToolDefinition> definitions(ErgonomicTestTools instance, ObjectMapper mapper) {
return List.of(new ToolDefinition("set_current_phase", "Sets the current phase of the agent",
Map.of("type", "object", "properties",
Map.ofEntries(Map.entry("phase",
(Map<String, Object>) (Map) withMeta(Map.of("type", "string"),
"The phase to transition to", null))),
"required", List.of("phase")),
invocation -> {
Map<String, Object> args = invocation.getArguments();
String phase = (String) args.get("phase");
return CompletableFuture.completedFuture(instance.setCurrentPhase(phase));
}, null, null, null, null),
new ToolDefinition(
"search_items", "Search for items by keyword", Map
.of("type", "object", "properties",
Map.ofEntries(Map.entry("keyword",
(Map<String, Object>) (Map) withMeta(Map.of("type", "string"),
"Search keyword", null))),
"required", List.of("keyword")),
invocation -> {
Map<String, Object> args = invocation.getArguments();
String keyword = (String) args.get("keyword");
return CompletableFuture.completedFuture(instance.searchItems(keyword));
}, null, null, null, null),
new ToolDefinition("get_status", "Returns the current status",
Map.of("type", "object", "properties", Map.of(), "required", List.of()), invocation -> {
return CompletableFuture.completedFuture(instance.getStatus());
}, null, null, null, null),
new ToolDefinition("combine_values", "Combines two values into a single string", Map.of(
"type", "object", "properties", Map
.ofEntries(
Map.entry("value1",
(Map<String, Object>) (Map) withMeta(Map.of("type", "string"),
"First value", null)),
Map.entry("value2",
(Map<String, Object>) (Map) withMeta(Map.of("type", "string"),
"Second value", null))),
"required", List.of("value1", "value2")), invocation -> {
Map<String, Object> args = invocation.getArguments();
String value1 = (String) args.get("value1");
String value2 = (String) args.get("value2");
return CompletableFuture.completedFuture(instance.combineValues(value1, value2));
}, null, null, null, null));
}
}