diff --git a/pkg/loader/loader.go b/pkg/loader/loader.go index e5a9bb1e..51c74921 100644 --- a/pkg/loader/loader.go +++ b/pkg/loader/loader.go @@ -184,13 +184,13 @@ func readTool(ctx context.Context, prg *types.Program, base *source, targetToolN mainTool = tool } - if existing, ok := localTools[tool.Parameters.Name]; ok { + if existing, ok := localTools[strings.ToLower(tool.Parameters.Name)]; ok { return types.Tool{}, parser.NewErrLine(tool.Source.Location, tool.Source.LineNo, fmt.Errorf("duplicate tool name [%s] in %s found at lines %d and %d", tool.Parameters.Name, tool.Source.Location, tool.Source.LineNo, existing.Source.LineNo)) } - localTools[tool.Parameters.Name] = tool + localTools[strings.ToLower(tool.Parameters.Name)] = tool } return link(ctx, prg, base, mainTool, localTools) diff --git a/pkg/tests/runner_test.go b/pkg/tests/runner_test.go index 33c3d2d3..76c5c5fa 100644 --- a/pkg/tests/runner_test.go +++ b/pkg/tests/runner_test.go @@ -633,6 +633,13 @@ func TestContext(t *testing.T) { assert.Equal(t, "TEST RESULT CALL: 1", x) } +func TestCase(t *testing.T) { + runner := tester.NewRunner(t) + x, err := runner.Run("", "") + require.NoError(t, err) + assert.Equal(t, "TEST RESULT CALL: 1", x) +} + func TestContextArg(t *testing.T) { runner := tester.NewRunner(t) x, err := runner.Run("", `{ diff --git a/pkg/tests/testdata/TestCase/call1.golden b/pkg/tests/testdata/TestCase/call1.golden new file mode 100644 index 00000000..9a760d4c --- /dev/null +++ b/pkg/tests/testdata/TestCase/call1.golden @@ -0,0 +1,37 @@ +`{ + "Model": "gpt-4-turbo-preview", + "InternalSystemPrompt": null, + "Tools": [ + { + "function": { + "toolID": "testdata/TestCase/test.gpt:6", + "name": "bob", + "description": "I'm Bob, a friendly guy.", + "parameters": { + "properties": { + "question": { + "description": "The question to ask Bob.", + "type": "string" + } + }, + "type": "object" + } + } + } + ], + "Messages": [ + { + "role": "system", + "content": [ + { + "text": "Ask Bob how he is doing and let me know exactly what he said." + } + ] + } + ], + "MaxTokens": 0, + "Temperature": null, + "JSONResponse": false, + "Grammar": "", + "Cache": null +}` diff --git a/pkg/tests/testdata/TestCase/test.gpt b/pkg/tests/testdata/TestCase/test.gpt new file mode 100644 index 00000000..be1914e1 --- /dev/null +++ b/pkg/tests/testdata/TestCase/test.gpt @@ -0,0 +1,12 @@ +tools: Bob + +Ask Bob how he is doing and let me know exactly what he said. + +--- +name: Bob +description: I'm Bob, a friendly guy. +args: question: The question to ask Bob. + +#!/bin/bash + +echo "Thanks for asking ${question}, I'm doing great fellow friendly AI tool!"