Skip to content

chore: add missing agents field and switch to parameter #437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/types/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ func (t ToolDef) String() string {
if t.Parameters.Description != "" {
_, _ = fmt.Fprintf(buf, "Description: %s\n", t.Parameters.Description)
}
if len(t.Parameters.Agents) != 0 {
_, _ = fmt.Fprintf(buf, "Agents: %s\n", strings.Join(t.Parameters.Agents, ", "))
}
if len(t.Parameters.Tools) != 0 {
_, _ = fmt.Fprintf(buf, "Tools: %s\n", strings.Join(t.Parameters.Tools, ", "))
}
Expand Down Expand Up @@ -285,7 +288,7 @@ func (t ToolDef) String() string {
sort.Strings(keys)
for _, key := range keys {
prop := t.Parameters.Arguments.Properties[key]
_, _ = fmt.Fprintf(buf, "Args: %s: %s\n", key, prop.Value.Description)
_, _ = fmt.Fprintf(buf, "Parameter: %s: %s\n", key, prop.Value.Description)
}
}
if t.Parameters.InternalPrompt != nil {
Expand Down
68 changes: 68 additions & 0 deletions pkg/types/tool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package types

import (
"testing"

"github.com/hexops/autogold/v2"
)

func TestToolDef_String(t *testing.T) {
tool := ToolDef{
Parameters: Parameters{
Name: "Tool Sample",
Description: "This is a sample tool",
MaxTokens: 1024,
ModelName: "ModelSample",
ModelProvider: true,
JSONResponse: true,
Chat: true,
Temperature: float32Ptr(0.8),
Cache: boolPtr(true),
InternalPrompt: boolPtr(true),
Arguments: ObjectSchema("arg1", "desc1", "arg2", "desc2"),
Tools: []string{"Tool1", "Tool2"},
GlobalTools: []string{"GlobalTool1", "GlobalTool2"},
GlobalModelName: "GlobalModelSample",
Context: []string{"Context1", "Context2"},
ExportContext: []string{"ExportContext1", "ExportContext2"},
Export: []string{"Export1", "Export2"},
Agents: []string{"Agent1", "Agent2"},
Credentials: []string{"Credential1", "Credential2"},
Blocking: true,
},
Instructions: "This is a sample instruction",
}

autogold.Expect(`Global Model Name: GlobalModelSample
Global Tools: GlobalTool1, GlobalTool2
Name: Tool Sample
Description: This is a sample tool
Agents: Agent1, Agent2
Tools: Tool1, Tool2
Share Tools: Export1, Export2
Share Context: ExportContext1, ExportContext2
Context: Context1, Context2
Max Tokens: 1024
Model: ModelSample
Model Provider: true
JSON Response: true
Temperature: 0.800000
Parameter: arg1: desc1
Parameter: arg2: desc2
Internal Prompt: true
Credentials: Credential1, Credential2
Chat: true

This is a sample instruction
`).Equal(t, tool.String())
}

// float32Ptr is used to return a pointer to a given float32 value
func float32Ptr(f float32) *float32 {
return &f
}

// boolPtr is used to return a pointer to a given bool value
func boolPtr(b bool) *bool {
return &b
}