Skip to content

Commit a9927c7

Browse files
Merge pull request #300 from ibuildthecloud/main
bug: fix upper case tools
2 parents 4549b96 + 0cef4eb commit a9927c7

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

pkg/loader/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ func readTool(ctx context.Context, prg *types.Program, base *source, targetToolN
184184
mainTool = tool
185185
}
186186

187-
if existing, ok := localTools[tool.Parameters.Name]; ok {
187+
if existing, ok := localTools[strings.ToLower(tool.Parameters.Name)]; ok {
188188
return types.Tool{}, parser.NewErrLine(tool.Source.Location, tool.Source.LineNo,
189189
fmt.Errorf("duplicate tool name [%s] in %s found at lines %d and %d", tool.Parameters.Name, tool.Source.Location,
190190
tool.Source.LineNo, existing.Source.LineNo))
191191
}
192192

193-
localTools[tool.Parameters.Name] = tool
193+
localTools[strings.ToLower(tool.Parameters.Name)] = tool
194194
}
195195

196196
return link(ctx, prg, base, mainTool, localTools)

pkg/tests/runner_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,13 @@ func TestContext(t *testing.T) {
633633
assert.Equal(t, "TEST RESULT CALL: 1", x)
634634
}
635635

636+
func TestCase(t *testing.T) {
637+
runner := tester.NewRunner(t)
638+
x, err := runner.Run("", "")
639+
require.NoError(t, err)
640+
assert.Equal(t, "TEST RESULT CALL: 1", x)
641+
}
642+
636643
func TestContextArg(t *testing.T) {
637644
runner := tester.NewRunner(t)
638645
x, err := runner.Run("", `{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
`{
2+
"Model": "gpt-4-turbo-preview",
3+
"InternalSystemPrompt": null,
4+
"Tools": [
5+
{
6+
"function": {
7+
"toolID": "testdata/TestCase/test.gpt:6",
8+
"name": "bob",
9+
"description": "I'm Bob, a friendly guy.",
10+
"parameters": {
11+
"properties": {
12+
"question": {
13+
"description": "The question to ask Bob.",
14+
"type": "string"
15+
}
16+
},
17+
"type": "object"
18+
}
19+
}
20+
}
21+
],
22+
"Messages": [
23+
{
24+
"role": "system",
25+
"content": [
26+
{
27+
"text": "Ask Bob how he is doing and let me know exactly what he said."
28+
}
29+
]
30+
}
31+
],
32+
"MaxTokens": 0,
33+
"Temperature": null,
34+
"JSONResponse": false,
35+
"Grammar": "",
36+
"Cache": null
37+
}`

pkg/tests/testdata/TestCase/test.gpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tools: Bob
2+
3+
Ask Bob how he is doing and let me know exactly what he said.
4+
5+
---
6+
name: Bob
7+
description: I'm Bob, a friendly guy.
8+
args: question: The question to ask Bob.
9+
10+
#!/bin/bash
11+
12+
echo "Thanks for asking ${question}, I'm doing great fellow friendly AI tool!"

0 commit comments

Comments
 (0)