Skip to content

Commit 3192ab8

Browse files
chore: add missing agents field and switch to parameter
1 parent 172dfb0 commit 3192ab8

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

pkg/types/tool.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ func (t ToolDef) String() string {
247247
if t.Parameters.Description != "" {
248248
_, _ = fmt.Fprintf(buf, "Description: %s\n", t.Parameters.Description)
249249
}
250+
if len(t.Parameters.Agents) != 0 {
251+
_, _ = fmt.Fprintf(buf, "Agents: %s\n", strings.Join(t.Parameters.Agents, ", "))
252+
}
250253
if len(t.Parameters.Tools) != 0 {
251254
_, _ = fmt.Fprintf(buf, "Tools: %s\n", strings.Join(t.Parameters.Tools, ", "))
252255
}
@@ -285,7 +288,7 @@ func (t ToolDef) String() string {
285288
sort.Strings(keys)
286289
for _, key := range keys {
287290
prop := t.Parameters.Arguments.Properties[key]
288-
_, _ = fmt.Fprintf(buf, "Args: %s: %s\n", key, prop.Value.Description)
291+
_, _ = fmt.Fprintf(buf, "Parameter: %s: %s\n", key, prop.Value.Description)
289292
}
290293
}
291294
if t.Parameters.InternalPrompt != nil {

pkg/types/tool_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package types
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hexops/autogold/v2"
7+
)
8+
9+
func TestToolDef_String(t *testing.T) {
10+
tool := ToolDef{
11+
Parameters: Parameters{
12+
Name: "Tool Sample",
13+
Description: "This is a sample tool",
14+
MaxTokens: 1024,
15+
ModelName: "ModelSample",
16+
ModelProvider: true,
17+
JSONResponse: true,
18+
Chat: true,
19+
Temperature: float32Ptr(0.8),
20+
Cache: boolPtr(true),
21+
InternalPrompt: boolPtr(true),
22+
Arguments: ObjectSchema("arg1", "desc1", "arg2", "desc2"),
23+
Tools: []string{"Tool1", "Tool2"},
24+
GlobalTools: []string{"GlobalTool1", "GlobalTool2"},
25+
GlobalModelName: "GlobalModelSample",
26+
Context: []string{"Context1", "Context2"},
27+
ExportContext: []string{"ExportContext1", "ExportContext2"},
28+
Export: []string{"Export1", "Export2"},
29+
Agents: []string{"Agent1", "Agent2"},
30+
Credentials: []string{"Credential1", "Credential2"},
31+
Blocking: true,
32+
},
33+
Instructions: "This is a sample instruction",
34+
}
35+
36+
autogold.Expect(`Global Model Name: GlobalModelSample
37+
Global Tools: GlobalTool1, GlobalTool2
38+
Name: Tool Sample
39+
Description: This is a sample tool
40+
Agents: Agent1, Agent2
41+
Tools: Tool1, Tool2
42+
Share Tools: Export1, Export2
43+
Share Context: ExportContext1, ExportContext2
44+
Context: Context1, Context2
45+
Max Tokens: 1024
46+
Model: ModelSample
47+
Model Provider: true
48+
JSON Response: true
49+
Temperature: 0.800000
50+
Parameter: arg1: desc1
51+
Parameter: arg2: desc2
52+
Internal Prompt: true
53+
Credentials: Credential1, Credential2
54+
Chat: true
55+
56+
This is a sample instruction
57+
`).Equal(t, tool.String())
58+
}
59+
60+
// float32Ptr is used to return a pointer to a given float32 value
61+
func float32Ptr(f float32) *float32 {
62+
return &f
63+
}
64+
65+
// boolPtr is used to return a pointer to a given bool value
66+
func boolPtr(b bool) *bool {
67+
return &b
68+
}

0 commit comments

Comments
 (0)