|
| 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